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