hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp
author neliasso
Tue, 27 Jun 2017 15:46:16 +0200
changeset 46596 a7c9706d25a9
parent 46592 6e357e2c8143
child 46620 750c6edff33b
permissions -rw-r--r--
8144448: Avoid placing CTI immediately following or preceding RDPC instruction Summary: Best practice for new SPARC CPUs Reviewed-by: kvn Contributed-by: phedlin@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     1
/*
46381
020219e46c86 8150388: Remove SPARC 32-bit support
gtriantafill
parents: 40032
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     4
 *
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     8
 *
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    13
 * accompanied this code).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    14
 *
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    18
 *
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    21
 * questions.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    22
 *
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    23
 */
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    24
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    25
#include "precompiled.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 25468
diff changeset
    26
#include "asm/macroAssembler.inline.hpp"
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    27
#include "compiler/disassembler.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30280
diff changeset
    28
#include "gc/shared/cardTableModRefBS.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30280
diff changeset
    29
#include "gc/shared/collectedHeap.inline.hpp"
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    30
#include "interpreter/interpreter.hpp"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
    32
#include "memory/universe.hpp"
31849
92ca49fa9fa7 8131344: Missing klass.inline.hpp include in compiler files
tschatzl
parents: 31515
diff changeset
    33
#include "oops/klass.inline.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
    34
#include "prims/jvm.h"
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    35
#include "prims/methodHandles.hpp"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    36
#include "runtime/biasedLocking.hpp"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    37
#include "runtime/interfaceSupport.hpp"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    38
#include "runtime/objectMonitor.hpp"
25468
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 24917
diff changeset
    39
#include "runtime/os.inline.hpp"
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    40
#include "runtime/sharedRuntime.hpp"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    41
#include "runtime/stubRoutines.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
    42
#include "utilities/macros.hpp"
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
    43
#if INCLUDE_ALL_GCS
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30280
diff changeset
    44
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30280
diff changeset
    45
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30280
diff changeset
    46
#include "gc/g1/heapRegion.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
    47
#endif // INCLUDE_ALL_GCS
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
    48
#ifdef COMPILER2
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
    49
#include "opto/intrinsicnode.hpp"
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
    50
