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