src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58273 08a5148e7c4e
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    25
#include "precompiled.hpp"
50380
bec342339138 8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents: 50102
diff changeset
    26
#include "asm/macroAssembler.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    27
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    28
#include "c1/c1_LIRAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    29
#include "c1/c1_MacroAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    30
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    31
#include "c1/c1_ValueStack.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    32
#include "ci/ciArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    33
#include "ci/ciInstance.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28954
diff changeset
    34
#include "gc/shared/barrierSet.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
    35
#include "gc/shared/cardTableBarrierSet.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28954
diff changeset
    36
#include "gc/shared/collectedHeap.hpp"
54825
1b03400e5a8f 8223637: Fix build breakage after 8223136
stefank
parents: 52675
diff changeset
    37
#include "memory/universe.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    38
#include "nativeInst_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    39
#include "oops/objArrayKlass.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49470
diff changeset
    40
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49192
diff changeset
    41
#include "runtime/interfaceSupport.inline.hpp"
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48856
diff changeset
    42
#include "runtime/jniHandles.inline.hpp"
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
    43
#include "runtime/safepointMechanism.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6756
diff changeset
    44
#include "runtime/sharedRuntime.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (opr->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    LIR_Const* constant = opr->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    switch (constant->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      case T_INT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        jint value = constant->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
        return Assembler::is_simm13(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
bool LIR_Assembler::is_single_instruction(LIR_Op* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  switch (op->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    case lir_null_check:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    case lir_add:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    case lir_ushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    case lir_shr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    case lir_shl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      // integer shifts and adds are always one instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      return op->result_opr()->is_single_cpu();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    case lir_move: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
      LIR_Op1* op1 = op->as_Op1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      LIR_Opr src = op1->in_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      LIR_Opr dst = op1->result_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      if (src == dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
        NEEDS_CLEANUP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
        // this works around a problem where moves with the same src and dst
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
        // end up in the delay slot and then the assembler swallows the mov
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
        // since it has no effect and then it complains because the delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        // is empty.  returning false stops the optimizer from putting this in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
        // the delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      // don't put moves involving oops into the delay slot since the VerifyOops code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      // will make it much larger than a single instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      if (VerifyOops) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      if (src->is_double_cpu() || dst->is_double_cpu() || op1->patch_code() != lir_patch_none ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
          ((src->is_double_fpu() || dst->is_double_fpu()) && op1->move_kind() != lir_move_normal)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   109
      if (UseCompressedOops) {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   110
        if (dst->is_address() && !dst->is_stack() && is_reference_type(dst->type())) return false;
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   111
        if (src->is_address() && !src->is_stack() && is_reference_type(src->type())) return false;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   112
      }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   113
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
   114
      if (UseCompressedClassPointers) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   115
        if (src->is_address() && !src->is_stack() && src->type() == T_ADDRESS &&
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   116
            src->as_address_ptr()->disp() == oopDesc::klass_offset_in_bytes()) return false;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   117
      }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   118
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      if (dst->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        if (src->is_address() && Assembler::is_simm13(src->as_address_ptr()->disp())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
          return !PatchALot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
        } else if (src->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
          return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      if (src->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
        if (dst->is_address() && Assembler::is_simm13(dst->as_address_ptr()->disp())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
          return !PatchALot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
        } else if (dst->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
          return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      if (dst->is_register() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
          ((src->is_register() && src->is_single_word() && src->is_same_type(dst)) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
           (src->is_constant() && LIR_Assembler::is_small_constant(op->as_Op1()->in_opr())))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
LIR_Opr LIR_Assembler::receiverOpr() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  return FrameMap::O0_oop_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
LIR_Opr LIR_Assembler::osrBufferPointer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  return FrameMap::I0_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23485
diff changeset
   161
int LIR_Assembler::initial_frame_size_in_bytes() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  return in_bytes(frame_map()->framesize_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
// inline cache check: the inline cached class is in G5_inline_cache_reg(G5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// we fetch the class of the receiver (O0) and compare it with the cached class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// If they do not match we jump to slow case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
int LIR_Assembler::check_icache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  int offset = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  __ inline_cache_check(O0, G5_inline_cache_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
55105
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 54825
diff changeset
   175
void LIR_Assembler::clinit_barrier(ciMethod* method) {
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 54825
diff changeset
   176
  ShouldNotReachHere(); // not implemented
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 54825
diff changeset
   177
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
void LIR_Assembler::osr_entry() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // On-stack-replacement entry sequence (interpreter frame layout described in interpreter_sparc.cpp):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  //   1. Create a new compiled activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  //   2. Initialize local variables in the compiled activation.  The expression stack must be empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  //      at the osr_bci; it is not initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  //   3. Jump to the continuation address in compiled code to resume execution.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // OSR entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  BlockBegin* osr_entry = compilation()->hir()->osr_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  ValueStack* entry_state = osr_entry->end()->state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  int number_of_locks = entry_state->locks_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Create a frame for the compiled activation.
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23485
diff changeset
   194
  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // OSR buffer is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // locals[nlocals-1..0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // monitors[number_of_locks-1..0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // locals is a direct copy of the interpreter frame so in the osr buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // so first slot in the local array is the last local from the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // and last slot is local[0] (receiver) from the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // Similarly with locks. The first lock slot in the osr buffer is the nth lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // in the interpreter frame (the method lock if a sync method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // Initialize monitors in the compiled activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  //   I0: pointer to osr buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // All other registers are dead at this point and the locals will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // copied into place by code emitted in the IR.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  Register OSR_buf = osrBufferPointer()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    int monitor_offset = BytesPerWord * method()->max_locals() +
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   218
      (2 * BytesPerWord) * (number_of_locks - 1);
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   219
    // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   220
    // the OSR buffer using 2 word entries: first the lock and then
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   221
    // the oop.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    for (int i = 0; i < number_of_locks; i++) {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   223
      int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      // verify the interpreter's monitor has a non-null object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        Label L;
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   228
        __ ld_ptr(OSR_buf, slot_offset + 1*BytesPerWord, O7);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
   229
        __ cmp_and_br_short(O7, G0, Assembler::notEqual, Assembler::pt, L);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        __ stop("locked object is NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      // Copy the lock field into the compiled activation.
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   235
      __ ld_ptr(OSR_buf, slot_offset + 0, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      __ st_ptr(O7, frame_map()->address_for_monitor_lock(i));
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   237
      __ ld_ptr(OSR_buf, slot_offset + 1*BytesPerWord, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      __ st_ptr(O7, frame_map()->address_for_monitor_object(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// --------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
void LIR_Assembler::monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register hdr, int monitor_no) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  if (!GenerateSynchronizationCode) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  Register obj_reg = obj_opr->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  Register lock_reg = lock_opr->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  Address mon_addr = frame_map()->address_for_monitor_lock(monitor_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  Register reg = mon_addr.base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  int offset = mon_addr.disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // compute pointer to BasicLock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  if (mon_addr.is_simm13()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    __ add(reg, offset, lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    __ set(offset, lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    __ add(reg, lock_reg, lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // unlock object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, UseFastLocking, monitor_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // _slow_case_stubs->append(slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // temporary fix: must be created after exceptionhandler, therefore as call stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  _slow_case_stubs->append(slow_case);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  if (UseFastLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    // try inlined fast unlocking first, revert to slow locking if it fails
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    // note: lock_reg points to the displaced header since the displaced header offset is 0!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    __ unlock_object(hdr, obj_reg, lock_reg, *slow_case->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    // always do slow unlocking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    // note: the slow unlocking code could be inlined here, however if we use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    //       slow unlocking, speed doesn't matter anyway and this solution is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    //       simpler and requires less duplicated code - additionally, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    //       slow unlocking code is the same in either case which simplifies
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    //       debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    __ br(Assembler::always, false, Assembler::pt, *slow_case->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // done
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  __ bind(*slow_case->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   288
int LIR_Assembler::emit_exception_handler() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // if the last instruction is a call (typically to do a throw which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // is coming at the end after block reordering) the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // must still point into the code area in order to avoid assertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // failures when searching for the corresponding bci => add a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // (was bug 5/14/1999 - gri)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // generate code for exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  ciMethod* method = compilation()->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
   299
  address handler_base = __ start_a_stub(exception_handler_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  if (handler_base == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    // not enough space left for the handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    bailout("exception handler overflow");
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   304
    return -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  }
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   306
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  int offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
8495
a4959965eaa3 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 7883
diff changeset
   309
  __ call(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id), relocInfo::runtime_call_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  __ delayed()->nop();
8495
a4959965eaa3 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 7883
diff changeset
   311
  __ should_not_reach_here();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
   312
  guarantee(code_offset() - offset <= exception_handler_size(), "overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  __ end_a_stub();
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   314
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   315
  return offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   318
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   319
// Emit the code to remove the frame from the stack in the exception
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   320
// unwind path.
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   321
int LIR_Assembler::emit_unwind_handler() {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   322
#ifndef PRODUCT
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   323
  if (CommentedAssembly) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   324
    _masm->block_comment("Unwind handler");
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   325
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   326
#endif
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   327
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   328
  int offset = code_offset();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   329
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   330
  // Fetch the exception from TLS and clear out exception related thread state
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   331
  __ ld_ptr(G2_thread, in_bytes(JavaThread::exception_oop_offset()), O0);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   332
  __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_oop_offset()));
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   333
  __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_pc_offset()));
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   335
  __ bind(_unwind_handler_entry);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   336
  __ verify_not_null_oop(O0);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   337
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   338
    __ mov(O0, I0);  // Preserve the exception
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   339
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   340
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   341
  // Preform needed unlocking
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   342
  MonitorExitStub* stub = NULL;
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   343
  if (method()->is_synchronized()) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   344
    monitor_address(0, FrameMap::I1_opr);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   345
    stub = new MonitorExitStub(FrameMap::I1_opr, true, 0);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   346
    __ unlock_object(I3, I2, I1, *stub->entry());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   347
    __ bind(*stub->continuation());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   348
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   349
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   350
  if (compilation()->env()->dtrace_method_probes()) {
6756
01ac7b1701eb 6988018: dtrace/hotspot/MethodInvocation/MethodInvocation002 crashes with client compiler
never
parents: 6461
diff changeset
   351
    __ mov(G2_thread, O0);
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   352
    __ save_thread(I1); // need to preserve thread in G2 across
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   353
                        // runtime call
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   354
    metadata2reg(method()->constant_encoding(), O1);
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   355
    __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), relocInfo::runtime_call_type);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   356
    __ delayed()->nop();
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   357
    __ restore_thread(I1);
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   358
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   359
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   360
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   361
    __ mov(I0, O0);  // Restore the exception
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   362
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   363
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   364
  // dispatch to the unwind logic
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   365
  __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   366
  __ delayed()->nop();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   367
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   368
  // Emit the slow path assembly
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   369
  if (stub != NULL) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   370
    stub->emit_code(this);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   371
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   372
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   373
  return offset;
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   374
}
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   375
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   376
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   377
int LIR_Assembler::emit_deopt_handler() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  // if the last instruction is a call (typically to do a throw which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  // is coming at the end after block reordering) the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  // must still point into the code area in order to avoid assertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  // failures when searching for the corresponding bci => add a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  // (was bug 5/14/1999 - gri)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  // generate code for deopt handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  ciMethod* method = compilation()->method();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
   387
  address handler_base = __ start_a_stub(deopt_handler_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  if (handler_base == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    // not enough space left for the handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    bailout("deopt handler overflow");
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   391
    return -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  }
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   393
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  int offset = code_offset();
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   395
  AddressLiteral deopt_blob(SharedRuntime::deopt_blob()->unpack());
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   396
  __ JUMP(deopt_blob, G3_scratch, 0); // sethi;jmp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  __ delayed()->nop();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
   398
  guarantee(code_offset() - offset <= deopt_handler_size(), "overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  __ end_a_stub();
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   400
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   401
  return offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
void LIR_Assembler::jobject2reg(jobject o, Register reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  if (o == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    __ set(NULL_WORD, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  } else {
48120
bb957f109a1f 8191227: issues with unsafe handle resolution
rraghavan
parents: 47881
diff changeset
   409
#ifdef ASSERT
bb957f109a1f 8191227: issues with unsafe handle resolution
rraghavan
parents: 47881
diff changeset
   410
    {
bb957f109a1f 8191227: issues with unsafe handle resolution
rraghavan
parents: 47881
diff changeset
   411
      ThreadInVMfromNative tiv(JavaThread::current());
58015
dd84de796f2c 8224815: Remove non-GC uses of CollectedHeap::is_in_reserved()
eosterlund
parents: 55105
diff changeset
   412
      assert(Universe::heap()->is_in(JNIHandles::resolve(o)), "should be real oop");
48120
bb957f109a1f 8191227: issues with unsafe handle resolution
rraghavan
parents: 47881
diff changeset
   413
    }
bb957f109a1f 8191227: issues with unsafe handle resolution
rraghavan
parents: 47881
diff changeset
   414
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    int oop_index = __ oop_recorder()->find_index(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    RelocationHolder rspec = oop_Relocation::spec(oop_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    __ set(NULL_WORD, reg, rspec); // Will be set when the nmethod is created
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   423
  // Allocate a new index in table to hold the object once it's been patched
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   424
  int oop_index = __ oop_recorder()->allocate_oop_index(NULL);
19710
2f8ca425504e 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents: 18507
diff changeset
   425
  PatchingStub* patch = new PatchingStub(_masm, patching_id(info), oop_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   427
  AddressLiteral addrlit(NULL, oop_Relocation::spec(oop_index));
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   428
  assert(addrlit.rspec().type() == relocInfo::oop_type, "must be an oop reloc");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  // It may not seem necessary to use a sethi/add pair to load a NULL into dest, but the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  // NULL will be dynamically patched later and the patched value may be large.  We must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // therefore generate the sethi/add as a placeholders
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   432
  __ patchable_set(addrlit, reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  patching_epilog(patch, lir_patch_normal, reg, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   438
void LIR_Assembler::metadata2reg(Metadata* o, Register reg) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   439
  __ set_metadata_constant(o, reg);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   440
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   441
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   442
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo *info) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   443
  // Allocate a new index in table to hold the klass once it's been patched
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   444
  int index = __ oop_recorder()->allocate_metadata_index(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   445
  PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id, index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   446
  AddressLiteral addrlit(NULL, metadata_Relocation::spec(index));
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   447
  assert(addrlit.rspec().type() == relocInfo::metadata_type, "must be an metadata reloc");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   448
  // It may not seem necessary to use a sethi/add pair to load a NULL into dest, but the
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   449
  // NULL will be dynamically patched later and the patched value may be large.  We must
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   450
  // therefore generate the sethi/add as a placeholders
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   451
  __ patchable_set(addrlit, reg);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   452
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   453
  patching_epilog(patch, lir_patch_normal, reg, info);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   454
}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   455
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
void LIR_Assembler::emit_op3(LIR_Op3* op) {
46597
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   457
  switch (op->code()) {
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   458
    case lir_idiv:
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   459
    case lir_irem:  // Both idiv & irem are handled after the switch (below).
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   460
      break;
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   461
    case lir_fmaf:
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   462
      __ fmadd(FloatRegisterImpl::S,
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   463
               op->in_opr1()->as_float_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   464
               op->in_opr2()->as_float_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   465
               op->in_opr3()->as_float_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   466
               op->result_opr()->as_float_reg());
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   467
      return;
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   468
    case lir_fmad:
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   469
      __ fmadd(FloatRegisterImpl::D,
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   470
               op->in_opr1()->as_double_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   471
               op->in_opr2()->as_double_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   472
               op->in_opr3()->as_double_reg(),
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   473
               op->result_opr()->as_double_reg());
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   474
      return;
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   475
    default:
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   476
      ShouldNotReachHere();
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   477
      break;
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   478
  }
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   479
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   480
  // Handle idiv & irem:
d669fb842ae3 8164888: Intrinsify fused mac operations on SPARC
neliasso
parents: 46462
diff changeset
   481
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  Register Rdividend = op->in_opr1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  Register Rdivisor  = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  Register Rscratch  = op->in_opr3()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  Register Rresult   = op->result_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  int divisor = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  if (op->in_opr2()->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    Rdivisor = op->in_opr2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    divisor = op->in_opr2()->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    assert(Assembler::is_simm13(divisor), "can only handle simm13");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  assert(Rdividend != Rscratch, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  assert(Rdivisor  != Rscratch, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  assert(op->code() == lir_idiv || op->code() == lir_irem, "Must be irem or idiv");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  if (Rdivisor == noreg && is_power_of_2(divisor)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    // convert division by a power of two into some shifts and logical operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    if (op->code() == lir_idiv) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
      if (divisor == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
        __ srl(Rdividend, 31, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
        __ sra(Rdividend, 31, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
        __ and3(Rscratch, divisor - 1, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      __ add(Rdividend, Rscratch, Rscratch);
52675
7d3cde494494 8214206: Fix for JDK-8213419 is broken on 32-bit
roland
parents: 51857
diff changeset
   509
      __ sra(Rscratch, log2_int(divisor), Rresult);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
      if (divisor == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
        __ srl(Rdividend, 31, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        __ sra(Rdividend, 31, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        __ and3(Rscratch, divisor - 1,Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      __ add(Rdividend, Rscratch, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
      __ andn(Rscratch, divisor - 1,Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      __ sub(Rdividend, Rscratch, Rresult);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  __ sra(Rdividend, 31, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  __ wry(Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  add_debug_info_for_div0_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  if (Rdivisor != noreg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    __ sdivcc(Rdividend, Rdivisor, (op->code() == lir_idiv ? Rresult : Rscratch));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    assert(Assembler::is_simm13(divisor), "can only handle simm13");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    __ sdivcc(Rdividend, divisor, (op->code() == lir_idiv ? Rresult : Rscratch));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  Label skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  __ br(Assembler::overflowSet, true, Assembler::pn, skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  __ delayed()->Assembler::sethi(0x80000000, (op->code() == lir_idiv ? Rresult : Rscratch));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  __ bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  if (op->code() == lir_irem) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    if (Rdivisor != noreg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
      __ smul(Rscratch, Rdivisor, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
      __ smul(Rscratch, divisor, Rscratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    __ sub(Rdividend, Rscratch, Rresult);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  if (op->block() != NULL)  _branch_target_blocks.append(op->block());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  assert(op->info() == NULL, "shouldn't have CodeEmitInfo");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  if (op->cond() == lir_cond_always) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    __ br(Assembler::always, false, Assembler::pt, *(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  } else if (op->code() == lir_cond_float_branch) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    assert(op->ublock() != NULL, "must have unordered successor");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    bool is_unordered = (op->ublock() == op->block());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    Assembler::Condition acond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    switch (op->cond()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
      case lir_cond_equal:         acond = Assembler::f_equal;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
      case lir_cond_notEqual:      acond = Assembler::f_notEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      case lir_cond_less:          acond = (is_unordered ? Assembler::f_unorderedOrLess          : Assembler::f_less);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
      case lir_cond_greater:       acond = (is_unordered ? Assembler::f_unorderedOrGreater       : Assembler::f_greater);        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
      case lir_cond_lessEqual:     acond = (is_unordered ? Assembler::f_unorderedOrLessOrEqual   : Assembler::f_lessOrEqual);    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
      case lir_cond_greaterEqual:  acond = (is_unordered ? Assembler::f_unorderedOrGreaterOrEqual: Assembler::f_greaterOrEqual); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
      default :                         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    __ fb( acond, false, Assembler::pn, *(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    assert (op->code() == lir_branch, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    Assembler::Condition acond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    switch (op->cond()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      case lir_cond_equal:        acond = Assembler::equal;                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      case lir_cond_notEqual:     acond = Assembler::notEqual;             break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      case lir_cond_less:         acond = Assembler::less;                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
      case lir_cond_lessEqual:    acond = Assembler::lessEqual;            break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      case lir_cond_greaterEqual: acond = Assembler::greaterEqual;         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
      case lir_cond_greater:      acond = Assembler::greater;              break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      case lir_cond_aboveEqual:   acond = Assembler::greaterEqualUnsigned; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
      case lir_cond_belowEqual:   acond = Assembler::lessEqualUnsigned;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
      default:                         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    // sparc has different condition codes for testing 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    // vs. 64-bit values.  We could always test xcc is we could
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    // guarantee that 32-bit loads always sign extended but that isn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    // true and since sign extension isn't free, it would impose a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    // slight cost.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    if  (op->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
      __ br(acond, false, Assembler::pn, *(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
      __ brx(acond, false, Assembler::pn, *(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  // The peephole pass fills the delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  Bytecodes::Code code = op->bytecode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  LIR_Opr dst = op->result_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
    case Bytecodes::_i2l: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
      Register rlo  = dst->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
      Register rhi  = dst->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
      Register rval = op->in_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
      __ sra(rval, 0, rlo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    case Bytecodes::_i2f: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
      bool is_double = (code == Bytecodes::_i2d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
      FloatRegister rdst = is_double ? dst->as_double_reg() : dst->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      FloatRegisterImpl::Width w = is_double ? FloatRegisterImpl::D : FloatRegisterImpl::S;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
      FloatRegister rsrc = op->in_opr()->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      if (rsrc != rdst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
        __ fmov(FloatRegisterImpl::S, rsrc, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      __ fitof(w, rdst, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    case Bytecodes::_f2i:{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
      FloatRegister rsrc = op->in_opr()->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
      Address       addr = frame_map()->address_for_slot(dst->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      Label L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      // result must be 0 if value is NaN; test by comparing value to itself
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
      __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, rsrc, rsrc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
      __ fb(Assembler::f_unordered, true, Assembler::pn, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      __ delayed()->st(G0, addr); // annuled if contents of rsrc is not NaN
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      __ ftoi(FloatRegisterImpl::S, rsrc, rsrc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      // move integer result from float register to int register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      __ stf(FloatRegisterImpl::S, rsrc, addr.base(), addr.disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
      __ bind (L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
    case Bytecodes::_l2i: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
      Register rlo  = op->in_opr()->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
      Register rhi  = op->in_opr()->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
      Register rdst = dst->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
      __ sra(rlo, 0, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    case Bytecodes::_f2d: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      bool is_double = (code == Bytecodes::_f2d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
      assert((!is_double && dst->is_single_fpu()) || (is_double && dst->is_double_fpu()), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      LIR_Opr val = op->in_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
      FloatRegister rval = (code == Bytecodes::_d2f) ? val->as_double_reg() : val->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
      FloatRegister rdst = is_double ? dst->as_double_reg() : dst->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
      FloatRegisterImpl::Width vw = is_double ? FloatRegisterImpl::S : FloatRegisterImpl::D;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
      FloatRegisterImpl::Width dw = is_double ? FloatRegisterImpl::D : FloatRegisterImpl::S;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
      __ ftof(vw, dw, rval, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    case Bytecodes::_i2b: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
      Register rval = op->in_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      Register rdst = dst->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
      int shift = (code == Bytecodes::_i2b) ? (BitsPerInt - T_BYTE_aelem_bytes * BitsPerByte) : (BitsPerInt - BitsPerShort);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      __ sll (rval, shift, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
      __ sra (rdst, shift, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    case Bytecodes::_i2c: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      Register rval = op->in_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      Register rdst = dst->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
      int shift = BitsPerInt - T_CHAR_aelem_bytes * BitsPerByte;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      __ sll (rval, shift, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
      __ srl (rdst, shift, rdst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
void LIR_Assembler::align_call(LIR_Code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  // do nothing since all instructions are word aligned on sparc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   692
void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   693
  __ call(op->addr(), rtype);
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
   694
  // The peephole pass fills the delay slot, add_call_info is done in
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
   695
  // LIR_Assembler::emit_delay.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   699
void LIR_Assembler::ic_call(LIR_OpJavaCall* op) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   700
  __ ic_call(op->addr(), false);
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
   701
  // The peephole pass fills the delay slot, add_call_info is done in
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
   702
  // LIR_Assembler::emit_delay.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   706
void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   707
  add_debug_info_for_null_check_here(op->info());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   708
  __ load_klass(O0, G3_scratch);
11190
d561d41f241a 7003454: order constants in constant table by number of references in code
twisti
parents: 10976
diff changeset
   709
  if (Assembler::is_simm13(op->vtable_offset())) {
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   710
    __ ld_ptr(G3_scratch, op->vtable_offset(), G5_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    // This will generate 2 instructions
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   713
    __ set(op->vtable_offset(), G5_method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    // ld_ptr, set_hi, set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
    __ ld_ptr(G3_scratch, G5_method, G5_method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   717
  __ ld_ptr(G5_method, Method::from_compiled_offset(), G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  __ callr(G3_scratch, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  // the peephole pass fills the delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   722
int LIR_Assembler::store(LIR_Opr from_reg, Register base, int offset, BasicType type, bool wide, bool unaligned) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  int store_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  if (!Assembler::is_simm13(offset + (type == T_LONG) ? wordSize : 0)) {
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   725
    assert(base != O7, "destroying register");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    assert(!unaligned, "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    // for offsets larger than a simm13 we setup the offset in O7
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   728
    __ set(offset, O7);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   729
    store_offset = store(from_reg, base, O7, type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  } else {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   731
    if (is_reference_type(type)) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   732
      __ verify_oop(from_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   733
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    store_offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
      case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
      case T_BYTE  : __ stb(from_reg->as_register(), base, offset); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
      case T_CHAR  : __ sth(from_reg->as_register(), base, offset); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
      case T_SHORT : __ sth(from_reg->as_register(), base, offset); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
      case T_INT   : __ stw(from_reg->as_register(), base, offset); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
      case T_LONG  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
        if (unaligned || PatchALot) {
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   743
          // Don't use O7 here because it may be equal to 'base' (see LIR_Assembler::reg2mem)
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   744
          assert(G3_scratch != base, "can't handle this");
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   745
          assert(G3_scratch != from_reg->as_register_lo(), "can't handle this");
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   746
          __ srax(from_reg->as_register_lo(), 32, G3_scratch);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
          __ stw(from_reg->as_register_lo(), base, offset + lo_word_offset_in_bytes);
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   748
          __ stw(G3_scratch,                 base, offset + hi_word_offset_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
          __ stx(from_reg->as_register_lo(), base, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
        break;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   753
      case T_ADDRESS:
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   754
      case T_METADATA:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   755
        __ st_ptr(from_reg->as_register(), base, offset);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   756
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      case T_ARRAY : // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   758
      case T_OBJECT:
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   759
        {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   760
          if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   761
            __ encode_heap_oop(from_reg->as_register(), G3_scratch);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   762
            store_offset = code_offset();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   763
            __ stw(G3_scratch, base, offset);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   764
          } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   765
            __ st_ptr(from_reg->as_register(), base, offset);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   766
          }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   767
          break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   768
        }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   769
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
      case T_FLOAT : __ stf(FloatRegisterImpl::S, from_reg->as_float_reg(), base, offset); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
      case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
          FloatRegister reg = from_reg->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
          // split unaligned stores
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
          if (unaligned || PatchALot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
            assert(Assembler::is_simm13(offset + 4), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
            __ stf(FloatRegisterImpl::S, reg->successor(), base, offset + 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
            __ stf(FloatRegisterImpl::S, reg,              base, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
            __ stf(FloatRegisterImpl::D, reg, base, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  return store_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   791
int LIR_Assembler::store(LIR_Opr from_reg, Register base, Register disp, BasicType type, bool wide) {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   792
  if (is_reference_type(type)) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   793
    __ verify_oop(from_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   794
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
  int store_offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    case T_BYTE  : __ stb(from_reg->as_register(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    case T_CHAR  : __ sth(from_reg->as_register(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    case T_SHORT : __ sth(from_reg->as_register(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    case T_INT   : __ stw(from_reg->as_register(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    case T_LONG  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
      __ stx(from_reg->as_register_lo(), base, disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
      break;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   805
    case T_ADDRESS:
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   806
      __ st_ptr(from_reg->as_register(), base, disp);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   807
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
    case T_ARRAY : // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   809
    case T_OBJECT:
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   810
      {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   811
        if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   812
          __ encode_heap_oop(from_reg->as_register(), G3_scratch);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   813
          store_offset = code_offset();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   814
          __ stw(G3_scratch, base, disp);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   815
        } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   816
          __ st_ptr(from_reg->as_register(), base, disp);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   817
        }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   818
        break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   819
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
    case T_FLOAT : __ stf(FloatRegisterImpl::S, from_reg->as_float_reg(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    case T_DOUBLE: __ stf(FloatRegisterImpl::D, from_reg->as_double_reg(), base, disp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  return store_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   828
int LIR_Assembler::load(Register base, int offset, LIR_Opr to_reg, BasicType type, bool wide, bool unaligned) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  int load_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  if (!Assembler::is_simm13(offset + (type == T_LONG) ? wordSize : 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
    assert(base != O7, "destroying register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
    assert(!unaligned, "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    // for offsets larger than a simm13 we setup the offset in O7
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
   834
    __ set(offset, O7);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   835
    load_offset = load(base, O7, to_reg, type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    load_offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    switch(type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
      case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
      case T_BYTE  : __ ldsb(base, offset, to_reg->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
      case T_CHAR  : __ lduh(base, offset, to_reg->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
      case T_SHORT : __ ldsh(base, offset, to_reg->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
      case T_INT   : __ ld(base, offset, to_reg->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
      case T_LONG  :
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
   845
        if (!unaligned && !PatchALot) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
          __ ldx(base, offset, to_reg->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
          assert(base != to_reg->as_register_lo(), "can't handle this");
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   849
          assert(O7 != to_reg->as_register_lo(), "can't handle this");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
          __ ld(base, offset + hi_word_offset_in_bytes, to_reg->as_register_lo());
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   851
          __ lduw(base, offset + lo_word_offset_in_bytes, O7); // in case O7 is base or offset, use it last
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
          __ sllx(to_reg->as_register_lo(), 32, to_reg->as_register_lo());
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   853
          __ or3(to_reg->as_register_lo(), O7, to_reg->as_register_lo());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
        break;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   856
      case T_METADATA:  __ ld_ptr(base, offset, to_reg->as_register()); break;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   857
      case T_ADDRESS:
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
   858
        if (offset == oopDesc::klass_offset_in_bytes() && UseCompressedClassPointers) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   859
          __ lduw(base, offset, to_reg->as_register());
13972
115bfa87d77a 8000753: compiler/6912517 crashes on 64bit sparc with compressed oops off
roland
parents: 13969
diff changeset
   860
          __ decode_klass_not_null(to_reg->as_register());
115bfa87d77a 8000753: compiler/6912517 crashes on 64bit sparc with compressed oops off
roland
parents: 13969
diff changeset
   861
        } else
115bfa87d77a 8000753: compiler/6912517 crashes on 64bit sparc with compressed oops off
roland
parents: 13969
diff changeset
   862
        {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   863
          __ ld_ptr(base, offset, to_reg->as_register());
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   864
        }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
   865
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
      case T_ARRAY : // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   867
      case T_OBJECT:
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   868
        {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   869
          if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   870
            __ lduw(base, offset, to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   871
            __ decode_heap_oop(to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   872
          } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   873
            __ ld_ptr(base, offset, to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   874
          }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   875
          break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   876
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
      case T_FLOAT:  __ ldf(FloatRegisterImpl::S, base, offset, to_reg->as_float_reg()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
      case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
          FloatRegister reg = to_reg->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
          // split unaligned loads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
          if (unaligned || PatchALot) {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   883
            __ ldf(FloatRegisterImpl::S, base, offset + 4, reg->successor());
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   884
            __ ldf(FloatRegisterImpl::S, base, offset,     reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
            __ ldf(FloatRegisterImpl::D, base, offset, to_reg->as_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
      default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
    }
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   892
    if (is_reference_type(type)) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   893
      __ verify_oop(to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   894
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  return load_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   900
int LIR_Assembler::load(Register base, Register disp, LIR_Opr to_reg, BasicType type, bool wide) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  int load_offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  switch(type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
    case T_BOOLEAN: // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   904
    case T_BYTE  :  __ ldsb(base, disp, to_reg->as_register()); break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   905
    case T_CHAR  :  __ lduh(base, disp, to_reg->as_register()); break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   906
    case T_SHORT :  __ ldsh(base, disp, to_reg->as_register()); break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   907
    case T_INT   :  __ ld(base, disp, to_reg->as_register()); break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   908
    case T_ADDRESS: __ ld_ptr(base, disp, to_reg->as_register()); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    case T_ARRAY : // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   910
    case T_OBJECT:
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   911
      {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   912
          if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   913
            __ lduw(base, disp, to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   914
            __ decode_heap_oop(to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   915
          } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   916
            __ ld_ptr(base, disp, to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   917
          }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   918
          break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   919
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    case T_FLOAT:  __ ldf(FloatRegisterImpl::S, base, disp, to_reg->as_float_reg()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
    case T_DOUBLE: __ ldf(FloatRegisterImpl::D, base, disp, to_reg->as_double_reg()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
    case T_LONG  :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
      __ ldx(base, disp, to_reg->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  }
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
   927
  if (is_reference_type(type)) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   928
    __ verify_oop(to_reg->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   929
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  return load_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  switch (c->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
    case T_INT:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   937
    case T_FLOAT: {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   938
      Register src_reg = O7;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   939
      int value = c->as_jint_bits();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   940
      if (value == 0) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   941
        src_reg = G0;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   942
      } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   943
        __ set(value, O7);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   944
      }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   945
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   946
      __ stw(src_reg, addr.base(), addr.disp());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   947
      break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   948
    }
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
   949
    case T_ADDRESS: {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
      Register src_reg = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
      int value = c->as_jint_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
      if (value == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
        src_reg = G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
        __ set(value, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   958
      __ st_ptr(src_reg, addr.base(), addr.disp());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
    case T_OBJECT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
      Register src_reg = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
      jobject2reg(c->as_jobject(), src_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      __ st_ptr(src_reg, addr.base(), addr.disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
    case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
      Address addr = frame_map()->address_for_double_slot(dest->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
      Register tmp = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
      int value_lo = c->as_jint_lo_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
      if (value_lo == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
        tmp = G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
        __ set(value_lo, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
      __ stw(tmp, addr.base(), addr.disp() + lo_word_offset_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
      int value_hi = c->as_jint_hi_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
      if (value_hi == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
        tmp = G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
        __ set(value_hi, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
      __ stw(tmp, addr.base(), addr.disp() + hi_word_offset_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
      Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   995
void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  LIR_Address* addr     = dest->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  Register base = addr->base()->as_pointer_register();
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   999
  int offset = -1;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1000
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  switch (c->type()) {
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48120
diff changeset
  1002
    case T_FLOAT: type = T_INT; // Float constants are stored by int store instructions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
    case T_INT:
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
  1004
    case T_ADDRESS: {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
      LIR_Opr tmp = FrameMap::O7_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
      int value = c->as_jint_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
      if (value == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
        tmp = FrameMap::G0_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
      } else if (Assembler::is_simm13(value)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
        __ set(value, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
      if (addr->index()->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
        assert(addr->disp() == 0, "must be zero");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1014
        offset = store(tmp, base, addr->index()->as_pointer_register(), type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
        assert(Assembler::is_simm13(addr->disp()), "can't handle larger addresses");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1017
        offset = store(tmp, base, addr->disp(), type, wide, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
    case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      assert(!addr->index()->is_valid(), "can't handle reg reg address here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
      assert(Assembler::is_simm13(addr->disp()) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
             Assembler::is_simm13(addr->disp() + 4), "can't handle larger addresses");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1027
      LIR_Opr tmp = FrameMap::O7_opr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
      int value_lo = c->as_jint_lo_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
      if (value_lo == 0) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1030
        tmp = FrameMap::G0_opr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
        __ set(value_lo, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
      }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1034
      offset = store(tmp, base, addr->disp() + lo_word_offset_in_bytes, T_INT, wide, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
      int value_hi = c->as_jint_hi_bits();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
      if (value_hi == 0) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1037
        tmp = FrameMap::G0_opr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
        __ set(value_hi, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
      }
10976
04322f78fd46 7103261: crash with jittester on sparc
never
parents: 10508
diff changeset
  1041
      store(tmp, base, addr->disp() + hi_word_offset_in_bytes, T_INT, wide, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    case T_OBJECT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
      jobject obj = c->as_jobject();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
      LIR_Opr tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
      if (obj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
        tmp = FrameMap::G0_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
        tmp = FrameMap::O7_opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
        jobject2reg(c->as_jobject(), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
      // handle either reg+reg or reg+disp address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
      if (addr->index()->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
        assert(addr->disp() == 0, "must be zero");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1056
        offset = store(tmp, base, addr->index()->as_pointer_register(), type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
        assert(Assembler::is_simm13(addr->disp()), "can't handle larger addresses");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1059
        offset = store(tmp, base, addr->disp(), type, wide, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
      Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
  }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1067
  if (info != NULL) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1068
    assert(offset != -1, "offset should've been set");
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1069
    add_debug_info_for_null_check(offset, info);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1070
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  LIR_Opr to_reg = dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
  switch (c->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
    case T_INT:
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
  1080
    case T_ADDRESS:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
        jint con = c->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
        if (to_reg->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
          assert(patch_code == lir_patch_none, "no patching handled here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
          __ set(con, to_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
          ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
          assert(to_reg->is_single_fpu(), "wrong register kind");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
          __ set(con, O7);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1091
          Address temp_slot(SP, (frame::register_save_words * wordSize) + STACK_BIAS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
          __ st(O7, temp_slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
          __ ldf(FloatRegisterImpl::S, temp_slot, to_reg->as_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
        jlong con = c->as_jlong();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
        if (to_reg->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
          __ set(con,  to_reg->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
        } else if (to_reg->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
          __ set(con, to_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
          ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
          assert(to_reg->is_double_fpu(), "wrong register kind");
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1109
          Address temp_slot_lo(SP, ((frame::register_save_words  ) * wordSize) + STACK_BIAS);
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1110
          Address temp_slot_hi(SP, ((frame::register_save_words) * wordSize) + (longSize/2) + STACK_BIAS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
          __ set(low(con),  O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
          __ st(O7, temp_slot_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
          __ set(high(con), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
          __ st(O7, temp_slot_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
          __ ldf(FloatRegisterImpl::D, temp_slot_lo, to_reg->as_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
    case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
        if (patch_code == lir_patch_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
          jobject2reg(c->as_jobject(), to_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
          jobject2reg_with_patching(to_reg->as_register(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1130
    case T_METADATA:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1131
      {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1132
        if (patch_code == lir_patch_none) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1133
          metadata2reg(c->as_metadata(), to_reg->as_register());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1134
        } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1135
          klass2reg_with_patching(to_reg->as_register(), info);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1136
        }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1137
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1138
      break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1139
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
    case T_FLOAT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
        address const_addr = __ float_constant(c->as_jfloat());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
        if (const_addr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
          bailout("const section overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
        RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1148
        AddressLiteral const_addrlit(const_addr, rspec);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
        if (to_reg->is_single_fpu()) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1150
          __ patchable_sethi(const_addrlit, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
          __ relocate(rspec);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1152
          __ ldf(FloatRegisterImpl::S, O7, const_addrlit.low10(), to_reg->as_float_reg());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
          assert(to_reg->is_single_cpu(), "Must be a cpu register.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1157
          __ set(const_addrlit, O7);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1158
          __ ld(O7, 0, to_reg->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
    case T_DOUBLE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
        address const_addr = __ double_constant(c->as_jdouble());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
        if (const_addr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
          bailout("const section overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
        RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
        if (to_reg->is_double_fpu()) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1173
          AddressLiteral const_addrlit(const_addr, rspec);
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1174
          __ patchable_sethi(const_addrlit, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
          __ relocate(rspec);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1176
          __ ldf (FloatRegisterImpl::D, O7, const_addrlit.low10(), to_reg->as_double_reg());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
          assert(to_reg->is_double_cpu(), "Must be a long register.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
          __ set(jlong_cast(c->as_jdouble()), to_reg->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
Address LIR_Assembler::as_Address(LIR_Address* addr) {
22504
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  1191
  Register reg = addr->base()->as_pointer_register();
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1192
  LIR_Opr index = addr->index();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1193
  if (index->is_illegal()) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1194
    return Address(reg, addr->disp());
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1195
  } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1196
    assert (addr->disp() == 0, "unsupported address mode");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1197
    return Address(reg, index->as_pointer_register());
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  1198
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
    case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
    case T_FLOAT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
      Register tmp = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
      Address from = frame_map()->address_for_slot(src->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
      Address to   = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
      __ lduw(from.base(), from.disp(), tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
      __ stw(tmp, to.base(), to.disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
    }
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48120
diff changeset
  1213
    case T_ADDRESS:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
    case T_OBJECT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
      Register tmp = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
      Address from = frame_map()->address_for_slot(src->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
      Address to   = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
      __ ld_ptr(from.base(), from.disp(), tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
      __ st_ptr(tmp, to.base(), to.disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
    case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
      Register tmp = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
      Address from = frame_map()->address_for_double_slot(src->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
      Address to   = frame_map()->address_for_double_slot(dest->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
      __ lduw(from.base(), from.disp(), tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
      __ stw(tmp, to.base(), to.disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
      __ lduw(from.base(), from.disp() + 4, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
      __ stw(tmp, to.base(), to.disp() + 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
  Address base = as_Address(addr);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1242
  return Address(base.base(), base.disp() + hi_word_offset_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
  Address base = as_Address(addr);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1248
  return Address(base.base(), base.disp() + lo_word_offset_in_bytes);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type,
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1253
                            LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool unaligned) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1255
  assert(type != T_METADATA, "load of metadata ptr not supported");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  LIR_Address* addr = src_opr->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
  LIR_Opr to_reg = dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  Register src = addr->base()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  Register disp_reg = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  int disp_value = addr->disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  bool needs_patching = (patch_code != lir_patch_none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
  if (addr->base()->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    __ verify_oop(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
  PatchingStub* patch = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  if (needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
    assert(!to_reg->is_double_cpu() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
           patch_code == lir_patch_none ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
           patch_code == lir_patch_normal, "patching doesn't match register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  if (addr->index()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
    if (!Assembler::is_simm13(disp_value) && (!unaligned || Assembler::is_simm13(disp_value + 4))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
      if (needs_patching) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1279
        __ patchable_set(0, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
        __ set(disp_value, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
      disp_reg = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  } else if (unaligned || PatchALot) {
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
  1286
    __ add(src, addr->index()->as_pointer_register(), O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
    src = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
    disp_reg = addr->index()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
    assert(disp_value == 0, "can't handle 3 operand addresses");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
  // remember the offset of the load.  The patching_epilog must be done
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  // before the call to add_debug_info, otherwise the PcDescs don't get
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
  // entered in increasing order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
  int offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
  assert(disp_reg != noreg || Assembler::is_simm13(disp_value), "should have set this up");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
  if (disp_reg == noreg) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1300
    offset = load(src, disp_value, to_reg, type, wide, unaligned);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
    assert(!unaligned, "can't handle this");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1303
    offset = load(src, disp_reg, to_reg, type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
  if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
    patching_epilog(patch, patch_code, src, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  if (info != NULL) add_debug_info_for_null_check(offset, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
  Address addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
  if (src->is_single_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
    addr = frame_map()->address_for_slot(src->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  } else if (src->is_double_word())  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
    addr = frame_map()->address_for_double_slot(src->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
  bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1322
  load(addr.base(), addr.disp(), dest, dest->type(), true /*wide*/, unaligned);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
void LIR_Assembler::reg2stack(LIR_Opr from_reg, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  Address addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
  if (dest->is_single_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
    addr = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  } else if (dest->is_double_word())  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
    addr = frame_map()->address_for_slot(dest->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
  bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1334
  store(from_reg, addr.base(), addr.disp(), from_reg->type(), true /*wide*/, unaligned);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
void LIR_Assembler::reg2reg(LIR_Opr from_reg, LIR_Opr to_reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
  if (from_reg->is_float_kind() && to_reg->is_float_kind()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
    if (from_reg->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
      // double to double moves
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
      assert(to_reg->is_double_fpu(), "should match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
      __ fmov(FloatRegisterImpl::D, from_reg->as_double_reg(), to_reg->as_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
      // float to float moves
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
      assert(to_reg->is_single_fpu(), "should match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
      __ fmov(FloatRegisterImpl::S, from_reg->as_float_reg(), to_reg->as_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  } else if (!from_reg->is_float_kind() && !to_reg->is_float_kind()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
    if (from_reg->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
      __ mov(from_reg->as_pointer_register(), to_reg->as_pointer_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
    } else if (to_reg->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
      // int to int moves
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
      __ mov(from_reg->as_register(), to_reg->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
      // int to int moves
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
      __ mov(from_reg->as_register(), to_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
  }
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
  1362
  if (is_reference_type(to_reg->type())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
    __ verify_oop(to_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
                            LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack,
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1369
                            bool wide, bool unaligned) {
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1370
  assert(type != T_METADATA, "store of metadata ptr not supported");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
  LIR_Address* addr = dest->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
  Register src = addr->base()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
  Register disp_reg = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
  int disp_value = addr->disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
  bool needs_patching = (patch_code != lir_patch_none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  if (addr->base()->is_oop_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
    __ verify_oop(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  PatchingStub* patch = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  if (needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
    assert(!from_reg->is_double_cpu() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
           patch_code == lir_patch_none ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
           patch_code == lir_patch_normal, "patching doesn't match register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
  if (addr->index()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
    if (!Assembler::is_simm13(disp_value) && (!unaligned || Assembler::is_simm13(disp_value + 4))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
      if (needs_patching) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1393
        __ patchable_set(0, O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
        __ set(disp_value, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
      disp_reg = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  } else if (unaligned || PatchALot) {
43429
1960562230bb 8171435: "assert(is_single_cpu() && !is_virtual()) failed: type check" with -XX:+PatchALot on SPARC
thartmann
parents: 42650
diff changeset
  1400
    __ add(src, addr->index()->as_pointer_register(), O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
    src = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
    disp_reg = addr->index()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
    assert(disp_value == 0, "can't handle 3 operand addresses");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  // remember the offset of the store.  The patching_epilog must be done
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
  // before the call to add_debug_info_for_null_check, otherwise the PcDescs don't get
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
  // entered in increasing order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  int offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
  assert(disp_reg != noreg || Assembler::is_simm13(disp_value), "should have set this up");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  if (disp_reg == noreg) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1414
    offset = store(from_reg, src, disp_value, type, wide, unaligned);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
    assert(!unaligned, "can't handle this");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1417
    offset = store(from_reg, src, disp_reg, type, wide);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
    patching_epilog(patch, patch_code, src, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
  if (info != NULL) add_debug_info_for_null_check(offset, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
void LIR_Assembler::return_op(LIR_Opr result) {
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34205
diff changeset
  1429
  if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34205
diff changeset
  1430
    __ reserved_stack_check();
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34205
diff changeset
  1431
  }
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1432
  if (SafepointMechanism::uses_thread_local_poll()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1433
    __ ld_ptr(Address(G2_thread, Thread::polling_page_offset()), L0);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1434
  } else {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1435
    __ set((intptr_t)os::get_polling_page(), L0);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1436
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
  __ relocate(relocInfo::poll_return_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
  __ ld_ptr(L0, 0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
  __ ret();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
  __ delayed()->restore();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1445
  if (SafepointMechanism::uses_thread_local_poll()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1446
    __ ld_ptr(Address(G2_thread, Thread::polling_page_offset()), tmp->as_register());
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1447
  } else {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1448
    __ set((intptr_t)os::get_polling_page(), tmp->as_register());
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1449
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
  if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
    add_debug_info_for_branch(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
  int offset = __ offset();
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
  1454
24935
046e99df67d0 8031389: On x86 C1 emits two relocations for polls
thartmann
parents: 24018
diff changeset
  1455
  __ relocate(relocInfo::poll_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
  __ ld_ptr(tmp->as_register(), 0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
  return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
void LIR_Assembler::emit_static_call_stub() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
  address call_pc = __ pc();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
  1463
  address stub = __ start_a_stub(call_stub_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  if (stub == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
    bailout("static call stub overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
  int start = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
  __ relocate(static_stub_Relocation::spec(call_pc));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1472
  __ set_metadata(NULL, G5);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  // must be set to -1 at code generation time
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1474
  AddressLiteral addrlit(-1);
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  1475
  __ jump_to(addrlit, G3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41543
diff changeset
  1478
  assert(__ offset() - start <= call_stub_size(), "stub too big");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
  __ end_a_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  if (opr1->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
    __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, opr1->as_float_reg(), opr2->as_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
  } else if (opr1->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
    __ fcmp(FloatRegisterImpl::D, Assembler::fcc0, opr1->as_double_reg(), opr2->as_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  } else if (opr1->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
    if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
      switch (opr2->as_constant_ptr()->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
        case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
          { jint con = opr2->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
            if (Assembler::is_simm13(con)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
              __ cmp(opr1->as_register(), con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
              __ set(con, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
              __ cmp(opr1->as_register(), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
        case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
          // there are only equal/notequal comparisions on objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
          { jobject con = opr2->as_constant_ptr()->as_jobject();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
            if (con == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
              __ cmp(opr1->as_register(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
              jobject2reg(con, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
              __ cmp(opr1->as_register(), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
        default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
          ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
      if (opr2->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
        LIR_Address * addr = opr2->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
        BasicType type = addr->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
        if ( type == T_OBJECT ) __ ld_ptr(as_Address(addr), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
        else                    __ ld(as_Address(addr), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
        __ cmp(opr1->as_register(), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
        __ cmp(opr1->as_register(), opr2->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  } else if (opr1->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
    Register xlo = opr1->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
    Register xhi = opr1->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
    if (opr2->is_constant() && opr2->as_jlong() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
      assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles these cases");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
      __ orcc(xhi, G0, G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
    } else if (opr2->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
      Register ylo = opr2->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
      Register yhi = opr2->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
      __ cmp(xlo, ylo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
  } else if (opr1->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
    LIR_Address * addr = opr1->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
    BasicType type = addr->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
    assert (opr2->is_constant(), "Checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
    if ( type == T_OBJECT ) __ ld_ptr(as_Address(addr), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
    else                    __ ld(as_Address(addr), O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
    __ cmp(O7, opr2->as_constant_ptr()->as_jint());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op){
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
  if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
    bool is_unordered_less = (code == lir_ucmp_fd2i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
    if (left->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
      __ float_cmp(true, is_unordered_less ? -1 : 1, left->as_float_reg(), right->as_float_reg(), dst->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
    } else if (left->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
      __ float_cmp(false, is_unordered_less ? -1 : 1, left->as_double_reg(), right->as_double_reg(), dst->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
  } else if (code == lir_cmp_l2i) {
5253
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5249
diff changeset
  1566
    __ lcmp(left->as_register_lo(), right->as_register_lo(), dst->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  1573
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
  Assembler::Condition acond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
  switch (condition) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
    case lir_cond_equal:        acond = Assembler::equal;        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
    case lir_cond_notEqual:     acond = Assembler::notEqual;     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
    case lir_cond_less:         acond = Assembler::less;         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
    case lir_cond_lessEqual:    acond = Assembler::lessEqual;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
    case lir_cond_greaterEqual: acond = Assembler::greaterEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
    case lir_cond_greater:      acond = Assembler::greater;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
    case lir_cond_aboveEqual:   acond = Assembler::greaterEqualUnsigned;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
    case lir_cond_belowEqual:   acond = Assembler::lessEqualUnsigned;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
    default:                         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
  if (opr1->is_constant() && opr1->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
    Register dest = result->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
    // load up first part of constant before branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    // and do the rest in the delay slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
    if (!Assembler::is_simm13(opr1->as_jint())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
      __ sethi(opr1->as_jint(), dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
  } else if (opr1->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
    const2reg(opr1, result, lir_patch_none, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  } else if (opr1->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
    reg2reg(opr1, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  } else if (opr1->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
    stack2reg(opr1, result, result->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
  Label skip;
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  1604
    if  (type == T_INT) {
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  1605
      __ br(acond, false, Assembler::pt, skip);
46462
f92a713126b1 8179903: Clean up SPARC 32-bit support
gtriantafill
parents: 46381
diff changeset
  1606
    } else {
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  1607
      __ brx(acond, false, Assembler::pt, skip); // checks icc on 32bit and xcc on 64bit
46462
f92a713126b1 8179903: Clean up SPARC 32-bit support
gtriantafill
parents: 46381
diff changeset
  1608
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
  if (opr1->is_constant() && opr1->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
    Register dest = result->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
    if (Assembler::is_simm13(opr1->as_jint())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
      __ delayed()->or3(G0, opr1->as_jint(), dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
      // the sethi has been done above, so just put in the low 10 bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
      __ delayed()->or3(dest, opr1->as_jint() & 0x3ff, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
    // can't do anything useful in the delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
  if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
    const2reg(opr2, result, lir_patch_none, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
  } else if (opr2->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
    reg2reg(opr2, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
  } else if (opr2->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
    stack2reg(opr2, result, result->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
  __ bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
  assert(info == NULL, "unused on this code path");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
  assert(left->is_register(), "wrong items state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
  assert(dest->is_register(), "wrong items state");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
  if (right->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    if (dest->is_float_kind()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
      FloatRegister lreg, rreg, res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
      FloatRegisterImpl::Width w;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
      if (right->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
        w = FloatRegisterImpl::S;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
        lreg = left->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
        rreg = right->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
        res  = dest->as_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
        w = FloatRegisterImpl::D;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
        lreg = left->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
        rreg = right->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
        res  = dest->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
        case lir_add: __ fadd(w, lreg, rreg, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
        case lir_sub: __ fsub(w, lreg, rreg, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
        case lir_mul: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
        case lir_mul_strictfp: __ fmul(w, lreg, rreg, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
        case lir_div: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
        case lir_div_strictfp: __ fdiv(w, lreg, rreg, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
    } else if (dest->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
      Register dst_lo = dest->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
      Register op1_lo = left->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
      Register op2_lo = right->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
        case lir_add:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
          __ add(op1_lo, op2_lo, dst_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
        case lir_sub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
          __ sub(op1_lo, op2_lo, dst_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
      assert (right->is_single_cpu(), "Just Checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
      Register lreg = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
      Register res  = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
      Register rreg = right->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
        case lir_add:  __ add  (lreg, rreg, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
        case lir_sub:  __ sub  (lreg, rreg, res); break;
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  1691
        case lir_mul:  __ mulx (lreg, rreg, res); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
    assert (right->is_constant(), "must be constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
    if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
      Register lreg = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
      Register res  = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
      int    simm13 = right->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
        case lir_add:  __ add  (lreg, simm13, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
        case lir_sub:  __ sub  (lreg, simm13, res); break;
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  1706
        case lir_mul:  __ mulx (lreg, simm13, res); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
      Register lreg = left->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
      Register res  = dest->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
      long con = right->as_constant_ptr()->as_jlong();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
      assert(Assembler::is_simm13(con), "must be simm13");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
        case lir_add:  __ add  (lreg, (int)con, res); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
        case lir_sub:  __ sub  (lreg, (int)con, res); break;
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  1718
        case lir_mul:  __ mulx (lreg, (int)con, res); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
void LIR_Assembler::fpop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
  // do nothing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr thread, LIR_Opr dest, LIR_Op* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  switch (code) {
35540
e001ad24dcdb 8143353: update for x86 sin and cos in the math lib
vdeshpande
parents: 35071
diff changeset
  1733
    case lir_tan: {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
      assert(thread->is_valid(), "preserve the thread object for performance reasons");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
      assert(dest->as_double_reg() == F0, "the result will be in f0/f1");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
    case lir_sqrt: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
      assert(!thread->is_valid(), "there is no need for a thread_reg for dsqrt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
      FloatRegister src_reg = value->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
      FloatRegister dst_reg = dest->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
      __ fsqrt(FloatRegisterImpl::D, src_reg, dst_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
    case lir_abs: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
      assert(!thread->is_valid(), "there is no need for a thread_reg for fabs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
      FloatRegister src_reg = value->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
      FloatRegister dst_reg = dest->as_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
      __ fabs(FloatRegisterImpl::D, src_reg, dst_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
    default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
    if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
      int simm13 = right->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
        case lir_logic_and:   __ and3 (left->as_register(), simm13, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
        case lir_logic_or:    __ or3  (left->as_register(), simm13, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
        case lir_logic_xor:   __ xor3 (left->as_register(), simm13, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
      long c = right->as_constant_ptr()->as_jlong();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
      assert(c == (int)c && Assembler::is_simm13(c), "out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
      int simm13 = (int)c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
        case lir_logic_and:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
          __ and3 (left->as_register_lo(), simm13, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
        case lir_logic_or:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
          __ or3 (left->as_register_lo(), simm13, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
        case lir_logic_xor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
          __ xor3 (left->as_register_lo(), simm13, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
    assert(right->is_register(), "right should be in register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
    if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
        case lir_logic_and:   __ and3 (left->as_register(), right->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
        case lir_logic_or:    __ or3  (left->as_register(), right->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
        case lir_logic_xor:   __ xor3 (left->as_register(), right->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
      Register l = (left->is_single_cpu() && left->is_oop_register()) ? left->as_register() :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
                                                                        left->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
      Register r = (right->is_single_cpu() && right->is_oop_register()) ? right->as_register() :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
                                                                          right->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
        case lir_logic_and: __ and3 (l, r, dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
        case lir_logic_or:  __ or3  (l, r, dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
        case lir_logic_xor: __ xor3 (l, r, dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
int LIR_Assembler::shift_amount(BasicType t) {
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
  1818
  int elem_size = type2aelembytes(t);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
  switch (elem_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
    case 1 : return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
    case 2 : return 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
    case 4 : return 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
    case 8 : return 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
  return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1830
void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
  assert(exceptionOop->as_register() == Oexception, "should match");
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1832
  assert(exceptionPC->as_register() == Oissuing_pc, "should match");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
  info->add_register_oop(exceptionOop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1836
  // reuse the debug info from the safepoint poll for the throw op itself
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1837
  address pc_for_athrow  = __ pc();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1838
  int pc_for_athrow_offset = __ offset();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1839
  RelocationHolder rspec = internal_word_Relocation::spec(pc_for_athrow);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1840
  __ set(pc_for_athrow, Oissuing_pc, rspec);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1841
  add_call_info(pc_for_athrow_offset, info); // for exception handler
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1842
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1843
  __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1844
  __ delayed()->nop();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1845
}
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1846
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1847
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1848
void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1849
  assert(exceptionOop->as_register() == Oexception, "should match");
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1850
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1851
  __ br(Assembler::always, false, Assembler::pt, _unwind_handler_entry);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  1852
  __ delayed()->nop();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
  Register src = op->src()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
  Register dst = op->dst()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
  Register src_pos = op->src_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
  Register dst_pos = op->dst_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
  Register length  = op->length()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
  Register tmp = op->tmp()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
  Register tmp2 = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
  int flags = op->flags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
  ciArrayKlass* default_type = op->expected_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
  BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
  if (basic_type == T_ARRAY) basic_type = T_OBJECT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
9105
afc81a03564f 7033732: C1: When calling c2 arraycopy stubs offsets and length must have clear upper 32bits
iveresov
parents: 9102
diff changeset
  1869
  // higher 32bits must be null
afc81a03564f 7033732: C1: When calling c2 arraycopy stubs offsets and length must have clear upper 32bits
iveresov
parents: 9102
diff changeset
  1870
  __ sra(dst_pos, 0, dst_pos);
afc81a03564f 7033732: C1: When calling c2 arraycopy stubs offsets and length must have clear upper 32bits
iveresov
parents: 9102
diff changeset
  1871
  __ sra(src_pos, 0, src_pos);
afc81a03564f 7033732: C1: When calling c2 arraycopy stubs offsets and length must have clear upper 32bits
iveresov
parents: 9102
diff changeset
  1872
  __ sra(length, 0, length);
afc81a03564f 7033732: C1: When calling c2 arraycopy stubs offsets and length must have clear upper 32bits
iveresov
parents: 9102
diff changeset
  1873
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
  // set up the arraycopy stub information
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
  ArrayCopyStub* stub = op->stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
  // always do stub if no type information is available.  it's ok if
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
  // the known type isn't loaded since the code sanity checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
  // in debug mode and the type isn't required when we know the exact type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
  // also check that the type is an array type.
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1881
  if (op->expected_type() == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
    __ mov(src,     O0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
    __ mov(src_pos, O1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
    __ mov(dst,     O2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
    __ mov(dst_pos, O3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
    __ mov(length,  O4);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1887
    address copyfunc_addr = StubRoutines::generic_arraycopy();
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1888
    assert(copyfunc_addr != NULL, "generic arraycopy stub required");
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1889
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1890
#ifndef PRODUCT
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1891
    if (PrintC1Statistics) {
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1892
      address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1893
      __ inc_counter(counter, G1, G3);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1894
    }
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1895
#endif
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1896
    __ call_VM_leaf(tmp, copyfunc_addr);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1897
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1898
    __ xor3(O0, -1, tmp);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1899
    __ sub(length, tmp, length);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1900
    __ add(src_pos, tmp, src_pos);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1901
    __ cmp_zero_and_br(Assembler::less, O0, *stub->entry());
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1902
    __ delayed()->add(dst_pos, tmp, dst_pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
    __ bind(*stub->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
  assert(default_type != NULL && default_type->is_array_klass(), "must be true at this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  // make sure src and dst are non-null and load array length
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
  if (flags & LIR_OpArrayCopy::src_null_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
    __ tst(src);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1912
    __ brx(Assembler::equal, false, Assembler::pn, *stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
  if (flags & LIR_OpArrayCopy::dst_null_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
    __ tst(dst);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1918
    __ brx(Assembler::equal, false, Assembler::pn, *stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
41543
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1922
  // If the compiler was not able to prove that exact type of the source or the destination
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1923
  // of the arraycopy is an array type, check at runtime if the source or the destination is
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1924
  // an instance type.
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1925
  if (flags & LIR_OpArrayCopy::type_check) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1926
    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1927
      __ load_klass(dst, tmp);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1928
      __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1929
      __ cmp(tmp2, Klass::_lh_neutral_value);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1930
      __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry());
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1931
      __ delayed()->nop();
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1932
    }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1933
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1934
    if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1935
      __ load_klass(src, tmp);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1936
      __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1937
      __ cmp(tmp2, Klass::_lh_neutral_value);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1938
      __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry());
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1939
      __ delayed()->nop();
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1940
    }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1941
  }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 38017
diff changeset
  1942
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
    // test src_pos register
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  1945
    __ cmp_zero_and_br(Assembler::less, src_pos, *stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
  if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
    // test dst_pos register
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  1951
    __ cmp_zero_and_br(Assembler::less, dst_pos, *stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  if (flags & LIR_OpArrayCopy::length_positive_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
    // make sure length isn't negative
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  1957
    __ cmp_zero_and_br(Assembler::less, length, *stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  if (flags & LIR_OpArrayCopy::src_range_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
    __ ld(src, arrayOopDesc::length_offset_in_bytes(), tmp2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
    __ add(length, src_pos, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
    __ cmp(tmp2, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
    __ br(Assembler::carrySet, false, Assembler::pn, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
  if (flags & LIR_OpArrayCopy::dst_range_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
    __ ld(dst, arrayOopDesc::length_offset_in_bytes(), tmp2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
    __ add(length, dst_pos, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
    __ cmp(tmp2, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
    __ br(Assembler::carrySet, false, Assembler::pn, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1977
  int shift = shift_amount(basic_type);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1978
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  if (flags & LIR_OpArrayCopy::type_check) {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1980
    // We don't know the array types are compatible
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1981
    if (basic_type != T_OBJECT) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1982
      // Simple test for basic type arrays
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  1983
      if (UseCompressedClassPointers) {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1984
        // We don't need decode because we just need to compare
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1985
        __ lduw(src, oopDesc::klass_offset_in_bytes(), tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1986
        __ lduw(dst, oopDesc::klass_offset_in_bytes(), tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1987
        __ cmp(tmp, tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1988
        __ br(Assembler::notEqual, false, Assembler::pt, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1989
      } else {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1990
        __ ld_ptr(src, oopDesc::klass_offset_in_bytes(), tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1991
        __ ld_ptr(dst, oopDesc::klass_offset_in_bytes(), tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1992
        __ cmp(tmp, tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1993
        __ brx(Assembler::notEqual, false, Assembler::pt, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1994
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1995
      __ delayed()->nop();
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1996
    } else {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1997
      // For object arrays, if src is a sub class of dst then we can
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1998
      // safely do the copy.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  1999
      address copyfunc_addr = StubRoutines::checkcast_arraycopy();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2000
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2001
      Label cont, slow;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2002
      assert_different_registers(tmp, tmp2, G3, G1);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2003
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2004
      __ load_klass(src, G3);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2005
      __ load_klass(dst, G1);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2006
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2007
      __ check_klass_subtype_fast_path(G3, G1, tmp, tmp2, &cont, copyfunc_addr == NULL ? stub->entry() : &slow, NULL);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2008
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2009
      __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2010
      __ delayed()->nop();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2011
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2012
      __ cmp(G3, 0);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2013
      if (copyfunc_addr != NULL) { // use stub if available
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2014
        // src is not a sub class of dst so we have to do a
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2015
        // per-element check.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2016
        __ br(Assembler::notEqual, false, Assembler::pt, cont);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2017
        __ delayed()->nop();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2018
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2019
        __ bind(slow);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2020
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2021
        int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2022
        if ((flags & mask) != mask) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2023
          // Check that at least both of them object arrays.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2024
          assert(flags & mask, "one of the two should be known to be an object array");
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2025
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2026
          if (!(flags & LIR_OpArrayCopy::src_objarray)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2027
            __ load_klass(src, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2028
          } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2029
            __ load_klass(dst, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2030
          }
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11190
diff changeset
  2031
          int lh_offset = in_bytes(Klass::layout_helper_offset());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2032
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2033
          __ lduw(tmp, lh_offset, tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2034
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2035
          jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2036
          __ set(objArray_lh, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2037
          __ cmp(tmp, tmp2);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2038
          __ br(Assembler::notEqual, false, Assembler::pt,  *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2039
          __ delayed()->nop();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2040
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2041
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2042
        Register src_ptr = O0;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2043
        Register dst_ptr = O1;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2044
        Register len     = O2;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2045
        Register chk_off = O3;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2046
        Register super_k = O4;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2047
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2048
        __ add(src, arrayOopDesc::base_offset_in_bytes(basic_type), src_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2049
        if (shift == 0) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2050
          __ add(src_ptr, src_pos, src_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2051
        } else {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2052
          __ sll(src_pos, shift, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2053
          __ add(src_ptr, tmp, src_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2054
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2055
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2056
        __ add(dst, arrayOopDesc::base_offset_in_bytes(basic_type), dst_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2057
        if (shift == 0) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2058
          __ add(dst_ptr, dst_pos, dst_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2059
        } else {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2060
          __ sll(dst_pos, shift, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2061
          __ add(dst_ptr, tmp, dst_ptr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2062
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2063
        __ mov(length, len);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2064
        __ load_klass(dst, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2065
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  2066
        int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2067
        __ ld_ptr(tmp, ek_offset, super_k);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2068
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11190
diff changeset
  2069
        int sco_offset = in_bytes(Klass::super_check_offset_offset());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2070
        __ lduw(super_k, sco_offset, chk_off);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2071
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2072
        __ call_VM_leaf(tmp, copyfunc_addr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2073
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2074
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2075
        if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2076
          Label failed;
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2077
          __ br_notnull_short(O0, Assembler::pn, failed);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2078
          __ inc_counter((address)&Runtime1::_arraycopy_checkcast_cnt, G1, G3);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2079
          __ bind(failed);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2080
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2081
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2082
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2083
        __ br_null(O0, false, Assembler::pt,  *stub->continuation());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2084
        __ delayed()->xor3(O0, -1, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2085
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2086
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2087
        if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2088
          __ inc_counter((address)&Runtime1::_arraycopy_checkcast_attempt_cnt, G1, G3);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2089
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2090
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2091
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2092
        __ sub(length, tmp, length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2093
        __ add(src_pos, tmp, src_pos);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2094
        __ br(Assembler::always, false, Assembler::pt, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2095
        __ delayed()->add(dst_pos, tmp, dst_pos);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2096
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2097
        __ bind(cont);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2098
      } else {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2099
        __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2100
        __ delayed()->nop();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2101
        __ bind(cont);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2102
      }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2103
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
  if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
    // Sanity check the known type with the incoming class.  For the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
    // primitive case the types must match exactly with src.klass and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
    // dst.klass each exactly matching the default type.  For the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
    // object array case, if no type check is needed then either the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
    // dst type is exactly the expected type and the src type is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
    // subtype which we can't check or src is the same array as dst
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
    // but not necessarily exactly of type default_type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
    Label known_ok, halt;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2116
    metadata2reg(op->expected_type()->constant_encoding(), tmp);
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  2117
    if (UseCompressedClassPointers) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2118
      // tmp holds the default type. It currently comes uncompressed after the
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2119
      // load of a constant, so encode it.
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  2120
      __ encode_klass_not_null(tmp);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2121
      // load the raw value of the dst klass, since we will be comparing
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2122
      // uncompressed values directly.
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2123
      __ lduw(dst, oopDesc::klass_offset_in_bytes(), tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2124
      if (basic_type != T_OBJECT) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2125
        __ cmp(tmp, tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2126
        __ br(Assembler::notEqual, false, Assembler::pn, halt);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2127
        // load the raw value of the src klass.
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2128
        __ delayed()->lduw(src, oopDesc::klass_offset_in_bytes(), tmp2);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2129
        __ cmp_and_br_short(tmp, tmp2, Assembler::equal, Assembler::pn, known_ok);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2130
      } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2131
        __ cmp(tmp, tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2132
        __ br(Assembler::equal, false, Assembler::pn, known_ok);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2133
        __ delayed()->cmp(src, dst);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2134
        __ brx(Assembler::equal, false, Assembler::pn, known_ok);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2135
        __ delayed()->nop();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2136
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
    } else {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2138
      __ ld_ptr(dst, oopDesc::klass_offset_in_bytes(), tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2139
      if (basic_type != T_OBJECT) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2140
        __ cmp(tmp, tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2141
        __ brx(Assembler::notEqual, false, Assembler::pn, halt);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2142
        __ delayed()->ld_ptr(src, oopDesc::klass_offset_in_bytes(), tmp2);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2143
        __ cmp_and_brx_short(tmp, tmp2, Assembler::equal, Assembler::pn, known_ok);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2144
      } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2145
        __ cmp(tmp, tmp2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2146
        __ brx(Assembler::equal, false, Assembler::pn, known_ok);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2147
        __ delayed()->cmp(src, dst);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2148
        __ brx(Assembler::equal, false, Assembler::pn, known_ok);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2149
        __ delayed()->nop();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2150
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
    __ bind(halt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
    __ stop("incorrect type information in arraycopy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
    __ bind(known_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2158
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2159
  if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2160
    address counter = Runtime1::arraycopy_count_address(basic_type);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2161
    __ inc_counter(counter, G1, G3);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2162
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2163
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
  Register src_ptr = O0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
  Register dst_ptr = O1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
  Register len     = O2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
  __ add(src, arrayOopDesc::base_offset_in_bytes(basic_type), src_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  if (shift == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
    __ add(src_ptr, src_pos, src_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
    __ sll(src_pos, shift, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
    __ add(src_ptr, tmp, src_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
  __ add(dst, arrayOopDesc::base_offset_in_bytes(basic_type), dst_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
  if (shift == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
    __ add(dst_ptr, dst_pos, dst_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
    __ sll(dst_pos, shift, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
    __ add(dst_ptr, tmp, dst_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2185
  bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2186
  bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2187
  const char *name;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2188
  address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2189
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2190
  // arraycopy stubs takes a length in number of elements, so don't scale it.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2191
  __ mov(length, len);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8495
diff changeset
  2192
  __ call_VM_leaf(tmp, entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
  __ bind(*stub->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
  if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
    if (left->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
        case lir_shl:  __ sllx  (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
        case lir_shr:  __ srax  (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
        case lir_ushr: __ srl   (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
        case lir_shl:  __ sll   (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
        case lir_shr:  __ sra   (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
        case lir_ushr: __ srl   (left->as_register(), count->as_register(), dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
      case lir_shl:  __ sllx  (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
      case lir_shr:  __ srax  (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
      case lir_ushr: __ srlx  (left->as_register_lo(), count->as_register(), dest->as_register_lo()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
  if (left->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
    count = count & 63;  // shouldn't shift by more than sizeof(intptr_t)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    Register l = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
    Register d = dest->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
      case lir_shl:  __ sllx  (l, count, d); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
      case lir_shr:  __ srax  (l, count, d); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
      case lir_ushr: __ srlx  (l, count, d); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
  if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
    count = count & 0x1F; // Java spec
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
      case lir_shl:  __ sll   (left->as_register(), count, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
      case lir_shr:  __ sra   (left->as_register(), count, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
      case lir_ushr: __ srl   (left->as_register(), count, dest->as_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
  } else if (dest->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
    count = count & 63; // Java spec
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
      case lir_shl:  __ sllx  (left->as_pointer_register(), count, dest->as_pointer_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
      case lir_shr:  __ srax  (left->as_pointer_register(), count, dest->as_pointer_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
      case lir_ushr: __ srlx  (left->as_pointer_register(), count, dest->as_pointer_register()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
  assert(op->tmp1()->as_register()  == G1 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
         op->tmp2()->as_register()  == G3 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
         op->tmp3()->as_register()  == G4 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
         op->obj()->as_register()   == O0 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
         op->klass()->as_register() == G5, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
  if (op->init_check()) {
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 48120
diff changeset
  2268
    add_debug_info_for_null_check_here(op->stub()->info());
11407
5399831730cd 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 10976
diff changeset
  2269
    __ ldub(op->klass()->as_register(),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2270
          in_bytes(InstanceKlass::init_state_offset()),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
          op->tmp1()->as_register());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2272
    __ cmp(op->tmp1()->as_register(), InstanceKlass::fully_initialized);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
    __ br(Assembler::notEqual, false, Assembler::pn, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
  __ allocate_object(op->obj()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
                     op->tmp1()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
                     op->tmp2()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
                     op->tmp3()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
                     op->header_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
                     op->object_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
                     op->klass()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
                     *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
  __ verify_oop(op->obj()->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
  assert(op->tmp1()->as_register()  == G1 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
         op->tmp2()->as_register()  == G3 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
         op->tmp3()->as_register()  == G4 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
         op->tmp4()->as_register()  == O1 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
         op->klass()->as_register() == G5, "must be");
7883
f29abf6b3466 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 7713
diff changeset
  2295
46381
020219e46c86 8150388: Remove SPARC 32-bit support
gtriantafill
parents: 43429
diff changeset
  2296
  __ signx(op->len()->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
  if (UseSlowPath ||
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
  2298
      (!UseFastNewObjectArray && is_reference_type(op->type())) ||
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 58015
diff changeset
  2299
      (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2300
    __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
    __ allocate_array(op->obj()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
                      op->len()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
                      op->tmp1()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
                      op->tmp2()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
                      op->tmp3()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
                      arrayOopDesc::header_size(op->type()),
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
  2309
                      type2aelembytes(op->type()),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
                      op->klass()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
                      *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2317
void LIR_Assembler::type_profile_helper(Register mdo, int mdo_offset_bias,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2318
                                        ciMethodData *md, ciProfileData *data,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2319
                                        Register recv, Register tmp1, Label* update_done) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2320
  uint i;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2321
  for (i = 0; i < VirtualCallData::row_limit(); i++) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2322
    Label next_test;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2323
    // See if the receiver is receiver[n].
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2324
    Address receiver_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2325
                          mdo_offset_bias);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2326
    __ ld_ptr(receiver_addr, tmp1);
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20702
diff changeset
  2327
    __ verify_klass_ptr(tmp1);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2328
    __ cmp_and_brx_short(recv, tmp1, Assembler::notEqual, Assembler::pt, next_test);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2329
    Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2330
                      mdo_offset_bias);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2331
    __ ld_ptr(data_addr, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2332
    __ add(tmp1, DataLayout::counter_increment, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2333
    __ st_ptr(tmp1, data_addr);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2334
    __ ba(*update_done);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2335
    __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2336
    __ bind(next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2337
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2338
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2339
  // Didn't find receiver; find next empty slot and fill it in
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2340
  for (i = 0; i < VirtualCallData::row_limit(); i++) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2341
    Label next_test;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2342
    Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2343
                      mdo_offset_bias);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2344
    __ ld_ptr(recv_addr, tmp1);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2345
    __ br_notnull_short(tmp1, Assembler::pt, next_test);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2346
    __ st_ptr(recv, recv_addr);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2347
    __ set(DataLayout::counter_increment, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2348
    __ st_ptr(tmp1, mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2349
              mdo_offset_bias);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2350
    __ ba(*update_done);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2351
    __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2352
    __ bind(next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2353
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2354
}
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2355
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2356
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2357
void LIR_Assembler::setup_md_access(ciMethod* method, int bci,
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2358
                                    ciMethodData*& md, ciProfileData*& data, int& mdo_offset_bias) {
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2359
  md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2360
  assert(md != NULL, "Sanity");
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2361
  data = md->bci_to_data(bci);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2362
  assert(data != NULL,       "need data for checkcast");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2363
  assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2364
  if (!Assembler::is_simm13(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2365
    // The offset is large so bias the mdo by the base of the slot so
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2366
    // that the ld can use simm13s to reference the slots of the data
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2367
    mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2368
  }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2369
}
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2370
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2371
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2372
  // we always need a stub for the failure case.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2373
  CodeStub* stub = op->stub();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2374
  Register obj = op->object()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2375
  Register k_RInfo = op->tmp1()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2376
  Register klass_RInfo = op->tmp2()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2377
  Register dst = op->result_opr()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2378
  Register Rtmp1 = op->tmp3()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2379
  ciKlass* k = op->klass();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2380
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2381
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2382
  if (obj == k_RInfo) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2383
    k_RInfo = klass_RInfo;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2384
    klass_RInfo = obj;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2385
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2386
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2387
  ciMethodData* md;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2388
  ciProfileData* data;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2389
  int mdo_offset_bias = 0;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2390
  if (op->should_profile()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2391
    ciMethod* method = op->profiled_method();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2392
    assert(method != NULL, "Should have method");
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2393
    setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2394
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2395
    Label not_null;
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2396
    __ br_notnull_short(obj, Assembler::pn, not_null);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2397
    Register mdo      = k_RInfo;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2398
    Register data_val = Rtmp1;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2399
    metadata2reg(md->constant_encoding(), mdo);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2400
    if (mdo_offset_bias > 0) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2401
      __ set(mdo_offset_bias, data_val);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2402
      __ add(mdo, data_val, mdo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2403
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2404
    Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2405
    __ ldub(flags_addr, data_val);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2406
    __ or3(data_val, BitData::null_seen_byte_constant(), data_val);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2407
    __ stb(data_val, flags_addr);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2408
    __ ba(*obj_is_null);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2409
    __ delayed()->nop();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2410
    __ bind(not_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2411
  } else {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2412
    __ br_null(obj, false, Assembler::pn, *obj_is_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2413
    __ delayed()->nop();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2414
  }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2415
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2416
  Label profile_cast_failure, profile_cast_success;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2417
  Label *failure_target = op->should_profile() ? &profile_cast_failure : failure;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2418
  Label *success_target = op->should_profile() ? &profile_cast_success : success;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2419
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2420
  // patching may screw with our temporaries on sparc,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2421
  // so let's do it before loading the class
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2422
  if (k->is_loaded()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2423
    metadata2reg(k->constant_encoding(), k_RInfo);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2424
  } else {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2425
    klass2reg_with_patching(k_RInfo, op->info_for_patch());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2426
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2427
  assert(obj != k_RInfo, "must be different");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2428
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2429
  // get object class
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2430
  // not a safepoint as obj null check happens earlier
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2431
  __ load_klass(obj, klass_RInfo);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2432
  if (op->fast_check()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2433
    assert_different_registers(klass_RInfo, k_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2434
    __ cmp(k_RInfo, klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2435
    __ brx(Assembler::notEqual, false, Assembler::pt, *failure_target);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2436
    __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2437
  } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2438
    bool need_slow_path = true;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2439
    if (k->is_loaded()) {
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 11190
diff changeset
  2440
      if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset()))
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2441
        need_slow_path = false;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2442
      // perform the fast part of the checking logic
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2443
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, noreg,
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2444
                                       (need_slow_path ? success_target : NULL),
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2445
                                       failure_target, NULL,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2446
                                       RegisterOrConstant(k->super_check_offset()));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2447
    } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2448
      // perform the fast part of the checking logic
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2449
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7, success_target,
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2450
                                       failure_target, NULL);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2451
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2452
    if (need_slow_path) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2453
      // call out-of-line instance of __ check_klass_subtype_slow_path(...):
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2454
      assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2455
      __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2456
      __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2457
      __ cmp(G3, 0);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2458
      __ br(Assembler::equal, false, Assembler::pn, *failure_target);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2459
      __ delayed()->nop();
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2460
      // Fall through to success case
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2461
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2462
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2463
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2464
  if (op->should_profile()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2465
    Register mdo  = klass_RInfo, recv = k_RInfo, tmp1 = Rtmp1;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2466
    assert_different_registers(obj, mdo, recv, tmp1);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2467
    __ bind(profile_cast_success);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2468
    metadata2reg(md->constant_encoding(), mdo);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2469
    if (mdo_offset_bias > 0) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2470
      __ set(mdo_offset_bias, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2471
      __ add(mdo, tmp1, mdo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2472
    }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2473
    __ load_klass(obj, recv);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2474
    type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, success);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2475
    // Jump over the failure case
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2476
    __ ba(*success);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2477
    __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2478
    // Cast failure case
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2479
    __ bind(profile_cast_failure);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2480
    metadata2reg(md->constant_encoding(), mdo);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2481
    if (mdo_offset_bias > 0) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2482
      __ set(mdo_offset_bias, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2483
      __ add(mdo, tmp1, mdo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2484
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2485
    Address data_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2486
    __ ld_ptr(data_addr, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2487
    __ sub(tmp1, DataLayout::counter_increment, tmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2488
    __ st_ptr(tmp1, data_addr);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2489
    __ ba(*failure);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2490
    __ delayed()->nop();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2491
  }
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2492
  __ ba(*success);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2493
  __ delayed()->nop();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2494
}
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2495
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2496
void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2497
  LIR_Code code = op->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2498
  if (code == lir_store_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2499
    Register value = op->object()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2500
    Register array = op->array()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2501
    Register k_RInfo = op->tmp1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2502
    Register klass_RInfo = op->tmp2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2503
    Register Rtmp1 = op->tmp3()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2504
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2505
    __ verify_oop(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2506
    CodeStub* stub = op->stub();
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2507
    // check if it needs to be profiled
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2508
    ciMethodData* md;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2509
    ciProfileData* data;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2510
    int mdo_offset_bias = 0;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2511
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2512
      ciMethod* method = op->profiled_method();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2513
      assert(method != NULL, "Should have method");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2514
      setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2515
    }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2516
    Label profile_cast_success, profile_cast_failure, done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2517
    Label *success_target = op->should_profile() ? &profile_cast_success : &done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2518
    Label *failure_target = op->should_profile() ? &profile_cast_failure : stub->entry();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2519
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2520
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2521
      Label not_null;
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2522
      __ br_notnull_short(value, Assembler::pn, not_null);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2523
      Register mdo      = k_RInfo;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2524
      Register data_val = Rtmp1;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2525
      metadata2reg(md->constant_encoding(), mdo);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2526
      if (mdo_offset_bias > 0) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2527
        __ set(mdo_offset_bias, data_val);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2528
        __ add(mdo, data_val, mdo);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2529
      }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2530
      Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2531
      __ ldub(flags_addr, data_val);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2532
      __ or3(data_val, BitData::null_seen_byte_constant(), data_val);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2533
      __ stb(data_val, flags_addr);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2534
      __ ba_short(done);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2535
      __ bind(not_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2536
    } else {
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2537
      __ br_null_short(value, Assembler::pn, done);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2538
    }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2539
    add_debug_info_for_null_check_here(op->info_for_exception());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2540
    __ load_klass(array, k_RInfo);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2541
    __ load_klass(value, klass_RInfo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2542
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2543
    // get instance klass
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  2544
    __ ld_ptr(Address(k_RInfo, ObjArrayKlass::element_klass_offset()), k_RInfo);
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1388
diff changeset
  2545
    // perform the fast part of the checking logic
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2546
    __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7, success_target, failure_target, NULL);
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1388
diff changeset
  2547
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1388
diff changeset
  2548
    // call out-of-line instance of __ check_klass_subtype_slow_path(...):
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 1388
diff changeset
  2549
    assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2550
    __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2551
    __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2552
    __ cmp(G3, 0);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2553
    __ br(Assembler::equal, false, Assembler::pn, *failure_target);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2554
    __ delayed()->nop();
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2555
    // fall through to the success case
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2556
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2557
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2558
      Register mdo  = klass_RInfo, recv = k_RInfo, tmp1 = Rtmp1;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2559
      assert_different_registers(value, mdo, recv, tmp1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2560
      __ bind(profile_cast_success);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2561
      metadata2reg(md->constant_encoding(), mdo);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2562
      if (mdo_offset_bias > 0) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2563
        __ set(mdo_offset_bias, tmp1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2564
        __ add(mdo, tmp1, mdo);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2565
      }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2566
      __ load_klass(value, recv);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2567
      type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &done);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2568
      __ ba_short(done);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2569
      // Cast failure case
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2570
      __ bind(profile_cast_failure);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2571
      metadata2reg(md->constant_encoding(), mdo);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2572
      if (mdo_offset_bias > 0) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2573
        __ set(mdo_offset_bias, tmp1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2574
        __ add(mdo, tmp1, mdo);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2575
      }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2576
      Address data_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2577
      __ ld_ptr(data_addr, tmp1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2578
      __ sub(tmp1, DataLayout::counter_increment, tmp1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2579
      __ st_ptr(tmp1, data_addr);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2580
      __ ba(*stub->entry());
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2581
      __ delayed()->nop();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2582
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
    __ bind(done);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2584
  } else if (code == lir_checkcast) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2585
    Register obj = op->object()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2586
    Register dst = op->result_opr()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2587
    Label success;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2588
    emit_typecheck_helper(op, &success, op->stub()->entry(), &success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2589
    __ bind(success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2590
    __ mov(obj, dst);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2591
  } else if (code == lir_instanceof) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2592
    Register obj = op->object()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2593
    Register dst = op->result_opr()->as_register();
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2594
    Label success, failure, done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2595
    emit_typecheck_helper(op, &success, &failure, &failure);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2596
    __ bind(failure);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2597
    __ set(0, dst);
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 9105
diff changeset
  2598
    __ ba_short(done);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2599
    __ bind(success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2600
    __ set(1, dst);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  2601
    __ bind(done);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2602
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2603
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2604
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2605
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2606
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2607
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2608
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2609
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2610
  if (op->code() == lir_cas_long) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2611
    assert(VM_Version::supports_cx8(), "wrong machine");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
    Register addr = op->addr()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
    Register cmp_value_lo = op->cmp_value()->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2614
    Register cmp_value_hi = op->cmp_value()->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2615
    Register new_value_lo = op->new_value()->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2616
    Register new_value_hi = op->new_value()->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
    Register t1 = op->tmp1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2618
    Register t2 = op->tmp2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2619
    __ mov(cmp_value_lo, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2620
    __ mov(new_value_lo, t2);
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  2621
    // perform the compare and swap operation
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  2622
    __ casx(addr, t1, t2);
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  2623
    // generate condition code - if the swap succeeded, t2 ("new value" reg) was
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  2624
    // overwritten with the original value in "addr" and will be equal to t1.
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7435
diff changeset
  2625
    __ cmp(t1, t2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2626
  } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2627
    Register addr = op->addr()->as_pointer_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2628
    Register cmp_value = op->cmp_value()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2629
    Register new_value = op->new_value()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2630
    Register t1 = op->tmp1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2631
    Register t2 = op->tmp2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2632
    __ mov(cmp_value, t1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2633
    __ mov(new_value, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2634
    if (op->code() == lir_cas_obj) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2635
      if (UseCompressedOops) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2636
        __ encode_heap_oop(t1);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2637
        __ encode_heap_oop(t2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2638
        __ cas(addr, t1, t2);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2639
      } else {
7435
3da377e9db3f 7004530: casx used for 32 bit cas after 7003554
never
parents: 7432
diff changeset
  2640
        __ cas_ptr(addr, t1, t2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
      }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2642
    } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2643
      __ cas(addr, t1, t2);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2644
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2645
    __ cmp(t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2648
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2650
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
void LIR_Assembler::set_24bit_FPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2652
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2653
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
void LIR_Assembler::reset_FPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2661
void LIR_Assembler::breakpoint() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2662
  __ breakpoint_trap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2663
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2664
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2665
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2666
void LIR_Assembler::push(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2667
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2668
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2669
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2670
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2671
void LIR_Assembler::pop(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2673
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2674
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2675
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2676
void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst_opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2677
  Address mon_addr = frame_map()->address_for_monitor_lock(monitor_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2678
  Register dst = dst_opr->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2679
  Register reg = mon_addr.base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2680
  int offset = mon_addr.disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
  // compute pointer to BasicLock
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
  if (mon_addr.is_simm13()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
    __ add(reg, offset, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2684
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2685
    __ set(offset, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2686
    __ add(dst, reg, dst);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2687
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2688
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2689
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18097
diff changeset
  2690
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
34205
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2691
  assert(op->crc()->is_single_cpu(),  "crc must be register");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2692
  assert(op->val()->is_single_cpu(),  "byte value must be register");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2693
  assert(op->result_opr()->is_single_cpu(), "result must be register");
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2694
  Register crc = op->crc()->as_register();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2695
  Register val = op->val()->as_register();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2696
  Register table = op->result_opr()->as_register();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2697
  Register res   = op->result_opr()->as_register();
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2698
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2699
  assert_different_registers(val, crc, table);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2700
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2701
  __ set(ExternalAddress(StubRoutines::crc_table_addr()), table);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2702
  __ not1(crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2703
  __ clruwu(crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2704
  __ update_byte_crc32(crc, val, table);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2705
  __ not1(crc);
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2706
9ec51d30a11e 8143012: CRC32 Intrinsics support on SPARC
kvn
parents: 33628
diff changeset
  2707
  __ mov(crc, res);
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 18097
diff changeset
  2708
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
void LIR_Assembler::emit_lock(LIR_OpLock* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
  Register obj = op->obj_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
  Register hdr = op->hdr_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
  Register lock = op->lock_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
  // obj may not be an oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
  if (op->code() == lir_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
    MonitorEnterStub* stub = (MonitorEnterStub*)op->stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
    if (UseFastLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
      assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
      // add debug info for NullPointerException only if one is possible
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
      if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
        add_debug_info_for_null_check_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
      __ lock_object(hdr, obj, lock, op->scratch_opr()->as_register(), *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
      // always do slow locking
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
      // note: the slow locking code could be inlined here, however if we use
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
      //       slow locking, speed doesn't matter anyway and this solution is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
      //       simpler and requires less duplicated code - additionally, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
      //       slow locking code is the same in either case which simplifies
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2731
      //       debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
      __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
      __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2736
    assert (op->code() == lir_unlock, "Invalid code, expected lir_unlock");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2737
    if (UseFastLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2738
      assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2739
      __ unlock_object(hdr, obj, lock, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
      // always do slow unlocking
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2742
      // note: the slow unlocking code could be inlined here, however if we use
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
      //       slow unlocking, speed doesn't matter anyway and this solution is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2744
      //       simpler and requires less duplicated code - additionally, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2745
      //       slow unlocking code is the same in either case which simplifies
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2746
      //       debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2747
      __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2748
      __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2752
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2756
  ciMethod* method = op->profiled_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2757
  int bci          = op->profiled_bci();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12623
diff changeset
  2758
  ciMethod* callee = op->profiled_callee();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2759
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2760
  // Update counter for all call types
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2761
  ciMethodData* md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2762
  assert(md != NULL, "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2763
  ciProfileData* data = md->bci_to_data(bci);
48856
c866eaca24cb 8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data()
dlong
parents: 48807
diff changeset
  2764
  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2765
  assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2766
  Register mdo  = op->mdo()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2767
  assert(op->tmp1()->is_double_cpu(), "tmp1 must be allocated");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2768
  Register tmp1 = op->tmp1()->as_register_lo();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2769
  metadata2reg(md->constant_encoding(), mdo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
  int mdo_offset_bias = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
  if (!Assembler::is_simm13(md->byte_offset_of_slot(data, CounterData::count_offset()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
                            data->size_in_bytes())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2773
    // The offset is large so bias the mdo by the base of the slot so
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2774
    // that the ld can use simm13s to reference the slots of the data
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
    mdo_offset_bias = md->byte_offset_of_slot(data, CounterData::count_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2776
    __ set(mdo_offset_bias, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
    __ add(mdo, O7, mdo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  2780
  Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
  // Perform additional virtual call profiling for invokevirtual and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
  // invokeinterface bytecodes
47698
d4bfafe600d0 8166750: C1 profiling handles statically bindable call sites differently than the interpreter
iveresov
parents: 47216
diff changeset
  2783
  if (op->should_profile_receiver_type()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
    assert(op->recv()->is_single_cpu(), "recv must be allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
    Register recv = op->recv()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
    assert_different_registers(mdo, tmp1, recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
    assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
    ciKlass* known_klass = op->known_holder();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2789
    if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
      // We know the type that will be seen at this call site; we can
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2791
      // statically update the MethodData* rather than needing to do
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2792
      // dynamic tests on the receiver type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2793
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2794
      // NOTE: we should probably put a lock around this search to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2795
      // avoid collisions by concurrent compilations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2796
      ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2797
      uint i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2798
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
        ciKlass* receiver = vc_data->receiver(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2800
        if (known_klass->equals(receiver)) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  2801
          Address data_addr(mdo, md->byte_offset_of_slot(data,
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  2802
                                                         VirtualCallData::receiver_count_offset(i)) -
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
                            mdo_offset_bias);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2804
          __ ld_ptr(data_addr, tmp1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
          __ add(tmp1, DataLayout::counter_increment, tmp1);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2806
          __ st_ptr(tmp1, data_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2809
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2810
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
      // Receiver type not found in profile data; select an empty slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
      // Note that this is less efficient than it should be because it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
      // always does a write to the receiver part of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
      // VirtualCallData rather than just the first time
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2816
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2817
        ciKlass* receiver = vc_data->receiver(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2818
        if (receiver == NULL) {
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  2819
          Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
                            mdo_offset_bias);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2821
          metadata2reg(known_klass->constant_encoding(), tmp1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2822
          __ st_ptr(tmp1, recv_addr);
2571
d602ad6538bd 6822110: Add AddressLiteral class on SPARC
twisti
parents: 2332
diff changeset
  2823
          Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2824
                            mdo_offset_bias);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2825
          __ ld_ptr(data_addr, tmp1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
          __ add(tmp1, DataLayout::counter_increment, tmp1);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2827
          __ st_ptr(tmp1, data_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2829
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2831
    } else {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2832
      __ load_klass(recv, recv);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
      Label update_done;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2834
      type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &update_done);
4892
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2835
      // Receiver did not match any saved receiver and there is no empty row for it.
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2836
      // Increment total counter to indicate polymorphic case.
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2837
      __ ld_ptr(counter_addr, tmp1);
4892
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2838
      __ add(tmp1, DataLayout::counter_increment, tmp1);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2839
      __ st_ptr(tmp1, counter_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
      __ bind(update_done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2842
    }
4892
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2843
  } else {
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2844
    // Static call
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2845
    __ ld_ptr(counter_addr, tmp1);
4892
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4752
diff changeset
  2846
    __ add(tmp1, DataLayout::counter_increment, tmp1);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  2847
    __ st_ptr(tmp1, counter_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19979
diff changeset
  2851
void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
22504
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2852
  Register obj = op->obj()->as_register();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2853
  Register tmp1 = op->tmp()->as_pointer_register();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2854
  Register tmp2 = G1;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2855
  Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2856
  ciKlass* exact_klass = op->exact_klass();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2857
  intptr_t current_klass = op->current_klass();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2858
  bool not_null = op->not_null();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2859
  bool no_conflict = op->no_conflict();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2860
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2861
  Label update, next, none;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2862
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2863
  bool do_null = !not_null;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2864
  bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2865
  bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2866
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2867
  assert(do_null || do_update, "why are we here?");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2868
  assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2869
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2870
  __ verify_oop(obj);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2871
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2872
  if (tmp1 != obj) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2873
    __ mov(obj, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2874
  }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2875
  if (do_null) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2876
    __ br_notnull_short(tmp1, Assembler::pt, update);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2877
    if (!TypeEntries::was_null_seen(current_klass)) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2878
      __ ld_ptr(mdo_addr, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2879
      __ or3(tmp1, TypeEntries::null_seen, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2880
      __ st_ptr(tmp1, mdo_addr);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2881
    }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2882
    if (do_update) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2883
      __ ba(next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2884
      __ delayed()->nop();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2885
    }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2886
#ifdef ASSERT
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2887
  } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2888
    __ br_notnull_short(tmp1, Assembler::pt, update);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2889
    __ stop("unexpect null obj");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2890
#endif
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2891
  }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2892
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2893
  __ bind(update);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2894
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2895
  if (do_update) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2896
#ifdef ASSERT
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2897
    if (exact_klass != NULL) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2898
      Label ok;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2899
      __ load_klass(tmp1, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2900
      metadata2reg(exact_klass->constant_encoding(), tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2901
      __ cmp_and_br_short(tmp1, tmp2, Assembler::equal, Assembler::pt, ok);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2902
      __ stop("exact klass and actual klass differ");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2903
      __ bind(ok);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2904
    }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2905
#endif
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2906
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2907
    Label do_update;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2908
    __ ld_ptr(mdo_addr, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2909
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2910
    if (!no_conflict) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2911
      if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2912
        if (exact_klass != NULL) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2913
          metadata2reg(exact_klass->constant_encoding(), tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2914
        } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2915
          __ load_klass(tmp1, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2916
        }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2917
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2918
        __ xor3(tmp1, tmp2, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2919
        __ btst(TypeEntries::type_klass_mask, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2920
        // klass seen before, nothing to do. The unknown bit may have been
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2921
        // set already but no need to check.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2922
        __ brx(Assembler::zero, false, Assembler::pt, next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2923
        __ delayed()->
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2924
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2925
           btst(TypeEntries::type_unknown, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2926
        // already unknown. Nothing to do anymore.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2927
        __ brx(Assembler::notZero, false, Assembler::pt, next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2928
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2929
        if (TypeEntries::is_type_none(current_klass)) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2930
          __ delayed()->btst(TypeEntries::type_mask, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2931
          __ brx(Assembler::zero, true, Assembler::pt, do_update);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2932
          // first time here. Set profile type.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2933
          __ delayed()->or3(tmp2, tmp1, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2934
        } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2935
          __ delayed()->nop();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2936
        }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2937
      } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2938
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2939
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2940
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2941
        __ btst(TypeEntries::type_unknown, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2942
        // already unknown. Nothing to do anymore.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2943
        __ brx(Assembler::notZero, false, Assembler::pt, next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2944
        __ delayed()->nop();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2945
      }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2946
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2947
      // different than before. Cannot keep accurate profile.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2948
      __ or3(tmp2, TypeEntries::type_unknown, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2949
    } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2950
      // There's a single possible klass at this profile point
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2951
      assert(exact_klass != NULL, "should be");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2952
      if (TypeEntries::is_type_none(current_klass)) {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2953
        metadata2reg(exact_klass->constant_encoding(), tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2954
        __ xor3(tmp1, tmp2, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2955
        __ btst(TypeEntries::type_klass_mask, tmp1);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2956
        __ brx(Assembler::zero, false, Assembler::pt, next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2957
#ifdef ASSERT
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2958
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2959
        {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2960
          Label ok;
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2961
          __ delayed()->btst(TypeEntries::type_mask, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2962
          __ brx(Assembler::zero, true, Assembler::pt, ok);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2963
          __ delayed()->nop();
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2964
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2965
          __ stop("unexpected profiling mismatch");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2966
          __ bind(ok);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2967
        }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2968
        // first time here. Set profile type.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2969
        __ or3(tmp2, tmp1, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2970
#else
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2971
        // first time here. Set profile type.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2972
        __ delayed()->or3(tmp2, tmp1, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2973
#endif
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2974
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2975
      } else {
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2976
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2977
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2978
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2979
        // already unknown. Nothing to do anymore.
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2980
        __ btst(TypeEntries::type_unknown, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2981
        __ brx(Assembler::notZero, false, Assembler::pt, next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2982
        __ delayed()->or3(tmp2, TypeEntries::type_unknown, tmp2);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2983
      }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2984
    }
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2985
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2986
    __ bind(do_update);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2987
    __ st_ptr(tmp2, mdo_addr);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2988
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2989
    __ bind(next);
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  2990
  }
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19979
diff changeset
  2991
}
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19979
diff changeset
  2992
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2993
void LIR_Assembler::align_backward_branch_target() {
5249
5cac34e6fe54 6940701: Don't align loops in stubs for Niagara sparc
kvn
parents: 5052
diff changeset
  2994
  __ align(OptoLoopAlignment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2995
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2996
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2997
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2998
void LIR_Assembler::emit_delay(LIR_OpDelay* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2999
  // make sure we are expecting a delay
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3000
  // this has the side effect of clearing the delay state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
  // so we can use _masm instead of _masm->delayed() to do the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
  // code generation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
  __ delayed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
  // make sure we only emit one instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
  int offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
  op->delay_op()->emit_code(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3009
  if (code_offset() - offset != NativeInstruction::nop_instruction_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
    op->delay_op()->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3012
  assert(code_offset() - offset == NativeInstruction::nop_instruction_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3013
         "only one instruction can go in a delay slot");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3014
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3016
  // we may also be emitting the call info for the instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3017
  // which we are the delay slot of.
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  3018
  CodeEmitInfo* call_info = op->call_info();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3019
  if (call_info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3020
    add_call_info(code_offset(), call_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3022
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3023
  if (VerifyStackAtCalls) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3024
    _masm->sub(FP, SP, O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3025
    _masm->cmp(O7, initial_frame_size_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
    _masm->trap(Assembler::notEqual, Assembler::ptr_cc, G0, ST_RESERVED_FOR_USER_0+2 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3027
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3028
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3030
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 50540
diff changeset
  3031
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 50540
diff changeset
  3032
  // tmp must be unused
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 50540
diff changeset
  3033
  assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3034
  assert(left->is_register(), "can only handle registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3036
  if (left->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3037
    __ neg(left->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3038
  } else if (left->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3039
    __ fneg(FloatRegisterImpl::S, left->as_float_reg(), dest->as_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3040
  } else if (left->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3041
    __ fneg(FloatRegisterImpl::D, left->as_double_reg(), dest->as_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3042
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3043
    assert (left->is_double_cpu(), "Must be a long");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3044
    Register Rlow = left->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3045
    Register Rhi = left->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3046
    __ sub(G0, Rlow, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3047
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3048
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3049
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3051
void LIR_Assembler::fxch(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3052
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3053
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3054
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3055
void LIR_Assembler::fld(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3056
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3057
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3058
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3059
void LIR_Assembler::ffree(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3060
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3061
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3062
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3063
void LIR_Assembler::rt_call(LIR_Opr result, address dest,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3064
                            const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3066
  // if tmp is invalid, then the function being called doesn't destroy the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3067
  if (tmp->is_valid()) {
23485
13a2ccc01c44 8037149: C1: getThreadTemp should return a T_LONG register on 64bit
iveresov
parents: 22504
diff changeset
  3068
    __ save_thread(tmp->as_pointer_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3069
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3070
  __ call(dest, relocInfo::runtime_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3071
  __ delayed()->nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3072
  if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3073
    add_call_info_here(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3074
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3075
  if (tmp->is_valid()) {
23485
13a2ccc01c44 8037149: C1: getThreadTemp should return a T_LONG register on 64bit
iveresov
parents: 22504
diff changeset
  3076
    __ restore_thread(tmp->as_pointer_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3077
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3079
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3080
  __ verify_thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3081
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3082
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3084
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3085
void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3086
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3087
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3088
  NEEDS_CLEANUP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3089
  if (type == T_LONG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3090
    LIR_Address* mem_addr = dest->is_address() ? dest->as_address_ptr() : src->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3091
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3092
    // (extended to allow indexed as well as constant displaced for JSR-166)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3093
    Register idx = noreg; // contains either constant offset or index
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3094
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3095
    int disp = mem_addr->disp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3096
    if (mem_addr->index() == LIR_OprFact::illegalOpr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3097
      if (!Assembler::is_simm13(disp)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3098
        idx = O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3099
        __ set(disp, idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3100
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3101
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3102
      assert(disp == 0, "not both indexed and disp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3103
      idx = mem_addr->index()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3104
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3105
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3106
    int null_check_offset = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3108
    Register base = mem_addr->base()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3109
    if (src->is_register() && dest->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3110
      // G4 is high half, G5 is low half
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3111
      // clear the top bits of G5, and scale up G4
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3112
      __ srl (src->as_register_lo(),  0, G5);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3113
      __ sllx(src->as_register_hi(), 32, G4);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3114
      // combine the two halves into the 64 bits of G4
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3115
      __ or3(G4, G5, G4);
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3116
      null_check_offset = __ offset();
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3117
      if (idx == noreg) {
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3118
        __ stx(G4, base, disp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3119
      } else {
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3120
        __ stx(G4, base, idx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3121
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3122
    } else if (src->is_address() && dest->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3123
      null_check_offset = __ offset();
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3124
      if (idx == noreg) {
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3125
        __ ldx(base, disp, G5);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3126
      } else {
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3127
        __ ldx(base, idx, G5);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3128
      }
18097
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3129
      __ srax(G5, 32, dest->as_register_hi()); // fetch the high half into hi
acd70736bd60 8008407: remove SPARC V8 support
morris
parents: 16611
diff changeset
  3130
      __ mov (G5, dest->as_register_lo());     // copy low half into lo
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3131
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3132
      Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3133
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3134
    if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3135
      add_debug_info_for_null_check(null_check_offset, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3136
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3137
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3138
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3139
    // use normal move for all other volatiles since they don't need
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3140
    // special handling to remain atomic.
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3141
    move_op(src, dest, type, lir_patch_none, info, false, false, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3145
void LIR_Assembler::membar() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3146
  // only StoreLoad membars are ever explicitly needed on sparcs in TSO mode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3147
  __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3149
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3150
void LIR_Assembler::membar_acquire() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3151
  // no-op on TSO
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3154
void LIR_Assembler::membar_release() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3155
  // no-op on TSO
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3156
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3157
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3158
void LIR_Assembler::membar_loadload() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3159
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3160
  //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3161
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3162
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3163
void LIR_Assembler::membar_storestore() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3164
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3165
  //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3166
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3167
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3168
void LIR_Assembler::membar_loadstore() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3169
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3170
  //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3171
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3172
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3173
void LIR_Assembler::membar_storeload() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3174
  __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3175
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3176
38017
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3177
void LIR_Assembler::on_spin_wait() {
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3178
  Unimplemented();
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3179
}
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3180
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3181
// Pack two sequential registers containing 32 bit values
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3182
// into a single 64 bit register.
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3183
// src and src->successor() are packed into dst
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3184
// src and dst may be the same register.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3185
// Note: src is destroyed
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3186
void LIR_Assembler::pack64(LIR_Opr src, LIR_Opr dst) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3187
  Register rs = src->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3188
  Register rd = dst->as_register_lo();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3189
  __ sllx(rs, 32, rs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3190
  __ srl(rs->successor(), 0, rs->successor());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3191
  __ or3(rs, rs->successor(), rd);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3192
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3193
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3194
// Unpack a 64 bit value in a register into
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3195
// two sequential registers.
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3196
// src is unpacked into dst and dst->successor()
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3197
void LIR_Assembler::unpack64(LIR_Opr src, LIR_Opr dst) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3198
  Register rs = src->as_register_lo();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3199
  Register rd = dst->as_register_hi();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3200
  assert_different_registers(rs, rd, rd->successor());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3201
  __ srlx(rs, 32, rd);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3202
  __ srl (rs,  0, rd->successor());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3203
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3204
50102
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3205
void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
46651
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3206
  const LIR_Address* addr = addr_opr->as_address_ptr();
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3207
  assert(addr->scale() == LIR_Address::times_1, "can't handle complex addresses yet");
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3208
  const Register dest_reg = dest->as_pointer_register();
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3209
  const Register base_reg = addr->base()->as_pointer_register();
22504
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  3210
50540
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3211
  if (patch_code != lir_patch_none) {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3212
    PatchingStub* patch = new PatchingStub(_masm, PatchingStub::access_field_id);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3213
    assert(addr->disp() != 0, "must have");
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3214
    assert(base_reg != G3_scratch, "invariant");
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3215
    __ patchable_set(0, G3_scratch);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3216
    patching_epilog(patch, patch_code, base_reg, info);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3217
    assert(dest_reg != G3_scratch, "invariant");
46651
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3218
    if (addr->index()->is_valid()) {
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3219
      const Register index_reg = addr->index()->as_pointer_register();
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3220
      assert(index_reg != G3_scratch, "invariant");
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3221
      __ add(index_reg, G3_scratch, G3_scratch);
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3222
    }
a0aef4e7599b 8184162: Support addresses with index operands in LIRAssembler::leal on SPARC
eosterlund
parents: 46597
diff changeset
  3223
    __ add(base_reg, G3_scratch, dest_reg);
50540
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3224
  } else {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3225
    if (Assembler::is_simm13(addr->disp())) {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3226
      if (addr->index()->is_valid()) {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3227
        const Register index_reg = addr->index()->as_pointer_register();
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3228
        assert(index_reg != G3_scratch, "invariant");
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3229
        __ add(base_reg, addr->disp(), G3_scratch);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3230
        __ add(index_reg, G3_scratch, dest_reg);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3231
      } else {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3232
        __ add(base_reg, addr->disp(), dest_reg);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3233
      }
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3234
    } else {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3235
      __ set(addr->disp(), G3_scratch);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3236
      if (addr->index()->is_valid()) {
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3237
        const Register index_reg = addr->index()->as_pointer_register();
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3238
        assert(index_reg != G3_scratch, "invariant");
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3239
        __ add(index_reg, G3_scratch, G3_scratch);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3240
      }
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3241
      __ add(base_reg, G3_scratch, dest_reg);
b93bf5846277 8203344: Make C1 leal patchable on SPARC
eosterlund
parents: 50380
diff changeset
  3242
    }
22504
b1837533ba65 8026253: New type profiling points: sparc support
roland
parents: 21088
diff changeset
  3243
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3244
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3247
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3248
  assert(result_reg->is_register(), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3249
  __ mov(G2_thread, result_reg->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3250
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3251
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3252
#ifdef ASSERT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3253
// emit run-time assertion
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3254
void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3255
  assert(op->code() == lir_assert, "must be");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3256
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3257
  if (op->in_opr1()->is_valid()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3258
    assert(op->in_opr2()->is_valid(), "both operands must be valid");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3259
    comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3260
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3261
    assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3262
    assert(op->condition() == lir_cond_always, "no other conditions allowed");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3263
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3264
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3265
  Label ok;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3266
  if (op->condition() != lir_cond_always) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3267
    Assembler::Condition acond;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3268
    switch (op->condition()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3269
      case lir_cond_equal:        acond = Assembler::equal;                break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3270
      case lir_cond_notEqual:     acond = Assembler::notEqual;             break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3271
      case lir_cond_less:         acond = Assembler::less;                 break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3272
      case lir_cond_lessEqual:    acond = Assembler::lessEqual;            break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3273
      case lir_cond_greaterEqual: acond = Assembler::greaterEqual;         break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3274
      case lir_cond_greater:      acond = Assembler::greater;              break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3275
      case lir_cond_aboveEqual:   acond = Assembler::greaterEqualUnsigned; break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3276
      case lir_cond_belowEqual:   acond = Assembler::lessEqualUnsigned;    break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3277
      default:                         ShouldNotReachHere();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3278
    };
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3279
    __ br(acond, false, Assembler::pt, ok);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3280
    __ delayed()->nop();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3281
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3282
  if (op->halt()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3283
    const char* str = __ code_string(op->msg());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3284
    __ stop(str);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3285
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3286
    breakpoint();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3287
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3288
  __ bind(ok);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3289
}
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13974
diff changeset
  3290
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3292
void LIR_Assembler::peephole(LIR_List* lir) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3293
  LIR_OpList* inst = lir->instructions_list();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3294
  for (int i = 0; i < inst->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3295
    LIR_Op* op = inst->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3296
    switch (op->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3297
      case lir_cond_float_branch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3298
      case lir_branch: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3299
        LIR_OpBranch* branch = op->as_OpBranch();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3300
        assert(branch->info() == NULL, "shouldn't be state on branches anymore");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3301
        LIR_Op* delay_op = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3302
        // we'd like to be able to pull following instructions into
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3303
        // this slot but we don't know enough to do it safely yet so
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3304
        // only optimize block to block control flow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3305
        if (LIRFillDelaySlots && branch->block()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3306
          LIR_Op* prev = inst->at(i - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3307
          if (prev && LIR_Assembler::is_single_instruction(prev) && prev->info() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3308
            // swap previous instruction into delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3309
            inst->at_put(i - 1, op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3310
            inst->at_put(i, new LIR_OpDelay(prev, op->info()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3311
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3312
            if (LIRTracePeephole) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3313
              tty->print_cr("delayed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3314
              inst->at(i - 1)->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3315
              inst->at(i)->print();
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  3316
              tty->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3317
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3318
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3319
            continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3320
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3321
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3323
        if (!delay_op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3324
          delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3325
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3326
        inst->insert_before(i + 1, delay_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3327
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3328
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3329
      case lir_static_call:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3330
      case lir_virtual_call:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3331
      case lir_icvirtual_call:
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  3332
      case lir_optvirtual_call:
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  3333
      case lir_dynamic_call: {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3334
        LIR_Op* prev = inst->at(i - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3335
        if (LIRFillDelaySlots && prev && prev->code() == lir_move && prev->info() == NULL &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3336
            (op->code() != lir_virtual_call ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3337
             !prev->result_opr()->is_single_cpu() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3338
             prev->result_opr()->as_register() != O0) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3339
            LIR_Assembler::is_single_instruction(prev)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3340
          // Only moves without info can be put into the delay slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3341
          // Also don't allow the setup of the receiver in the delay
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3342
          // slot for vtable calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3343
          inst->at_put(i - 1, op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3344
          inst->at_put(i, new LIR_OpDelay(prev, op->info()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3345
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3346
          if (LIRTracePeephole) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3347
            tty->print_cr("delayed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3348
            inst->at(i - 1)->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3349
            inst->at(i)->print();
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  3350
            tty->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3351
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3352
#endif
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3353
        } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3354
          LIR_Op* delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), op->as_OpJavaCall()->info());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3355
          inst->insert_before(i + 1, delay_op);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3356
          i++;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3357
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3358
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3359
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3360
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3362
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3363
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3364
void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3365
  LIR_Address* addr = src->as_address_ptr();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3366
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3367
  assert(data == dest, "swap uses only 2 operands");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3368
  assert (code == lir_xchg, "no xadd on sparc");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3369
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3370
  if (data->type() == T_INT) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3371
    __ swap(as_Address(addr), data->as_register());
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3372
  } else if (data->is_oop()) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3373
    Register obj = data->as_register();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3374
    Register narrow = tmp->as_register();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3375
    assert(UseCompressedOops, "swap is 32bit only");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3376
    __ encode_heap_oop(obj, narrow);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3377
    __ swap(as_Address(addr), narrow);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3378
    __ decode_heap_oop(narrow, obj);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3379
  } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3380
    ShouldNotReachHere();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3381
  }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3382
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3384
#undef __