#endif
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    51
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    52
#ifdef PRODUCT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    53
#define BLOCK_COMMENT(str) /* nothing */
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    54
#define STOP(error) stop(error)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    55
#else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    56
#define BLOCK_COMMENT(str) block_comment(str)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    57
#define STOP(error) block_comment(error); stop(error)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    58
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    59
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    60
// Convert the raw encoding form into the form expected by the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    61
// constructor for Address.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    62
Address Address::make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    63
  assert(scale == 0, "not supported");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    64
  RelocationHolder rspec;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    65
  if (disp_reloc != relocInfo::none) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    66
    rspec = Relocation::spec_simple(disp_reloc);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    67
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    68
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    69
  Register rindex = as_Register(index);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    70
  if (rindex != G0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    71
    Address madr(as_Register(base), rindex);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    72
    madr._rspec = rspec;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    73
    return madr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    74
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    75
    Address madr(as_Register(base), disp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    76
    madr._rspec = rspec;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    77
    return madr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    78
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    79
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    80
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    81
Address Argument::address_in_frame() const {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    82
  // Warning: In LP64 mode disp will occupy more than 10 bits, but
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    83
  //          op codes such as ld or ldx, only access disp() to get
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    84
  //          their simm13 argument.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    85
  int disp = ((_number - Argument::n_register_parameters + frame::memory_parameter_word_sp_offset) * BytesPerWord) + STACK_BIAS;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    86
  if (is_in())
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    87
    return Address(FP, disp); // In argument.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    88
  else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    89
    return Address(SP, disp); // Out argument.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    90
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    91
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    92
static const char* argumentNames[][2] = {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    93
  {"A0","P0"}, {"A1","P1"}, {"A2","P2"}, {"A3","P3"}, {"A4","P4"},
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    94
  {"A5","P5"}, {"A6","P6"}, {"A7","P7"}, {"A8","P8"}, {"A9","P9"},
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    95
  {"A(n>9)","P(n>9)"}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    96
};
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    97
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    98
const char* Argument::name() const {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
    99
  int nofArgs = sizeof argumentNames / sizeof argumentNames[0];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   100
  int num = number();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   101
  if (num >= nofArgs)  num = nofArgs - 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   102
  return argumentNames[num][is_in() ? 1 : 0];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   103
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   104
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   105
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   106
// On RISC, there's no benefit to verifying instruction boundaries.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   107
bool AbstractAssembler::pd_check_instruction_mark() { return false; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   108
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   109
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   110
// Patch instruction inst at offset inst_pos to refer to dest_pos
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   111
// and return the resulting instruction.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   112
// We should have pcs, not offsets, but since all is relative, it will work out
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   113
// OK.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   114
int MacroAssembler::patched_branch(int dest_pos, int inst, int inst_pos) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   115
  int m; // mask for displacement field
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   116
  int v; // new value for displacement field
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   117
  const int word_aligned_ones = -4;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   118
  switch (inv_op(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   119
  default: ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   120
  case call_op:    m = wdisp(word_aligned_ones, 0, 30);  v = wdisp(dest_pos, inst_pos, 30); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   121
  case branch_op:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   122
    switch (inv_op2(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   123
      case fbp_op2:    m = wdisp(  word_aligned_ones, 0, 19);  v = wdisp(  dest_pos, inst_pos, 19); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   124
      case bp_op2:     m = wdisp(  word_aligned_ones, 0, 19);  v = wdisp(  dest_pos, inst_pos, 19); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   125
      case fb_op2:     m = wdisp(  word_aligned_ones, 0, 22);  v = wdisp(  dest_pos, inst_pos, 22); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   126
      case br_op2:     m = wdisp(  word_aligned_ones, 0, 22);  v = wdisp(  dest_pos, inst_pos, 22); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   127
      case bpr_op2: {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   128
        if (is_cbcond(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   129
          m = wdisp10(word_aligned_ones, 0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   130
          v = wdisp10(dest_pos, inst_pos);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   131
        } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   132
          m = wdisp16(word_aligned_ones, 0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   133
          v = wdisp16(dest_pos, inst_pos);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   134
        }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   135
        break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   136
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   137
      default: ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   138
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   139
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   140
  return  inst & ~m  |  v;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   141
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   142
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   143
// Return the offset of the branch destionation of instruction inst
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   144
// at offset pos.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   145
// Should have pcs, but since all is relative, it works out.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   146
int MacroAssembler::branch_destination(int inst, int pos) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   147
  int r;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   148
  switch (inv_op(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   149
  default: ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   150
  case call_op:        r = inv_wdisp(inst, pos, 30);  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   151
  case branch_op:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   152
    switch (inv_op2(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   153
      case fbp_op2:    r = inv_wdisp(  inst, pos, 19);  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   154
      case bp_op2:     r = inv_wdisp(  inst, pos, 19);  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   155
      case fb_op2:     r = inv_wdisp(  inst, pos, 22);  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   156
      case br_op2:     r = inv_wdisp(  inst, pos, 22);  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   157
      case bpr_op2: {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   158
        if (is_cbcond(inst)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   159
          r = inv_wdisp10(inst, pos);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   160
        } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   161
          r = inv_wdisp16(inst, pos);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   162
        }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   163
        break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   164
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   165
      default: ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   166
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   167
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   168
  return r;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   169
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   170
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   171
void MacroAssembler::null_check(Register reg, int offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   172
  if (needs_explicit_null_check((intptr_t)offset)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   173
    // provoke OS NULL exception if reg = NULL by
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   174
    // accessing M[reg] w/o changing any registers
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   175
    ld_ptr(reg, 0, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   176
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   177
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   178
    // nothing to do, (later) access of M[reg + offset]
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   179
    // will provoke OS NULL exception if reg = NULL
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   180
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   181
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   182
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   183
// Ring buffer jumps
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   184
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   185
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   186
void MacroAssembler::jmp2(Register r1, Register r2, const char* file, int line ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   187
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   188
  jmpl(r1, r2, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   189
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   190
void MacroAssembler::jmp(Register r1, int offset, const char* file, int line ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   191
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   192
  jmp(r1, offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   193
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   194
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   195
// This code sequence is relocatable to any address, even on LP64.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   196
void MacroAssembler::jumpl(const AddressLiteral& addrlit, Register temp, Register d, int offset, const char* file, int line) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   197
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   198
  // Force fixed length sethi because NativeJump and NativeFarCall don't handle
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   199
  // variable length instruction streams.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   200
  patchable_sethi(addrlit, temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   201
  Address a(temp, addrlit.low10() + offset);  // Add the offset to the displacement.
40032
bc2e42cd23ea 8132318: -XX:TraceJumps is broken on Sparc
dpochepk
parents: 38304
diff changeset
   202
  jmpl(a.base(), a.disp(), d);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   203
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   204
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   205
void MacroAssembler::jump(const AddressLiteral& addrlit, Register temp, int offset, const char* file, int line) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   206
  jumpl(addrlit, temp, G0, offset, file, line);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   207
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   208
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   209
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   210
// Conditional breakpoint (for assertion checks in assembly code)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   211
void MacroAssembler::breakpoint_trap(Condition c, CC cc) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   212
  trap(c, cc, G0, ST_RESERVED_FOR_USER_0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   213
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   214
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   215
// We want to use ST_BREAKPOINT here, but the debugger is confused by it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   216
void MacroAssembler::breakpoint_trap() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   217
  trap(ST_RESERVED_FOR_USER_0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   218
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   219
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   220
// Write serialization page so VM thread can do a pseudo remote membar
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   221
// We use the current thread pointer to calculate a thread specific
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   222
// offset to write to within the page. This minimizes bus traffic
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   223
// due to cache line collision.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   224
void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   225
  srl(thread, os::get_serialize_page_shift_count(), tmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   226
  if (Assembler::is_simm13(os::vm_page_size())) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   227
    and3(tmp2, (os::vm_page_size() - sizeof(int)), tmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   228
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   229
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   230
    set((os::vm_page_size() - sizeof(int)), tmp1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   231
    and3(tmp2, tmp1, tmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   232
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   233
  set(os::get_memory_serialize_page(), tmp1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   234
  st(G0, tmp1, tmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   235
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   236
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   237
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   238
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   239
void MacroAssembler::enter() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   240
  Unimplemented();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   241
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   242
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   243
void MacroAssembler::leave() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   244
  Unimplemented();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   245
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   246
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   247
// Calls to C land
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   248
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   249
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   250
// a hook for debugging
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   251
static Thread* reinitialize_thread() {
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 34211
diff changeset
   252
  return Thread::current();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   253
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   254
#else
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 34211
diff changeset
   255
#define reinitialize_thread Thread::current
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   256
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   257
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   258
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   259
address last_get_thread = NULL;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   260
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   261
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   262
// call this when G2_thread is not known to be valid
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   263
void MacroAssembler::get_thread() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   264
  save_frame(0);                // to avoid clobbering O0
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   265
  mov(G1, L0);                  // avoid clobbering G1
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   266
  mov(G5_method, L1);           // avoid clobbering G5
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   267
  mov(G3, L2);                  // avoid clobbering G3 also
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   268
  mov(G4, L5);                  // avoid clobbering G4
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   269
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   270
  AddressLiteral last_get_thread_addrlit(&last_get_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   271
  set(last_get_thread_addrlit, L3);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
   272
  rdpc(L4);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
   273
  inc(L4, 3 * BytesPerInstWord); // skip rdpc + inc + st_ptr to point L4 at call  st_ptr(L4, L3, 0);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   274
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   275
  call(CAST_FROM_FN_PTR(address, reinitialize_thread), relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   276
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   277
  mov(L0, G1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   278
  mov(L1, G5_method);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   279
  mov(L2, G3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   280
  mov(L5, G4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   281
  restore(O0, 0, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   282
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   283
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   284
static Thread* verify_thread_subroutine(Thread* gthread_value) {
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 34211
diff changeset
   285
  Thread* correct_value = Thread::current();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   286
  guarantee(gthread_value == correct_value, "G2_thread value must be the thread");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   287
  return correct_value;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   288
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   289
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   290
void MacroAssembler::verify_thread() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   291
  if (VerifyThread) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   292
    // NOTE: this chops off the heads of the 64-bit O registers.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   293
    // make sure G2_thread contains the right value
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   294
    save_frame_and_mov(0, Lmethod, Lmethod);   // to avoid clobbering O0 (and propagate Lmethod for -Xprof)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   295
    mov(G1, L1);                // avoid clobbering G1
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   296
    // G2 saved below
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   297
    mov(G3, L3);                // avoid clobbering G3
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   298
    mov(G4, L4);                // avoid clobbering G4
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   299
    mov(G5_method, L5);         // avoid clobbering G5_method
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   300
    call(CAST_FROM_FN_PTR(address,verify_thread_subroutine), relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   301
    delayed()->mov(G2_thread, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   302
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   303
    mov(L1, G1);                // Restore G1
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   304
    // G2 restored below
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   305
    mov(L3, G3);                // restore G3
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   306
    mov(L4, G4);                // restore G4
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   307
    mov(L5, G5_method);         // restore G5_method
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   308
    restore(O0, 0, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   309
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   310
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   311
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   312
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   313
void MacroAssembler::save_thread(const Register thread_cache) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   314
  verify_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   315
  if (thread_cache->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   316
    assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   317
    mov(G2_thread, thread_cache);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   318
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   319
  if (VerifyThread) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   320
    // smash G2_thread, as if the VM were about to anyway
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   321
    set(0x67676767, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   322
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   323
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   324
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   325
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   326
void MacroAssembler::restore_thread(const Register thread_cache) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   327
  if (thread_cache->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   328
    assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   329
    mov(thread_cache, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   330
    verify_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   331
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   332
    // do it the slow way
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   333
    get_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   334
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   335
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   336
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   337
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   338
// %%% maybe get rid of [re]set_last_Java_frame
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   339
void MacroAssembler::set_last_Java_frame(Register last_java_sp, Register last_Java_pc) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   340
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   341
  Address flags(G2_thread, JavaThread::frame_anchor_offset() +
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   342
                           JavaFrameAnchor::flags_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   343
  Address pc_addr(G2_thread, JavaThread::last_Java_pc_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   344
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   345
  // Always set last_Java_pc and flags first because once last_Java_sp is visible
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   346
  // has_last_Java_frame is true and users will look at the rest of the fields.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   347
  // (Note: flags should always be zero before we get here so doesn't need to be set.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   348
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   349
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   350
  // Verify that flags was zeroed on return to Java
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   351
  Label PcOk;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   352
  save_frame(0);                // to avoid clobbering O0
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   353
  ld_ptr(pc_addr, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   354
  br_null_short(L0, Assembler::pt, PcOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   355
  STOP("last_Java_pc not zeroed before leaving Java");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   356
  bind(PcOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   357
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   358
  // Verify that flags was zeroed on return to Java
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   359
  Label FlagsOk;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   360
  ld(flags, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   361
  tst(L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   362
  br(Assembler::zero, false, Assembler::pt, FlagsOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   363
  delayed() -> restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   364
  STOP("flags not zeroed before leaving Java");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   365
  bind(FlagsOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   366
#endif /* ASSERT */
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   367
  //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   368
  // When returning from calling out from Java mode the frame anchor's last_Java_pc
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   369
  // will always be set to NULL. It is set here so that if we are doing a call to
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   370
  // native (not VM) that we capture the known pc and don't have to rely on the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   371
  // native call having a standard frame linkage where we can find the pc.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   372
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   373
  if (last_Java_pc->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   374
    st_ptr(last_Java_pc, pc_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   375
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   376
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   377
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   378
  // Make sure that we have an odd stack
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   379
  Label StackOk;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   380
  andcc(last_java_sp, 0x01, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   381
  br(Assembler::notZero, false, Assembler::pt, StackOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   382
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   383
  STOP("Stack Not Biased in set_last_Java_frame");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   384
  bind(StackOk);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   385
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   386
  assert( last_java_sp != G4_scratch, "bad register usage in set_last_Java_frame");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   387
  add( last_java_sp, STACK_BIAS, G4_scratch );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   388
  st_ptr(G4_scratch, G2_thread, JavaThread::last_Java_sp_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   389
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   390
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   391
void MacroAssembler::reset_last_Java_frame(void) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   392
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   393
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   394
  Address sp_addr(G2_thread, JavaThread::last_Java_sp_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   395
  Address pc_addr(G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   396
  Address flags  (G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   397
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   398
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   399
  // check that it WAS previously set
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   400
    save_frame_and_mov(0, Lmethod, Lmethod);     // Propagate Lmethod to helper frame for -Xprof
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   401
    ld_ptr(sp_addr, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   402
    tst(L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   403
    breakpoint_trap(Assembler::zero, Assembler::ptr_cc);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   404
    restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   405
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   406
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   407
  st_ptr(G0, sp_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   408
  // Always return last_Java_pc to zero
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   409
  st_ptr(G0, pc_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   410
  // Always null flags after return to Java
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   411
  st(G0, flags);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   412
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   413
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   414
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   415
void MacroAssembler::call_VM_base(
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   416
  Register        oop_result,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   417
  Register        thread_cache,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   418
  Register        last_java_sp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   419
  address         entry_point,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   420
  int             number_of_arguments,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   421
  bool            check_exceptions)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   422
{
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   423
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   424
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   425
  // determine last_java_sp register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   426
  if (!last_java_sp->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   427
    last_java_sp = SP;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   428
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   429
  // debugging support
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   430
  assert(number_of_arguments >= 0   , "cannot have negative number of arguments");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   431
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   432
  // 64-bit last_java_sp is biased!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   433
  set_last_Java_frame(last_java_sp, noreg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   434
  if (VerifyThread)  mov(G2_thread, O0); // about to be smashed; pass early
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   435
  save_thread(thread_cache);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   436
  // do the call
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   437
  call(entry_point, relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   438
  if (!VerifyThread)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   439
    delayed()->mov(G2_thread, O0);  // pass thread as first argument
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   440
  else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   441
    delayed()->nop();             // (thread already passed)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   442
  restore_thread(thread_cache);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   443
  reset_last_Java_frame();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   444
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   445
  // check for pending exceptions. use Gtemp as scratch register.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   446
  if (check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   447
    check_and_forward_exception(Gtemp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   448
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   449
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   450
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   451
  set(badHeapWordVal, G3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   452
  set(badHeapWordVal, G4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   453
  set(badHeapWordVal, G5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   454
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   455
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   456
  // get oop result if there is one and reset the value in the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   457
  if (oop_result->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   458
    get_vm_result(oop_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   459
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   460
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   461
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   462
void MacroAssembler::check_and_forward_exception(Register scratch_reg)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   463
{
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   464
  Label L;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   465
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   466
  check_and_handle_popframe(scratch_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   467
  check_and_handle_earlyret(scratch_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   468
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   469
  Address exception_addr(G2_thread, Thread::pending_exception_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   470
  ld_ptr(exception_addr, scratch_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   471
  br_null_short(scratch_reg, pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   472
  // we use O7 linkage so that forward_exception_entry has the issuing PC
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   473
  call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   474
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   475
  bind(L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   476
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   477
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   478
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   479
void MacroAssembler::check_and_handle_popframe(Register scratch_reg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   480
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   481
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   482
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   483
void MacroAssembler::check_and_handle_earlyret(Register scratch_reg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   484
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   485
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   486
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   487
void MacroAssembler::call_VM(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   488
  call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   489
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   490
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   491
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   492
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   493
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   494
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   495
  call_VM(oop_result, entry_point, 1, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   496
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   497
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   498
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   499
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   500
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   501
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   502
  mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   503
  call_VM(oop_result, entry_point, 2, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   504
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   505
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   506
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   507
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   508
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   509
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   510
  mov(arg_2, O2); assert(arg_2 != O1,                "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   511
  mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   512
  call_VM(oop_result, entry_point, 3, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   513
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   514
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   515
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   516
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   517
// Note: The following call_VM overloadings are useful when a "save"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   518
// has already been performed by a stub, and the last Java frame is
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   519
// the previous one.  In that case, last_java_sp must be passed as FP
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   520
// instead of SP.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   521
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   522
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   523
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, int number_of_arguments, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   524
  call_VM_base(oop_result, noreg, last_java_sp, entry_point, number_of_arguments, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   525
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   526
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   527
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   528
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   529
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   530
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   531
  call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   532
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   533
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   534
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   535
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   536
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   537
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   538
  mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   539
  call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   540
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   541
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   542
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   543
void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   544
  // O0 is reserved for the thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   545
  mov(arg_1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   546
  mov(arg_2, O2); assert(arg_2 != O1,                "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   547
  mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   548
  call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   549
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   550
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   551
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   552
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   553
void MacroAssembler::call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   554
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   555
  save_thread(thread_cache);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   556
  // do the call
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   557
  call(entry_point, relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   558
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   559
  restore_thread(thread_cache);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   560
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   561
  set(badHeapWordVal, G3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   562
  set(badHeapWordVal, G4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   563
  set(badHeapWordVal, G5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   564
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   565
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   566
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   567
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   568
void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   569
  call_VM_leaf_base(thread_cache, entry_point, number_of_arguments);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   570
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   571
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   572
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   573
void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   574
  mov(arg_1, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   575
  call_VM_leaf(thread_cache, entry_point, 1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   576
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   577
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   578
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   579
void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   580
  mov(arg_1, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   581
  mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   582
  call_VM_leaf(thread_cache, entry_point, 2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   583
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   584
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   585
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   586
void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2, Register arg_3) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   587
  mov(arg_1, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   588
  mov(arg_2, O1); assert(arg_2 != O0,                "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   589
  mov(arg_3, O2); assert(arg_3 != O0 && arg_3 != O1, "smashed argument");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   590
  call_VM_leaf(thread_cache, entry_point, 3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   591
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   592
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   593
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   594
void MacroAssembler::get_vm_result(Register oop_result) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   595
  verify_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   596
  Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   597
  ld_ptr(    vm_result_addr, oop_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   598
  st_ptr(G0, vm_result_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   599
  verify_oop(oop_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   600
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   601
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   602
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   603
void MacroAssembler::get_vm_result_2(Register metadata_result) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   604
  verify_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   605
  Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   606
  ld_ptr(vm_result_addr_2, metadata_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   607
  st_ptr(G0, vm_result_addr_2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   608
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   609
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   610
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   611
// We require that C code which does not return a value in vm_result will
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   612
// leave it undisturbed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   613
void MacroAssembler::set_vm_result(Register oop_result) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   614
  verify_thread();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   615
  Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   616
  verify_oop(oop_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   617
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   618
# ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   619
    // Check that we are not overwriting any other oop.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   620
    save_frame_and_mov(0, Lmethod, Lmethod);     // Propagate Lmethod for -Xprof
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   621
    ld_ptr(vm_result_addr, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   622
    tst(L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   623
    restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   624
    breakpoint_trap(notZero, Assembler::ptr_cc);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   625
    // }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   626
# endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   627
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   628
  st_ptr(oop_result, vm_result_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   629
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   630
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   631
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 34211
diff changeset
   632
void MacroAssembler::ic_call(address entry, bool emit_delay, jint method_index) {
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 34211
diff changeset
   633
  RelocationHolder rspec = virtual_call_Relocation::spec(pc(), method_index);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   634
  patchable_set((intptr_t)Universe::non_oop_word(), G5_inline_cache_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   635
  relocate(rspec);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   636
  call(entry, relocInfo::none);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   637
  if (emit_delay) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   638
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   639
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   640
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   641
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   642
void MacroAssembler::card_table_write(jbyte* byte_map_base,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   643
                                      Register tmp, Register obj) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   644
  srlx(obj, CardTableModRefBS::card_shift, obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   645
  assert(tmp != obj, "need separate temp reg");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   646
  set((address) byte_map_base, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   647
  stb(G0, tmp, obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   648
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   649
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   650
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   651
void MacroAssembler::internal_sethi(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   652
  address save_pc;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   653
  int shiftcnt;
46596
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46592
diff changeset
   654
#ifdef VALIDATE_PIPELINE
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46592
diff changeset
   655
  assert_no_delay("Cannot put two instructions in delay-slot.");
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46592
diff changeset
   656
#endif
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   657
  v9_dep();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   658
  save_pc = pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   659
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   660
  int msb32 = (int) (addrlit.value() >> 32);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   661
  int lsb32 = (int) (addrlit.value());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   662
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   663
  if (msb32 == 0 && lsb32 >= 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   664
    Assembler::sethi(lsb32, d, addrlit.rspec());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   665
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   666
  else if (msb32 == -1) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   667
    Assembler::sethi(~lsb32, d, addrlit.rspec());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   668
    xor3(d, ~low10(~0), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   669
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   670
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   671
    Assembler::sethi(msb32, d, addrlit.rspec());  // msb 22-bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   672
    if (msb32 & 0x3ff)                            // Any bits?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   673
      or3(d, msb32 & 0x3ff, d);                   // msb 32-bits are now in lsb 32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   674
    if (lsb32 & 0xFFFFFC00) {                     // done?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   675
      if ((lsb32 >> 20) & 0xfff) {                // Any bits set?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   676
        sllx(d, 12, d);                           // Make room for next 12 bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   677
        or3(d, (lsb32 >> 20) & 0xfff, d);         // Or in next 12
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   678
        shiftcnt = 0;                             // We already shifted
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   679
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   680
      else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   681
        shiftcnt = 12;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   682
      if ((lsb32 >> 10) & 0x3ff) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   683
        sllx(d, shiftcnt + 10, d);                // Make room for last 10 bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   684
        or3(d, (lsb32 >> 10) & 0x3ff, d);         // Or in next 10
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   685
        shiftcnt = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   686
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   687
      else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   688
        shiftcnt = 10;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   689
      sllx(d, shiftcnt + 10, d);                  // Shift leaving disp field 0'd
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   690
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   691
    else
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   692
      sllx(d, 32, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   693
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   694
  // Pad out the instruction sequence so it can be patched later.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   695
  if (ForceRelocatable || (addrlit.rtype() != relocInfo::none &&
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   696
                           addrlit.rtype() != relocInfo::runtime_call_type)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   697
    while (pc() < (save_pc + (7 * BytesPerInstWord)))
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   698
      nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   699
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   700
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   701
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   702
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   703
void MacroAssembler::sethi(const AddressLiteral& addrlit, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   704
  internal_sethi(addrlit, d, false);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   705
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   706
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   707
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   708
void MacroAssembler::patchable_sethi(const AddressLiteral& addrlit, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   709
  internal_sethi(addrlit, d, true);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   710
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   711
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   712
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   713
int MacroAssembler::insts_for_sethi(address a, bool worst_case) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   714
  if (worst_case)  return 7;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   715
  intptr_t iaddr = (intptr_t) a;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   716
  int msb32 = (int) (iaddr >> 32);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   717
  int lsb32 = (int) (iaddr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   718
  int count;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   719
  if (msb32 == 0 && lsb32 >= 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   720
    count = 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   721
  else if (msb32 == -1)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   722
    count = 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   723
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   724
    count = 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   725
    if (msb32 & 0x3ff)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   726
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   727
    if (lsb32 & 0xFFFFFC00 ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   728
      if ((lsb32 >> 20) & 0xfff)  count += 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   729
      if ((lsb32 >> 10) & 0x3ff)  count += 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   730
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   731
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   732
  return count;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   733
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   734
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   735
int MacroAssembler::worst_case_insts_for_set() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   736
  return insts_for_sethi(NULL, true) + 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   737
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   738
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   739
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   740
// Keep in sync with MacroAssembler::insts_for_internal_set
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   741
void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   742
  intptr_t value = addrlit.value();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   743
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   744
  if (!ForceRelocatable && addrlit.rspec().type() == relocInfo::none) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   745
    // can optimize
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   746
    if (-4096 <= value && value <= 4095) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   747
      or3(G0, value, d); // setsw (this leaves upper 32 bits sign-extended)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   748
      return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   749
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   750
    if (inv_hi22(hi22(value)) == value) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   751
      sethi(addrlit, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   752
      return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   753
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   754
  }
46596
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46592
diff changeset
   755
  assert_no_delay("Cannot put two instructions in delay-slot.");
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   756
  internal_sethi(addrlit, d, ForceRelocatable);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   757
  if (ForceRelocatable || addrlit.rspec().type() != relocInfo::none || addrlit.low10() != 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   758
    add(d, addrlit.low10(), d, addrlit.rspec());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   759
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   760
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   761
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   762
// Keep in sync with MacroAssembler::internal_set
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   763
int MacroAssembler::insts_for_internal_set(intptr_t value) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   764
  // can optimize
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   765
  if (-4096 <= value && value <= 4095) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   766
    return 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   767
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   768
  if (inv_hi22(hi22(value)) == value) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   769
    return insts_for_sethi((address) value);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   770
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   771
  int count = insts_for_sethi((address) value);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   772
  AddressLiteral al(value);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   773
  if (al.low10() != 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   774
    count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   775
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   776
  return count;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   777
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   778
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   779
void MacroAssembler::set(const AddressLiteral& al, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   780
  internal_set(al, d, false);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   781
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   782
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   783
void MacroAssembler::set(intptr_t value, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   784
  AddressLiteral al(value);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   785
  internal_set(al, d, false);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   786
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   787
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   788
void MacroAssembler::set(address addr, Register d, RelocationHolder const& rspec) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   789
  AddressLiteral al(addr, rspec);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   790
  internal_set(al, d, false);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   791
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   792
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   793
void MacroAssembler::patchable_set(const AddressLiteral& al, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   794
  internal_set(al, d, true);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   795
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   796
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   797
void MacroAssembler::patchable_set(intptr_t value, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   798
  AddressLiteral al(value);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   799
  internal_set(al, d, true);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   800
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   801
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   802
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   803
void MacroAssembler::set64(jlong value, Register d, Register tmp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   804
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   805
  v9_dep();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   806
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   807
  int hi = (int)(value >> 32);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   808
  int lo = (int)(value & ~0);
31515
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   809
  int bits_33to2 = (int)((value >> 2) & ~0);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   810
  // (Matcher::isSimpleConstant64 knows about the following optimizations.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   811
  if (Assembler::is_simm13(lo) && value == lo) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   812
    or3(G0, lo, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   813
  } else if (hi == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   814
    Assembler::sethi(lo, d);   // hardware version zero-extends to upper 32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   815
    if (low10(lo) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   816
      or3(d, low10(lo), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   817
  }
31515
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   818
  else if ((hi >> 2) == 0) {
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   819
    Assembler::sethi(bits_33to2, d);  // hardware version zero-extends to upper 32
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   820
    sllx(d, 2, d);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   821
    if (low12(lo) != 0)
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   822
      or3(d, low12(lo), d);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
   823
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   824
  else if (hi == -1) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   825
    Assembler::sethi(~lo, d);  // hardware version zero-extends to upper 32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   826
    xor3(d, low10(lo) ^ ~low10(~0), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   827
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   828
  else if (lo == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   829
    if (Assembler::is_simm13(hi)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   830
      or3(G0, hi, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   831
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   832
      Assembler::sethi(hi, d);   // hardware version zero-extends to upper 32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   833
      if (low10(hi) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   834
        or3(d, low10(hi), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   835
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   836
    sllx(d, 32, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   837
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   838
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   839
    Assembler::sethi(hi, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   840
    Assembler::sethi(lo,   d); // macro assembler version sign-extends
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   841
    if (low10(hi) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   842
      or3 (tmp, low10(hi), tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   843
    if (low10(lo) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   844
      or3 (  d, low10(lo),   d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   845
    sllx(tmp, 32, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   846
    or3 (d, tmp, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   847
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   848
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   849
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   850
int MacroAssembler::insts_for_set64(jlong value) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   851
  v9_dep();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   852
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   853
  int hi = (int) (value >> 32);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   854
  int lo = (int) (value & ~0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   855
  int count = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   856
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   857
  // (Matcher::isSimpleConstant64 knows about the following optimizations.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   858
  if (Assembler::is_simm13(lo) && value == lo) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   859
    count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   860
  } else if (hi == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   861
    count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   862
    if (low10(lo) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   863
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   864
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   865
  else if (hi == -1) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   866
    count += 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   867
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   868
  else if (lo == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   869
    if (Assembler::is_simm13(hi)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   870
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   871
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   872
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   873
      if (low10(hi) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   874
        count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   875
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   876
    count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   877
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   878
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   879
    count += 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   880
    if (low10(hi) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   881
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   882
    if (low10(lo) != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   883
      count++;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   884
    count += 2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   885
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   886
  return count;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   887
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   888
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   889
// compute size in bytes of sparc frame, given
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   890
// number of extraWords
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   891
int MacroAssembler::total_frame_size_in_bytes(int extraWords) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   892
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   893
  int nWords = frame::memory_parameter_word_sp_offset;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   894
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   895
  nWords += extraWords;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   896
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   897
  if (nWords & 1) ++nWords; // round up to double-word
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   898
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   899
  return nWords * BytesPerWord;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   900
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   901
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   902
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   903
// save_frame: given number of "extra" words in frame,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   904
// issue approp. save instruction (p 200, v8 manual)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   905
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   906
void MacroAssembler::save_frame(int extraWords) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   907
  int delta = -total_frame_size_in_bytes(extraWords);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   908
  if (is_simm13(delta)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   909
    save(SP, delta, SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   910
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   911
    set(delta, G3_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   912
    save(SP, G3_scratch, SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   913
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   914
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   915
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   916
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   917
void MacroAssembler::save_frame_c1(int size_in_bytes) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   918
  if (is_simm13(-size_in_bytes)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   919
    save(SP, -size_in_bytes, SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   920
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   921
    set(-size_in_bytes, G3_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   922
    save(SP, G3_scratch, SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   923
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   924
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   925
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   926
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   927
void MacroAssembler::save_frame_and_mov(int extraWords,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   928
                                        Register s1, Register d1,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   929
                                        Register s2, Register d2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   930
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   931
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   932
  // The trick here is to use precisely the same memory word
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   933
  // that trap handlers also use to save the register.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   934
  // This word cannot be used for any other purpose, but
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   935
  // it works fine to save the register's value, whether or not
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   936
  // an interrupt flushes register windows at any given moment!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   937
  Address s1_addr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   938
  if (s1->is_valid() && (s1->is_in() || s1->is_local())) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   939
    s1_addr = s1->address_in_saved_window();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   940
    st_ptr(s1, s1_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   941
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   942
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   943
  Address s2_addr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   944
  if (s2->is_valid() && (s2->is_in() || s2->is_local())) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   945
    s2_addr = s2->address_in_saved_window();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   946
    st_ptr(s2, s2_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   947
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   948
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   949
  save_frame(extraWords);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   950
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   951
  if (s1_addr.base() == SP) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   952
    ld_ptr(s1_addr.after_save(), d1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   953
  } else if (s1->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   954
    mov(s1->after_save(), d1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   955
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   956
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   957
  if (s2_addr.base() == SP) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   958
    ld_ptr(s2_addr.after_save(), d2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   959
  } else if (s2->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   960
    mov(s2->after_save(), d2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   961
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   962
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   963
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   964
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   965
AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   966
  assert(oop_recorder() != NULL, "this assembler needs a Recorder");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   967
  int index = oop_recorder()->allocate_metadata_index(obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   968
  RelocationHolder rspec = metadata_Relocation::spec(index);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   969
  return AddressLiteral((address)obj, rspec);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   970
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   971
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   972
AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   973
  assert(oop_recorder() != NULL, "this assembler needs a Recorder");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   974
  int index = oop_recorder()->find_index(obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   975
  RelocationHolder rspec = metadata_Relocation::spec(index);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   976
  return AddressLiteral((address)obj, rspec);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   977
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   978
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   979
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   980
AddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   981
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   982
  assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(obj)), "not an oop");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   983
  int oop_index = oop_recorder()->find_index(obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   984
  return AddressLiteral(obj, oop_Relocation::spec(oop_index));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   985
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   986
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   987
void  MacroAssembler::set_narrow_oop(jobject obj, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   988
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   989
  int oop_index = oop_recorder()->find_index(obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   990
  RelocationHolder rspec = oop_Relocation::spec(oop_index);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   991
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   992
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   993
  // Relocation with special format (see relocInfo_sparc.hpp).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   994
  relocate(rspec, 1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   995
  // Assembler::sethi(0x3fffff, d);
15116
af423dcb739c 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 14827
diff changeset
   996
  emit_int32( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(0x3fffff) );
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   997
  // Don't add relocation for 'add'. Do patching during 'sethi' processing.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   998
  add(d, 0x3ff, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
   999
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1000
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1001
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1002
void  MacroAssembler::set_narrow_klass(Klass* k, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1003
  assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1004
  int klass_index = oop_recorder()->find_index(k);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1005
  RelocationHolder rspec = metadata_Relocation::spec(klass_index);
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  1006
  narrowOop encoded_k = Klass::encode_klass(k);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1007
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1008
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1009
  // Relocation with special format (see relocInfo_sparc.hpp).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1010
  relocate(rspec, 1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1011
  // Assembler::sethi(encoded_k, d);
15116
af423dcb739c 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 14827
diff changeset
  1012
  emit_int32( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(encoded_k) );
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1013
  // Don't add relocation for 'add'. Do patching during 'sethi' processing.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1014
  add(d, low10(encoded_k), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1015
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1016
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1017
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1018
void MacroAssembler::align(int modulus) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1019
  while (offset() % modulus != 0) nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1020
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1021
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1022
void RegistersForDebugging::print(outputStream* s) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1023
  FlagSetting fs(Debugging, true);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1024
  int j;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1025
  for (j = 0; j < 8; ++j) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1026
    if (j != 6) { s->print("i%d = ", j); os::print_location(s, i[j]); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1027
    else        { s->print( "fp = "   ); os::print_location(s, i[j]); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1028
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1029
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1030
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1031
  for (j = 0;  j < 8;  ++j) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1032
    s->print("l%d = ", j); os::print_location(s, l[j]);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1033
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1034
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1035
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1036
  for (j = 0; j < 8; ++j) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1037
    if (j != 6) { s->print("o%d = ", j); os::print_location(s, o[j]); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1038
    else        { s->print( "sp = "   ); os::print_location(s, o[j]); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1039
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1040
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1041
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1042
  for (j = 0; j < 8; ++j) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1043
    s->print("g%d = ", j); os::print_location(s, g[j]);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1044
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1045
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1046
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1047
  // print out floats with compression
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1048
  for (j = 0; j < 32; ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1049
    jfloat val = f[j];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1050
    int last = j;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1051
    for ( ;  last+1 < 32;  ++last ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1052
      char b1[1024], b2[1024];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1053
      sprintf(b1, "%f", val);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1054
      sprintf(b2, "%f", f[last+1]);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1055
      if (strcmp(b1, b2))
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1056
        break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1057
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1058
    s->print("f%d", j);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1059
    if ( j != last )  s->print(" - f%d", last);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1060
    s->print(" = %f", val);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1061
    s->fill_to(25);
24917
bf961166fa07 8044071: Print format/argument warnings
mikael
parents: 24018
diff changeset
  1062
    s->print_cr(" (0x%x)", *(int*)&val);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1063
    j = last + 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1064
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1065
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1066
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1067
  // and doubles (evens only)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1068
  for (j = 0; j < 32; ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1069
    jdouble val = d[j];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1070
    int last = j;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1071
    for ( ;  last+1 < 32;  ++last ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1072
      char b1[1024], b2[1024];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1073
      sprintf(b1, "%f", val);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1074
      sprintf(b2, "%f", d[last+1]);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1075
      if (strcmp(b1, b2))
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1076
        break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1077
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1078
    s->print("d%d", 2 * j);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1079
    if ( j != last )  s->print(" - d%d", last);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1080
    s->print(" = %f", val);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1081
    s->fill_to(30);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1082
    s->print("(0x%x)", *(int*)&val);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1083
    s->fill_to(42);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1084
    s->print_cr("(0x%x)", *(1 + (int*)&val));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1085
    j = last + 1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1086
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1087
  s->cr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1088
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1089
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1090
void RegistersForDebugging::save_registers(MacroAssembler* a) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1091
  a->sub(FP, round_to(sizeof(RegistersForDebugging), sizeof(jdouble)) - STACK_BIAS, O0);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1092
  a->flushw();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1093
  int i;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1094
  for (i = 0; i < 8; ++i) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1095
    a->ld_ptr(as_iRegister(i)->address_in_saved_window().after_save(), L1);  a->st_ptr( L1, O0, i_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1096
    a->ld_ptr(as_lRegister(i)->address_in_saved_window().after_save(), L1);  a->st_ptr( L1, O0, l_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1097
    a->st_ptr(as_oRegister(i)->after_save(), O0, o_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1098
    a->st_ptr(as_gRegister(i)->after_save(), O0, g_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1099
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1100
  for (i = 0;  i < 32; ++i) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1101
    a->stf(FloatRegisterImpl::S, as_FloatRegister(i), O0, f_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1102
  }
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1103
  for (i = 0; i < 64; i += 2) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1104
    a->stf(FloatRegisterImpl::D, as_FloatRegister(i), O0, d_offset(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1105
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1106
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1107
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1108
void RegistersForDebugging::restore_registers(MacroAssembler* a, Register r) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1109
  for (int i = 1; i < 8;  ++i) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1110
    a->ld_ptr(r, g_offset(i), as_gRegister(i));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1111
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1112
  for (int j = 0; j < 32; ++j) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1113
    a->ldf(FloatRegisterImpl::S, O0, f_offset(j), as_FloatRegister(j));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1114
  }
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1115
  for (int k = 0; k < 64; k += 2) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1116
    a->ldf(FloatRegisterImpl::D, O0, d_offset(k), as_FloatRegister(k));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1117
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1118
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1119
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1120
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1121
// pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1122
void MacroAssembler::push_fTOS() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1123
  // %%%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1124
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1125
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1126
// pops double TOS element from CPU stack and pushes on FPU stack
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1127
void MacroAssembler::pop_fTOS() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1128
  // %%%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1129
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1130
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1131
void MacroAssembler::empty_FPU_stack() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1132
  // %%%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1133
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1134
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1135
void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1136
  // plausibility check for oops
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1137
  if (!VerifyOops) return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1138
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1139
  if (reg == G0)  return;       // always NULL, which is always an oop
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1140
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1141
  BLOCK_COMMENT("verify_oop {");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1142
  char buffer[64];
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1143
#ifdef COMPILER1
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1144
  if (CommentedAssembly) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1145
    snprintf(buffer, sizeof(buffer), "verify_oop at %d", offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1146
    block_comment(buffer);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1147
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1148
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1149
16368
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1150
  const char* real_msg = NULL;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1151
  {
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1152
    ResourceMark rm;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1153
    stringStream ss;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1154
    ss.print("%s at offset %d (%s:%d)", msg, offset(), file, line);
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1155
    real_msg = code_string(ss.as_string());
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1156
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1157
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1158
  // Call indirectly to solve generation ordering problem
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1159
  AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1160
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1161
  // Make some space on stack above the current register window.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1162
  // Enough to hold 8 64-bit registers.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1163
  add(SP,-8*8,SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1164
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1165
  // Save some 64-bit registers; a normal 'save' chops the heads off
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1166
  // of 64-bit longs in the 32-bit build.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1167
  stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1168
  stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1169
  mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1170
  stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1171
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1172
  // Size of set() should stay the same
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1173
  patchable_set((intptr_t)real_msg, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1174
  // Load address to call to into O7
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1175
  load_ptr_contents(a, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1176
  // Register call to verify_oop_subroutine
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1177
  callr(O7, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1178
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1179
  // recover frame size
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1180
  add(SP, 8*8,SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1181
  BLOCK_COMMENT("} verify_oop");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1182
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1183
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1184
void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char * file, int line) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1185
  // plausibility check for oops
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1186
  if (!VerifyOops) return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1187
16368
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1188
  const char* real_msg = NULL;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1189
  {
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1190
    ResourceMark rm;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1191
    stringStream ss;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1192
    ss.print("%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1193
    real_msg = code_string(ss.as_string());
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1194
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1195
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1196
  // Call indirectly to solve generation ordering problem
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1197
  AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1198
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1199
  // Make some space on stack above the current register window.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1200
  // Enough to hold 8 64-bit registers.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1201
  add(SP,-8*8,SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1202
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1203
  // Save some 64-bit registers; a normal 'save' chops the heads off
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1204
  // of 64-bit longs in the 32-bit build.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1205
  stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1206
  stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1207
  ld_ptr(addr.base(), addr.disp() + 8*8, O0); // Load arg into O0; arg might be in O7 which is about to be crushed
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1208
  stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1209
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1210
  // Size of set() should stay the same
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1211
  patchable_set((intptr_t)real_msg, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1212
  // Load address to call to into O7
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1213
  load_ptr_contents(a, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1214
  // Register call to verify_oop_subroutine
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1215
  callr(O7, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1216
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1217
  // recover frame size
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1218
  add(SP, 8*8,SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1219
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1220
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1221
// side-door communication with signalHandler in os_solaris.cpp
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1222
address MacroAssembler::_verify_oop_implicit_branch[3] = { NULL };
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1223
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1224
// This macro is expanded just once; it creates shared code.  Contract:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1225
// receives an oop in O0.  Must restore O0 & O7 from TLS.  Must not smash ANY
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1226
// registers, including flags.  May not use a register 'save', as this blows
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1227
// the high bits of the O-regs if they contain Long values.  Acts as a 'leaf'
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1228
// call.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1229
void MacroAssembler::verify_oop_subroutine() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1230
  // Leaf call; no frame.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1231
  Label succeed, fail, null_or_fail;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1232
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1233
  // O0 and O7 were saved already (O0 in O0's TLS home, O7 in O5's TLS home).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1234
  // O0 is now the oop to be checked.  O7 is the return address.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1235
  Register O0_obj = O0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1236
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1237
  // Save some more registers for temps.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1238
  stx(O2,SP,frame::register_save_words*wordSize+STACK_BIAS+2*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1239
  stx(O3,SP,frame::register_save_words*wordSize+STACK_BIAS+3*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1240
  stx(O4,SP,frame::register_save_words*wordSize+STACK_BIAS+4*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1241
  stx(O5,SP,frame::register_save_words*wordSize+STACK_BIAS+5*8);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1242
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1243
  // Save flags
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1244
  Register O5_save_flags = O5;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1245
  rdccr( O5_save_flags );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1246
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1247
  { // count number of verifies
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1248
    Register O2_adr   = O2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1249
    Register O3_accum = O3;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1250
    inc_counter(StubRoutines::verify_oop_count_addr(), O2_adr, O3_accum);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1251
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1252
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1253
  Register O2_mask = O2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1254
  Register O3_bits = O3;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1255
  Register O4_temp = O4;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1256
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1257
  // mark lower end of faulting range
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1258
  assert(_verify_oop_implicit_branch[0] == NULL, "set once");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1259
  _verify_oop_implicit_branch[0] = pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1260
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1261
  // We can't check the mark oop because it could be in the process of
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1262
  // locking or unlocking while this is running.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1263
  set(Universe::verify_oop_mask (), O2_mask);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1264
  set(Universe::verify_oop_bits (), O3_bits);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1265
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1266
  // assert((obj & oop_mask) == oop_bits);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1267
  and3(O0_obj, O2_mask, O4_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1268
  cmp_and_brx_short(O4_temp, O3_bits, notEqual, pn, null_or_fail);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1269
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1270
  if ((NULL_WORD & Universe::verify_oop_mask()) == Universe::verify_oop_bits()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1271
    // the null_or_fail case is useless; must test for null separately
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1272
    br_null_short(O0_obj, pn, succeed);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1273
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1274
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1275
  // Check the Klass* of this object for being in the right area of memory.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1276
  // Cannot do the load in the delay above slot in case O0 is null
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1277
  load_klass(O0_obj, O0_obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1278
  // assert((klass != NULL)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1279
  br_null_short(O0_obj, pn, fail);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1280
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1281
  wrccr( O5_save_flags ); // Restore CCR's
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1282
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1283
  // mark upper end of faulting range
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1284
  _verify_oop_implicit_branch[1] = pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1285
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1286
  //-----------------------
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1287
  // all tests pass
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1288
  bind(succeed);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1289
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1290
  // Restore prior 64-bit registers
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1291
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+0*8,O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1292
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+1*8,O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1293
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+2*8,O2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1294
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+3*8,O3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1295
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+4*8,O4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1296
  ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+5*8,O5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1297
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1298
  retl();                       // Leaf return; restore prior O7 in delay slot
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1299
  delayed()->ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+7*8,O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1300
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1301
  //-----------------------
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1302
  bind(null_or_fail);           // nulls are less common but OK
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1303
  br_null(O0_obj, false, pt, succeed);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1304
  delayed()->wrccr( O5_save_flags ); // Restore CCR's
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1305
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1306
  //-----------------------
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1307
  // report failure:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1308
  bind(fail);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1309
  _verify_oop_implicit_branch[2] = pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1310
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1311
  wrccr( O5_save_flags ); // Restore CCR's
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1312
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1313
  save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1314
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1315
  // stop_subroutine expects message pointer in I1.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1316
  mov(I1, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1317
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1318
  // Restore prior 64-bit registers
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1319
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+0*8,I0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1320
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+1*8,I1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1321
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+2*8,I2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1322
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+3*8,I3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1323
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+4*8,I4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1324
  ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+5*8,I5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1325
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1326
  // factor long stop-sequence into subroutine to save space
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1327
  assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1328
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1329
  // call indirectly to solve generation ordering problem
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1330
  AddressLiteral al(StubRoutines::Sparc::stop_subroutine_entry_address());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1331
  load_ptr_contents(al, O5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1332
  jmpl(O5, 0, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1333
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1334
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1335
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1336
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1337
void MacroAssembler::stop(const char* msg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1338
  // save frame first to get O7 for return address
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1339
  // add one word to size in case struct is odd number of words long
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1340
  // It must be doubleword-aligned for storing doubles into it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1341
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1342
    save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1343
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1344
    // stop_subroutine expects message pointer in I1.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1345
    // Size of set() should stay the same
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1346
    patchable_set((intptr_t)msg, O1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1347
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1348
    // factor long stop-sequence into subroutine to save space
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1349
    assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1350
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1351
    // call indirectly to solve generation ordering problem
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1352
    AddressLiteral a(StubRoutines::Sparc::stop_subroutine_entry_address());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1353
    load_ptr_contents(a, O5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1354
    jmpl(O5, 0, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1355
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1356
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1357
    breakpoint_trap();   // make stop actually stop rather than writing
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1358
                         // unnoticeable results in the output files.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1359
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1360
    // restore(); done in callee to save space!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1361
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1362
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1363
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1364
void MacroAssembler::warn(const char* msg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1365
  save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1366
  RegistersForDebugging::save_registers(this);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1367
  mov(O0, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1368
  // Size of set() should stay the same
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1369
  patchable_set((intptr_t)msg, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1370
  call( CAST_FROM_FN_PTR(address, warning) );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1371
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1372
//  ret();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1373
//  delayed()->restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1374
  RegistersForDebugging::restore_registers(this, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1375
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1376
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1377
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1378
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1379
void MacroAssembler::untested(const char* what) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1380
  // We must be able to turn interactive prompting off
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1381
  // in order to run automated test scripts on the VM
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1382
  // Use the flag ShowMessageBoxOnError
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1383
16368
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1384
  const char* b = NULL;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1385
  {
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1386
    ResourceMark rm;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1387
    stringStream ss;
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1388
    ss.print("untested: %s", what);
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1389
    b = code_string(ss.as_string());
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 15482
diff changeset
  1390
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1391
  if (ShowMessageBoxOnError) { STOP(b); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1392
  else                       { warn(b); }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1393
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1394
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1395
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1396
void MacroAssembler::unimplemented(const char* what) {
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1397
  char* b = new char[1024];
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1398
  jio_snprintf(b, 1024, "unimplemented: %s", what);
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1399
  stop(b);
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1400
}
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1401
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46381
diff changeset
  1402
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1403
void MacroAssembler::stop_subroutine() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1404
  RegistersForDebugging::save_registers(this);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1405
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1406
  // for the sake of the debugger, stick a PC on the current frame
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1407
  // (this assumes that the caller has performed an extra "save")
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1408
  mov(I7, L7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1409
  add(O7, -7 * BytesPerInt, I7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1410
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1411
  save_frame(); // one more save to free up another O7 register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1412
  mov(I0, O1); // addr of reg save area
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1413
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1414
  // We expect pointer to message in I1. Caller must set it up in O1
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1415
  mov(I1, O0); // get msg
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1416
  call (CAST_FROM_FN_PTR(address, MacroAssembler::debug), relocInfo::runtime_call_type);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1417
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1418
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1419
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1420
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1421
  RegistersForDebugging::restore_registers(this, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1422
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1423
  save_frame(0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1424
  call(CAST_FROM_FN_PTR(address,breakpoint));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1425
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1426
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1427
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1428
  mov(L7, I7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1429
  retl();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1430
  delayed()->restore(); // see stop above
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1431
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1432
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1433
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1434
void MacroAssembler::debug(char* msg, RegistersForDebugging* regs) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1435
  if ( ShowMessageBoxOnError ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1436
    JavaThread* thread = JavaThread::current();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1437
    JavaThreadState saved_state = thread->thread_state();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1438
    thread->set_thread_state(_thread_in_vm);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1439
      {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1440
        // In order to get locks work, we need to fake a in_VM state
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1441
        ttyLocker ttyl;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1442
        ::tty->print_cr("EXECUTION STOPPED: %s\n", msg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1443
        if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1444
        BytecodeCounter::print();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1445
        }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1446
        if (os::message_box(msg, "Execution stopped, print registers?"))
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1447
          regs->print(::tty);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1448
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1449
    BREAKPOINT;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1450
      ThreadStateTransition::transition(JavaThread::current(), _thread_in_vm, saved_state);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1451
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1452
  else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1453
     ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1454
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32596
diff changeset
  1455
  assert(false, "DEBUG MESSAGE: %s", msg);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1456
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1457
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1458
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1459
void MacroAssembler::calc_mem_param_words(Register Rparam_words, Register Rresult) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1460
  subcc( Rparam_words, Argument::n_register_parameters, Rresult); // how many mem words?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1461
  Label no_extras;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1462
  br( negative, true, pt, no_extras ); // if neg, clear reg
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1463
  delayed()->set(0, Rresult);          // annuled, so only if taken
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1464
  bind( no_extras );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1465
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1466
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1467
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1468
void MacroAssembler::calc_frame_size(Register Rextra_words, Register Rresult) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1469
  add(Rextra_words, frame::memory_parameter_word_sp_offset, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1470
  bclr(1, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1471
  sll(Rresult, LogBytesPerWord, Rresult);  // Rresult has total frame bytes
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1472
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1473
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1474
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1475
void MacroAssembler::calc_frame_size_and_save(Register Rextra_words, Register Rresult) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1476
  calc_frame_size(Rextra_words, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1477
  neg(Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1478
  save(SP, Rresult, SP);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1479
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1480
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1481
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1482
// ---------------------------------------------------------
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1483
Assembler::RCondition cond2rcond(Assembler::Condition c) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1484
  switch (c) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1485
    /*case zero: */
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1486
    case Assembler::equal:        return Assembler::rc_z;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1487
    case Assembler::lessEqual:    return Assembler::rc_lez;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1488
    case Assembler::less:         return Assembler::rc_lz;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1489
    /*case notZero:*/
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1490
    case Assembler::notEqual:     return Assembler::rc_nz;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1491
    case Assembler::greater:      return Assembler::rc_gz;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1492
    case Assembler::greaterEqual: return Assembler::rc_gez;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1493
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1494
  ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1495
  return Assembler::rc_z;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1496
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1497
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1498
// compares (32 bit) register with zero and branches.  NOT FOR USE WITH 64-bit POINTERS
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1499
void MacroAssembler::cmp_zero_and_br(Condition c, Register s1, Label& L, bool a, Predict p) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1500
  tst(s1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1501
  br (c, a, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1502
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1503
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1504
// Compares a pointer register with zero and branches on null.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1505
// Does a test & branch on 32-bit systems and a register-branch on 64-bit.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1506
void MacroAssembler::br_null( Register s1, bool a, Predict p, Label& L ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1507
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1508
  bpr( rc_z, a, p, s1, L );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1509
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1510
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1511
void MacroAssembler::br_notnull( Register s1, bool a, Predict p, Label& L ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1512
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1513
  bpr( rc_nz, a, p, s1, L );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1514
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1515
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1516
// Compare registers and branch with nop in delay slot or cbcond without delay slot.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1517
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1518
// Compare integer (32 bit) values (icc only).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1519
void MacroAssembler::cmp_and_br_short(Register s1, Register s2, Condition c,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1520
                                      Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1521
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1522
  if (use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1523
    Assembler::cbcond(c, icc, s1, s2, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1524
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1525
    cmp(s1, s2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1526
    br(c, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1527
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1528
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1529
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1530
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1531
// Compare integer (32 bit) values (icc only).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1532
void MacroAssembler::cmp_and_br_short(Register s1, int simm13a, Condition c,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1533
                                      Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1534
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1535
  if (is_simm(simm13a,5) && use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1536
    Assembler::cbcond(c, icc, s1, simm13a, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1537
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1538
    cmp(s1, simm13a);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1539
    br(c, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1540
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1541
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1542
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1543
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1544
// Branch that tests xcc in LP64 and icc in !LP64
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1545
void MacroAssembler::cmp_and_brx_short(Register s1, Register s2, Condition c,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1546
                                       Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1547
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1548
  if (use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1549
    Assembler::cbcond(c, ptr_cc, s1, s2, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1550
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1551
    cmp(s1, s2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1552
    brx(c, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1553
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1554
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1555
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1556
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1557
// Branch that tests xcc in LP64 and icc in !LP64
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1558
void MacroAssembler::cmp_and_brx_short(Register s1, int simm13a, Condition c,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1559
                                       Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1560
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1561
  if (is_simm(simm13a,5) && use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1562
    Assembler::cbcond(c, ptr_cc, s1, simm13a, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1563
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1564
    cmp(s1, simm13a);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1565
    brx(c, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1566
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1567
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1568
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1569
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1570
// Short branch version for compares a pointer with zero.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1571
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1572
void MacroAssembler::br_null_short(Register s1, Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1573
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1574
  if (use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1575
    Assembler::cbcond(zero, ptr_cc, s1, 0, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1576
    return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1577
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1578
  br_null(s1, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1579
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1580
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1581
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1582
void MacroAssembler::br_notnull_short(Register s1, Predict p, Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1583
  assert_not_delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1584
  if (use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1585
    Assembler::cbcond(notZero, ptr_cc, s1, 0, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1586
    return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1587
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1588
  br_notnull(s1, false, p, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1589
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1590
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1591
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1592
// Unconditional short branch
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1593
void MacroAssembler::ba_short(Label& L) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1594
  if (use_cbcond(L)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1595
    Assembler::cbcond(equal, icc, G0, G0, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1596
    return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1597
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1598
  br(always, false, pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1599
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1600
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1601
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1602
// instruction sequences factored across compiler & interpreter
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1603
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1604
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1605
void MacroAssembler::lcmp( Register Ra_hi, Register Ra_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1606
                           Register Rb_hi, Register Rb_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1607
                           Register Rresult) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1608
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1609
  Label check_low_parts, done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1610
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1611
  cmp(Ra_hi, Rb_hi );  // compare hi parts
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1612
  br(equal, true, pt, check_low_parts);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1613
  delayed()->cmp(Ra_low, Rb_low); // test low parts
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1614
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1615
  // And, with an unsigned comparison, it does not matter if the numbers
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1616
  // are negative or not.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1617
  // E.g., -2 cmp -1: the low parts are 0xfffffffe and 0xffffffff.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1618
  // The second one is bigger (unsignedly).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1619
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1620
  // Other notes:  The first move in each triplet can be unconditional
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1621
  // (and therefore probably prefetchable).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1622
  // And the equals case for the high part does not need testing,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1623
  // since that triplet is reached only after finding the high halves differ.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1624
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1625
  mov(-1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1626
  ba(done);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1627
  delayed()->movcc(greater, false, icc,  1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1628
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1629
  bind(check_low_parts);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1630
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1631
  mov(                               -1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1632
  movcc(equal,           false, icc,  0, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1633
  movcc(greaterUnsigned, false, icc,  1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1634
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1635
  bind(done);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1636
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1637
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1638
void MacroAssembler::lneg( Register Rhi, Register Rlow ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1639
  subcc(  G0, Rlow, Rlow );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1640
  subc(   G0, Rhi,  Rhi  );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1641
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1642
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1643
void MacroAssembler::lshl( Register Rin_high,  Register Rin_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1644
                           Register Rcount,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1645
                           Register Rout_high, Register Rout_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1646
                           Register Rtemp ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1647
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1648
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1649
  Register Ralt_count = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1650
  Register Rxfer_bits = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1651
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1652
  assert( Ralt_count != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1653
      &&  Ralt_count != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1654
      &&  Ralt_count != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1655
      &&  Rxfer_bits != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1656
      &&  Rxfer_bits != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1657
      &&  Rxfer_bits != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1658
      &&  Rxfer_bits != Rout_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1659
      &&  Rout_low   != Rin_high,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1660
        "register alias checks");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1661
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1662
  Label big_shift, done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1663
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1664
  // This code can be optimized to use the 64 bit shifts in V9.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1665
  // Here we use the 32 bit shifts.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1666
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1667
  and3( Rcount, 0x3f, Rcount);     // take least significant 6 bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1668
  subcc(Rcount,   31, Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1669
  br(greater, true, pn, big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1670
  delayed()->dec(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1671
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1672
  // shift < 32 bits, Ralt_count = Rcount-31
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1673
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1674
  // We get the transfer bits by shifting right by 32-count the low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1675
  // register. This is done by shifting right by 31-count and then by one
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1676
  // more to take care of the special (rare) case where count is zero
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1677
  // (shifting by 32 would not work).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1678
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1679
  neg(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1680
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1681
  // The order of the next two instructions is critical in the case where
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1682
  // Rin and Rout are the same and should not be reversed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1683
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1684
  srl(Rin_low, Ralt_count, Rxfer_bits); // shift right by 31-count
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1685
  if (Rcount != Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1686
    sll(Rin_low, Rcount, Rout_low); // low half
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1687
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1688
  sll(Rin_high, Rcount, Rout_high);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1689
  if (Rcount == Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1690
    sll(Rin_low, Rcount, Rout_low); // low half
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1691
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1692
  srl(Rxfer_bits, 1, Rxfer_bits ); // shift right by one more
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1693
  ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1694
  delayed()->or3(Rout_high, Rxfer_bits, Rout_high);   // new hi value: or in shifted old hi part and xfer from low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1695
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1696
  // shift >= 32 bits, Ralt_count = Rcount-32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1697
  bind(big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1698
  sll(Rin_low, Ralt_count, Rout_high  );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1699
  clr(Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1700
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1701
  bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1702
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1703
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1704
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1705
void MacroAssembler::lshr( Register Rin_high,  Register Rin_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1706
                           Register Rcount,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1707
                           Register Rout_high, Register Rout_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1708
                           Register Rtemp ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1709
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1710
  Register Ralt_count = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1711
  Register Rxfer_bits = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1712
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1713
  assert( Ralt_count != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1714
      &&  Ralt_count != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1715
      &&  Ralt_count != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1716
      &&  Rxfer_bits != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1717
      &&  Rxfer_bits != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1718
      &&  Rxfer_bits != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1719
      &&  Rxfer_bits != Rout_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1720
      &&  Rout_high  != Rin_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1721
        "register alias checks");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1722
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1723
  Label big_shift, done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1724
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1725
  // This code can be optimized to use the 64 bit shifts in V9.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1726
  // Here we use the 32 bit shifts.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1727
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1728
  and3( Rcount, 0x3f, Rcount);     // take least significant 6 bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1729
  subcc(Rcount,   31, Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1730
  br(greater, true, pn, big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1731
  delayed()->dec(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1732
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1733
  // shift < 32 bits, Ralt_count = Rcount-31
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1734
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1735
  // We get the transfer bits by shifting left by 32-count the high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1736
  // register. This is done by shifting left by 31-count and then by one
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1737
  // more to take care of the special (rare) case where count is zero
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1738
  // (shifting by 32 would not work).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1739
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1740
  neg(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1741
  if (Rcount != Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1742
    srl(Rin_low, Rcount, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1743
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1744
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1745
  // The order of the next two instructions is critical in the case where
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1746
  // Rin and Rout are the same and should not be reversed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1747
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1748
  sll(Rin_high, Ralt_count, Rxfer_bits); // shift left by 31-count
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1749
  sra(Rin_high,     Rcount, Rout_high ); // high half
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1750
  sll(Rxfer_bits,        1, Rxfer_bits); // shift left by one more
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1751
  if (Rcount == Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1752
    srl(Rin_low, Rcount, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1753
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1754
  ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1755
  delayed()->or3(Rout_low, Rxfer_bits, Rout_low); // new low value: or shifted old low part and xfer from high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1756
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1757
  // shift >= 32 bits, Ralt_count = Rcount-32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1758
  bind(big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1759
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1760
  sra(Rin_high, Ralt_count, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1761
  sra(Rin_high,         31, Rout_high); // sign into hi
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1762
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1763
  bind( done );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1764
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1765
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1766
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1767
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1768
void MacroAssembler::lushr( Register Rin_high,  Register Rin_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1769
                            Register Rcount,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1770
                            Register Rout_high, Register Rout_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1771
                            Register Rtemp ) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1772
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1773
  Register Ralt_count = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1774
  Register Rxfer_bits = Rtemp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1775
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1776
  assert( Ralt_count != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1777
      &&  Ralt_count != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1778
      &&  Ralt_count != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1779
      &&  Rxfer_bits != Rin_low
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1780
      &&  Rxfer_bits != Rin_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1781
      &&  Rxfer_bits != Rcount
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1782
      &&  Rxfer_bits != Rout_high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1783
      &&  Rout_high  != Rin_low,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1784
        "register alias checks");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1785
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1786
  Label big_shift, done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1787
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1788
  // This code can be optimized to use the 64 bit shifts in V9.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1789
  // Here we use the 32 bit shifts.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1790
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1791
  and3( Rcount, 0x3f, Rcount);     // take least significant 6 bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1792
  subcc(Rcount,   31, Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1793
  br(greater, true, pn, big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1794
  delayed()->dec(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1795
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1796
  // shift < 32 bits, Ralt_count = Rcount-31
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1797
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1798
  // We get the transfer bits by shifting left by 32-count the high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1799
  // register. This is done by shifting left by 31-count and then by one
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1800
  // more to take care of the special (rare) case where count is zero
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1801
  // (shifting by 32 would not work).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1802
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1803
  neg(Ralt_count);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1804
  if (Rcount != Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1805
    srl(Rin_low, Rcount, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1806
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1807
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1808
  // The order of the next two instructions is critical in the case where
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1809
  // Rin and Rout are the same and should not be reversed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1810
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1811
  sll(Rin_high, Ralt_count, Rxfer_bits); // shift left by 31-count
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1812
  srl(Rin_high,     Rcount, Rout_high ); // high half
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1813
  sll(Rxfer_bits,        1, Rxfer_bits); // shift left by one more
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1814
  if (Rcount == Rout_low) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1815
    srl(Rin_low, Rcount, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1816
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1817
  ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1818
  delayed()->or3(Rout_low, Rxfer_bits, Rout_low); // new low value: or shifted old low part and xfer from high
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1819
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1820
  // shift >= 32 bits, Ralt_count = Rcount-32
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1821
  bind(big_shift);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1822
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1823
  srl(Rin_high, Ralt_count, Rout_low);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1824
  clr(Rout_high);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1825
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1826
  bind( done );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1827
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1828
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1829
void MacroAssembler::lcmp( Register Ra, Register Rb, Register Rresult) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1830
  cmp(Ra, Rb);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1831
  mov(-1, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1832
  movcc(equal,   false, xcc,  0, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1833
  movcc(greater, false, xcc,  1, Rresult);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1834
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1835
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1836
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1837
void MacroAssembler::load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1838
  switch (size_in_bytes) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1839
  case  8:  ld_long(src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1840
  case  4:  ld(     src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1841
  case  2:  is_signed ? ldsh(src, dst) : lduh(src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1842
  case  1:  is_signed ? ldsb(src, dst) : ldub(src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1843
  default:  ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1844
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1845
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1846
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1847
void MacroAssembler::store_sized_value(Register src, Address dst, size_t size_in_bytes) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1848
  switch (size_in_bytes) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1849
  case  8:  st_long(src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1850
  case  4:  st(     src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1851
  case  2:  sth(    src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1852
  case  1:  stb(    src, dst); break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1853
  default:  ShouldNotReachHere();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1854
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1855
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1856
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1857
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1858
void MacroAssembler::float_cmp( bool is_float, int unordered_result,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1859
                                FloatRegister Fa, FloatRegister Fb,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1860
                                Register Rresult) {
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1861
  if (is_float) {
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1862
    fcmp(FloatRegisterImpl::S, fcc0, Fa, Fb);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1863
  } else {
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1864
    fcmp(FloatRegisterImpl::D, fcc0, Fa, Fb);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1865
  }
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1866
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1867
  if (unordered_result == 1) {
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1868
    mov(                                    -1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1869
    movcc(f_equal,              true, fcc0,  0, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1870
    movcc(f_unorderedOrGreater, true, fcc0,  1, Rresult);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1871
  } else {
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1872
    mov(                                    -1, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1873
    movcc(f_equal,              true, fcc0,  0, Rresult);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  1874
    movcc(f_greater,            true, fcc0,  1, Rresult);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1875
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1876
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1877
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1878
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1879
void MacroAssembler::save_all_globals_into_locals() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1880
  mov(G1,L1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1881
  mov(G2,L2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1882
  mov(G3,L3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1883
  mov(G4,L4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1884
  mov(G5,L5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1885
  mov(G6,L6);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1886
  mov(G7,L7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1887
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1888
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1889
void MacroAssembler::restore_globals_from_locals() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1890
  mov(L1,G1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1891
  mov(L2,G2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1892
  mov(L3,G3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1893
  mov(L4,G4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1894
  mov(L5,G5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1895
  mov(L6,G6);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1896
  mov(L7,G7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1897
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1898
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1899
RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1900
                                                      Register tmp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1901
                                                      int offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1902
  intptr_t value = *delayed_value_addr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1903
  if (value != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1904
    return RegisterOrConstant(value + offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1905
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1906
  // load indirectly to solve generation ordering problem
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1907
  AddressLiteral a(delayed_value_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1908
  load_ptr_contents(a, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1909
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1910
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1911
  tst(tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1912
  breakpoint_trap(zero, xcc);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1913
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1914
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1915
  if (offset != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1916
    add(tmp, offset, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1917
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1918
  return RegisterOrConstant(tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1919
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1920
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1921
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1922
RegisterOrConstant MacroAssembler::regcon_andn_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1923
  assert(d.register_or_noreg() != G0, "lost side effect");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1924
  if ((s2.is_constant() && s2.as_constant() == 0) ||
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1925
      (s2.is_register() && s2.as_register() == G0)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1926
    // Do nothing, just move value.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1927
    if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1928
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1929
      mov(s1.as_register(), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1930
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1931
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1932
      return s1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1933
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1934
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1935
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1936
  if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1937
    assert_different_registers(s1.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1938
    if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1939
    andn(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1940
    return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1941
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1942
    if (s2.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1943
      assert_different_registers(s2.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1944
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1945
      set(s1.as_constant(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1946
      andn(temp, s2.as_register(), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1947
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1948
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1949
      intptr_t res = s1.as_constant() & ~s2.as_constant();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1950
      return res;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1951
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1952
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1953
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1954
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1955
RegisterOrConstant MacroAssembler::regcon_inc_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1956
  assert(d.register_or_noreg() != G0, "lost side effect");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1957
  if ((s2.is_constant() && s2.as_constant() == 0) ||
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1958
      (s2.is_register() && s2.as_register() == G0)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1959
    // Do nothing, just move value.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1960
    if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1961
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1962
      mov(s1.as_register(), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1963
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1964
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1965
      return s1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1966
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1967
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1968
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1969
  if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1970
    assert_different_registers(s1.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1971
    if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1972
    add(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1973
    return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1974
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1975
    if (s2.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1976
      assert_different_registers(s2.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1977
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1978
      add(s2.as_register(), ensure_simm13_or_reg(s1, temp), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1979
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1980
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1981
      intptr_t res = s1.as_constant() + s2.as_constant();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1982
      return res;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1983
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1984
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1985
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1986
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1987
RegisterOrConstant MacroAssembler::regcon_sll_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1988
  assert(d.register_or_noreg() != G0, "lost side effect");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1989
  if (!is_simm13(s2.constant_or_zero()))
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1990
    s2 = (s2.as_constant() & 0xFF);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1991
  if ((s2.is_constant() && s2.as_constant() == 0) ||
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1992
      (s2.is_register() && s2.as_register() == G0)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1993
    // Do nothing, just move value.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1994
    if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1995
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1996
      mov(s1.as_register(), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1997
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1998
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  1999
      return s1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2000
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2001
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2002
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2003
  if (s1.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2004
    assert_different_registers(s1.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2005
    if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2006
    sll_ptr(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2007
    return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2008
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2009
    if (s2.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2010
      assert_different_registers(s2.as_register(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2011
      if (d.is_constant())  d = temp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2012
      set(s1.as_constant(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2013
      sll_ptr(temp, s2.as_register(), d.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2014
      return d;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2015
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2016
      intptr_t res = s1.as_constant() << s2.as_constant();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2017
      return res;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2018
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2019
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2020
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2021
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2022
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2023
// Look up the method for a megamorphic invokeinterface call.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2024
// The target method is determined by <intf_klass, itable_index>.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2025
// The receiver klass is in recv_klass.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2026
// On success, the result will be in method_result, and execution falls through.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2027
// On failure, execution transfers to the given label.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2028
void MacroAssembler::lookup_interface_method(Register recv_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2029
                                             Register intf_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2030
                                             RegisterOrConstant itable_index,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2031
                                             Register method_result,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2032
                                             Register scan_temp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2033
                                             Register sethi_temp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2034
                                             Label& L_no_such_interface) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2035
  assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2036
  assert(itable_index.is_constant() || itable_index.as_register() == method_result,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2037
         "caller must use same register for non-constant itable index as for method");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2038
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2039
  Label L_no_such_interface_restore;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2040
  bool did_save = false;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2041
  if (scan_temp == noreg || sethi_temp == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2042
    Register recv_2 = recv_klass->is_global() ? recv_klass : L0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2043
    Register intf_2 = intf_klass->is_global() ? intf_klass : L1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2044
    assert(method_result->is_global(), "must be able to return value");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2045
    scan_temp  = L2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2046
    sethi_temp = L3;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2047
    save_frame_and_mov(0, recv_klass, recv_2, intf_klass, intf_2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2048
    recv_klass = recv_2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2049
    intf_klass = intf_2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2050
    did_save = true;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2051
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2052
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2053
  // 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
  2054
  int vtable_base = in_bytes(Klass::vtable_start_offset());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2055
  int scan_step   = itableOffsetEntry::size() * wordSize;
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2056
  int vte_size    = vtableEntry::size_in_bytes();
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2057
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  2058
  lduw(recv_klass, in_bytes(Klass::vtable_length_offset()), scan_temp);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2059
  // %%% We should store the aligned, prescaled offset in the klassoop.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2060
  // Then the next several instructions would fold away.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2061
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2062
  int itb_offset = vtable_base;
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2063
  int itb_scale = exact_log2(vtableEntry::size_in_bytes());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2064
  sll(scan_temp, itb_scale,  scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2065
  add(scan_temp, itb_offset, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2066
  add(recv_klass, scan_temp, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2067
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2068
  // Adjust recv_klass by scaled itable_index, so we can free itable_index.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2069
  RegisterOrConstant itable_offset = itable_index;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2070
  itable_offset = regcon_sll_ptr(itable_index, exact_log2(itableMethodEntry::size() * wordSize), itable_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2071
  itable_offset = regcon_inc_ptr(itable_offset, itableMethodEntry::method_offset_in_bytes(), itable_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2072
  add(recv_klass, ensure_simm13_or_reg(itable_offset, sethi_temp), recv_klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2073
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2074
  // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2075
  //   if (scan->interface() == intf) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2076
  //     result = (klass + scan->offset() + itable_index);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2077
  //   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2078
  // }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2079
  Label L_search, L_found_method;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2080
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2081
  for (int peel = 1; peel >= 0; peel--) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2082
    // %%%% Could load both offset and interface in one ldx, if they were
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2083
    // in the opposite order.  This would save a load.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2084
    ld_ptr(scan_temp, itableOffsetEntry::interface_offset_in_bytes(), method_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2085
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2086
    // Check that this entry is non-null.  A null entry means that
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2087
    // the receiver class doesn't implement the interface, and wasn't the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2088
    // same as when the caller was compiled.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2089
    bpr(Assembler::rc_z, false, Assembler::pn, method_result, did_save ? L_no_such_interface_restore : L_no_such_interface);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2090
    delayed()->cmp(method_result, intf_klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2091
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2092
    if (peel) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2093
      brx(Assembler::equal,    false, Assembler::pt, L_found_method);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2094
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2095
      brx(Assembler::notEqual, false, Assembler::pn, L_search);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2096
      // (invert the test to fall through to found_method...)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2097
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2098
    delayed()->add(scan_temp, scan_step, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2099
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2100
    if (!peel)  break;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2101
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2102
    bind(L_search);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2103
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2104
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2105
  bind(L_found_method);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2106
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2107
  // Got a hit.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2108
  int ito_offset = itableOffsetEntry::offset_offset_in_bytes();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2109
  // scan_temp[-scan_step] points to the vtable offset we need
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2110
  ito_offset -= scan_step;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2111
  lduw(scan_temp, ito_offset, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2112
  ld_ptr(recv_klass, scan_temp, method_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2113
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2114
  if (did_save) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2115
    Label L_done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2116
    ba(L_done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2117
    delayed()->restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2118
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2119
    bind(L_no_such_interface_restore);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2120
    ba(L_no_such_interface);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2121
    delayed()->restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2122
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2123
    bind(L_done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2124
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2125
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2126
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2127
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2128
// virtual method calling
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2129
void MacroAssembler::lookup_virtual_method(Register recv_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2130
                                           RegisterOrConstant vtable_index,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2131
                                           Register method_result) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2132
  assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2133
  Register sethi_temp = method_result;
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  2134
  const int base = in_bytes(Klass::vtable_start_offset()) +
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2135
                   // method pointer offset within the vtable entry:
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2136
                   vtableEntry::method_offset_in_bytes();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2137
  RegisterOrConstant vtable_offset = vtable_index;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2138
  // Each of the following three lines potentially generates an instruction.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2139
  // But the total number of address formation instructions will always be
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2140
  // at most two, and will often be zero.  In any case, it will be optimal.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2141
  // If vtable_index is a register, we will have (sll_ptr N,x; inc_ptr B,x; ld_ptr k,x).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2142
  // If vtable_index is a constant, we will have at most (set B+X<<N,t; ld_ptr k,t).
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35847
diff changeset
  2143
  vtable_offset = regcon_sll_ptr(vtable_index, exact_log2(vtableEntry::size_in_bytes()), vtable_offset);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2144
  vtable_offset = regcon_inc_ptr(vtable_offset, base, vtable_offset, sethi_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2145
  Address vtable_entry_addr(recv_klass, ensure_simm13_or_reg(vtable_offset, sethi_temp));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2146
  ld_ptr(vtable_entry_addr, method_result);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2147
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2148
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2149
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2150
void MacroAssembler::check_klass_subtype(Register sub_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2151
                                         Register super_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2152
                                         Register temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2153
                                         Register temp2_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2154
                                         Label& L_success) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2155
  Register sub_2 = sub_klass;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2156
  Register sup_2 = super_klass;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2157
  if (!sub_2->is_global())  sub_2 = L0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2158
  if (!sup_2->is_global())  sup_2 = L1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2159
  bool did_save = false;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2160
  if (temp_reg == noreg || temp2_reg == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2161
    temp_reg = L2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2162
    temp2_reg = L3;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2163
    save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2164
    sub_klass = sub_2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2165
    super_klass = sup_2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2166
    did_save = true;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2167
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2168
  Label L_failure, L_pop_to_failure, L_pop_to_success;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2169
  check_klass_subtype_fast_path(sub_klass, super_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2170
                                temp_reg, temp2_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2171
                                (did_save ? &L_pop_to_success : &L_success),
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2172
                                (did_save ? &L_pop_to_failure : &L_failure), NULL);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2173
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2174
  if (!did_save)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2175
    save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2176
  check_klass_subtype_slow_path(sub_2, sup_2,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2177
                                L2, L3, L4, L5,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2178
                                NULL, &L_pop_to_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2179
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2180
  // on success:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2181
  bind(L_pop_to_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2182
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2183
  ba_short(L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2184
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2185
  // on failure:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2186
  bind(L_pop_to_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2187
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2188
  bind(L_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2189
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2190
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2191
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2192
void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2193
                                                   Register super_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2194
                                                   Register temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2195
                                                   Register temp2_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2196
                                                   Label* L_success,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2197
                                                   Label* L_failure,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2198
                                                   Label* L_slow_path,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2199
                                        RegisterOrConstant super_check_offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2200
  int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2201
  int sco_offset = in_bytes(Klass::super_check_offset_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2202
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2203
  bool must_load_sco  = (super_check_offset.constant_or_zero() == -1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2204
  bool need_slow_path = (must_load_sco ||
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2205
                         super_check_offset.constant_or_zero() == sco_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2206
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2207
  assert_different_registers(sub_klass, super_klass, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2208
  if (super_check_offset.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2209
    assert_different_registers(sub_klass, super_klass, temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2210
                               super_check_offset.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2211
  } else if (must_load_sco) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2212
    assert(temp2_reg != noreg, "supply either a temp or a register offset");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2213
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2214
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2215
  Label L_fallthrough;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2216
  int label_nulls = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2217
  if (L_success == NULL)   { L_success   = &L_fallthrough; label_nulls++; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2218
  if (L_failure == NULL)   { L_failure   = &L_fallthrough; label_nulls++; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2219
  if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2220
  assert(label_nulls <= 1 ||
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2221
         (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path),
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2222
         "at most one NULL in the batch, usually");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2223
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2224
  // If the pointers are equal, we are done (e.g., String[] elements).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2225
  // This self-check enables sharing of secondary supertype arrays among
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2226
  // non-primary types such as array-of-interface.  Otherwise, each such
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2227
  // type would need its own customized SSA.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2228
  // We move this check to the front of the fast path because many
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2229
  // type checks are in fact trivially successful in this manner,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2230
  // so we get a nicely predicted branch right at the start of the check.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2231
  cmp(super_klass, sub_klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2232
  brx(Assembler::equal, false, Assembler::pn, *L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2233
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2234
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2235
  // Check the supertype display:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2236
  if (must_load_sco) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2237
    // The super check offset is always positive...
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2238
    lduw(super_klass, sco_offset, temp2_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2239
    super_check_offset = RegisterOrConstant(temp2_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2240
    // super_check_offset is register.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2241
    assert_different_registers(sub_klass, super_klass, temp_reg, super_check_offset.as_register());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2242
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2243
  ld_ptr(sub_klass, super_check_offset, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2244
  cmp(super_klass, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2245
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2246
  // This check has worked decisively for primary supers.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2247
  // Secondary supers are sought in the super_cache ('super_cache_addr').
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2248
  // (Secondary supers are interfaces and very deeply nested subtypes.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2249
  // This works in the same check above because of a tricky aliasing
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2250
  // between the super_cache and the primary super display elements.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2251
  // (The 'super_check_addr' can address either, as the case requires.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2252
  // Note that the cache is updated below if it does not help us find
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2253
  // what we need immediately.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2254
  // So if it was a primary super, we can just fail immediately.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2255
  // Otherwise, it's the slow path for us (no success at this point).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2256
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2257
  // Hacked ba(), which may only be used just before L_fallthrough.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2258
#define FINAL_JUMP(label)            \
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2259
  if (&(label) != &L_fallthrough) {  \
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2260
    ba(label);  delayed()->nop();    \
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2261
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2262
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2263
  if (super_check_offset.is_register()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2264
    brx(Assembler::equal, false, Assembler::pn, *L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2265
    delayed()->cmp(super_check_offset.as_register(), sc_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2266
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2267
    if (L_failure == &L_fallthrough) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2268
      brx(Assembler::equal, false, Assembler::pt, *L_slow_path);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2269
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2270
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2271
      brx(Assembler::notEqual, false, Assembler::pn, *L_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2272
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2273
      FINAL_JUMP(*L_slow_path);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2274
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2275
  } else if (super_check_offset.as_constant() == sc_offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2276
    // Need a slow path; fast failure is impossible.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2277
    if (L_slow_path == &L_fallthrough) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2278
      brx(Assembler::equal, false, Assembler::pt, *L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2279
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2280
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2281
      brx(Assembler::notEqual, false, Assembler::pn, *L_slow_path);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2282
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2283
      FINAL_JUMP(*L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2284
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2285
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2286
    // No slow path; it's a fast decision.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2287
    if (L_failure == &L_fallthrough) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2288
      brx(Assembler::equal, false, Assembler::pt, *L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2289
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2290
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2291
      brx(Assembler::notEqual, false, Assembler::pn, *L_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2292
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2293
      FINAL_JUMP(*L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2294
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2295
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2296
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2297
  bind(L_fallthrough);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2298
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2299
#undef FINAL_JUMP
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2300
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2301
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2302
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2303
void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2304
                                                   Register super_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2305
                                                   Register count_temp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2306
                                                   Register scan_temp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2307
                                                   Register scratch_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2308
                                                   Register coop_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2309
                                                   Label* L_success,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2310
                                                   Label* L_failure) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2311
  assert_different_registers(sub_klass, super_klass,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2312
                             count_temp, scan_temp, scratch_reg, coop_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2313
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2314
  Label L_fallthrough, L_loop;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2315
  int label_nulls = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2316
  if (L_success == NULL)   { L_success   = &L_fallthrough; label_nulls++; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2317
  if (L_failure == NULL)   { L_failure   = &L_fallthrough; label_nulls++; }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2318
  assert(label_nulls <= 1, "at most one NULL in the batch");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2319
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2320
  // a couple of useful fields in sub_klass:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2321
  int ss_offset = in_bytes(Klass::secondary_supers_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2322
  int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2323
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2324
  // Do a linear scan of the secondary super-klass chain.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2325
  // This code is rarely used, so simplicity is a virtue here.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2326
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2327
#ifndef PRODUCT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2328
  int* pst_counter = &SharedRuntime::_partial_subtype_ctr;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2329
  inc_counter((address) pst_counter, count_temp, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2330
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2331
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2332
  // We will consult the secondary-super array.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2333
  ld_ptr(sub_klass, ss_offset, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2334
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2335
  Register search_key = super_klass;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2336
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2337
  // Load the array length.  (Positive movl does right thing on LP64.)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2338
  lduw(scan_temp, Array<Klass*>::length_offset_in_bytes(), count_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2339
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2340
  // Check for empty secondary super list
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2341
  tst(count_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2342
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2343
  // In the array of super classes elements are pointer sized.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2344
  int element_size = wordSize;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2345
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2346
  // Top of search loop
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2347
  bind(L_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2348
  br(Assembler::equal, false, Assembler::pn, *L_failure);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2349
  delayed()->add(scan_temp, element_size, scan_temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2350
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2351
  // Skip the array header in all array accesses.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2352
  int elem_offset = Array<Klass*>::base_offset_in_bytes();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2353
  elem_offset -= element_size;   // the scan pointer was pre-incremented also
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2354
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2355
  // Load next super to check
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2356
    ld_ptr( scan_temp, elem_offset, scratch_reg );
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2357
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2358
  // Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2359
  cmp(scratch_reg, search_key);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2360
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2361
  // A miss means we are NOT a subtype and need to keep looping
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2362
  brx(Assembler::notEqual, false, Assembler::pn, L_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2363
  delayed()->deccc(count_temp); // decrement trip counter in delay slot
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2364
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2365
  // Success.  Cache the super we found and proceed in triumph.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2366
  st_ptr(super_klass, sub_klass, sc_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2367
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2368
  if (L_success != &L_fallthrough) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2369
    ba(*L_success);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2370
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2371
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2372
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2373
  bind(L_fallthrough);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2374
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2375
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2376
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2377
RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2378
                                                   Register temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2379
                                                   int extra_slot_offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2380
  // cf. TemplateTable::prepare_invoke(), if (load_receiver).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2381
  int stackElementSize = Interpreter::stackElementSize;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2382
  int offset = extra_slot_offset * stackElementSize;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2383
  if (arg_slot.is_constant()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2384
    offset += arg_slot.as_constant() * stackElementSize;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2385
    return offset;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2386
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2387
    assert(temp_reg != noreg, "must specify");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2388
    sll_ptr(arg_slot.as_register(), exact_log2(stackElementSize), temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2389
    if (offset != 0)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2390
      add(temp_reg, offset, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2391
    return temp_reg;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2392
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2393
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2394
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2395
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2396
Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2397
                                         Register temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2398
                                         int extra_slot_offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2399
  return Address(Gargs, argument_offset(arg_slot, temp_reg, extra_slot_offset));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2400
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2401
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2402
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2403
void MacroAssembler::biased_locking_enter(Register obj_reg, Register mark_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2404
                                          Register temp_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2405
                                          Label& done, Label* slow_case,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2406
                                          BiasedLockingCounters* counters) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2407
  assert(UseBiasedLocking, "why call this otherwise?");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2408
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2409
  if (PrintBiasedLockingStatistics) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2410
    assert_different_registers(obj_reg, mark_reg, temp_reg, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2411
    if (counters == NULL)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2412
      counters = BiasedLocking::counters();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2413
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2414
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2415
  Label cas_label;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2416
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2417
  // Biased locking
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2418
  // See whether the lock is currently biased toward our thread and
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2419
  // whether the epoch is still valid
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2420
  // Note that the runtime guarantees sufficient alignment of JavaThread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2421
  // pointers to allow age to be placed into low bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2422
  assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2423
  and3(mark_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2424
  cmp_and_brx_short(temp_reg, markOopDesc::biased_lock_pattern, Assembler::notEqual, Assembler::pn, cas_label);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2425
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2426
  load_klass(obj_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2427
  ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2428
  or3(G2_thread, temp_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2429
  xor3(mark_reg, temp_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2430
  andcc(temp_reg, ~((int) markOopDesc::age_mask_in_place), temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2431
  if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2432
    cond_inc(Assembler::equal, (address) counters->biased_lock_entry_count_addr(), mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2433
    // Reload mark_reg as we may need it later
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2434
    ld_ptr(Address(obj_reg, oopDesc::mark_offset_in_bytes()), mark_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2435
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2436
  brx(Assembler::equal, true, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2437
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2438
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2439
  Label try_revoke_bias;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2440
  Label try_rebias;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2441
  Address mark_addr = Address(obj_reg, oopDesc::mark_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2442
  assert(mark_addr.disp() == 0, "cas must take a zero displacement");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2443
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2444
  // At this point we know that the header has the bias pattern and
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2445
  // that we are not the bias owner in the current epoch. We need to
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2446
  // figure out more details about the state of the header in order to
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2447
  // know what operations can be legally performed on the object's
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2448
  // header.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2449
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2450
  // If the low three bits in the xor result aren't clear, that means
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2451
  // the prototype header is no longer biased and we have to revoke
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2452
  // the bias on this object.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2453
  btst(markOopDesc::biased_lock_mask_in_place, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2454
  brx(Assembler::notZero, false, Assembler::pn, try_revoke_bias);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2455
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2456
  // Biasing is still enabled for this data type. See whether the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2457
  // epoch of the current bias is still valid, meaning that the epoch
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2458
  // bits of the mark word are equal to the epoch bits of the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2459
  // prototype header. (Note that the prototype header's epoch bits
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2460
  // only change at a safepoint.) If not, attempt to rebias the object
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2461
  // toward the current thread. Note that we must be absolutely sure
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2462
  // that the current epoch is invalid in order to do this because
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2463
  // otherwise the manipulations it performs on the mark word are
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2464
  // illegal.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2465
  delayed()->btst(markOopDesc::epoch_mask_in_place, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2466
  brx(Assembler::notZero, false, Assembler::pn, try_rebias);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2467
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2468
  // The epoch of the current bias is still valid but we know nothing
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2469
  // about the owner; it might be set or it might be clear. Try to
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2470
  // acquire the bias of the object using an atomic operation. If this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2471
  // fails we will go in to the runtime to revoke the object's bias.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2472
  // Note that we first construct the presumed unbiased header so we
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2473
  // don't accidentally blow away another thread's valid bias.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2474
  delayed()->and3(mark_reg,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2475
                  markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2476
                  mark_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2477
  or3(G2_thread, mark_reg, temp_reg);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2478
  cas_ptr(mark_addr.base(), mark_reg, temp_reg);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2479
  // If the biasing toward our thread failed, this means that
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2480
  // another thread succeeded in biasing it toward itself and we
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2481
  // need to revoke that bias. The revocation will occur in the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2482
  // interpreter runtime in the slow case.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2483
  cmp(mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2484
  if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2485
    cond_inc(Assembler::zero, (address) counters->anonymously_biased_lock_entry_count_addr(), mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2486
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2487
  if (slow_case != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2488
    brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2489
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2490
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2491
  ba_short(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2492
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2493
  bind(try_rebias);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2494
  // At this point we know the epoch has expired, meaning that the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2495
  // current "bias owner", if any, is actually invalid. Under these
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2496
  // circumstances _only_, we are allowed to use the current header's
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2497
  // value as the comparison value when doing the cas to acquire the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2498
  // bias in the current epoch. In other words, we allow transfer of
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2499
  // the bias from one thread to another directly in this situation.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2500
  //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2501
  // FIXME: due to a lack of registers we currently blow away the age
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2502
  // bits in this situation. Should attempt to preserve them.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2503
  load_klass(obj_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2504
  ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2505
  or3(G2_thread, temp_reg, temp_reg);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2506
  cas_ptr(mark_addr.base(), mark_reg, temp_reg);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2507
  // If the biasing toward our thread failed, this means that
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2508
  // another thread succeeded in biasing it toward itself and we
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2509
  // need to revoke that bias. The revocation will occur in the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2510
  // interpreter runtime in the slow case.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2511
  cmp(mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2512
  if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2513
    cond_inc(Assembler::zero, (address) counters->rebiased_lock_entry_count_addr(), mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2514
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2515
  if (slow_case != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2516
    brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2517
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2518
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2519
  ba_short(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2520
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2521
  bind(try_revoke_bias);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2522
  // The prototype mark in the klass doesn't have the bias bit set any
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2523
  // more, indicating that objects of this data type are not supposed
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2524
  // to be biased any more. We are going to try to reset the mark of
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2525
  // this object to the prototype value and fall through to the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2526
  // CAS-based locking scheme. Note that if our CAS fails, it means
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2527
  // that another thread raced us for the privilege of revoking the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2528
  // bias of this particular object, so it's okay to continue in the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2529
  // normal locking code.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2530
  //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2531
  // FIXME: due to a lack of registers we currently blow away the age
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2532
  // bits in this situation. Should attempt to preserve them.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2533
  load_klass(obj_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2534
  ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2535
  cas_ptr(mark_addr.base(), mark_reg, temp_reg);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2536
  // Fall through to the normal CAS-based lock, because no matter what
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2537
  // the result of the above CAS, some thread must have succeeded in
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2538
  // removing the bias bit from the object's header.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2539
  if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2540
    cmp(mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2541
    cond_inc(Assembler::zero, (address) counters->revoked_lock_entry_count_addr(), mark_reg, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2542
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2543
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2544
  bind(cas_label);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2545
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2546
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2547
void MacroAssembler::biased_locking_exit (Address mark_addr, Register temp_reg, Label& done,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2548
                                          bool allow_delay_slot_filling) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2549
  // Check for biased locking unlock case, which is a no-op
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2550
  // Note: we do not have to check the thread ID for two reasons.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2551
  // First, the interpreter checks for IllegalMonitorStateException at
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2552
  // a higher level. Second, if the bias was revoked while we held the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2553
  // lock, the object could not be rebiased toward another thread, so
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2554
  // the bias bit would be clear.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2555
  ld_ptr(mark_addr, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2556
  and3(temp_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2557
  cmp(temp_reg, markOopDesc::biased_lock_pattern);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2558
  brx(Assembler::equal, allow_delay_slot_filling, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2559
  delayed();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2560
  if (!allow_delay_slot_filling) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2561
    nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2562
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2563
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2564
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2565
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2566
// compiler_lock_object() and compiler_unlock_object() are direct transliterations
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2567
// of i486.ad fast_lock() and fast_unlock().  See those methods for detailed comments.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2568
// The code could be tightened up considerably.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2569
//
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2570
// box->dhw disposition - post-conditions at DONE_LABEL.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2571
// -   Successful inflated lock:  box->dhw != 0.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2572
//     Any non-zero value suffices.
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2573
//     Consider G2_thread, rsp, boxReg, or markOopDesc::unused_mark()
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2574
// -   Successful Stack-lock: box->dhw == mark.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2575
//     box->dhw must contain the displaced mark word value
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2576
// -   Failure -- icc.ZFlag == 0 and box->dhw is undefined.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2577
//     The slow-path fast_enter() and slow_enter() operators
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2578
//     are responsible for setting box->dhw = NonZero (typically markOopDesc::unused_mark()).
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2579
// -   Biased: box->dhw is undefined
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2580
//
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2581
// SPARC refworkload performance - specifically jetstream and scimark - are
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2582
// extremely sensitive to the size of the code emitted by compiler_lock_object
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2583
// and compiler_unlock_object.  Critically, the key factor is code size, not path
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2584
// length.  (Simply experiments to pad CLO with unexecuted NOPs demonstrte the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2585
// effect).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2586
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2587
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2588
void MacroAssembler::compiler_lock_object(Register Roop, Register Rmark,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2589
                                          Register Rbox, Register Rscratch,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2590
                                          BiasedLockingCounters* counters,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2591
                                          bool try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2592
   Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2593
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2594
   verify_oop(Roop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2595
   Label done ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2596
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2597
   if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2598
     inc_counter((address) counters->total_entry_count_addr(), Rmark, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2599
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2600
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2601
   if (EmitSync & 1) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2602
     mov(3, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2603
     st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2604
     cmp(SP, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2605
     return ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2606
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2607
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2608
   if (EmitSync & 2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2609
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2610
     // Fetch object's markword
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2611
     ld_ptr(mark_addr, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2612
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2613
     if (try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2614
        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2615
     }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2616
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2617
     // Save Rbox in Rscratch to be used for the cas operation
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2618
     mov(Rbox, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2619
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2620
     // set Rmark to markOop | markOopDesc::unlocked_value
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2621
     or3(Rmark, markOopDesc::unlocked_value, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2622
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2623
     // Initialize the box.  (Must happen before we update the object mark!)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2624
     st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2625
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2626
     // compare object markOop with Rmark and if equal exchange Rscratch with object markOop
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2627
     assert(mark_addr.disp() == 0, "cas must take a zero displacement");
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2628
     cas_ptr(mark_addr.base(), Rmark, Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2629
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2630
     // if compare/exchange succeeded we found an unlocked object and we now have locked it
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2631
     // hence we are done
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2632
     cmp(Rmark, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2633
     sub(Rscratch, STACK_BIAS, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2634
     brx(Assembler::equal, false, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2635
     delayed()->sub(Rscratch, SP, Rscratch);  //pull next instruction into delay slot
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2636
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2637
     // we did not find an unlocked object so see if this is a recursive case
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2638
     // sub(Rscratch, SP, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2639
     assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2640
     andcc(Rscratch, 0xfffff003, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2641
     st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2642
     bind (done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2643
     return ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2644
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2645
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2646
   Label Egress ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2647
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2648
   if (EmitSync & 256) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2649
      Label IsInflated ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2650
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2651
      ld_ptr(mark_addr, Rmark);           // fetch obj->mark
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2652
      // Triage: biased, stack-locked, neutral, inflated
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2653
      if (try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2654
        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2655
        // Invariant: if control reaches this point in the emitted stream
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2656
        // then Rmark has not been modified.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2657
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2658
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2659
      // Store mark into displaced mark field in the on-stack basic-lock "box"
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2660
      // Critically, this must happen before the CAS
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2661
      // Maximize the ST-CAS distance to minimize the ST-before-CAS penalty.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2662
      st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2663
      andcc(Rmark, 2, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2664
      brx(Assembler::notZero, false, Assembler::pn, IsInflated);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2665
      delayed()->
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2666
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2667
      // Try stack-lock acquisition.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2668
      // Beware: the 1st instruction is in a delay slot
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2669
      mov(Rbox,  Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2670
      or3(Rmark, markOopDesc::unlocked_value, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2671
      assert(mark_addr.disp() == 0, "cas must take a zero displacement");
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2672
      cas_ptr(mark_addr.base(), Rmark, Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2673
      cmp(Rmark, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2674
      brx(Assembler::equal, false, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2675
      delayed()->sub(Rscratch, SP, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2676
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2677
      // Stack-lock attempt failed - check for recursive stack-lock.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2678
      // See the comments below about how we might remove this case.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2679
      sub(Rscratch, STACK_BIAS, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2680
      assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2681
      andcc(Rscratch, 0xfffff003, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2682
      br(Assembler::always, false, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2683
      delayed()-> st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2684
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2685
      bind(IsInflated);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2686
      if (EmitSync & 64) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2687
         // If m->owner != null goto IsLocked
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2688
         // Pessimistic form: Test-and-CAS vs CAS
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2689
         // The optimistic form avoids RTS->RTO cache line upgrades.
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2690
         ld_ptr(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2691
         andcc(Rscratch, Rscratch, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2692
         brx(Assembler::notZero, false, Assembler::pn, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2693
         delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2694
         // m->owner == null : it's unlocked.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2695
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2696
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2697
      // Try to CAS m->owner from null to Self
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2698
      // Invariant: if we acquire the lock then _recursions should be 0.
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2699
      add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2700
      mov(G2_thread, Rscratch);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2701
      cas_ptr(Rmark, G0, Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2702
      cmp(Rscratch, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2703
      // Intentional fall-through into done
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2704
   } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2705
      // Aggressively avoid the Store-before-CAS penalty
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2706
      // Defer the store into box->dhw until after the CAS
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2707
      Label IsInflated, Recursive ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2708
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2709
// Anticipate CAS -- Avoid RTS->RTO upgrade
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2710
// prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2711
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2712
      ld_ptr(mark_addr, Rmark);           // fetch obj->mark
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2713
      // Triage: biased, stack-locked, neutral, inflated
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2714
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2715
      if (try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2716
        biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2717
        // Invariant: if control reaches this point in the emitted stream
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2718
        // then Rmark has not been modified.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2719
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2720
      andcc(Rmark, 2, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2721
      brx(Assembler::notZero, false, Assembler::pn, IsInflated);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2722
      delayed()->                         // Beware - dangling delay-slot
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2723
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2724
      // Try stack-lock acquisition.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2725
      // Transiently install BUSY (0) encoding in the mark word.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2726
      // if the CAS of 0 into the mark was successful then we execute:
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2727
      //   ST box->dhw  = mark   -- save fetched mark in on-stack basiclock box
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2728
      //   ST obj->mark = box    -- overwrite transient 0 value
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2729
      // This presumes TSO, of course.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2730
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2731
      mov(0, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2732
      or3(Rmark, markOopDesc::unlocked_value, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2733
      assert(mark_addr.disp() == 0, "cas must take a zero displacement");
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2734
      cas_ptr(mark_addr.base(), Rmark, Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2735
// prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2736
      cmp(Rscratch, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2737
      brx(Assembler::notZero, false, Assembler::pn, Recursive);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2738
      delayed()->st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2739
      if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2740
        cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2741
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2742
      ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2743
      delayed()->st_ptr(Rbox, mark_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2744
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2745
      bind(Recursive);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2746
      // Stack-lock attempt failed - check for recursive stack-lock.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2747
      // Tests show that we can remove the recursive case with no impact
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2748
      // on refworkload 0.83.  If we need to reduce the size of the code
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2749
      // emitted by compiler_lock_object() the recursive case is perfect
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2750
      // candidate.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2751
      //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2752
      // A more extreme idea is to always inflate on stack-lock recursion.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2753
      // This lets us eliminate the recursive checks in compiler_lock_object
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2754
      // and compiler_unlock_object and the (box->dhw == 0) encoding.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2755
      // A brief experiment - requiring changes to synchronizer.cpp, interpreter,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2756
      // and showed a performance *increase*.  In the same experiment I eliminated
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2757
      // the fast-path stack-lock code from the interpreter and always passed
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2758
      // control to the "slow" operators in synchronizer.cpp.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2759
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2760
      // RScratch contains the fetched obj->mark value from the failed CAS.
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2761
      sub(Rscratch, STACK_BIAS, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2762
      sub(Rscratch, SP, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2763
      assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2764
      andcc(Rscratch, 0xfffff003, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2765
      if (counters != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2766
        // Accounting needs the Rscratch register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2767
        st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2768
        cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2769
        ba_short(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2770
      } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2771
        ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2772
        delayed()->st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2773
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2774
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2775
      bind   (IsInflated);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2776
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2777
      // Try to CAS m->owner from null to Self
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2778
      // Invariant: if we acquire the lock then _recursions should be 0.
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2779
      add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2780
      mov(G2_thread, Rscratch);
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2781
      cas_ptr(Rmark, G0, Rscratch);
29070
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 27636
diff changeset
  2782
      andcc(Rscratch, Rscratch, G0);             // set ICCs for done: icc.zf iff success
b0a5fc9c59c8 8061553: Contended Locking fast enter bucket
dcubed
parents: 27636
diff changeset
  2783
      // set icc.zf : 1=success 0=failure
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2784
      // ST box->displaced_header = NonZero.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2785
      // Any non-zero value suffices:
27608
80d91e264baf 8062851: cleanup ObjectMonitor offset adjustments
dcubed
parents: 25715
diff changeset
  2786
      //    markOopDesc::unused_mark(), G2_thread, RBox, RScratch, rsp, etc.
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2787
      st_ptr(Rbox, Rbox, BasicLock::displaced_header_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2788
      // Intentional fall-through into done
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2789
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2790
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2791
   bind   (done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2792
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2793
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2794
void MacroAssembler::compiler_unlock_object(Register Roop, Register Rmark,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2795
                                            Register Rbox, Register Rscratch,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2796
                                            bool try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2797
   Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2798
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2799
   Label done ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2800
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2801
   if (EmitSync & 4) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2802
     cmp(SP, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2803
     return ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2804
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2805
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2806
   if (EmitSync & 8) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2807
     if (try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2808
        biased_locking_exit(mark_addr, Rscratch, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2809
     }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2810
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2811
     // Test first if it is a fast recursive unlock
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2812
     ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2813
     br_null_short(Rmark, Assembler::pt, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2814
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2815
     // Check if it is still a light weight lock, this is is true if we see
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2816
     // the stack address of the basicLock in the markOop of the object
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2817
     assert(mark_addr.disp() == 0, "cas must take a zero displacement");
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2818
     cas_ptr(mark_addr.base(), Rbox, Rmark);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2819
     ba(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2820
     delayed()->cmp(Rbox, Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2821
     bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2822
     return ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2823
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2824
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2825
   // Beware ... If the aggregate size of the code emitted by CLO and CUO is
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2826
   // is too large performance rolls abruptly off a cliff.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2827
   // This could be related to inlining policies, code cache management, or
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2828
   // I$ effects.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2829
   Label LStacked ;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2830
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2831
   if (try_bias) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2832
      // TODO: eliminate redundant LDs of obj->mark
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2833
      biased_locking_exit(mark_addr, Rscratch, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2834
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2835
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2836
   ld_ptr(Roop, oopDesc::mark_offset_in_bytes(), Rmark);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2837
   ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2838
   andcc(Rscratch, Rscratch, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2839
   brx(Assembler::zero, false, Assembler::pn, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2840
   delayed()->nop();      // consider: relocate fetch of mark, above, into this DS
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2841
   andcc(Rmark, 2, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2842
   brx(Assembler::zero, false, Assembler::pt, LStacked);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2843
   delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2844
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2845
   // It's inflated
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2846
   // Conceptually we need a #loadstore|#storestore "release" MEMBAR before
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2847
   // the ST of 0 into _owner which releases the lock.  This prevents loads
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2848
   // and stores within the critical section from reordering (floating)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2849
   // past the store that releases the lock.  But TSO is a strong memory model
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2850
   // and that particular flavor of barrier is a noop, so we can safely elide it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2851
   // Note that we use 1-0 locking by default for the inflated case.  We
30244
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2852
   // close the resultant (and rare) race by having contended threads in
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2853
   // monitorenter periodically poll _owner.
30244
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2854
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2855
   if (EmitSync & 1024) {
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2856
     // Emit code to check that _owner == Self
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2857
     // We could fold the _owner test into subsequent code more efficiently
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2858
     // than using a stand-alone check, but since _owner checking is off by
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2859
     // default we don't bother. We also might consider predicating the
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2860
     // _owner==Self check on Xcheck:jni or running on a debug build.
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2861
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2862
     orcc(Rscratch, G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2863
     brx(Assembler::notZero, false, Assembler::pn, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2864
     delayed()->nop();
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2865
   }
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2866
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2867
   if (EmitSync & 512) {
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2868
     // classic lock release code absent 1-0 locking
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2869
     //   m->Owner = null;
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2870
     //   membar #storeload
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2871
     //   if (m->cxq|m->EntryList) == null goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2872
     //   if (m->succ != null) goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2873
     //   if CAS (&m->Owner,0,Self) != 0 goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2874
     //   goto SlowPath
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2875
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), Rbox);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2876
     orcc(Rbox, G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2877
     brx(Assembler::notZero, false, Assembler::pn, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2878
     delayed()->nop();
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2879
     st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2880
     if (os::is_MP()) { membar(StoreLoad); }
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2881
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2882
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)), Rbox);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2883
     orcc(Rbox, Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2884
     brx(Assembler::zero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2885
     delayed()->
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2886
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2887
     andcc(Rscratch, Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2888
     brx(Assembler::notZero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2889
     delayed()->andcc(G0, G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2890
     add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2891
     mov(G2_thread, Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2892
     cas_ptr(Rmark, G0, Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2893
     cmp(Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2894
     // invert icc.zf and goto done
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2895
     brx(Assembler::notZero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2896
     delayed()->cmp(G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2897
     br(Assembler::always, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2898
     delayed()->cmp(G0, 1);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2899
   } else {
30244
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2900
     // 1-0 form : avoids CAS and MEMBAR in the common case
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2901
     // Do not bother to ratify that m->Owner == Self.
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2902
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), Rbox);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2903
     orcc(Rbox, G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2904
     brx(Assembler::notZero, false, Assembler::pn, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2905
     delayed()->
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2906
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2907
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)), Rbox);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2908
     orcc(Rbox, Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2909
     if (EmitSync & 16384) {
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2910
       // As an optional optimization, if (EntryList|cxq) != null and _succ is null then
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2911
       // we should transfer control directly to the slow-path.
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2912
       // This test makes the reacquire operation below very infrequent.
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2913
       // The logic is equivalent to :
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2914
       //   if (cxq|EntryList) == null : Owner=null; goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2915
       //   if succ == null : goto SlowPath
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2916
       //   Owner=null; membar #storeload
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2917
       //   if succ != null : goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2918
       //   if CAS(&Owner,null,Self) != null goto Success
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2919
       //   goto SlowPath
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2920
       brx(Assembler::zero, true, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2921
       delayed()->
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2922
       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2923
       ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2924
       andcc(Rscratch, Rscratch, G0) ;
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2925
       brx(Assembler::zero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2926
       delayed()->orcc(G0, 1, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2927
       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2928
     } else {
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2929
       brx(Assembler::zero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2930
       delayed()->
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2931
       st_ptr(G0, Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2932
     }
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2933
     if (os::is_MP()) { membar(StoreLoad); }
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2934
     // Check that _succ is (or remains) non-zero
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2935
     ld_ptr(Address(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2936
     andcc(Rscratch, Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2937
     brx(Assembler::notZero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2938
     delayed()->andcc(G0, G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2939
     add(Rmark, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), Rmark);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2940
     mov(G2_thread, Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2941
     cas_ptr(Rmark, G0, Rscratch);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2942
     cmp(Rscratch, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2943
     // invert icc.zf and goto done
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2944
     // A slightly better v8+/v9 idiom would be the following:
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2945
     //   movrnz Rscratch,1,Rscratch
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2946
     //   ba done
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2947
     //   xorcc Rscratch,1,G0
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2948
     // In v8+ mode the idiom would be valid IFF Rscratch was a G or O register
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2949
     brx(Assembler::notZero, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2950
     delayed()->cmp(G0, G0);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2951
     br(Assembler::always, false, Assembler::pt, done);
d4e471395ff5 8073165: Contended Locking fast exit bucket
dcubed
parents: 29325
diff changeset
  2952
     delayed()->cmp(G0, 1);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2953
   }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2954
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2955
   bind   (LStacked);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2956
   // Consider: we could replace the expensive CAS in the exit
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2957
   // path with a simple ST of the displaced mark value fetched from
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2958
   // the on-stack basiclock box.  That admits a race where a thread T2
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2959
   // in the slow lock path -- inflating with monitor M -- could race a
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2960
   // thread T1 in the fast unlock path, resulting in a missed wakeup for T2.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2961
   // More precisely T1 in the stack-lock unlock path could "stomp" the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2962
   // inflated mark value M installed by T2, resulting in an orphan
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2963
   // object monitor M and T2 becoming stranded.  We can remedy that situation
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2964
   // by having T2 periodically poll the object's mark word using timed wait
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2965
   // operations.  If T2 discovers that a stomp has occurred it vacates
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2966
   // the monitor M and wakes any other threads stranded on the now-orphan M.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2967
   // In addition the monitor scavenger, which performs deflation,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2968
   // would also need to check for orpan monitors and stranded threads.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2969
   //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2970
   // Finally, inflation is also used when T2 needs to assign a hashCode
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2971
   // to O and O is stack-locked by T1.  The "stomp" race could cause
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2972
   // an assigned hashCode value to be lost.  We can avoid that condition
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2973
   // and provide the necessary hashCode stability invariants by ensuring
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2974
   // that hashCode generation is idempotent between copying GCs.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2975
   // For example we could compute the hashCode of an object O as
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2976
   // O's heap address XOR some high quality RNG value that is refreshed
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2977
   // at GC-time.  The monitor scavenger would install the hashCode
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2978
   // found in any orphan monitors.  Again, the mechanism admits a
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2979
   // lost-update "stomp" WAW race but detects and recovers as needed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2980
   //
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2981
   // A prototype implementation showed excellent results, although
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2982
   // the scavenger and timeout code was rather involved.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2983
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  2984
   cas_ptr(mark_addr.base(), Rbox, Rscratch);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2985
   cmp(Rbox, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2986
   // Intentional fall through into done ...
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2987
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2988
   bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2989
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2990
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2991
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2992
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2993
void MacroAssembler::print_CPU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2994
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2995
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2996
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2997
void MacroAssembler::verify_FPU(int stack_depth, const char* s) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2998
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  2999
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3000
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3001
void MacroAssembler::push_IU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3002
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3003
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3004
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3005
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3006
void MacroAssembler::pop_IU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3007
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3008
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3009
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3010
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3011
void MacroAssembler::push_FPU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3012
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3013
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3014
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3015
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3016
void MacroAssembler::pop_FPU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3017
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3018
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3019
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3020
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3021
void MacroAssembler::push_CPU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3022
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3023
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3024
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3025
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3026
void MacroAssembler::pop_CPU_state() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3027
  // %%%%% need to implement this
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3028
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3029
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3030
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3031
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3032
void MacroAssembler::verify_tlab() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3033
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3034
  if (UseTLAB && VerifyOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3035
    Label next, next2, ok;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3036
    Register t1 = L0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3037
    Register t2 = L1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3038
    Register t3 = L2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3039
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3040
    save_frame(0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3041
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3042
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3043
    or3(t1, t2, t3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3044
    cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3045
    STOP("assert(top >= start)");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3046
    should_not_reach_here();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3047
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3048
    bind(next);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3049
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3050
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3051
    or3(t3, t2, t3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3052
    cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3053
    STOP("assert(top <= end)");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3054
    should_not_reach_here();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3055
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3056
    bind(next2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3057
    and3(t3, MinObjAlignmentInBytesMask, t3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3058
    cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3059
    STOP("assert(aligned)");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3060
    should_not_reach_here();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3061
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3062
    bind(ok);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3063
    restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3064
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3065
#endif
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3066
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3067
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3068
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3069
void MacroAssembler::eden_allocate(
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3070
  Register obj,                        // result: pointer to object after successful allocation
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3071
  Register var_size_in_bytes,          // object size in bytes if unknown at compile time; invalid otherwise
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3072
  int      con_size_in_bytes,          // object size in bytes if   known at compile time
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3073
  Register t1,                         // temp register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3074
  Register t2,                         // temp register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3075
  Label&   slow_case                   // continuation point if fast allocation fails
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3076
){
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3077
  // make sure arguments make sense
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3078
  assert_different_registers(obj, var_size_in_bytes, t1, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3079
  assert(0 <= con_size_in_bytes && Assembler::is_simm13(con_size_in_bytes), "illegal object size");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3080
  assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3081
27625
07829380b8cd 8061308: Remove iCMS
brutisso
parents: 25715
diff changeset
  3082
  if (!Universe::heap()->supports_inline_contig_alloc()) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3083
    // No allocation in the shared eden.
18095
0ca57ec93f20 8015437: SPARC cbcond branch offset out of 10-bit range
morris
parents: 16368
diff changeset
  3084
    ba(slow_case);
0ca57ec93f20 8015437: SPARC cbcond branch offset out of 10-bit range
morris
parents: 16368
diff changeset
  3085
    delayed()->nop();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3086
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3087
    // get eden boundaries
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3088
    // note: we need both top & top_addr!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3089
    const Register top_addr = t1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3090
    const Register end      = t2;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3091
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3092
    CollectedHeap* ch = Universe::heap();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3093
    set((intx)ch->top_addr(), top_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3094
    intx delta = (intx)ch->end_addr() - (intx)ch->top_addr();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3095
    ld_ptr(top_addr, delta, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3096
    ld_ptr(top_addr, 0, obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3097
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3098
    // try to allocate
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3099
    Label retry;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3100
    bind(retry);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3101
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3102
    // make sure eden top is properly aligned
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3103
    {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3104
      Label L;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3105
      btst(MinObjAlignmentInBytesMask, obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3106
      br(Assembler::zero, false, Assembler::pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3107
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3108
      STOP("eden top is not properly aligned");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3109
      bind(L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3110
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3111
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3112
    const Register free = end;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3113
    sub(end, obj, free);                                   // compute amount of free space
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3114
    if (var_size_in_bytes->is_valid()) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3115
      // size is unknown at compile time
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3116
      cmp(free, var_size_in_bytes);
38042
95b4f1f6cb72 8151708: C1 FastTLABRefill can allocate TLABs past the end of the heap
zmajo
parents: 36808
diff changeset
  3117
      brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3118
      delayed()->add(obj, var_size_in_bytes, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3119
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3120
      // size is known at compile time
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3121
      cmp(free, con_size_in_bytes);
38042
95b4f1f6cb72 8151708: C1 FastTLABRefill can allocate TLABs past the end of the heap
zmajo
parents: 36808
diff changeset
  3122
      brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3123
      delayed()->add(obj, con_size_in_bytes, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3124
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3125
    // Compare obj with the value at top_addr; if still equal, swap the value of
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3126
    // end with the value at top_addr. If not equal, read the value at top_addr
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3127
    // into end.
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 18095
diff changeset
  3128
    cas_ptr(top_addr, obj, end);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3129
    // if someone beat us on the allocation, try again, otherwise continue
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3130
    cmp(obj, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3131
    brx(Assembler::notEqual, false, Assembler::pn, retry);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3132
    delayed()->mov(end, obj);                              // nop if successfull since obj == end
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3133
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3134
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3135
    // make sure eden top is properly aligned
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3136
    {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3137
      Label L;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3138
      const Register top_addr = t1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3139
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3140
      set((intx)ch->top_addr(), top_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3141
      ld_ptr(top_addr, 0, top_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3142
      btst(MinObjAlignmentInBytesMask, top_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3143
      br(Assembler::zero, false, Assembler::pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3144
      delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3145
      STOP("eden top is not properly aligned");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3146
      bind(L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3147
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3148
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3149
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3150
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3151
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3152
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3153
void MacroAssembler::tlab_allocate(
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3154
  Register obj,                        // result: pointer to object after successful allocation
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3155
  Register var_size_in_bytes,          // object size in bytes if unknown at compile time; invalid otherwise
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3156
  int      con_size_in_bytes,          // object size in bytes if   known at compile time
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3157
  Register t1,                         // temp register
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3158
  Label&   slow_case                   // continuation point if fast allocation fails
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3159
){
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3160
  // make sure arguments make sense
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3161
  assert_different_registers(obj, var_size_in_bytes, t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3162
  assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3163
  assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3164
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3165
  const Register free  = t1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3166
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3167
  verify_tlab();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3168
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3169
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), obj);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3170
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3171
  // calculate amount of free space
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3172
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), free);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3173
  sub(free, obj, free);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3174
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3175
  Label done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3176
  if (var_size_in_bytes == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3177
    cmp(free, con_size_in_bytes);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3178
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3179
    cmp(free, var_size_in_bytes);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3180
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3181
  br(Assembler::less, false, Assembler::pn, slow_case);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3182
  // calculate the new top pointer
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3183
  if (var_size_in_bytes == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3184
    delayed()->add(obj, con_size_in_bytes, free);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3185
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3186
    delayed()->add(obj, var_size_in_bytes, free);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3187
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3188
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3189
  bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3190
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3191
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3192
  // make sure new free pointer is properly aligned
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3193
  {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3194
    Label L;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3195
    btst(MinObjAlignmentInBytesMask, free);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3196
    br(Assembler::zero, false, Assembler::pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3197
    delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3198
    STOP("updated TLAB free is not properly aligned");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3199
    bind(L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3200
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3201
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3202
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3203
  // update the tlab top pointer
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3204
  st_ptr(free, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3205
  verify_tlab();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3206
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3207
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3208
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3209
void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3210
  Register top = O0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3211
  Register t1 = G1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3212
  Register t2 = G3;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3213
  Register t3 = O1;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3214
  assert_different_registers(top, t1, t2, t3, G4, G5 /* preserve G4 and G5 */);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3215
  Label do_refill, discard_tlab;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3216
27625
07829380b8cd 8061308: Remove iCMS
brutisso
parents: 25715
diff changeset
  3217
  if (!Universe::heap()->supports_inline_contig_alloc()) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3218
    // No allocation in the shared eden.
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3219
    ba(slow_case);
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3220
    delayed()->nop();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3221
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3222
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3223
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3224
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3225
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3226
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3227
  // calculate amount of free space
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3228
  sub(t1, top, t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3229
  srl_ptr(t1, LogHeapWordSize, t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3230
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3231
  // Retain tlab and allocate object in shared space if
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3232
  // the amount free in the tlab is too large to discard.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3233
  cmp(t1, t2);
35470
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3234
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3235
  brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3236
  // increment waste limit to prevent getting stuck on this slow path
35470
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3237
  if (Assembler::is_simm13(ThreadLocalAllocBuffer::refill_waste_limit_increment())) {
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3238
    delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3239
  } else {
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3240
    delayed()->nop();
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3241
    // set64 does not use the temp register if the given constant is 32 bit. So
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3242
    // we can just use any register; using G0 results in ignoring of the upper 32 bit
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3243
    // of that value.
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3244
    set64(ThreadLocalAllocBuffer::refill_waste_limit_increment(), t3, G0);
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3245
    add(t2, t3, t2);
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3246
  }
75c679ad0747 8144573: TLABWasteIncrement=max_jint fires an assert on SPARC for non-G1 GC mode
sangheki
parents: 35214
diff changeset
  3247
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3248
  st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3249
  if (TLABStats) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3250
    // increment number of slow_allocations
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3251
    ld(G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3252
    add(t2, 1, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3253
    stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3254
  }
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3255
  ba(try_eden);
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3256
  delayed()->nop();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3257
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3258
  bind(discard_tlab);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3259
  if (TLABStats) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3260
    // increment number of refills
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3261
    ld(G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3262
    add(t2, 1, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3263
    stw(t2, G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3264
    // accumulate wastage
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3265
    ld(G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3266
    add(t2, t1, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3267
    stw(t2, G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3268
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3269
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3270
  // if tlab is currently allocated (top or end != null) then
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3271
  // fill [top, end + alignment_reserve) with array object
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3272
  br_null_short(top, Assembler::pn, do_refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3273
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3274
  set((intptr_t)markOopDesc::prototype()->copy_set_hash(0x2), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3275
  st_ptr(t2, top, oopDesc::mark_offset_in_bytes()); // set up the mark word
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3276
  // set klass to intArrayKlass
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3277
  sub(t1, typeArrayOopDesc::header_size(T_INT), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3278
  add(t1, ThreadLocalAllocBuffer::alignment_reserve(), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3279
  sll_ptr(t1, log2_intptr(HeapWordSize/sizeof(jint)), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3280
  st(t1, top, arrayOopDesc::length_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3281
  set((intptr_t)Universe::intArrayKlassObj_addr(), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3282
  ld_ptr(t2, 0, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3283
  // store klass last.  concurrent gcs assumes klass length is valid if
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3284
  // klass field is not null.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3285
  store_klass(t2, top);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3286
  verify_oop(top);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3287
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3288
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3289
  sub(top, t1, t1); // size of tlab's allocated portion
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3290
  incr_allocated_bytes(t1, t2, t3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3291
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3292
  // refill the tlab with an eden allocation
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3293
  bind(do_refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3294
  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3295
  sll_ptr(t1, LogHeapWordSize, t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3296
  // allocate new tlab, address returned in top
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3297
  eden_allocate(top, t1, 0, t2, t3, slow_case);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3298
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3299
  st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3300
  st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3301
#ifdef ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3302
  // check that tlab_size (t1) is still valid
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3303
  {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3304
    Label ok;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3305
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3306
    sll_ptr(t2, LogHeapWordSize, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3307
    cmp_and_br_short(t1, t2, Assembler::equal, Assembler::pt, ok);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3308
    STOP("assert(t1 == tlab_size)");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3309
    should_not_reach_here();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3310
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3311
    bind(ok);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3312
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3313
#endif // ASSERT
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3314
  add(top, t1, top); // t1 is tlab_size
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3315
  sub(top, ThreadLocalAllocBuffer::alignment_reserve_in_bytes(), top);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3316
  st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_end_offset()));
35548
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3317
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3318
  if (ZeroTLAB) {
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3319
    // This is a fast TLAB refill, therefore the GC is not notified of it.
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3320
    // So compiled code must fill the new TLAB with zeroes.
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3321
    ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3322
    zero_memory(t2, t1);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3323
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3324
  verify_tlab();
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3325
  ba(retry);
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20403
diff changeset
  3326
  delayed()->nop();
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3327
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3328
35548
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3329
void MacroAssembler::zero_memory(Register base, Register index) {
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3330
  assert_different_registers(base, index);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3331
  Label loop;
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3332
  bind(loop);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3333
  subcc(index, HeapWordSize, index);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3334
  brx(Assembler::greaterEqual, true, Assembler::pt, loop);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3335
  delayed()->st_ptr(G0, base, index);
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3336
}
8d3afe96ffea 8086053: Address inconsistencies regarding ZeroTLAB
zmajo
parents: 35232
diff changeset
  3337
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3338
void MacroAssembler::incr_allocated_bytes(RegisterOrConstant size_in_bytes,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3339
                                          Register t1, Register t2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3340
  // Bump total bytes allocated by this thread
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3341
  assert(t1->is_global(), "must be global reg"); // so all 64 bits are saved on a context switch
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3342
  assert_different_registers(size_in_bytes.register_or_noreg(), t1, t2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3343
  // v8 support has gone the way of the dodo
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3344
  ldx(G2_thread, in_bytes(JavaThread::allocated_bytes_offset()), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3345
  add(t1, ensure_simm13_or_reg(size_in_bytes, t2), t1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3346
  stx(t1, G2_thread, in_bytes(JavaThread::allocated_bytes_offset()));
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3347
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3348
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3349
Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3350
  switch (cond) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3351
    // Note some conditions are synonyms for others
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3352
    case Assembler::never:                return Assembler::always;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3353
    case Assembler::zero:                 return Assembler::notZero;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3354
    case Assembler::lessEqual:            return Assembler::greater;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3355
    case Assembler::less:                 return Assembler::greaterEqual;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3356
    case Assembler::lessEqualUnsigned:    return Assembler::greaterUnsigned;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3357
    case Assembler::lessUnsigned:         return Assembler::greaterEqualUnsigned;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3358
    case Assembler::negative:             return Assembler::positive;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3359
    case Assembler::overflowSet:          return Assembler::overflowClear;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3360
    case Assembler::always:               return Assembler::never;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3361
    case Assembler::notZero:              return Assembler::zero;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3362
    case Assembler::greater:              return Assembler::lessEqual;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3363
    case Assembler::greaterEqual:         return Assembler::less;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3364
    case Assembler::greaterUnsigned:      return Assembler::lessEqualUnsigned;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3365
    case Assembler::greaterEqualUnsigned: return Assembler::lessUnsigned;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3366
    case Assembler::positive:             return Assembler::negative;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3367
    case Assembler::overflowClear:        return Assembler::overflowSet;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3368
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3369
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3370
  ShouldNotReachHere(); return Assembler::overflowClear;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3371
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3372
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3373
void MacroAssembler::cond_inc(Assembler::Condition cond, address counter_ptr,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3374
                              Register Rtmp1, Register Rtmp2 /*, Register Rtmp3, Register Rtmp4 */) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3375
  Condition negated_cond = negate_condition(cond);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3376
  Label L;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3377
  brx(negated_cond, false, Assembler::pt, L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3378
  delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3379
  inc_counter(counter_ptr, Rtmp1, Rtmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3380
  bind(L);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3381
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3382
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3383
void MacroAssembler::inc_counter(address counter_addr, Register Rtmp1, Register Rtmp2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3384
  AddressLiteral addrlit(counter_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3385
  sethi(addrlit, Rtmp1);                 // Move hi22 bits into temporary register.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3386
  Address addr(Rtmp1, addrlit.low10());  // Build an address with low10 bits.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3387
  ld(addr, Rtmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3388
  inc(Rtmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3389
  st(Rtmp2, addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3390
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3391
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3392
void MacroAssembler::inc_counter(int* counter_addr, Register Rtmp1, Register Rtmp2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3393
  inc_counter((address) counter_addr, Rtmp1, Rtmp2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3394
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3395
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3396
SkipIfEqual::SkipIfEqual(
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3397
    MacroAssembler* masm, Register temp, const bool* flag_addr,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3398
    Assembler::Condition condition) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3399
  _masm = masm;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3400
  AddressLiteral flag(flag_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3401
  _masm->sethi(flag, temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3402
  _masm->ldub(temp, flag.low10(), temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3403
  _masm->tst(temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3404
  _masm->br(condition, false, Assembler::pt, _label);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3405
  _masm->delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3406
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3407
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3408
SkipIfEqual::~SkipIfEqual() {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3409
  _masm->bind(_label);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3410
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3411
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3412
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3413
// Writes to stack successive pages until offset reached to check for
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3414
// stack overflow + shadow pages.  This clobbers tsp and scratch.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3415
void MacroAssembler::bang_stack_size(Register Rsize, Register Rtsp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3416
                                     Register Rscratch) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3417
  // Use stack pointer in temp stack pointer
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3418
  mov(SP, Rtsp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3419
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3420
  // Bang stack for total size given plus stack shadow page size.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3421
  // Bang one page at a time because a large size can overflow yellow and
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3422
  // red zones (the bang will fail but stack overflow handling can't tell that
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3423
  // it was a stack overflow bang vs a regular segv).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3424
  int offset = os::vm_page_size();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3425
  Register Roffset = Rscratch;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3426
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3427
  Label loop;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3428
  bind(loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3429
  set((-offset)+STACK_BIAS, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3430
  st(G0, Rtsp, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3431
  set(offset, Roffset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3432
  sub(Rsize, Roffset, Rsize);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3433
  cmp(Rsize, G0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3434
  br(Assembler::greater, false, Assembler::pn, loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3435
  delayed()->sub(Rtsp, Roffset, Rtsp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3436
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3437
  // Bang down shadow pages too.
21528
479228ecf6ac 8026775: nsk/jvmti/RedefineClasses/StressRedefine crashes due to EXCEPTION_ACCESS_VIOLATION
mikael
parents: 21189
diff changeset
  3438
  // At this point, (tmp-0) is the last address touched, so don't
479228ecf6ac 8026775: nsk/jvmti/RedefineClasses/StressRedefine crashes due to EXCEPTION_ACCESS_VIOLATION
mikael
parents: 21189
diff changeset
  3439
  // touch it again.  (It was touched as (tmp-pagesize) but then tmp
479228ecf6ac 8026775: nsk/jvmti/RedefineClasses/StressRedefine crashes due to EXCEPTION_ACCESS_VIOLATION
mikael
parents: 21189
diff changeset
  3440
  // was post-decremented.)  Skip this address by starting at i=1, and
479228ecf6ac 8026775: nsk/jvmti/RedefineClasses/StressRedefine crashes due to EXCEPTION_ACCESS_VIOLATION
mikael
parents: 21189
diff changeset
  3441
  // touch a few more pages below.  N.B.  It is important to touch all
479228ecf6ac 8026775: nsk/jvmti/RedefineClasses/StressRedefine crashes due to EXCEPTION_ACCESS_VIOLATION
mikael
parents: 21189
diff changeset
  3442
  // the way down to and including i=StackShadowPages.
35201
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35071
diff changeset
  3443
  for (int i = 1; i < JavaThread::stack_shadow_zone_size() / os::vm_page_size(); i++) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3444
    set((-i*offset)+STACK_BIAS, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3445
    st(G0, Rtsp, Rscratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3446
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3447
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3448
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3449
void MacroAssembler::reserved_stack_check() {
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3450
  // testing if reserved zone needs to be enabled
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3451
  Label no_reserved_zone_enabling;
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3452
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3453
  ld_ptr(G2_thread, JavaThread::reserved_stack_activation_offset(), G4_scratch);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3454
  cmp_and_brx_short(SP, G4_scratch, Assembler::lessUnsigned, Assembler::pt, no_reserved_zone_enabling);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3455
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3456
  call_VM_leaf(L0, CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), G2_thread);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3457
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3458
  AddressLiteral stub(StubRoutines::throw_delayed_StackOverflowError_entry());
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3459
  jump_to(stub, G4_scratch);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3460
  delayed()->restore();
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3461
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3462
  should_not_reach_here();
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3463
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3464
  bind(no_reserved_zone_enabling);
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3465
}
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34633
diff changeset
  3466
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3467
///////////////////////////////////////////////////////////////////////////////////
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
  3468
#if INCLUDE_ALL_GCS
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3469
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3470
static address satb_log_enqueue_with_frame = NULL;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3471
static u_char* satb_log_enqueue_with_frame_end = NULL;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3472
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3473
static address satb_log_enqueue_frameless = NULL;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3474
static u_char* satb_log_enqueue_frameless_end = NULL;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3475
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3476
static int EnqueueCodeSize = 128 DEBUG_ONLY( + 256); // Instructions?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3477
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3478
static void generate_satb_log_enqueue(bool with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3479
  BufferBlob* bb = BufferBlob::create("enqueue_with_frame", EnqueueCodeSize);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3480
  CodeBuffer buf(bb);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3481
  MacroAssembler masm(&buf);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3482
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3483
#define __ masm.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3484
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3485
  address start = __ pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3486
  Register pre_val;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3487
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3488
  Label refill, restart;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3489
  if (with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3490
    __ save_frame(0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3491
    pre_val = I0;  // Was O0 before the save.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3492
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3493
    pre_val = O0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3494
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3495
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3496
  int satb_q_index_byte_offset =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3497
    in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3498
             SATBMarkQueue::byte_offset_of_index());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3499
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3500
  int satb_q_buf_byte_offset =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3501
    in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3502
             SATBMarkQueue::byte_offset_of_buf());
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3503
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3504
  assert(in_bytes(SATBMarkQueue::byte_width_of_index()) == sizeof(intptr_t) &&
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3505
         in_bytes(SATBMarkQueue::byte_width_of_buf()) == sizeof(intptr_t),
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3506
         "check sizes in assembly below");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3507
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3508
  __ bind(restart);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3509
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3510
  // Load the index into the SATB buffer. SATBMarkQueue::_index is a size_t
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3511
  // so ld_ptr is appropriate.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3512
  __ ld_ptr(G2_thread, satb_q_index_byte_offset, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3513
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3514
  // index == 0?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3515
  __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3516
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3517
  __ ld_ptr(G2_thread, satb_q_buf_byte_offset, L1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3518
  __ sub(L0, oopSize, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3519
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3520
  __ st_ptr(pre_val, L1, L0);  // [_buf + index] := I0
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3521
  if (!with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3522
    // Use return-from-leaf
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3523
    __ retl();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3524
    __ delayed()->st_ptr(L0, G2_thread, satb_q_index_byte_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3525
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3526
    // Not delayed.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3527
    __ st_ptr(L0, G2_thread, satb_q_index_byte_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3528
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3529
  if (with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3530
    __ ret();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3531
    __ delayed()->restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3532
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3533
  __ bind(refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3534
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3535
  address handle_zero =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3536
    CAST_FROM_FN_PTR(address,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3537
                     &SATBMarkQueueSet::handle_zero_index_for_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3538
  // This should be rare enough that we can afford to save all the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3539
  // scratch registers that the calling context might be using.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3540
  __ mov(G1_scratch, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3541
  __ mov(G3_scratch, L1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3542
  __ mov(G4, L2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3543
  // We need the value of O0 above (for the write into the buffer), so we
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3544
  // save and restore it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3545
  __ mov(O0, L3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3546
  // Since the call will overwrite O7, we save and restore that, as well.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3547
  __ mov(O7, L4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3548
  __ call_VM_leaf(L5, handle_zero, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3549
  __ mov(L0, G1_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3550
  __ mov(L1, G3_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3551
  __ mov(L2, G4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3552
  __ mov(L3, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3553
  __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3554
  __ delayed()->mov(L4, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3555
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3556
  if (with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3557
    satb_log_enqueue_with_frame = start;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3558
    satb_log_enqueue_with_frame_end = __ pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3559
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3560
    satb_log_enqueue_frameless = start;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3561
    satb_log_enqueue_frameless_end = __ pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3562
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3563
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3564
#undef __
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3565
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3566
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3567
static inline void generate_satb_log_enqueue_if_necessary(bool with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3568
  if (with_frame) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3569
    if (satb_log_enqueue_with_frame == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3570
      generate_satb_log_enqueue(with_frame);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3571
      assert(satb_log_enqueue_with_frame != 0, "postcondition.");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3572
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3573
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3574
    if (satb_log_enqueue_frameless == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3575
      generate_satb_log_enqueue(with_frame);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3576
      assert(satb_log_enqueue_frameless != 0, "postcondition.");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3577
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3578
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3579
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3580
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3581
void MacroAssembler::g1_write_barrier_pre(Register obj,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3582
                                          Register index,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3583
                                          int offset,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3584
                                          Register pre_val,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3585
                                          Register tmp,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3586
                                          bool preserve_o_regs) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3587
  Label filtered;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3588
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3589
  if (obj == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3590
    // We are not loading the previous value so make
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3591
    // sure that we don't trash the value in pre_val
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3592
    // with the code below.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3593
    assert_different_registers(pre_val, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3594
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3595
    // We will be loading the previous value
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3596
    // in this code so...
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3597
    assert(offset == 0 || index == noreg, "choose one");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3598
    assert(pre_val == noreg, "check this code");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3599
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3600
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3601
  // Is marking active?
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3602
  if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3603
    ld(G2,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3604
       in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3605
                SATBMarkQueue::byte_offset_of_active()),
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3606
       tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3607
  } else {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3608
    guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1,
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3609
              "Assumption");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3610
    ldsb(G2,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3611
         in_bytes(JavaThread::satb_mark_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3612
                  SATBMarkQueue::byte_offset_of_active()),
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3613
         tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3614
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3615
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3616
  // Is marking active?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3617
  cmp_and_br_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3618
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3619
  // Do we need to load the previous value?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3620
  if (obj != noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3621
    // Load the previous value...
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3622
    if (index == noreg) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3623
      if (Assembler::is_simm13(offset)) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3624
        load_heap_oop(obj, offset, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3625
      } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3626
        set(offset, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3627
        load_heap_oop(obj, tmp, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3628
      }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3629
    } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3630
      load_heap_oop(obj, index, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3631
    }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3632
    // Previous value has been loaded into tmp
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3633
    pre_val = tmp;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3634
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3635
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3636
  assert(pre_val != noreg, "must have a real register");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3637
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3638
  // Is the previous value null?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3639
  cmp_and_brx_short(pre_val, G0, Assembler::equal, Assembler::pt, filtered);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3640
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3641
  // OK, it's not filtered, so we'll need to call enqueue.  In the normal
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3642
  // case, pre_val will be a scratch G-reg, but there are some cases in
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3643
  // which it's an O-reg.  In the first case, do a normal call.  In the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3644
  // latter, do a save here and call the frameless version.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3645
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3646
  guarantee(pre_val->is_global() || pre_val->is_out(),
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3647
            "Or we need to think harder.");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3648
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3649
  if (pre_val->is_global() && !preserve_o_regs) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3650
    generate_satb_log_enqueue_if_necessary(true); // with frame
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3651
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3652
    call(satb_log_enqueue_with_frame);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3653
    delayed()->mov(pre_val, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3654
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3655
    generate_satb_log_enqueue_if_necessary(false); // frameless
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3656
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3657
    save_frame(0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3658
    call(satb_log_enqueue_frameless);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3659
    delayed()->mov(pre_val->after_save(), O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3660
    restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3661
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3662
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3663
  bind(filtered);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3664
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3665
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3666
static address dirty_card_log_enqueue = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3667
static u_char* dirty_card_log_enqueue_end = 0;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3668
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3669
// This gets to assume that o0 contains the object address.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3670
static void generate_dirty_card_log_enqueue(jbyte* byte_map_base) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3671
  BufferBlob* bb = BufferBlob::create("dirty_card_enqueue", EnqueueCodeSize*2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3672
  CodeBuffer buf(bb);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3673
  MacroAssembler masm(&buf);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3674
#define __ masm.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3675
  address start = __ pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3676
20403
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3677
  Label not_already_dirty, restart, refill, young_card;
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3678
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3679
  __ srlx(O0, CardTableModRefBS::card_shift, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3680
  AddressLiteral addrlit(byte_map_base);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3681
  __ set(addrlit, O1); // O1 := <card table base>
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3682
  __ ldub(O0, O1, O2); // O2 := [O0 + O1]
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3683
20403
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3684
  __ cmp_and_br_short(O2, G1SATBCardTableModRefBS::g1_young_card_val(), Assembler::equal, Assembler::pt, young_card);
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3685
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3686
  __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3687
  __ ldub(O0, O1, O2); // O2 := [O0 + O1]
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3688
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3689
  assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3690
  __ cmp_and_br_short(O2, G0, Assembler::notEqual, Assembler::pt, not_already_dirty);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3691
20403
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 19979
diff changeset
  3692
  __ bind(young_card);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3693
  // We didn't take the branch, so we're already dirty: return.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3694
  // Use return-from-leaf
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3695
  __ retl();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3696
  __ delayed()->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3697
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3698
  // Not dirty.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3699
  __ bind(not_already_dirty);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3700
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3701
  // Get O0 + O1 into a reg by itself
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3702
  __ add(O0, O1, O3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3703
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3704
  // First, dirty it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3705
  __ stb(G0, O3, G0);  // [cardPtr] := 0  (i.e., dirty).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3706
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3707
  int dirty_card_q_index_byte_offset =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3708
    in_bytes(JavaThread::dirty_card_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3709
             DirtyCardQueue::byte_offset_of_index());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3710
  int dirty_card_q_buf_byte_offset =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3711
    in_bytes(JavaThread::dirty_card_queue_offset() +
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3712
             DirtyCardQueue::byte_offset_of_buf());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3713
  __ bind(restart);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3714
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33628
diff changeset
  3715
  // Load the index into the update buffer. DirtyCardQueue::_index is
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3716
  // a size_t so ld_ptr is appropriate here.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3717
  __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3718
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3719
  // index == 0?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3720
  __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3721
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3722
  __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, L1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3723
  __ sub(L0, oopSize, L0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3724
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3725
  __ st_ptr(O3, L1, L0);  // [_buf + index] := I0
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3726
  // Use return-from-leaf
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3727
  __ retl();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3728
  __ delayed()->st_ptr(L0, G2_thread, dirty_card_q_index_byte_offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3729
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3730
  __ bind(refill);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3731
  address handle_zero =
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3732
    CAST_FROM_FN_PTR(address,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3733
                     &DirtyCardQueueSet::handle_zero_index_for_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3734
  // This should be rare enough that we can afford to save all the
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3735
  // scratch registers that the calling context might be using.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3736
  __ mov(G1_scratch, L3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3737
  __ mov(G3_scratch, L5);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3738
  // We need the value of O3 above (for the write into the buffer), so we
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3739
  // save and restore it.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3740
  __ mov(O3, L6);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3741
  // Since the call will overwrite O7, we save and restore that, as well.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3742
  __ mov(O7, L4);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3743
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3744
  __ call_VM_leaf(L7_thread_cache, handle_zero, G2_thread);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3745
  __ mov(L3, G1_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3746
  __ mov(L5, G3_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3747
  __ mov(L6, O3);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3748
  __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3749
  __ delayed()->mov(L4, O7);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3750
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3751
  dirty_card_log_enqueue = start;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3752
  dirty_card_log_enqueue_end = __ pc();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3753
  // XXX Should have a guarantee here about not going off the end!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3754
  // Does it already do so?  Do an experiment...
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3755
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3756
#undef __
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3757
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3758
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3759
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3760
static inline void
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3761
generate_dirty_card_log_enqueue_if_necessary(jbyte* byte_map_base) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3762
  if (dirty_card_log_enqueue == 0) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3763
    generate_dirty_card_log_enqueue(byte_map_base);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3764
    assert(dirty_card_log_enqueue != 0, "postcondition.");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3765
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3766
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3767
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3768
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3769
void MacroAssembler::g1_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3770
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3771
  Label filtered;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3772
  MacroAssembler* post_filter_masm = this;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3773
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3774
  if (new_val == G0) return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3775
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29070
diff changeset
  3776
  G1SATBCardTableLoggingModRefBS* bs =
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29070
diff changeset
  3777
    barrier_set_cast<G1SATBCardTableLoggingModRefBS>(Universe::heap()->barrier_set());
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3778
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3779
  if (G1RSBarrierRegionFilter) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3780
    xor3(store_addr, new_val, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3781
    srlx(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3782
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3783
    // XXX Should I predict this taken or not?  Does it matter?
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3784
    cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3785
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3786
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3787
  // If the "store_addr" register is an "in" or "local" register, move it to
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3788
  // a scratch reg so we can pass it as an argument.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3789
  bool use_scr = !(store_addr->is_global() || store_addr->is_out());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3790
  // Pick a scratch register different from "tmp".
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3791
  Register scr = (tmp == G1_scratch ? G3_scratch : G1_scratch);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3792
  // Make sure we use up the delay slot!
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3793
  if (use_scr) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3794
    post_filter_masm->mov(store_addr, scr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3795
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3796
    post_filter_masm->nop();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3797
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3798
  generate_dirty_card_log_enqueue_if_necessary(bs->byte_map_base);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3799
  save_frame(0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3800
  call(dirty_card_log_enqueue);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3801
  if (use_scr) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3802
    delayed()->mov(scr, O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3803
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3804
    delayed()->mov(store_addr->after_save(), O0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3805
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3806
  restore();
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3807
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3808
  bind(filtered);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3809
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3810
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 15116
diff changeset
  3811
#endif // INCLUDE_ALL_GCS
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3812
///////////////////////////////////////////////////////////////////////////////////
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3813
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3814
void MacroAssembler::card_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3815
  // If we're writing constant NULL, we can skip the write barrier.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3816
  if (new_val == G0) return;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29070
diff changeset
  3817
  CardTableModRefBS* bs =
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29070
diff changeset
  3818
    barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set());
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31849
diff changeset
  3819
  assert(bs->kind() == BarrierSet::CardTableForRS ||
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3820
         bs->kind() == BarrierSet::CardTableExtension, "wrong barrier");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3821
  card_table_write(bs->byte_map_base, tmp, store_addr);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3822
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3823
38074
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3824
void MacroAssembler::load_mirror(Register mirror, Register method) {
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3825
  const int mirror_offset = in_bytes(Klass::java_mirror_offset());
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3826
  ld_ptr(method, in_bytes(Method::const_offset()), mirror);
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3827
  ld_ptr(mirror, in_bytes(ConstMethod::constants_offset()), mirror);
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3828
  ld_ptr(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3829
  ld_ptr(mirror, mirror_offset, mirror);
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3830
}
8475fdc6dcc3 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents: 38042
diff changeset
  3831
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3832
void MacroAssembler::load_klass(Register src_oop, Register klass) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3833
  // The number of bytes in this code is used by
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3834
  // MachCallDynamicJavaNode::ret_addr_offset()
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3835
  // if this changes, change that.
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  3836
  if (UseCompressedClassPointers) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3837
    lduw(src_oop, oopDesc::klass_offset_in_bytes(), klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3838
    decode_klass_not_null(klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3839
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3840
    ld_ptr(src_oop, oopDesc::klass_offset_in_bytes(), klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3841
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3842
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3843
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3844
void MacroAssembler::store_klass(Register klass, Register dst_oop) {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  3845
  if (UseCompressedClassPointers) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3846
    assert(dst_oop != klass, "not enough registers");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3847
    encode_klass_not_null(klass);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3848
    st(klass, dst_oop, oopDesc::klass_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3849
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3850
    st_ptr(klass, dst_oop, oopDesc::klass_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3851
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3852
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3853
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3854
void MacroAssembler::store_klass_gap(Register s, Register d) {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  3855
  if (UseCompressedClassPointers) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3856
    assert(s != d, "not enough registers");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3857
    st(s, d, oopDesc::klass_gap_offset_in_bytes());
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3858
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3859
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3860
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3861
void MacroAssembler::load_heap_oop(const Address& s, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3862
  if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3863
    lduw(s, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3864
    decode_heap_oop(d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3865
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3866
    ld_ptr(s, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3867
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3868
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3869
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3870
void MacroAssembler::load_heap_oop(Register s1, Register s2, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3871
   if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3872
    lduw(s1, s2, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3873
    decode_heap_oop(d, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3874
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3875
    ld_ptr(s1, s2, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3876
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3877
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3878
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3879
void MacroAssembler::load_heap_oop(Register s1, int simm13a, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3880
   if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3881
    lduw(s1, simm13a, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3882
    decode_heap_oop(d, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3883
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3884
    ld_ptr(s1, simm13a, d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3885
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3886
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3887
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3888
void MacroAssembler::load_heap_oop(Register s1, RegisterOrConstant s2, Register d) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3889
  if (s2.is_constant())  load_heap_oop(s1, s2.as_constant(), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3890
  else                   load_heap_oop(s1, s2.as_register(), d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3891
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3892
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3893
void MacroAssembler::store_heap_oop(Register d, Register s1, Register s2) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3894
  if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3895
    assert(s1 != d && s2 != d, "not enough registers");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3896
    encode_heap_oop(d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3897
    st(d, s1, s2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3898
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3899
    st_ptr(d, s1, s2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3900
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3901
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3902
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3903
void MacroAssembler::store_heap_oop(Register d, Register s1, int simm13a) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3904
  if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3905
    assert(s1 != d, "not enough registers");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3906
    encode_heap_oop(d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3907
    st(d, s1, simm13a);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3908
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3909
    st_ptr(d, s1, simm13a);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3910
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3911
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3912
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3913
void MacroAssembler::store_heap_oop(Register d, const Address& a, int offset) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3914
  if (UseCompressedOops) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3915
    assert(a.base() != d, "not enough registers");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3916
    encode_heap_oop(d);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3917
    st(d, a, offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3918
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3919
    st_ptr(d, a, offset);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3920
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3921
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3922
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3923
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3924
void MacroAssembler::encode_heap_oop(Register src, Register dst) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3925
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3926
  assert (Universe::heap() != NULL, "java heap should be initialized");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3927
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3928
  verify_oop(src);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3929
  if (Universe::narrow_oop_base() == NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3930
    srlx(src, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3931
    return;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3932
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3933
  Label done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3934
  if (src == dst) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3935
    // optimize for frequent case src == dst
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3936
    bpr(rc_nz, true, Assembler::pt, src, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3937
    delayed() -> sub(src, G6_heapbase, dst); // annuled if not taken
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3938
    bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3939
    srlx(src, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3940
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3941
    bpr(rc_z, false, Assembler::pn, src, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3942
    delayed() -> mov(G0, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3943
    // could be moved before branch, and annulate delay,
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3944
    // but may add some unneeded work decoding null
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3945
    sub(src, G6_heapbase, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3946
    srlx(dst, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3947
    bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3948
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3949
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3950
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3951
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3952
void MacroAssembler::encode_heap_oop_not_null(Register r) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3953
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3954
  assert (Universe::heap() != NULL, "java heap should be initialized");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3955
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3956
  verify_oop(r);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3957
  if (Universe::narrow_oop_base() != NULL)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3958
    sub(r, G6_heapbase, r);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3959
  srlx(r, LogMinObjAlignmentInBytes, r);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3960
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3961
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3962
void MacroAssembler::encode_heap_oop_not_null(Register src, Register dst) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3963
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3964
  assert (Universe::heap() != NULL, "java heap should be initialized");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3965
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3966
  verify_oop(src);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3967
  if (Universe::narrow_oop_base() == NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3968
    srlx(src, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3969
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3970
    sub(src, G6_heapbase, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3971
    srlx(dst, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3972
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3973
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3974
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3975
// Same algorithm as oops.inline.hpp decode_heap_oop.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3976
void  MacroAssembler::decode_heap_oop(Register src, Register dst) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3977
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3978
  assert (Universe::heap() != NULL, "java heap should be initialized");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3979
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3980
  sllx(src, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3981
  if (Universe::narrow_oop_base() != NULL) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3982
    Label done;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3983
    bpr(rc_nz, true, Assembler::pt, dst, done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3984
    delayed() -> add(dst, G6_heapbase, dst); // annuled if not taken
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3985
    bind(done);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3986
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3987
  verify_oop(dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3988
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3989
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3990
void  MacroAssembler::decode_heap_oop_not_null(Register r) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3991
  // Do not add assert code to this unless you change vtableStubs_sparc.cpp
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3992
  // pd_code_size_limit.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3993
  // Also do not verify_oop as this is called by verify_oop.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3994
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3995
  assert (Universe::heap() != NULL, "java heap should be initialized");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3996
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3997
  sllx(r, LogMinObjAlignmentInBytes, r);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3998
  if (Universe::narrow_oop_base() != NULL)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  3999
    add(r, G6_heapbase, r);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4000
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4001
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4002
void  MacroAssembler::decode_heap_oop_not_null(Register src, Register dst) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4003
  // Do not add assert code to this unless you change vtableStubs_sparc.cpp
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4004
  // pd_code_size_limit.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4005
  // Also do not verify_oop as this is called by verify_oop.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4006
  assert (UseCompressedOops, "must be compressed");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4007
  assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4008
  sllx(src, LogMinObjAlignmentInBytes, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4009
  if (Universe::narrow_oop_base() != NULL)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4010
    add(dst, G6_heapbase, dst);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4011
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4012
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4013
void MacroAssembler::encode_klass_not_null(Register r) {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4014
  assert (UseCompressedClassPointers, "must be compressed");
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4015
  if (Universe::narrow_klass_base() != NULL) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4016
    assert(r != G6_heapbase, "bad register choice");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4017
    set((intptr_t)Universe::narrow_klass_base(), G6_heapbase);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4018
    sub(r, G6_heapbase, r);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4019
    if (Universe::narrow_klass_shift() != 0) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4020
      assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4021
      srlx(r, LogKlassAlignmentInBytes, r);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4022
    }
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4023
    reinit_heapbase();
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4024
  } else {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4025
    assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4026
    srlx(r, Universe::narrow_klass_shift(), r);
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4027
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4028
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4029
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4030
void MacroAssembler::encode_klass_not_null(Register src, Register dst) {
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4031
  if (src == dst) {
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4032
    encode_klass_not_null(src);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4033
  } else {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4034
    assert (UseCompressedClassPointers, "must be compressed");
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4035
    if (Universe::narrow_klass_base() != NULL) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4036
      set((intptr_t)Universe::narrow_klass_base(), dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4037
      sub(src, dst, dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4038
      if (Universe::narrow_klass_shift() != 0) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4039
        srlx(dst, LogKlassAlignmentInBytes, dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4040
      }
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4041
    } else {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4042
      // shift src into dst
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4043
      assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4044
      srlx(src, Universe::narrow_klass_shift(), dst);
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4045
    }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4046
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4047
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4048
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4049
// Function instr_size_for_decode_klass_not_null() counts the instructions
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4050
// generated by decode_klass_not_null() and reinit_heapbase().  Hence, if
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4051
// the instructions they generate change, then this method needs to be updated.
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4052
int MacroAssembler::instr_size_for_decode_klass_not_null() {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4053
  assert (UseCompressedClassPointers, "only for compressed klass ptrs");
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4054
  int num_instrs = 1;  // shift src,dst or add
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4055
  if (Universe::narrow_klass_base() != NULL) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4056
    // set + add + set
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4057
    num_instrs += insts_for_internal_set((intptr_t)Universe::narrow_klass_base()) +
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4058
                  insts_for_internal_set((intptr_t)Universe::narrow_ptrs_base());
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4059
    if (Universe::narrow_klass_shift() != 0) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4060
      num_instrs += 1;  // sllx
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4061
    }
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4062
  }
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4063
  return num_instrs * BytesPerInstWord;
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4064
}
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4065
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4066
// !!! If the instructions that get generated here change then function
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4067
// instr_size_for_decode_klass_not_null() needs to get updated.
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4068
void  MacroAssembler::decode_klass_not_null(Register r) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4069
  // Do not add assert code to this unless you change vtableStubs_sparc.cpp
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4070
  // pd_code_size_limit.
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4071
  assert (UseCompressedClassPointers, "must be compressed");
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4072
  if (Universe::narrow_klass_base() != NULL) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4073
    assert(r != G6_heapbase, "bad register choice");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4074
    set((intptr_t)Universe::narrow_klass_base(), G6_heapbase);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4075
    if (Universe::narrow_klass_shift() != 0)
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4076
      sllx(r, LogKlassAlignmentInBytes, r);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4077
    add(r, G6_heapbase, r);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4078
    reinit_heapbase();
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4079
  } else {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4080
    assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4081
    sllx(r, Universe::narrow_klass_shift(), r);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4082
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4083
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4084
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4085
void  MacroAssembler::decode_klass_not_null(Register src, Register dst) {
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4086
  if (src == dst) {
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4087
    decode_klass_not_null(src);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4088
  } else {
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4089
    // Do not add assert code to this unless you change vtableStubs_sparc.cpp
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4090
    // pd_code_size_limit.
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4091
    assert (UseCompressedClassPointers, "must be compressed");
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4092
    if (Universe::narrow_klass_base() != NULL) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4093
      if (Universe::narrow_klass_shift() != 0) {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4094
        assert((src != G6_heapbase) && (dst != G6_heapbase), "bad register choice");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4095
        set((intptr_t)Universe::narrow_klass_base(), G6_heapbase);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4096
        sllx(src, LogKlassAlignmentInBytes, dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4097
        add(dst, G6_heapbase, dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4098
        reinit_heapbase();
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4099
      } else {
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4100
        set((intptr_t)Universe::narrow_klass_base(), dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4101
        add(src, dst, dst);
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4102
      }
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4103
    } else {
21188
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4104
      // shift/mov src into dst.
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4105
      assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong");
d053e4e8f901 8024927: Nashorn performance regression with CompressedOops
coleenp
parents: 20403
diff changeset
  4106
      sllx(src, Universe::narrow_klass_shift(), dst);
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4107
    }
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4108
  }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4109
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4110
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4111
void MacroAssembler::reinit_heapbase() {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19319
diff changeset
  4112
  if (UseCompressedOops || UseCompressedClassPointers) {
19319
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4113
    if (Universe::heap() != NULL) {
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4114
      set((intptr_t)Universe::narrow_ptrs_base(), G6_heapbase);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4115
    } else {
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4116
      AddressLiteral base(Universe::narrow_ptrs_base_addr());
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4117
      load_ptr_contents(base, G6_heapbase);
0ad35be0733a 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 18446
diff changeset
  4118
    }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4119
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4120
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4121
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4122
#ifdef COMPILER2
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4123
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4124
// Compress char[] to byte[] by compressing 16 bytes at once. Return 0 on failure.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4125
void MacroAssembler::string_compress_16(Register src, Register dst, Register cnt, Register result,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4126
                                        Register tmp1, Register tmp2, Register tmp3, Register tmp4,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4127
                                        FloatRegister ftmp1, FloatRegister ftmp2, FloatRegister ftmp3, Label& Ldone) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4128
  Label Lloop, Lslow;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4129
  assert(UseVIS >= 3, "VIS3 is required");
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4130
  assert_different_registers(src, dst, cnt, tmp1, tmp2, tmp3, tmp4, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4131
  assert_different_registers(ftmp1, ftmp2, ftmp3);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4132
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4133
  // Check if cnt >= 8 (= 16 bytes)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4134
  cmp(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4135
  br(Assembler::less, false, Assembler::pn, Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4136
  delayed()->mov(cnt, result); // copy count
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4137
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4138
  // Check for 8-byte alignment of src and dst
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4139
  or3(src, dst, tmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4140
  andcc(tmp1, 7, G0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4141
  br(Assembler::notZero, false, Assembler::pn, Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4142
  delayed()->nop();
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4143
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4144
  // Set mask for bshuffle instruction
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4145
  Register mask = tmp4;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4146
  set(0x13579bdf, mask);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4147
  bmask(mask, G0, G0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4148
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4149
  // Set mask to 0xff00 ff00 ff00 ff00 to check for non-latin1 characters
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4150
  Assembler::sethi(0xff00fc00, mask); // mask = 0x0000 0000 ff00 fc00
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4151
  add(mask, 0x300, mask);             // mask = 0x0000 0000 ff00 ff00
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4152
  sllx(mask, 32, tmp1);               // tmp1 = 0xff00 ff00 0000 0000
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4153
  or3(mask, tmp1, mask);              // mask = 0xff00 ff00 ff00 ff00
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4154
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4155
  // Load first 8 bytes
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4156
  ldx(src, 0, tmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4157
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4158
  bind(Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4159
  // Load next 8 bytes
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4160
  ldx(src, 8, tmp2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4161
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4162
  // Check for non-latin1 character by testing if the most significant byte of a char is set.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4163
  // Although we have to move the data between integer and floating point registers, this is
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4164
  // still faster than the corresponding VIS instructions (ford/fand/fcmpd).
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4165
  or3(tmp1, tmp2, tmp3);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4166
  btst(tmp3, mask);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4167
  // annul zeroing if branch is not taken to preserve original count
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4168
  brx(Assembler::notZero, true, Assembler::pn, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4169
  delayed()->mov(G0, result); // 0 - failed
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4170
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4171
  // Move bytes into float register
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4172
  movxtod(tmp1, ftmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4173
  movxtod(tmp2, ftmp2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4174
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4175
  // Compress by copying one byte per char from ftmp1 and ftmp2 to ftmp3
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4176
  bshuffle(ftmp1, ftmp2, ftmp3);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4177
  stf(FloatRegisterImpl::D, ftmp3, dst, 0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4178
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4179
  // Increment addresses and decrement count
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4180
  inc(src, 16);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4181
  inc(dst, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4182
  dec(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4183
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4184
  cmp(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4185
  // annul LDX if branch is not taken to prevent access past end of string
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4186
  br(Assembler::greaterEqual, true, Assembler::pt, Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4187
  delayed()->ldx(src, 0, tmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4188
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4189
  // Fallback to slow version
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4190
  bind(Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4191
}
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4192
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4193
// Compress char[] to byte[]. Return 0 on failure.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4194
void MacroAssembler::string_compress(Register src, Register dst, Register cnt, Register result, Register tmp, Label& Ldone) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4195
  Label Lloop;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4196
  assert_different_registers(src, dst, cnt, tmp, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4197
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4198
  lduh(src, 0, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4199
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4200
  bind(Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4201
  inc(src, sizeof(jchar));
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4202
  cmp(tmp, 0xff);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4203
  // annul zeroing if branch is not taken to preserve original count
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4204
  br(Assembler::greater, true, Assembler::pn, Ldone); // don't check xcc
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4205
  delayed()->mov(G0, result); // 0 - failed
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4206
  deccc(cnt);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4207
  stb(tmp, dst, 0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4208
  inc(dst);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4209
  // annul LDUH if branch is not taken to prevent access past end of string
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4210
  br(Assembler::notZero, true, Assembler::pt, Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4211
  delayed()->lduh(src, 0, tmp); // hoisted
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4212
}
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4213
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4214
// Inflate byte[] to char[] by inflating 16 bytes at once.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4215
void MacroAssembler::string_inflate_16(Register src, Register dst, Register cnt, Register tmp,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4216
                                       FloatRegister ftmp1, FloatRegister ftmp2, FloatRegister ftmp3, FloatRegister ftmp4, Label& Ldone) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4217
  Label Lloop, Lslow;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4218
  assert(UseVIS >= 3, "VIS3 is required");
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4219
  assert_different_registers(src, dst, cnt, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4220
  assert_different_registers(ftmp1, ftmp2, ftmp3, ftmp4);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4221
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4222
  // Check if cnt >= 8 (= 16 bytes)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4223
  cmp(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4224
  br(Assembler::less, false, Assembler::pn, Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4225
  delayed()->nop();
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4226
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4227
  // Check for 8-byte alignment of src and dst
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4228
  or3(src, dst, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4229
  andcc(tmp, 7, G0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4230
  br(Assembler::notZero, false, Assembler::pn, Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4231
  // Initialize float register to zero
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4232
  FloatRegister zerof = ftmp4;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4233
  delayed()->fzero(FloatRegisterImpl::D, zerof);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4234
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4235
  // Load first 8 bytes
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4236
  ldf(FloatRegisterImpl::D, src, 0, ftmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4237
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4238
  bind(Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4239
  inc(src, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4240
  dec(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4241
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4242
  // Inflate the string by interleaving each byte from the source array
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4243
  // with a zero byte and storing the result in the destination array.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4244
  fpmerge(zerof, ftmp1->successor(), ftmp2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4245
  stf(FloatRegisterImpl::D, ftmp2, dst, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4246
  fpmerge(zerof, ftmp1, ftmp3);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4247
  stf(FloatRegisterImpl::D, ftmp3, dst, 0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4248
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4249
  inc(dst, 16);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4250
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4251
  cmp(cnt, 8);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4252
  // annul LDX if branch is not taken to prevent access past end of string
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4253
  br(Assembler::greaterEqual, true, Assembler::pt, Lloop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4254
  delayed()->ldf(FloatRegisterImpl::D, src, 0, ftmp1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4255
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4256
  // Fallback to slow version
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4257
  bind(Lslow);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4258
}
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4259
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4260
// Inflate byte[] to char[].
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4261
void MacroAssembler::string_inflate(Register src, Register dst, Register cnt, Register tmp, Label& Ldone) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4262
  Label Loop;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4263
  assert_different_registers(src, dst, cnt, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4264
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4265
  ldub(src, 0, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4266
  bind(Loop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4267
  inc(src);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4268
  deccc(cnt);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4269
  sth(tmp, dst, 0);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4270
  inc(dst, sizeof(jchar));
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4271
  // annul LDUB if branch is not taken to prevent access past end of string
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4272
  br(Assembler::notZero, true, Assembler::pt, Loop);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4273
  delayed()->ldub(src, 0, tmp); // hoisted
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4274
}
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4275
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4276
void MacroAssembler::string_compare(Register str1, Register str2,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4277
                                    Register cnt1, Register cnt2,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4278
                                    Register tmp1, Register tmp2,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4279
                                    Register result, int ae) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4280
  Label Ldone, Lloop;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4281
  assert_different_registers(str1, str2, cnt1, cnt2, tmp1, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4282
  int stride1, stride2;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4283
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4284
  // Note: Making use of the fact that compareTo(a, b) == -compareTo(b, a)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4285
  // we interchange str1 and str2 in the UL case and negate the result.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4286
  // Like this, str1 is always latin1 encoded, expect for the UU case.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4287
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4288
  if (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4289
    srl(cnt2, 1, cnt2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4290
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4291
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4292
  // See if the lengths are different, and calculate min in cnt1.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4293
  // Save diff in case we need it for a tie-breaker.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4294
  Label Lskip;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4295
  Register diff = tmp1;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4296
  subcc(cnt1, cnt2, diff);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4297
  br(Assembler::greater, true, Assembler::pt, Lskip);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4298
  // cnt2 is shorter, so use its count:
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4299
  delayed()->mov(cnt2, cnt1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4300
  bind(Lskip);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4301
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4302
  // Rename registers
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4303
  Register limit1 = cnt1;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4304
  Register limit2 = limit1;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4305
  Register chr1   = result;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4306
  Register chr2   = cnt2;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4307
  if (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4308
    // We need an additional register to keep track of two limits
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4309
    assert_different_registers(str1, str2, cnt1, cnt2, tmp1, tmp2, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4310
    limit2 = tmp2;
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4311
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4312
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4313
  // Is the minimum length zero?
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4314
  cmp(limit1, (int)0); // use cast to resolve overloading ambiguity
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4315
  br(Assembler::equal, true, Assembler::pn, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4316
  // result is difference in lengths
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4317
  if (ae == StrIntrinsicNode::UU) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4318
    delayed()->sra(diff, 1, result);  // Divide by 2 to get number of chars
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4319
  } else {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4320
    delayed()->mov(diff, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4321
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4322
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4323
  // Load first characters
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4324
  if (ae == StrIntrinsicNode::LL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4325
    stride1 = stride2 = sizeof(jbyte);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4326
    ldub(str1, 0, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4327
    ldub(str2, 0, chr2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4328
  } else if (ae == StrIntrinsicNode::UU) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4329
    stride1 = stride2 = sizeof(jchar);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4330
    lduh(str1, 0, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4331
    lduh(str2, 0, chr2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4332
  } else {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4333
    stride1 = sizeof(jbyte);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4334
    stride2 = sizeof(jchar);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4335
    ldub(str1, 0, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4336
    lduh(str2, 0, chr2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4337
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4338
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4339
  // Compare first characters
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4340
  subcc(chr1, chr2, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4341
  br(Assembler::notZero, false, Assembler::pt, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4342
  assert(chr1 == result, "result must be pre-placed");
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4343
  delayed()->nop();
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4344
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4345
  // Check if the strings start at same location
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4346
  cmp(str1, str2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4347
  brx(Assembler::equal, true, Assembler::pn, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4348
  delayed()->mov(G0, result);  // result is zero
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4349
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4350
  // We have no guarantee that on 64 bit the higher half of limit is 0
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4351
  signx(limit1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4352
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4353
  // Get limit
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4354
  if (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4355
    sll(limit1, 1, limit2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4356
    subcc(limit2, stride2, chr2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4357
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4358
  subcc(limit1, stride1, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4359
  br(Assembler::zero, true, Assembler::pn, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4360
  // result is difference in lengths
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4361
  if (ae == StrIntrinsicNode::UU) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4362
    delayed()->sra(diff, 1, result);  // Divide by 2 to get number of chars
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4363
  } else {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4364
    delayed()->mov(diff, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4365
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4366
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4367
  // Shift str1 and str2 to the end of the arrays, negate limit
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4368
  add(str1, limit1, str1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4369
  add(str2, limit2, str2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4370
  neg(chr1, limit1);  // limit1 = -(limit1-stride1)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4371
  if (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4372
    neg(chr2, limit2);  // limit2 = -(limit2-stride2)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4373
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4374
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4375
  // Compare the rest of the characters
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4376
  load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false);
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4377
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4378
  bind(Lloop);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4379
  load_sized_value(Address(str2, limit2), chr2, (ae == StrIntrinsicNode::LL) ? 1 : 2, false);
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4380
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4381
  subcc(chr1, chr2, chr1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4382
  br(Assembler::notZero, false, Assembler::pt, Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4383
  assert(chr1 == result, "result must be pre-placed");
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4384
  delayed()->inccc(limit1, stride1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4385
  if (ae == StrIntrinsicNode::LU || ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4386
    inccc(limit2, stride2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4387
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4388
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4389
  // annul LDUB if branch is not taken to prevent access past end of string
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4390
  br(Assembler::notZero, true, Assembler::pt, Lloop);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4391
  delayed()->load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false);
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4392
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4393
  // If strings are equal up to min length, return the length difference.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4394
  if (ae == StrIntrinsicNode::UU) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4395
    // Divide by 2 to get number of chars
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4396
    sra(diff, 1, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4397
  } else {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4398
    mov(diff, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4399
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4400
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4401
  // Otherwise, return the difference between the first mismatched chars.
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4402
  bind(Ldone);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4403
  if(ae == StrIntrinsicNode::UL) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4404
    // Negate result (see note above)
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4405
    neg(result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4406
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4407
}
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4408
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4409
void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2,
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4410
                                  Register limit, Register tmp, Register result, bool is_byte) {
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4411
  Label Ldone, Lloop, Lremaining;
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4412
  assert_different_registers(ary1, ary2, limit, tmp, result);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4413
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4414
  int length_offset  = arrayOopDesc::length_offset_in_bytes();
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4415
  int base_offset    = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4416
  assert(base_offset % 8 == 0, "Base offset must be 8-byte aligned");
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4417
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4418
  if (is_array_equ) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4419
    // return true if the same array
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4420
    cmp(ary1, ary2);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4421
    brx(Assembler::equal, true, Assembler::pn, Ldone);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4422
    delayed()->mov(1, result);  // equal
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4423
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4424
    br_null(ary1, true, Assembler::pn, Ldone);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4425
    delayed()->clr(result);     // not equal
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4426
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4427
    br_null(ary2, true, Assembler::pn, Ldone);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4428
    delayed()->clr(result);     // not equal
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4429
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4430
    // load the lengths of arrays
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4431
    ld(Address(ary1, length_offset), limit);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4432
    ld(Address(ary2, length_offset), tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4433
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4434
    // return false if the two arrays are not equal length
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4435
    cmp(limit, tmp);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4436
    br(Assembler::notEqual, true, Assembler::pn, Ldone);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4437
    delayed()->clr(result);     // not equal
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4438
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4439
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4440
  cmp_zero_and_br(Assembler::zero, limit, Ldone, true, Assembler::pn);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4441
  delayed()->mov(1, result); // zero-length arrays are equal
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4442
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4443
  if (is_array_equ) {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4444
    // load array addresses
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4445
    add(ary1, base_offset, ary1);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4446
    add(ary2, base_offset, ary2);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4447
    // set byte count
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4448
    if (!is_byte) {
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4449
      sll(limit, exact_log2(sizeof(jchar)), limit);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4450
    }
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4451
  } else {
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4452
    // We have no guarantee that on 64 bit the higher half of limit is 0
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4453
    signx(limit);
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4454
  }
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4455
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4456
#ifdef ASSERT
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4457
  // Sanity check for doubleword (8-byte) alignment of ary1 and ary2.
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4458
  // Guaranteed on 64-bit systems (see arrayOopDesc::header_size_in_bytes()).
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4459
  Label Laligned;
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4460
  or3(ary1, ary2, tmp);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4461
  andcc(tmp, 7, tmp);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4462
  br_null_short(tmp, Assembler::pn, Laligned);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4463
  STOP("First array element is not 8-byte aligned.");
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4464
  should_not_reach_here();
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4465
  bind(Laligned);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4466
#endif
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4467
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4468
  // Shift ary1 and ary2 to the end of the arrays, negate limit
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4469
  add(ary1, limit, ary1);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4470
  add(ary2, limit, ary2);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4471
  neg(limit, limit);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4472
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4473
  // MAIN LOOP
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4474
  // Load and compare array elements of size 'byte_width' until the elements are not
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4475
  // equal or we reached the end of the arrays. If the size of the arrays is not a
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4476
  // multiple of 'byte_width', we simply read over the end of the array, bail out and
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4477
  // compare the remaining bytes below by skipping the garbage bytes.
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4478
  ldx(ary1, limit, result);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4479
  bind(Lloop);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4480
  ldx(ary2, limit, tmp);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4481
  inccc(limit, 8);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4482
  // Bail out if we reached the end (but still do the comparison)
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4483
  br(Assembler::positive, false, Assembler::pn, Lremaining);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4484
  delayed()->cmp(result, tmp);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4485
  // Check equality of elements
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4486
  brx(Assembler::equal, false, Assembler::pt, target(Lloop));
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4487
  delayed()->ldx(ary1, limit, result);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4488
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4489
  ba(Ldone);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4490
  delayed()->clr(result); // not equal
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4491
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4492
  // TAIL COMPARISON
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4493
  // We got here because we reached the end of the arrays. 'limit' is the number of
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4494
  // garbage bytes we may have compared by reading over the end of the arrays. Shift
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4495
  // out the garbage and compare the remaining elements.
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4496
  bind(Lremaining);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4497
  // Optimistic shortcut: elements potentially including garbage are equal
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4498
  brx(Assembler::equal, true, Assembler::pt, target(Ldone));
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4499
  delayed()->mov(1, result); // equal
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4500
  // Shift 'limit' bytes to the right and compare
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4501
  sll(limit, 3, limit); // bytes to bits
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4502
  srlx(result, limit, result);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4503
  srlx(tmp, limit, tmp);
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4504
  cmp(result, tmp);
38142
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4505
  clr(result);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4506
  movcc(Assembler::equal, false, xcc, 1, result);
e16b23089599 6941938: Improve array equals intrinsic on SPARC
thartmann
parents: 38042
diff changeset
  4507
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4508
  bind(Ldone);
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4509
}
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4510
36808
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4511
void MacroAssembler::has_negatives(Register inp, Register size, Register result, Register t2, Register t3, Register t4, Register t5) {
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4512
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4513
  // test for negative bytes in input string of a given size
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4514
  // result 1 if found, 0 otherwise.
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4515
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4516
  Label Lcore, Ltail, Lreturn, Lcore_rpt;
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4517
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4518
  assert_different_registers(inp, size, t2, t3, t4, t5, result);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4519
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4520
  Register i     = result;  // result used as integer index i until very end
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4521
  Register lmask = t2;      // t2 is aliased to lmask
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4522
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4523
  // INITIALIZATION
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4524
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4525
  // initialize highbits mask -> lmask = 0x8080808080808080  (8B/64b)
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4526
  // compute unaligned offset -> i
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4527
  // compute core end index   -> t5
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4528
  Assembler::sethi(0x80808000, t2);   //! sethi macro fails to emit optimal
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4529
  add(t2, 0x80, t2);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4530
  sllx(t2, 32, t3);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4531
  or3(t3, t2, lmask);                 // 0x8080808080808080 -> lmask
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4532
  sra(size,0,size);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4533
  andcc(inp, 0x7, i);                 // unaligned offset -> i
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4534
  br(Assembler::zero, true, Assembler::pn, Lcore); // starts 8B aligned?
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4535
  delayed()->add(size, -8, t5);       // (annuled) core end index -> t5
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4536
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4537
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4538
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4539
  // UNALIGNED HEAD
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4540
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4541
  // * unaligned head handling: grab aligned 8B containing unaligned inp(ut)
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4542
  // * obliterate (ignore) bytes outside string by shifting off reg ends
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4543
  // * compare with bitmask, short circuit return true if one or more high
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4544
  //   bits set.
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4545
  cmp(size, 0);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4546
  br(Assembler::zero, true, Assembler::pn, Lreturn); // short-circuit?
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4547
  delayed()->mov(0,result);      // annuled so i not clobbered for following
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4548
  neg(i, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4549
  add(i, size, t5);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4550
  ldx(inp, t4, t3);  // raw aligned 8B containing unaligned head -> t3
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4551
  mov(8, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4552
  sub(t4, t5, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4553
  sra(t4, 31, t5);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4554
  andn(t4, t5, t5);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4555
  add(i, t5, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4556
  sll(t5, 3, t5);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4557
  sll(t4, 3, t4);   // # bits to shift right, left -> t5,t4
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4558
  srlx(t3, t5, t3);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4559
  sllx(t3, t4, t3); // bytes outside string in 8B header obliterated -> t3
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4560
  andcc(lmask, t3, G0);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4561
  brx(Assembler::notZero, true, Assembler::pn, Lreturn); // short circuit?
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4562
  delayed()->mov(1,result);      // annuled so i not clobbered for following
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4563
  add(size, -8, t5);             // core end index -> t5
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4564
  mov(8, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4565
  sub(t4, i, i);                 // # bytes examined in unalgn head (<8) -> i
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4566
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4567
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4568
  // ALIGNED CORE
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4569
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4570
  // * iterate index i over aligned 8B sections of core, comparing with
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4571
  //   bitmask, short circuit return true if one or more high bits set
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4572
  // t5 contains core end index/loop limit which is the index
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4573
  //     of the MSB of last (unaligned) 8B fully contained in the string.
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4574
  // inp   contains address of first byte in string/array
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4575
  // lmask contains 8B high bit mask for comparison
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4576
  // i     contains next index to be processed (adr. inp+i is on 8B boundary)
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4577
  bind(Lcore);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4578
  cmp_and_br_short(i, t5, Assembler::greater, Assembler::pn, Ltail);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4579
  bind(Lcore_rpt);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4580
  ldx(inp, i, t3);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4581
  andcc(t3, lmask, G0);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4582
  brx(Assembler::notZero, true, Assembler::pn, Lreturn);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4583
  delayed()->mov(1, result);    // annuled so i not clobbered for following
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4584
  add(i, 8, i);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4585
  cmp_and_br_short(i, t5, Assembler::lessEqual, Assembler::pn, Lcore_rpt);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4586
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4587
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4588
  // ALIGNED TAIL (<8B)
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4589
  // ===========================================================
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4590
  // handle aligned tail of 7B or less as complete 8B, obliterating end of
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4591
  // string bytes by shifting them off end, compare what's left with bitmask
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4592
  // inp   contains address of first byte in string/array
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4593
  // lmask contains 8B high bit mask for comparison
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4594
  // i     contains next index to be processed (adr. inp+i is on 8B boundary)
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4595
  bind(Ltail);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4596
  subcc(size, i, t4);   // # of remaining bytes in string -> t4
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4597
  // return 0 if no more remaining bytes
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4598
  br(Assembler::lessEqual, true, Assembler::pn, Lreturn);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4599
  delayed()->mov(0, result); // annuled so i not clobbered for following
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4600
  ldx(inp, i, t3);       // load final 8B (aligned) containing tail -> t3
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4601
  mov(8, t5);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4602
  sub(t5, t4, t4);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4603
  mov(0, result);        // ** i clobbered at this point
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4604
  sll(t4, 3, t4);        // bits beyond end of string          -> t4
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4605
  srlx(t3, t4, t3);      // bytes beyond end now obliterated   -> t3
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4606
  andcc(lmask, t3, G0);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4607
  movcc(Assembler::notZero, false, xcc,  1, result);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4608
  bind(Lreturn);
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4609
}
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4610
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4611
#endif
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 33105
diff changeset
  4612
36808
bae14ddeff3b 8144693: Intrinsify StringCoding.hasNegatives() on SPARC
thartmann
parents: 35913
diff changeset
  4613
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4614
// Use BIS for zeroing (count is in bytes).
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4615
void MacroAssembler::bis_zeroing(Register to, Register count, Register temp, Label& Ldone) {
46592
6e357e2c8143 8172231: SPARC ISA/CPU feature detection is broken/insufficient (on Solaris)
neliasso
parents: 46560
diff changeset
  4616
  assert(UseBlockZeroing && VM_Version::has_blk_zeroing(), "only works with BIS zeroing");
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4617
  Register end = count;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4618
  int cache_line_size = VM_Version::prefetch_data_size();
38304
6c8815222785 8157184: java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed with a fatal error
kvn
parents: 38241
diff changeset
  4619
  assert(cache_line_size > 0, "cache line size should be known for this code");
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4620
  // Minimum count when BIS zeroing can be used since
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4621
  // it needs membar which is expensive.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4622
  int block_zero_size  = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4623
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4624
  Label small_loop;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4625
  // Check if count is negative (dead code) or zero.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4626
  // Note, count uses 64bit in 64 bit VM.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4627
  cmp_and_brx_short(count, 0, Assembler::lessEqual, Assembler::pn, Ldone);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4628
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4629
  // Use BIS zeroing only for big arrays since it requires membar.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4630
  if (Assembler::is_simm13(block_zero_size)) { // < 4096
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4631
    cmp(count, block_zero_size);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4632
  } else {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4633
    set(block_zero_size, temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4634
    cmp(count, temp);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4635
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4636
  br(Assembler::lessUnsigned, false, Assembler::pt, small_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4637
  delayed()->add(to, count, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4638
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4639
  // Note: size is >= three (32 bytes) cache lines.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4640
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4641
  // Clean the beginning of space up to next cache line.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4642
  for (int offs = 0; offs < cache_line_size; offs += 8) {
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4643
    stx(G0, to, offs);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4644
  }
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4645
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4646
  // align to next cache line
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4647
  add(to, cache_line_size, to);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4648
  and3(to, -cache_line_size, to);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4649
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4650
  // Note: size left >= two (32 bytes) cache lines.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4651
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4652
  // BIS should not be used to zero tail (64 bytes)
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4653
  // to avoid zeroing a header of the following object.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4654
  sub(end, (cache_line_size*2)-8, end);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4655
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4656
  Label bis_loop;
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4657
  bind(bis_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4658
  stxa(G0, to, G0, Assembler::ASI_ST_BLKINIT_PRIMARY);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4659
  add(to, cache_line_size, to);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4660
  cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, bis_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4661
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4662
  // BIS needs membar.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4663
  membar(Assembler::StoreLoad);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4664
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4665
  add(end, (cache_line_size*2)-8, end); // restore end
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4666
  cmp_and_brx_short(to, end, Assembler::greaterEqualUnsigned, Assembler::pn, Ldone);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4667
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4668
  // Clean the tail.
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4669
  bind(small_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4670
  stx(G0, to, 0);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4671
  add(to, 8, to);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4672
  cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, small_loop);
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4673
  nop(); // Separate short branches
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
  4674
}
31515
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4675
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4676
/**
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4677
 * Update CRC-32[C] with a byte value according to constants in table
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4678
 *
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4679
 * @param [in,out]crc   Register containing the crc.
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4680
 * @param [in]val       Register containing the byte to fold into the CRC.
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4681
 * @param [in]table     Register containing the table of crc constants.
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4682
 *
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4683
 * uint32_t crc;
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4684
 * val = crc_table[(val ^ crc) & 0xFF];
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4685
 * crc = val ^ (crc >> 8);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4686
 */
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4687
void MacroAssembler::update_byte_crc32(Register crc, Register val, Register table) {
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4688
  xor3(val, crc, val);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4689
  and3(val, 0xFF, val);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4690
  sllx(val, 2, val);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4691
  lduw(table, val, val);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4692
  srlx(crc, 8, crc);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4693
  xor3(val, crc, crc);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4694
}
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4695
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4696
// Reverse byte order of lower 32 bits, assuming upper 32 bits all zeros
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4697
void MacroAssembler::reverse_bytes_32(Register src, Register dst, Register tmp) {
38237
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4698
    srlx(src, 24, dst);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4699
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4700
    sllx(src, 32+8, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4701
    srlx(tmp, 32+24, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4702
    sllx(tmp, 8, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4703
    or3(dst, tmp, dst);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4704
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4705
    sllx(src, 32+16, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4706
    srlx(tmp, 32+24, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4707
    sllx(tmp, 16, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4708
    or3(dst, tmp, dst);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4709
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4710
    sllx(src, 32+24, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4711
    srlx(tmp, 32, tmp);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4712
    or3(dst, tmp, dst);
31515
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4713
}
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4714
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4715
void MacroAssembler::movitof_revbytes(Register src, FloatRegister dst, Register tmp1, Register tmp2) {
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4716
  reverse_bytes_32(src, tmp1, tmp2);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4717
  movxtod(tmp1, dst);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4718
}
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4719
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4720
void MacroAssembler::movftoi_revbytes(FloatRegister src, Register dst, Register tmp1, Register tmp2) {
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4721
  movdtox(src, tmp1);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4722
  reverse_bytes_32(tmp1, dst, tmp2);
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 30764
diff changeset
  4723
}
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4724
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4725
void MacroAssembler::fold_128bit_crc32(Register xcrc_hi, Register xcrc_lo, Register xK_hi, Register xK_lo, Register xtmp_hi, Register xtmp_lo, Register buf, int offset) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4726
  xmulx(xcrc_hi, xK_hi, xtmp_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4727
  xmulxhi(xcrc_hi, xK_hi, xtmp_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4728
  xmulxhi(xcrc_lo, xK_lo, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4729
  xmulx(xcrc_lo, xK_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4730
  xor3(xcrc_lo, xtmp_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4731
  xor3(xcrc_hi, xtmp_hi, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4732
  ldxl(buf, G0, xtmp_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4733
  inc(buf, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4734
  ldxl(buf, G0, xtmp_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4735
  inc(buf, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4736
  xor3(xcrc_lo, xtmp_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4737
  xor3(xcrc_hi, xtmp_hi, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4738
}
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4739
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4740
void MacroAssembler::fold_128bit_crc32(Register xcrc_hi, Register xcrc_lo, Register xK_hi, Register xK_lo, Register xtmp_hi, Register xtmp_lo, Register xbuf_hi, Register xbuf_lo) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4741
  mov(xcrc_lo, xtmp_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4742
  mov(xcrc_hi, xtmp_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4743
  xmulx(xtmp_hi, xK_hi, xtmp_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4744
  xmulxhi(xtmp_hi, xK_hi, xtmp_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4745
  xmulxhi(xcrc_lo, xK_lo, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4746
  xmulx(xcrc_lo, xK_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4747
  xor3(xcrc_lo, xbuf_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4748
  xor3(xcrc_hi, xbuf_hi, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4749
  xor3(xcrc_lo, xtmp_lo, xcrc_lo);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4750
  xor3(xcrc_hi, xtmp_hi, xcrc_hi);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4751
}
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4752
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4753
void MacroAssembler::fold_8bit_crc32(Register xcrc, Register table, Register xtmp, Register tmp) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4754
  and3(xcrc, 0xFF, tmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4755
  sllx(tmp, 2, tmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4756
  lduw(table, tmp, xtmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4757
  srlx(xcrc, 8, xcrc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4758
  xor3(xtmp, xcrc, xcrc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4759
}
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4760
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4761
void MacroAssembler::fold_8bit_crc32(Register crc, Register table, Register tmp) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4762
  and3(crc, 0xFF, tmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4763
  srlx(crc, 8, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4764
  sllx(tmp, 2, tmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4765
  lduw(table, tmp, tmp);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4766
  xor3(tmp, crc, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4767
}
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4768
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4769
#define CRC32_TMP_REG_NUM 18
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4770
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4771
#define CRC32_CONST_64  0x163cd6124
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4772
#define CRC32_CONST_96  0x0ccaa009e
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4773
#define CRC32_CONST_160 0x1751997d0
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4774
#define CRC32_CONST_480 0x1c6e41596
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4775
#define CRC32_CONST_544 0x154442bd4
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4776
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4777
void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Register table) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4778
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4779
  Label L_cleanup_loop, L_cleanup_check, L_align_loop, L_align_check;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4780
  Label L_main_loop_prologue;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4781
  Label L_fold_512b, L_fold_512b_loop, L_fold_128b;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4782
  Label L_fold_tail, L_fold_tail_loop;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4783
  Label L_8byte_fold_loop, L_8byte_fold_check;
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4784
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4785
  const Register tmp[CRC32_TMP_REG_NUM] = {L0, L1, L2, L3, L4, L5, L6, G1, I0, I1, I2, I3, I4, I5, I7, O4, O5, G3};
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4786
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4787
  Register const_64  = tmp[CRC32_TMP_REG_NUM-1];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4788
  Register const_96  = tmp[CRC32_TMP_REG_NUM-1];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4789
  Register const_160 = tmp[CRC32_TMP_REG_NUM-2];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4790
  Register const_480 = tmp[CRC32_TMP_REG_NUM-1];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4791
  Register const_544 = tmp[CRC32_TMP_REG_NUM-2];
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4792
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4793
  set(ExternalAddress(StubRoutines::crc_table_addr()), table);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4794
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4795
  not1(crc); // ~c
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4796
  clruwu(crc); // clear upper 32 bits of crc
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4797
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4798
  // Check if below cutoff, proceed directly to cleanup code
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4799
  mov(31, G4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4800
  cmp_and_br_short(len, G4, Assembler::lessEqualUnsigned, Assembler::pt, L_cleanup_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4801
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4802
  // Align buffer to 8 byte boundry
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4803
  mov(8, O5);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4804
  and3(buf, 0x7, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4805
  sub(O5, O4, O5);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4806
  and3(O5, 0x7, O5);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4807
  sub(len, O5, len);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4808
  ba(L_align_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4809
  delayed()->nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4810
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4811
  // Alignment loop, table look up method for up to 7 bytes
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4812
  bind(L_align_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4813
  ldub(buf, 0, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4814
  inc(buf);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4815
  dec(O5);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4816
  xor3(O4, crc, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4817
  and3(O4, 0xFF, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4818
  sllx(O4, 2, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4819
  lduw(table, O4, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4820
  srlx(crc, 8, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4821
  xor3(O4, crc, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4822
  bind(L_align_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4823
  nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4824
  cmp_and_br_short(O5, 0, Assembler::notEqual, Assembler::pt, L_align_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4825
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4826
  // Aligned on 64-bit (8-byte) boundry at this point
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4827
  // Check if still above cutoff (31-bytes)
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4828
  mov(31, G4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4829
  cmp_and_br_short(len, G4, Assembler::lessEqualUnsigned, Assembler::pt, L_cleanup_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4830
  // At least 32 bytes left to process
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4831
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4832
  // Free up registers by storing them to FP registers
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4833
  for (int i = 0; i < CRC32_TMP_REG_NUM; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4834
    movxtod(tmp[i], as_FloatRegister(2*i));
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4835
  }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4836
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4837
  // Determine which loop to enter
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4838
  // Shared prologue
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4839
  ldxl(buf, G0, tmp[0]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4840
  inc(buf, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4841
  ldxl(buf, G0, tmp[1]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4842
  inc(buf, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4843
  xor3(tmp[0], crc, tmp[0]); // Fold CRC into first few bytes
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4844
  and3(crc, 0, crc); // Clear out the crc register
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4845
  // Main loop needs 128-bytes at least
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4846
  mov(128, G4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4847
  mov(64, tmp[2]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4848
  cmp_and_br_short(len, G4, Assembler::greaterEqualUnsigned, Assembler::pt, L_main_loop_prologue);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4849
  // Less than 64 bytes
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4850
  nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4851
  cmp_and_br_short(len, tmp[2], Assembler::lessUnsigned, Assembler::pt, L_fold_tail);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4852
  // Between 64 and 127 bytes
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4853
  set64(CRC32_CONST_96,  const_96,  tmp[8]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4854
  set64(CRC32_CONST_160, const_160, tmp[9]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4855
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[2], tmp[3], buf, 0);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4856
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[4], tmp[5], buf, 16);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4857
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[6], tmp[7], buf, 32);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4858
  dec(len, 48);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4859
  ba(L_fold_tail);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4860
  delayed()->nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4861
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4862
  bind(L_main_loop_prologue);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4863
  for (int i = 2; i < 8; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4864
    ldxl(buf, G0, tmp[i]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4865
    inc(buf, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4866
  }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4867
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4868
  // Fold total 512 bits of polynomial on each iteration,
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4869
  // 128 bits per each of 4 parallel streams
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4870
  set64(CRC32_CONST_480, const_480, tmp[8]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4871
  set64(CRC32_CONST_544, const_544, tmp[9]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4872
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4873
  mov(128, G4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4874
  bind(L_fold_512b_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4875
  fold_128bit_crc32(tmp[1], tmp[0], const_480, const_544, tmp[9],  tmp[8],  buf,  0);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4876
  fold_128bit_crc32(tmp[3], tmp[2], const_480, const_544, tmp[11], tmp[10], buf, 16);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4877
  fold_128bit_crc32(tmp[5], tmp[4], const_480, const_544, tmp[13], tmp[12], buf, 32);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4878
  fold_128bit_crc32(tmp[7], tmp[6], const_480, const_544, tmp[15], tmp[14], buf, 64);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4879
  dec(len, 64);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4880
  cmp_and_br_short(len, G4, Assembler::greaterEqualUnsigned, Assembler::pt, L_fold_512b_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4881
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4882
  // Fold 512 bits to 128 bits
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4883
  bind(L_fold_512b);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4884
  set64(CRC32_CONST_96,  const_96,  tmp[8]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4885
  set64(CRC32_CONST_160, const_160, tmp[9]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4886
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4887
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[8], tmp[9], tmp[3], tmp[2]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4888
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[8], tmp[9], tmp[5], tmp[4]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4889
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[8], tmp[9], tmp[7], tmp[6]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4890
  dec(len, 48);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4891
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4892
  // Fold the rest of 128 bits data chunks
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4893
  bind(L_fold_tail);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4894
  mov(32, G4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4895
  cmp_and_br_short(len, G4, Assembler::lessEqualUnsigned, Assembler::pt, L_fold_128b);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4896
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4897
  set64(CRC32_CONST_96,  const_96,  tmp[8]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4898
  set64(CRC32_CONST_160, const_160, tmp[9]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4899
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4900
  bind(L_fold_tail_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4901
  fold_128bit_crc32(tmp[1], tmp[0], const_96, const_160, tmp[2], tmp[3], buf, 0);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4902
  sub(len, 16, len);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4903
  cmp_and_br_short(len, G4, Assembler::greaterEqualUnsigned, Assembler::pt, L_fold_tail_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4904
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4905
  // Fold the 128 bits in tmps 0 - 1 into tmp 1
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4906
  bind(L_fold_128b);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4907
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4908
  set64(CRC32_CONST_64, const_64, tmp[4]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4909
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4910
  xmulx(const_64, tmp[0], tmp[2]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4911
  xmulxhi(const_64, tmp[0], tmp[3]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4912
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4913
  srl(tmp[2], G0, tmp[4]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4914
  xmulx(const_64, tmp[4], tmp[4]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4915
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4916
  srlx(tmp[2], 32, tmp[2]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4917
  sllx(tmp[3], 32, tmp[3]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4918
  or3(tmp[2], tmp[3], tmp[2]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4919
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4920
  xor3(tmp[4], tmp[1], tmp[4]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4921
  xor3(tmp[4], tmp[2], tmp[1]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4922
  dec(len, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4923
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4924
  // Use table lookup for the 8 bytes left in tmp[1]
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4925
  dec(len, 8);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4926
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4927
  // 8 8-bit folds to compute 32-bit CRC.
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4928
  for (int j = 0; j < 4; j++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4929
    fold_8bit_crc32(tmp[1], table, tmp[2], tmp[3]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4930
  }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4931
  srl(tmp[1], G0, crc); // move 32 bits to general register
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4932
  for (int j = 0; j < 4; j++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4933
    fold_8bit_crc32(crc, table, tmp[3]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4934
  }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4935
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4936
  bind(L_8byte_fold_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4937
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4938
  // Restore int registers saved in FP registers
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4939
  for (int i = 0; i < CRC32_TMP_REG_NUM; i++) {
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4940
    movdtox(as_FloatRegister(2*i), tmp[i]);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4941
  }
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4942
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4943
  ba(L_cleanup_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4944
  delayed()->nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4945
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4946
  // Table look-up method for the remaining few bytes
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4947
  bind(L_cleanup_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4948
  ldub(buf, 0, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4949
  inc(buf);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4950
  dec(len);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4951
  xor3(O4, crc, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4952
  and3(O4, 0xFF, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4953
  sllx(O4, 2, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4954
  lduw(table, O4, O4);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4955
  srlx(crc, 8, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4956
  xor3(O4, crc, crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4957
  bind(L_cleanup_check);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4958
  nop();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4959
  cmp_and_br_short(len, 0, Assembler::greaterUnsigned, Assembler::pt, L_cleanup_loop);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4960
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4961
  not1(crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4962
}
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  4963
38237
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4964
#define CHUNK_LEN   128          /* 128 x 8B = 1KB */
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4965
#define CHUNK_K1    0x1307a0206  /* reverseBits(pow(x, CHUNK_LEN*8*8*3 - 32) mod P(x)) << 1 */
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4966
#define CHUNK_K2    0x1a0f717c4  /* reverseBits(pow(x, CHUNK_LEN*8*8*2 - 32) mod P(x)) << 1 */
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4967
#define CHUNK_K3    0x0170076fa  /* reverseBits(pow(x, CHUNK_LEN*8*8*1 - 32) mod P(x)) << 1 */
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4968
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4969
void MacroAssembler::kernel_crc32c(Register crc, Register buf, Register len, Register table) {
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4970
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4971
  Label L_crc32c_head, L_crc32c_aligned;
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4972
  Label L_crc32c_parallel, L_crc32c_parallel_loop;
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4973
  Label L_crc32c_serial, L_crc32c_x32_loop, L_crc32c_x8, L_crc32c_x8_loop;
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4974
  Label L_crc32c_done, L_crc32c_tail, L_crc32c_return;
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4975
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4976
  set(ExternalAddress(StubRoutines::crc32c_table_addr()), table);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4977
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4978
  cmp_and_br_short(len, 0, Assembler::lessEqual, Assembler::pn, L_crc32c_return);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4979
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4980
  // clear upper 32 bits of crc
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4981
  clruwu(crc);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4982
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4983
  and3(buf, 7, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4984
  cmp_and_brx_short(G4, 0, Assembler::equal, Assembler::pt, L_crc32c_aligned);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4985
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4986
  mov(8, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4987
  sub(G1, G4, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4988
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4989
  // ------ process the misaligned head (7 bytes or less) ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4990
  bind(L_crc32c_head);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4991
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4992
  // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4993
  ldub(buf, 0, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4994
  update_byte_crc32(crc, G1, table);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4995
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4996
  inc(buf);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4997
  dec(len);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4998
  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pn, L_crc32c_return);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  4999
  dec(G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5000
  cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_head);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5001
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5002
  // ------ process the 8-byte-aligned body ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5003
  bind(L_crc32c_aligned);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5004
  nop();
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5005
  cmp_and_br_short(len, 8, Assembler::less, Assembler::pn, L_crc32c_tail);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5006
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5007
  // reverse the byte order of lower 32 bits to big endian, and move to FP side
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5008
  movitof_revbytes(crc, F0, G1, G3);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5009
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5010
  set(CHUNK_LEN*8*4, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5011
  cmp_and_br_short(len, G4, Assembler::less, Assembler::pt, L_crc32c_serial);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5012
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5013
  // ------ process four 1KB chunks in parallel ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5014
  bind(L_crc32c_parallel);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5015
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5016
  fzero(FloatRegisterImpl::D, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5017
  fzero(FloatRegisterImpl::D, F4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5018
  fzero(FloatRegisterImpl::D, F6);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5019
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5020
  mov(CHUNK_LEN - 1, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5021
  bind(L_crc32c_parallel_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5022
  // schedule ldf's ahead of crc32c's to hide the load-use latency
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5023
  ldf(FloatRegisterImpl::D, buf, 0,            F8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5024
  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5025
  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5026
  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*24, F14);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5027
  crc32c(F0, F8,  F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5028
  crc32c(F2, F10, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5029
  crc32c(F4, F12, F4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5030
  crc32c(F6, F14, F6);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5031
  inc(buf, 8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5032
  dec(G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5033
  cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_parallel_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5034
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5035
  ldf(FloatRegisterImpl::D, buf, 0,            F8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5036
  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8,  F10);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5037
  ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5038
  crc32c(F0, F8,  F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5039
  crc32c(F2, F10, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5040
  crc32c(F4, F12, F4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5041
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5042
  inc(buf, CHUNK_LEN*24);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5043
  ldfl(FloatRegisterImpl::D, buf, G0, F14);  // load in little endian
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5044
  inc(buf, 8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5045
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5046
  prefetch(buf, 0,            Assembler::severalReads);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5047
  prefetch(buf, CHUNK_LEN*8,  Assembler::severalReads);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5048
  prefetch(buf, CHUNK_LEN*16, Assembler::severalReads);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5049
  prefetch(buf, CHUNK_LEN*24, Assembler::severalReads);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5050
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5051
  // move to INT side, and reverse the byte order of lower 32 bits to little endian
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5052
  movftoi_revbytes(F0, O4, G1, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5053
  movftoi_revbytes(F2, O5, G1, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5054
  movftoi_revbytes(F4, G5, G1, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5055
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5056
  // combine the results of 4 chunks
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5057
  set64(CHUNK_K1, G3, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5058
  xmulx(O4, G3, O4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5059
  set64(CHUNK_K2, G3, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5060
  xmulx(O5, G3, O5);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5061
  set64(CHUNK_K3, G3, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5062
  xmulx(G5, G3, G5);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5063
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5064
  movdtox(F14, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5065
  xor3(O4, O5, O5);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5066
  xor3(G5, O5, O5);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5067
  xor3(G4, O5, O5);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5068
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5069
  // reverse the byte order to big endian, via stack, and move to FP side
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5070
  // TODO: use new revb instruction
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5071
  add(SP, -8, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5072
  srlx(G1, 3, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5073
  sllx(G1, 3, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5074
  stx(O5, G1, G0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5075
  ldfl(FloatRegisterImpl::D, G1, G0, F2);  // load in little endian
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5076
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5077
  crc32c(F6, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5078
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5079
  set(CHUNK_LEN*8*4, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5080
  sub(len, G4, len);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5081
  cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_parallel);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5082
  nop();
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5083
  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_done);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5084
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5085
  bind(L_crc32c_serial);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5086
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5087
  mov(32, G4);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5088
  cmp_and_br_short(len, G4, Assembler::less, Assembler::pn, L_crc32c_x8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5089
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5090
  // ------ process 32B chunks ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5091
  bind(L_crc32c_x32_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5092
  ldf(FloatRegisterImpl::D, buf, 0, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5093
  crc32c(F0, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5094
  ldf(FloatRegisterImpl::D, buf, 8, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5095
  crc32c(F0, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5096
  ldf(FloatRegisterImpl::D, buf, 16, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5097
  crc32c(F0, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5098
  ldf(FloatRegisterImpl::D, buf, 24, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5099
  inc(buf, 32);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5100
  crc32c(F0, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5101
  dec(len, 32);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5102
  cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_x32_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5103
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5104
  bind(L_crc32c_x8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5105
  nop();
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5106
  cmp_and_br_short(len, 8, Assembler::less, Assembler::pt, L_crc32c_done);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5107
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5108
  // ------ process 8B chunks ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5109
  bind(L_crc32c_x8_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5110
  ldf(FloatRegisterImpl::D, buf, 0, F2);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5111
  inc(buf, 8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5112
  crc32c(F0, F2, F0);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5113
  dec(len, 8);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5114
  cmp_and_br_short(len, 8, Assembler::greaterEqual, Assembler::pt, L_crc32c_x8_loop);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5115
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5116
  bind(L_crc32c_done);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5117
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5118
  // move to INT side, and reverse the byte order of lower 32 bits to little endian
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5119
  movftoi_revbytes(F0, crc, G1, G3);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5120
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5121
  cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_return);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5122
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5123
  // ------ process the misaligned tail (7 bytes or less) ------
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5124
  bind(L_crc32c_tail);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5125
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5126
  // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF];
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5127
  ldub(buf, 0, G1);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5128
  update_byte_crc32(crc, G1, table);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5129
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5130
  inc(buf);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5131
  dec(len);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5132
  cmp_and_br_short(len, 0, Assembler::greater, Assembler::pt, L_crc32c_tail);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5133
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5134
  bind(L_crc32c_return);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5135
  nop();
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38142
diff changeset
  5136
}