hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
author kamg
Thu, 17 Apr 2008 22:18:15 -0400
changeset 363 99d43e8a76ad
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes Summary: Initial checkin of JSDT code Reviewed-by: acorn, sbohne
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
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
// We have interface for the following instructions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// - NativeInstruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// - - NativeCall
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// - - NativeFarCall
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// - - NativeMovConstReg
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// - - NativeMovConstRegPatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// - - NativeMovRegMem
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// - - NativeMovRegMemPatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// - - NativeJump
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// - - NativeGeneralJump
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// - - NativeIllegalInstruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// The base class for different kinds of native instruction abstractions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Provides the primitive operations to manipulate code relative to this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class NativeInstruction VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  friend class Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    nop_instruction_size        =    4
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
363
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents: 1
diff changeset
    46
  bool is_dtrace_trap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  bool is_nop()                        { return long_at(0) == nop_instruction(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  bool is_call()                       { return is_op(long_at(0), Assembler::call_op); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  bool is_sethi()                      { return (is_op2(long_at(0), Assembler::sethi_op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
                                          && inv_rd(long_at(0)) != G0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  bool sets_cc() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    // conservative (returns true for some instructions that do not set the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    // the condition code, such as, "save".
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    // Does not return true for the deprecated tagged instructions, such as, TADDcc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    return (is_op(x, Assembler::arith_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
            (inv_op3(x) & Assembler::cc_bit_op3) == Assembler::cc_bit_op3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  bool is_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  bool is_zombie() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    return is_op3(x,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
                  VM_Version::v9_instructions_work() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
                    Assembler::ldsw_op3 : Assembler::lduw_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
                  Assembler::ldst_op)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
        && Assembler::inv_rs1(x) == G0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        && Assembler::inv_rd(x) == O7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  bool is_ic_miss_trap();       // Inline-cache uses a trap to detect a miss
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  bool is_return() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    // is it the output of MacroAssembler::ret or MacroAssembler::retl?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    const int pc_return_offset = 8; // see frame_sparc.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    return is_op3(x, Assembler::jmpl_op3, Assembler::arith_op)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        && (inv_rs1(x) == I7 || inv_rs1(x) == O7)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        && inv_immed(x) && inv_simm(x, 13) == pc_return_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        && inv_rd(x) == G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  bool is_int_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    // is it the output of MacroAssembler::b?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    return is_op2(x, Assembler::bp_op2) || is_op2(x, Assembler::br_op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  bool is_float_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    // is it the output of MacroAssembler::fb?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    return is_op2(x, Assembler::fbp_op2) || is_op2(x, Assembler::fb_op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  bool is_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    return is_int_jump() || is_float_jump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  bool is_cond_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    return (is_int_jump() && Assembler::inv_cond(x) != Assembler::always) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
           (is_float_jump() && Assembler::inv_cond(x) != Assembler::f_always);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  bool is_stack_bang() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    return is_op3(x, Assembler::stw_op3, Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      (inv_rd(x) == G0) && (inv_rs1(x) == SP) && (inv_rs2(x) == G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  bool is_prefetch() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    return is_op3(x, Assembler::prefetch_op3, Assembler::ldst_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  bool is_membar() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    return is_op3(x, Assembler::membar_op3, Assembler::arith_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      (inv_rd(x) == G0) && (inv_rs1(x) == O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  bool is_safepoint_poll() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    return is_op3(x, Assembler::ldx_op3,  Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    return is_op3(x, Assembler::lduw_op3, Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      (inv_rd(x) == G0) && (inv_immed(x) ? Assembler::inv_simm13(x) == 0 : inv_rs2(x) == G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  bool is_zero_test(Register &reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  bool is_load_store_with_small_offset(Register reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  static int rdpc_instruction()        { return Assembler::op(Assembler::arith_op ) | Assembler::op3(Assembler::rdreg_op3) | Assembler::u_field(5, 18, 14) | Assembler::rd(O7); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Temporary fix: in optimized mode, u_field is a macro for efficiency reasons (see Assembler::u_field) - needs to be fixed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  static int rdpc_instruction()        { return Assembler::op(Assembler::arith_op ) | Assembler::op3(Assembler::rdreg_op3) |            u_field(5, 18, 14) | Assembler::rd(O7); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  static int nop_instruction()         { return Assembler::op(Assembler::branch_op) | Assembler::op2(Assembler::sethi_op2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  static int illegal_instruction();    // the output of __ breakpoint_trap()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  static int call_instruction(address destination, address pc) { return Assembler::op(Assembler::call_op) | Assembler::wdisp((intptr_t)destination, (intptr_t)pc, 30); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  static int branch_instruction(Assembler::op2s op2val, Assembler::Condition c, bool a) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    return Assembler::op(Assembler::branch_op) | Assembler::op2(op2val) | Assembler::annul(a) | Assembler::cond(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  static int op3_instruction(Assembler::ops opval, Register rd, Assembler::op3s op3val, Register rs1, int simm13a) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    return Assembler::op(opval) | Assembler::rd(rd) | Assembler::op3(op3val) | Assembler::rs1(rs1) | Assembler::immed(true) | Assembler::simm(simm13a, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  static int sethi_instruction(Register rd, int imm22a) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    return Assembler::op(Assembler::branch_op) | Assembler::rd(rd) | Assembler::op2(Assembler::sethi_op2) | Assembler::hi22(imm22a);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  address  addr_at(int offset) const    { return address(this) + offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  int      long_at(int offset) const    { return *(int*)addr_at(offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void set_long_at(int offset, int i);      /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  void set_jlong_at(int offset, jlong i);   /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  void set_addr_at(int offset, address x);  /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  address next_instruction_address() const  { return addr_at(BytesPerInstWord); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  static bool is_op( int x, Assembler::ops opval)  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    return Assembler::inv_op(x) == opval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  static bool is_op2(int x, Assembler::op2s op2val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    return Assembler::inv_op(x) == Assembler::branch_op && Assembler::inv_op2(x) == op2val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  static bool is_op3(int x, Assembler::op3s op3val, Assembler::ops opval) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    return Assembler::inv_op(x) == opval && Assembler::inv_op3(x) == op3val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // utilities to help subclasses decode:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  static Register inv_rd(  int x ) { return Assembler::inv_rd( x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  static Register inv_rs1( int x ) { return Assembler::inv_rs1(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  static Register inv_rs2( int x ) { return Assembler::inv_rs2(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  static bool inv_immed( int x ) { return Assembler::inv_immed(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  static bool inv_annul( int x ) { return (Assembler::annul(true) & x) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  static int  inv_cond(  int x ) { return Assembler::inv_cond(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  static int inv_op(  int x ) { return Assembler::inv_op( x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  static int inv_op2( int x ) { return Assembler::inv_op2(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  static int inv_op3( int x ) { return Assembler::inv_op3(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  static int inv_simm(    int x, int nbits ) { return Assembler::inv_simm(x, nbits); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  static intptr_t inv_wdisp(   int x, int nbits ) { return Assembler::inv_wdisp(  x, 0, nbits); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  static intptr_t inv_wdisp16( int x )            { return Assembler::inv_wdisp16(x, 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  static int branch_destination_offset(int x) { return Assembler::branch_destination(x, 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  static int patch_branch_destination_offset(int dest_offset, int x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    return Assembler::patched_branch(dest_offset, x, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  void set_annul_bit() { set_long_at(0, long_at(0) | Assembler::annul(true)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // utility for checking if x is either of 2 small constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  static bool is_either(int x, int k1, int k2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    // return x == k1 || x == k2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    return (1 << x) & (1 << k1 | 1 << k2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // utility for checking overflow of signed instruction fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  static bool fits_in_simm(int x, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    // cf. Assembler::assert_signed_range()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    // return -(1 << nbits-1) <= x  &&  x < ( 1 << nbits-1),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    return (unsigned)(x + (1 << nbits-1)) < (unsigned)(1 << nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // set a signed immediate field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  static int set_simm(int insn, int imm, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    return (insn &~ Assembler::simm(-1, nbits)) | Assembler::simm(imm, nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // set a wdisp field (disp should be the difference of two addresses)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  static int set_wdisp(int insn, intptr_t disp, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    return (insn &~ Assembler::wdisp((intptr_t)-4, (intptr_t)0, nbits)) | Assembler::wdisp(disp, 0, nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  static int set_wdisp16(int insn, intptr_t disp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    return (insn &~ Assembler::wdisp16((intptr_t)-4, 0)) | Assembler::wdisp16(disp, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // get a simm13 field from an arithmetic or memory instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  static int get_simm13(int insn) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    assert(is_either(Assembler::inv_op(insn),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
                     Assembler::arith_op, Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
            (insn & Assembler::immed(true)), "must have a simm13 field");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    return Assembler::inv_simm(insn, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // set the simm13 field of an arithmetic or memory instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  static bool set_simm13(int insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    get_simm13(insn);           // tickle the assertion check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    return set_simm(insn, imm, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // combine the fields of a sethi stream (7 instructions ) and an add, jmp or ld/st
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  static intptr_t data64( address pc, int arith_insn ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    assert(is_op2(*(unsigned int *)pc, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    intptr_t hi = (intptr_t)gethi( (unsigned int *)pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    intptr_t lo = (intptr_t)get_simm13(arith_insn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    assert((unsigned)lo < (1 << 10), "offset field of set_oop must be 10 bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    return hi | lo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Regenerate the instruction sequence that performs the 64 bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // sethi.  This only does the sethi.  The disp field (bottom 10 bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // must be handled seperately.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  static void set_data64_sethi(address instaddr, intptr_t x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // combine the fields of a sethi/simm13 pair (simm13 = or, add, jmpl, ld/st)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  static int data32(int sethi_insn, int arith_insn) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    assert(is_op2(sethi_insn, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    int hi = Assembler::inv_hi22(sethi_insn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    int lo = get_simm13(arith_insn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    assert((unsigned)lo < (1 << 10), "offset field of set_oop must be 10 bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    return hi | lo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  static int set_data32_sethi(int sethi_insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    // note that Assembler::hi22 clips the low 10 bits for us
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    assert(is_op2(sethi_insn, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    return (sethi_insn &~ Assembler::hi22(-1)) | Assembler::hi22(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  static int set_data32_simm13(int arith_insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    get_simm13(arith_insn);             // tickle the assertion check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    int imm10 = Assembler::low10(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    return (arith_insn &~ Assembler::simm(-1, 13)) | Assembler::simm(imm10, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  static int low10(int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    return Assembler::low10(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // Perform the inverse of the LP64 Macroassembler::sethi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // routine.  Extracts the 54 bits of address from the instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // stream. This routine must agree with the sethi routine in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // assembler_inline_sparc.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  static address gethi( unsigned int *pc ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    uintptr_t adr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    // We first start out with the real sethi instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    assert(is_op2(*pc, Assembler::sethi_op2), "in gethi - must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    adr = (unsigned int)Assembler::inv_hi22( *(pc++) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    while ( i < 7 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
       // We're done if we hit a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
       if ( (int)*pc == nop_instruction() ) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
       assert ( Assembler::inv_op(*pc) == Assembler::arith_op, "in gethi - must be arith_op" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
       switch  ( Assembler::inv_op3(*pc) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
         case Assembler::xor_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
           adr ^= (intptr_t)get_simm13( *pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
           return ( (address)adr );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
         case Assembler::sll_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
           adr <<= ( *pc & 0x3f );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
         case Assembler::or_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
           adr |= (intptr_t)get_simm13( *pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
         default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
           assert ( 0, "in gethi - Should not reach here" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
       pc++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
       i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    return ( (address)adr );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  static void test() {}                 // override for testing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  inline friend NativeInstruction* nativeInstruction_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
inline NativeInstruction* nativeInstruction_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    NativeInstruction* inst = (NativeInstruction*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      inst->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    return inst;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// The NativeCall is an abstraction for accessing/manipulating native call imm32 instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// (used to manipulate inline caches, primitive & dll calls, etc.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
inline NativeCall* nativeCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
inline NativeCall* nativeCall_overwriting_at(address instr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
                                             address destination);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
inline NativeCall* nativeCall_before(address return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
class NativeCall: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    instruction_size                   = 8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    return_address_offset              = 8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    call_displacement_width            = 30,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    displacement_offset                = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    instruction_offset                 = 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  address return_address() const            { return addr_at(return_address_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  address destination() const               { return inv_wdisp(long_at(0), call_displacement_width) + instruction_address(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  address displacement_address() const      { return addr_at(displacement_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  void  set_destination(address dest)       { set_long_at(0, set_wdisp(long_at(0), dest - instruction_address(), call_displacement_width)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  void  set_destination_mt_safe(address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  void  verify_alignment() {} // do nothing on sparc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  static void  test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  friend inline NativeCall* nativeCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  friend NativeCall* nativeCall_overwriting_at(address instr, address destination = NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    // insert a "blank" call:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    NativeCall* call = (NativeCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    call->set_long_at(0 * BytesPerInstWord, call_instruction(destination, instr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    call->set_long_at(1 * BytesPerInstWord, nop_instruction());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    assert(call->addr_at(2 * BytesPerInstWord) - instr == instruction_size, "instruction size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    // check its structure now:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    assert(nativeCall_at(instr)->destination() == destination, "correct call destination");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  friend inline NativeCall* nativeCall_before(address return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    NativeCall* call = (NativeCall*)(return_address - return_address_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  static bool is_call_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    return nativeInstruction_at(instr)->is_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  static bool is_call_before(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    return nativeInstruction_at(instr - return_address_offset)->is_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  static bool is_call_to(address instr, address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    return nativeInstruction_at(instr)->is_call() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      nativeCall_at(instr)->destination() == target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  // MT-safe patching of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  static void insert(address code_pos, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    (void)nativeCall_overwriting_at(code_pos, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  static void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
inline NativeCall* nativeCall_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  NativeCall* call = (NativeCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
// The NativeFarCall is an abstraction for accessing/manipulating native call-anywhere
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
// instructions in the sparcv9 vm.  Used to call native methods which may be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
// anywhere in the address space, possibly out of reach of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
#ifndef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
// On 32-bit systems, a far call is the same as a near one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
class NativeFarCall;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
inline NativeFarCall* nativeFarCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
class NativeFarCall : public NativeCall {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  friend inline NativeFarCall* nativeFarCall_at(address instr) { return (NativeFarCall*)nativeCall_at(instr); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  friend NativeFarCall* nativeFarCall_overwriting_at(address instr, address destination = NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
                                                        { return (NativeFarCall*)nativeCall_overwriting_at(instr, destination); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  friend NativeFarCall* nativeFarCall_before(address return_address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
                                                        { return (NativeFarCall*)nativeCall_before(return_address); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
// The format of this extended-range call is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
//      jumpl_to addr, lreg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
//      == sethi %hi54(addr), O7 ;  jumpl O7, %lo10(addr), O7 ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
// That is, it is essentially the same as a NativeJump.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
class NativeFarCall;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
inline NativeFarCall* nativeFarCall_overwriting_at(address instr, address destination);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
inline NativeFarCall* nativeFarCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
class NativeFarCall: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    // instruction_size includes the delay slot instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    instruction_size                   = 9 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    return_address_offset              = 9 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    jmpl_offset                        = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    displacement_offset                = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    instruction_offset                 = 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  address return_address() const            { return addr_at(return_address_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  address destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    return (address) data64(addr_at(0), long_at(jmpl_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  address displacement_address() const      { return addr_at(displacement_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  void set_destination(address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  bool destination_is_compiled_verified_entry_point();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  static void  test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  friend inline NativeFarCall* nativeFarCall_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    NativeFarCall* call = (NativeFarCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  friend inline NativeFarCall* nativeFarCall_overwriting_at(address instr, address destination = NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    NativeFarCall* call = (NativeFarCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  friend NativeFarCall* nativeFarCall_before(address return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    NativeFarCall* call = (NativeFarCall*)(return_address - return_address_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  static bool is_call_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // MT-safe patching of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  static void insert(address code_pos, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    (void)nativeFarCall_overwriting_at(code_pos, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  static void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
#endif // _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
// An interface for accessing/manipulating native set_oop imm, reg instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
// (used to manipulate inlined data references, etc.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
//      set_oop imm, reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
//      == sethi %hi22(imm), reg ;  add reg, %lo10(imm), reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
class NativeMovConstReg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
inline NativeMovConstReg* nativeMovConstReg_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
class NativeMovConstReg: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    add_offset             = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    instruction_size       = 8 * BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    add_offset             = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    instruction_size       = 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  // (The [set_]data accessor respects oop_type relocs also.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  intptr_t data() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  void set_data(intptr_t x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  // report the destination register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  Register destination() { return inv_rd(long_at(sethi_offset)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  friend inline NativeMovConstReg* nativeMovConstReg_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    NativeMovConstReg* test = (NativeMovConstReg*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  friend NativeMovConstReg* nativeMovConstReg_before(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    NativeMovConstReg* test = (NativeMovConstReg*)(address - instruction_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
// An interface for accessing/manipulating native set_oop imm, reg instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
// (used to manipulate inlined data references, etc.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
//      set_oop imm, reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
//      == sethi %hi22(imm), reg; nop; add reg, %lo10(imm), reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
// Note that it is identical to NativeMovConstReg with the exception of a nop between the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
// sethi and the add.  The nop is required to be in the delay slot of the call instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
// which overwrites the sethi during patching.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
class NativeMovConstRegPatching;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
inline NativeMovConstRegPatching* nativeMovConstRegPatching_at(address address);class NativeMovConstRegPatching: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    nop_offset             = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    nop_offset             = sethi_offset + BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    add_offset             = nop_offset   + BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    instruction_size       = add_offset   + BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  // (The [set_]data accessor respects oop_type relocs also.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  int data() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  void  set_data(int x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  // report the destination register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  Register destination() { return inv_rd(long_at(sethi_offset)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  friend inline NativeMovConstRegPatching* nativeMovConstRegPatching_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    NativeMovConstRegPatching* test = (NativeMovConstRegPatching*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  friend NativeMovConstRegPatching* nativeMovConstRegPatching_before(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    NativeMovConstRegPatching* test = (NativeMovConstRegPatching*)(address - instruction_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
// An interface for accessing/manipulating native memory ops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
//      ld* [reg + offset], reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
//      st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
//      sethi %hi(imm), reg; add reg, %lo(imm), reg; ld* [reg1 + reg], reg2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
//      sethi %hi(imm), reg; add reg, %lo(imm), reg; st* reg2, [reg1 + reg]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
// Ops covered: {lds,ldu,st}{w,b,h}, {ld,st}{d,x}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
class NativeMovRegMem;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
inline NativeMovRegMem* nativeMovRegMem_at (address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
class NativeMovRegMem: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
    op3_mask_ld = 1 << Assembler::lduw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
                  1 << Assembler::ldub_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
                  1 << Assembler::lduh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
                  1 << Assembler::ldd_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
                  1 << Assembler::ldsw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
                  1 << Assembler::ldsb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
                  1 << Assembler::ldsh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
                  1 << Assembler::ldx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
    op3_mask_st = 1 << Assembler::stw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
                  1 << Assembler::stb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
                  1 << Assembler::sth_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
                  1 << Assembler::std_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
                  1 << Assembler::stx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    op3_ldst_int_limit = Assembler::ldf_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
    op3_mask_ldf = 1 << (Assembler::ldf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
                   1 << (Assembler::lddf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    op3_mask_stf = 1 << (Assembler::stf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
                   1 << (Assembler::stdf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    offset_width    = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    sethi_offset    = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
    add_offset      = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    add_offset      = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    ldst_offset     = add_offset + BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  bool is_immediate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    // check if instruction is ld* [reg + offset], reg or st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    int i0 = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    return (is_op(i0, Assembler::ldst_op));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  address instruction_address() const           { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  address next_instruction_address() const      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    return addr_at(is_immediate() ? 4 : (7 * BytesPerInstWord));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    return addr_at(is_immediate() ? 4 : 12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  intptr_t   offset() const                             {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
     return is_immediate()? inv_simm(long_at(0), offset_width) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
                            nativeMovConstReg_at(addr_at(0))->data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  void  set_offset(intptr_t x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    if (is_immediate()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
      guarantee(fits_in_simm(x, offset_width), "data block offset overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      set_long_at(0, set_simm(long_at(0), x, offset_width));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
      nativeMovConstReg_at(addr_at(0))->set_data(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  void  add_offset_in_bytes(intptr_t radd_offset)     {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
      set_offset (offset() + radd_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  void  copy_instruction_to(address new_instruction_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  void print ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  friend inline NativeMovRegMem* nativeMovRegMem_at (address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    NativeMovRegMem* test = (NativeMovRegMem*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
// An interface for accessing/manipulating native memory ops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
//      ld* [reg + offset], reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
//      st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
//      sethi %hi(imm), reg; nop; add reg, %lo(imm), reg; ld* [reg1 + reg], reg2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
//      sethi %hi(imm), reg; nop; add reg, %lo(imm), reg; st* reg2, [reg1 + reg]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
// Ops covered: {lds,ldu,st}{w,b,h}, {ld,st}{d,x}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
// Note that it is identical to NativeMovRegMem with the exception of a nop between the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
// sethi and the add.  The nop is required to be in the delay slot of the call instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
// which overwrites the sethi during patching.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
class NativeMovRegMemPatching;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
inline NativeMovRegMemPatching* nativeMovRegMemPatching_at (address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
class NativeMovRegMemPatching: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
    op3_mask_ld = 1 << Assembler::lduw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
                  1 << Assembler::ldub_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
                  1 << Assembler::lduh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
                  1 << Assembler::ldd_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
                  1 << Assembler::ldsw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
                  1 << Assembler::ldsb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
                  1 << Assembler::ldsh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
                  1 << Assembler::ldx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    op3_mask_st = 1 << Assembler::stw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
                  1 << Assembler::stb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
                  1 << Assembler::sth_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
                  1 << Assembler::std_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
                  1 << Assembler::stx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    op3_ldst_int_limit = Assembler::ldf_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    op3_mask_ldf = 1 << (Assembler::ldf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
                   1 << (Assembler::lddf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    op3_mask_stf = 1 << (Assembler::stf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
                   1 << (Assembler::stdf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    offset_width    = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
    sethi_offset    = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
    nop_offset      = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    nop_offset      = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
    add_offset      = nop_offset + BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    ldst_offset     = add_offset + BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  bool is_immediate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
    // check if instruction is ld* [reg + offset], reg or st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    int i0 = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    return (is_op(i0, Assembler::ldst_op));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  address instruction_address() const           { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  address next_instruction_address() const      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
    return addr_at(is_immediate()? 4 : 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  int   offset() const                          {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
     return is_immediate()? inv_simm(long_at(0), offset_width) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
                            nativeMovConstRegPatching_at(addr_at(0))->data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  void  set_offset(int x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
    if (is_immediate()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
      guarantee(fits_in_simm(x, offset_width), "data block offset overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
      set_long_at(0, set_simm(long_at(0), x, offset_width));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
      nativeMovConstRegPatching_at(addr_at(0))->set_data(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  void  add_offset_in_bytes(intptr_t radd_offset)     {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
      set_offset (offset() + radd_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  void  copy_instruction_to(address new_instruction_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  void print ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  friend inline NativeMovRegMemPatching* nativeMovRegMemPatching_at (address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    NativeMovRegMemPatching* test = (NativeMovRegMemPatching*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
// An interface for accessing/manipulating native jumps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
//      jump_to addr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
//      == sethi %hi22(addr), temp ;  jumpl reg, %lo10(addr), G0 ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
//      jumpl_to addr, lreg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
//      == sethi %hi22(addr), temp ;  jumpl reg, %lo10(addr), lreg ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
class NativeJump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
inline NativeJump* nativeJump_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
class NativeJump: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
  void guarantee_displacement(int disp, int width) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    guarantee(fits_in_simm(disp, width + 2), "branch displacement overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
    jmpl_offset            = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
    instruction_size       = 9 * BytesPerInstWord  // includes delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    jmpl_offset            = 1 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    instruction_size       = 3 * BytesPerInstWord  // includes delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  address jump_destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    return (address) data64(instruction_address(), long_at(jmpl_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  void set_jump_destination(address dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    set_data64_sethi( instruction_address(), (intptr_t)dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    set_long_at(jmpl_offset,  set_data32_simm13( long_at(jmpl_offset),  (intptr_t)dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  address jump_destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    return (address) data32(long_at(sethi_offset), long_at(jmpl_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  void set_jump_destination(address dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
    set_long_at(sethi_offset, set_data32_sethi(  long_at(sethi_offset), (intptr_t)dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    set_long_at(jmpl_offset,  set_data32_simm13( long_at(jmpl_offset),  (intptr_t)dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  friend inline NativeJump* nativeJump_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    NativeJump* jump = (NativeJump*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
      jump->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    return jump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  // Unit testing stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  // Insertion of native jump instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  static void insert(address code_pos, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  // MT-safe insertion of native jump at verified method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  static void check_verified_entry_alignment(address entry, address verified_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    // nothing to do for sparc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
  static void patch_verified_entry(address entry, address verified_entry, address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
// Despite the name, handles only simple branches.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
class NativeGeneralJump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
inline NativeGeneralJump* nativeGeneralJump_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
class NativeGeneralJump: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    instruction_size                   = 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  address jump_destination()    const       { return addr_at(0) + branch_destination_offset(long_at(0)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  void set_jump_destination(address dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    int patched_instr = patch_branch_destination_offset(dest - addr_at(0), long_at(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
    set_long_at(0, patched_instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  void set_annul() { set_annul_bit(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  NativeInstruction *delay_slot_instr() { return nativeInstruction_at(addr_at(4));}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  void fill_delay_slot(int instr) { set_long_at(4, instr);}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
  Assembler::Condition condition() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    return (Assembler::Condition) Assembler::inv_cond(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  friend inline NativeGeneralJump* nativeGeneralJump_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    NativeGeneralJump* jump = (NativeGeneralJump*)(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
      jump->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
    return jump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  // Insertion of native general jump instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  static void insert_unconditional(address code_pos, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  static void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
class NativeIllegalInstruction: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    instruction_size            =    4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  // Insert illegal opcode as specific address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  static void insert(address code_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
};