src/hotspot/cpu/sparc/nativeInst_sparc.hpp
author mdoerr
Tue, 05 Nov 2019 11:53:46 +0100
changeset 58932 8623f75be895
parent 58050 9fba708740d6
permissions -rw-r--r--
8233081: C1: PatchingStub for field access copies too much Reviewed-by: thartmann, dlong
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
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: 2131
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    25
#ifndef CPU_SPARC_NATIVEINST_SPARC_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    26
#define CPU_SPARC_NATIVEINST_SPARC_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
    28
#include "asm/macroAssembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/icache.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// We have interface for the following instructions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// - NativeInstruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// - - NativeCall
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// - - NativeFarCall
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// - - NativeMovConstReg
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// - - NativeMovConstRegPatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// - - NativeMovRegMem
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// - - NativeJump
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// - - NativeGeneralJump
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// - - NativeIllegalInstruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// The base class for different kinds of native instruction abstractions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// Provides the primitive operations to manipulate code relative to this.
49364
601146c66cad 8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents: 47216
diff changeset
    44
class NativeInstruction {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  friend class Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    nop_instruction_size        =    4
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  bool is_nop()                        { return long_at(0) == nop_instruction(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  bool is_call()                       { return is_op(long_at(0), Assembler::call_op); }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
    54
  bool is_call_reg()                   { return is_op(long_at(0), Assembler::arith_op); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  bool is_sethi()                      { return (is_op2(long_at(0), Assembler::sethi_op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
                                          && inv_rd(long_at(0)) != G0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  bool sets_cc() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    // conservative (returns true for some instructions that do not set the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    // the condition code, such as, "save".
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    // Does not return true for the deprecated tagged instructions, such as, TADDcc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    return (is_op(x, Assembler::arith_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
            (inv_op3(x) & Assembler::cc_bit_op3) == Assembler::cc_bit_op3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  bool is_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  bool is_zombie() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    int x = long_at(0);
46596
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46381
diff changeset
    69
    return (is_op3(x, Assembler::ldsw_op3, Assembler::ldst_op) &&
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46381
diff changeset
    70
            inv_rs1(x) == G0 && inv_rd(x) == O7);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  bool is_ic_miss_trap();       // Inline-cache uses a trap to detect a miss
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool is_return() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    // is it the output of MacroAssembler::ret or MacroAssembler::retl?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    const int pc_return_offset = 8; // see frame_sparc.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    return is_op3(x, Assembler::jmpl_op3, Assembler::arith_op)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        && (inv_rs1(x) == I7 || inv_rs1(x) == O7)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
        && inv_immed(x) && inv_simm(x, 13) == pc_return_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        && inv_rd(x) == G0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool is_int_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    // is it the output of MacroAssembler::b?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    return is_op2(x, Assembler::bp_op2) || is_op2(x, Assembler::br_op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  bool is_float_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    // is it the output of MacroAssembler::fb?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    return is_op2(x, Assembler::fbp_op2) || is_op2(x, Assembler::fb_op2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  bool is_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    return is_int_jump() || is_float_jump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  bool is_cond_jump() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    return (is_int_jump() && Assembler::inv_cond(x) != Assembler::always) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
           (is_float_jump() && Assembler::inv_cond(x) != Assembler::f_always);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  bool is_stack_bang() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    return is_op3(x, Assembler::stw_op3, Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      (inv_rd(x) == G0) && (inv_rs1(x) == SP) && (inv_rs2(x) == G3_scratch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  bool is_prefetch() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    return is_op3(x, Assembler::prefetch_op3, Assembler::ldst_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  bool is_membar() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    return is_op3(x, Assembler::membar_op3, Assembler::arith_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      (inv_rd(x) == G0) && (inv_rs1(x) == O7);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  bool is_safepoint_poll() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    return is_op3(x, Assembler::ldx_op3,  Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      (inv_rd(x) == G0) && (inv_immed(x) ? Assembler::inv_simm13(x) == 0 : inv_rs2(x) == G0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  bool is_zero_test(Register &reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_load_store_with_small_offset(Register reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  static int nop_instruction()         { return Assembler::op(Assembler::branch_op) | Assembler::op2(Assembler::sethi_op2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  static int illegal_instruction();    // the output of __ breakpoint_trap()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  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
   131
46596
a7c9706d25a9 8144448: Avoid placing CTI immediately following or preceding RDPC instruction
neliasso
parents: 46381
diff changeset
   132
protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  address  addr_at(int offset) const    { return address(this) + offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  int      long_at(int offset) const    { return *(int*)addr_at(offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void set_long_at(int offset, int i);      /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void set_jlong_at(int offset, jlong i);   /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void set_addr_at(int offset, address x);  /* deals with I-cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  address next_instruction_address() const  { return addr_at(BytesPerInstWord); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  static bool is_op( int x, Assembler::ops opval)  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    return Assembler::inv_op(x) == opval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  static bool is_op2(int x, Assembler::op2s op2val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    return Assembler::inv_op(x) == Assembler::branch_op && Assembler::inv_op2(x) == op2val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  static bool is_op3(int x, Assembler::op3s op3val, Assembler::ops opval) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    return Assembler::inv_op(x) == opval && Assembler::inv_op3(x) == op3val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // utilities to help subclasses decode:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  static Register inv_rd(  int x ) { return Assembler::inv_rd( x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  static Register inv_rs1( int x ) { return Assembler::inv_rs1(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  static Register inv_rs2( int x ) { return Assembler::inv_rs2(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static bool inv_immed( int x ) { return Assembler::inv_immed(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  static bool inv_annul( int x ) { return (Assembler::annul(true) & x) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  static int  inv_cond(  int x ) { return Assembler::inv_cond(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  static int inv_op(  int x ) { return Assembler::inv_op( x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  static int inv_op2( int x ) { return Assembler::inv_op2(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  static int inv_op3( int x ) { return Assembler::inv_op3(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  static int inv_simm(    int x, int nbits ) { return Assembler::inv_simm(x, nbits); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  static intptr_t inv_wdisp(   int x, int nbits ) { return Assembler::inv_wdisp(  x, 0, nbits); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  static intptr_t inv_wdisp16( int x )            { return Assembler::inv_wdisp16(x, 0); }
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
   168
  static int branch_destination_offset(int x) { return MacroAssembler::branch_destination(x, 0); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  static int patch_branch_destination_offset(int dest_offset, int x) {
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
   170
    return MacroAssembler::patched_branch(dest_offset, x, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // utility for checking if x is either of 2 small constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  static bool is_either(int x, int k1, int k2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // return x == k1 || x == k2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return (1 << x) & (1 << k1 | 1 << k2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // utility for checking overflow of signed instruction fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  static bool fits_in_simm(int x, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    // cf. Assembler::assert_signed_range()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    // return -(1 << nbits-1) <= x  &&  x < ( 1 << nbits-1),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    return (unsigned)(x + (1 << nbits-1)) < (unsigned)(1 << nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // set a signed immediate field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  static int set_simm(int insn, int imm, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    return (insn &~ Assembler::simm(-1, nbits)) | Assembler::simm(imm, nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // set a wdisp field (disp should be the difference of two addresses)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  static int set_wdisp(int insn, intptr_t disp, int nbits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    return (insn &~ Assembler::wdisp((intptr_t)-4, (intptr_t)0, nbits)) | Assembler::wdisp(disp, 0, nbits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  static int set_wdisp16(int insn, intptr_t disp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    return (insn &~ Assembler::wdisp16((intptr_t)-4, 0)) | Assembler::wdisp16(disp, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // get a simm13 field from an arithmetic or memory instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  static int get_simm13(int insn) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    assert(is_either(Assembler::inv_op(insn),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
                     Assembler::arith_op, Assembler::ldst_op) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
            (insn & Assembler::immed(true)), "must have a simm13 field");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    return Assembler::inv_simm(insn, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // set the simm13 field of an arithmetic or memory instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  static bool set_simm13(int insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    get_simm13(insn);           // tickle the assertion check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    return set_simm(insn, imm, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  // combine the fields of a sethi stream (7 instructions ) and an add, jmp or ld/st
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  static intptr_t data64( address pc, int arith_insn ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    assert(is_op2(*(unsigned int *)pc, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    intptr_t hi = (intptr_t)gethi( (unsigned int *)pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    intptr_t lo = (intptr_t)get_simm13(arith_insn);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   219
    assert((unsigned)lo < (1 << 10), "offset field of set_metadata must be 10 bits");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    return hi | lo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // Regenerate the instruction sequence that performs the 64 bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // sethi.  This only does the sethi.  The disp field (bottom 10 bits)
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 670
diff changeset
   225
  // must be handled separately.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  static void set_data64_sethi(address instaddr, intptr_t x);
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 7397
diff changeset
   227
  static void verify_data64_sethi(address instaddr, intptr_t x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // combine the fields of a sethi/simm13 pair (simm13 = or, add, jmpl, ld/st)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  static int data32(int sethi_insn, int arith_insn) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    assert(is_op2(sethi_insn, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    int hi = Assembler::inv_hi22(sethi_insn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    int lo = get_simm13(arith_insn);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   234
    assert((unsigned)lo < (1 << 10), "offset field of set_metadata must be 10 bits");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    return hi | lo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  static int set_data32_sethi(int sethi_insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    // note that Assembler::hi22 clips the low 10 bits for us
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    assert(is_op2(sethi_insn, Assembler::sethi_op2), "must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    return (sethi_insn &~ Assembler::hi22(-1)) | Assembler::hi22(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  static int set_data32_simm13(int arith_insn, int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    get_simm13(arith_insn);             // tickle the assertion check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    int imm10 = Assembler::low10(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    return (arith_insn &~ Assembler::simm(-1, 13)) | Assembler::simm(imm10, 13);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  static int low10(int imm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    return Assembler::low10(imm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  // Perform the inverse of the LP64 Macroassembler::sethi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // routine.  Extracts the 54 bits of address from the instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // stream. This routine must agree with the sethi routine in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // assembler_inline_sparc.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  static address gethi( unsigned int *pc ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    uintptr_t adr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    // We first start out with the real sethi instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    assert(is_op2(*pc, Assembler::sethi_op2), "in gethi - must be sethi");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    adr = (unsigned int)Assembler::inv_hi22( *(pc++) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    while ( i < 7 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
       // We're done if we hit a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
       if ( (int)*pc == nop_instruction() ) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
       assert ( Assembler::inv_op(*pc) == Assembler::arith_op, "in gethi - must be arith_op" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
       switch  ( Assembler::inv_op3(*pc) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
         case Assembler::xor_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
           adr ^= (intptr_t)get_simm13( *pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
           return ( (address)adr );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
         case Assembler::sll_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
           adr <<= ( *pc & 0x3f );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
         case Assembler::or_op3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
           adr |= (intptr_t)get_simm13( *pc );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
         default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
           assert ( 0, "in gethi - Should not reach here" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
       pc++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
       i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    return ( (address)adr );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  static void test() {}                 // override for testing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  inline friend NativeInstruction* nativeInstruction_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
inline NativeInstruction* nativeInstruction_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    NativeInstruction* inst = (NativeInstruction*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      inst->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return inst;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
//-----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// The NativeCall is an abstraction for accessing/manipulating native call imm32 instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// (used to manipulate inline caches, primitive & dll calls, etc.)
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
   314
class NativeCall;
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
   315
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
inline NativeCall* nativeCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
inline NativeCall* nativeCall_overwriting_at(address instr,
58050
9fba708740d6 8230708: Hotspot fails to build on linux-sparc with gcc-9
glaubitz
parents: 53244
diff changeset
   318
                                             address destination = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
inline NativeCall* nativeCall_before(address return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
class NativeCall: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    instruction_size                   = 8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    return_address_offset              = 8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    call_displacement_width            = 30,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    displacement_offset                = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    instruction_offset                 = 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  address return_address() const            { return addr_at(return_address_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  address destination() const               { return inv_wdisp(long_at(0), call_displacement_width) + instruction_address(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  address displacement_address() const      { return addr_at(displacement_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  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
   336
  void  set_destination_mt_safe(address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  void  verify_alignment() {} // do nothing on sparc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  static void  test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  friend inline NativeCall* nativeCall_at(address instr);
58050
9fba708740d6 8230708: Hotspot fails to build on linux-sparc with gcc-9
glaubitz
parents: 53244
diff changeset
   347
  friend NativeCall* nativeCall_overwriting_at(address instr, address destination) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    // insert a "blank" call:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    NativeCall* call = (NativeCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    call->set_long_at(0 * BytesPerInstWord, call_instruction(destination, instr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    call->set_long_at(1 * BytesPerInstWord, nop_instruction());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    assert(call->addr_at(2 * BytesPerInstWord) - instr == instruction_size, "instruction size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    // check its structure now:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    assert(nativeCall_at(instr)->destination() == destination, "correct call destination");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  friend inline NativeCall* nativeCall_before(address return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    NativeCall* call = (NativeCall*)(return_address - return_address_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  static bool is_call_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    return nativeInstruction_at(instr)->is_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  static bool is_call_before(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    return nativeInstruction_at(instr - return_address_offset)->is_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  static bool is_call_to(address instr, address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    return nativeInstruction_at(instr)->is_call() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      nativeCall_at(instr)->destination() == target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  // MT-safe patching of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  static void insert(address code_pos, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    (void)nativeCall_overwriting_at(code_pos, entry);
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 void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
inline NativeCall* nativeCall_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  NativeCall* call = (NativeCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   394
class NativeCallReg: public NativeInstruction {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   395
 public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   396
  enum Sparc_specific_constants {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   397
    instruction_size      = 8,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   398
    return_address_offset = 8,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   399
    instruction_offset    = 0
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   400
  };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   401
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   402
  address next_instruction_address() const {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   403
    return addr_at(instruction_size);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   404
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   405
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 28947
diff changeset
   406
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
// The NativeFarCall is an abstraction for accessing/manipulating native call-anywhere
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
// instructions in the sparcv9 vm.  Used to call native methods which may be loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
// anywhere in the address space, possibly out of reach of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
// The format of this extended-range call is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
//      jumpl_to addr, lreg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
//      == sethi %hi54(addr), O7 ;  jumpl O7, %lo10(addr), O7 ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
// That is, it is essentially the same as a NativeJump.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
class NativeFarCall;
58050
9fba708740d6 8230708: Hotspot fails to build on linux-sparc with gcc-9
glaubitz
parents: 53244
diff changeset
   416
inline NativeFarCall* nativeFarCall_overwriting_at(address instr, address destination = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
inline NativeFarCall* nativeFarCall_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
class NativeFarCall: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    // instruction_size includes the delay slot instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    instruction_size                   = 9 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    return_address_offset              = 9 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    jmpl_offset                        = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    displacement_offset                = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    instruction_offset                 = 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  address return_address() const            { return addr_at(return_address_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  address destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    return (address) data64(addr_at(0), long_at(jmpl_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  address displacement_address() const      { return addr_at(displacement_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  void set_destination(address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  bool destination_is_compiled_verified_entry_point();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  static void  test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  friend inline NativeFarCall* nativeFarCall_at(address instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    NativeFarCall* call = (NativeFarCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
58050
9fba708740d6 8230708: Hotspot fails to build on linux-sparc with gcc-9
glaubitz
parents: 53244
diff changeset
   455
  friend inline NativeFarCall* nativeFarCall_overwriting_at(address instr, address destination) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    NativeFarCall* call = (NativeFarCall*)instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  friend NativeFarCall* nativeFarCall_before(address return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    NativeFarCall* call = (NativeFarCall*)(return_address - return_address_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
      call->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    return call;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  static bool is_call_at(address instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  // MT-safe patching of a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  static void insert(address code_pos, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    (void)nativeFarCall_overwriting_at(code_pos, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  static void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   479
// An interface for accessing/manipulating 32 bit native set_metadata imm, reg instructions
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   480
// (used to manipulate inlined data references, etc.)
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   481
//      set_metadata imm, reg
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   482
//      == sethi %hi22(imm), reg ;  add reg, %lo10(imm), reg
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   483
class NativeMovConstReg32;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   484
inline NativeMovConstReg32* nativeMovConstReg32_at(address address);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   485
class NativeMovConstReg32: public NativeInstruction {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   486
 public:
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   487
  enum Sparc_specific_constants {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   488
    sethi_offset           = 0,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   489
    add_offset             = 4,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   490
    instruction_size       = 8
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   491
  };
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   492
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   493
  address instruction_address() const       { return addr_at(0); }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   494
  address next_instruction_address() const  { return addr_at(instruction_size); }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   495
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   496
  // (The [set_]data accessor respects oop_type relocs also.)
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   497
  intptr_t data() const;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   498
  void set_data(intptr_t x);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   499
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   500
  // report the destination register
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   501
  Register destination() { return inv_rd(long_at(sethi_offset)); }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   502
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   503
  void  verify();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   504
  void  print();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   505
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   506
  // unit test stuff
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   507
  static void test();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   508
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   509
  // Creation
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   510
  friend inline NativeMovConstReg32* nativeMovConstReg32_at(address address) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   511
    NativeMovConstReg32* test = (NativeMovConstReg32*)address;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   512
    #ifdef ASSERT
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   513
      test->verify();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   514
    #endif
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   515
    return test;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   516
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   517
};
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   518
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   519
// An interface for accessing/manipulating native set_metadata imm, reg instructions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
// (used to manipulate inlined data references, etc.)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   521
//      set_metadata imm, reg
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
//      == sethi %hi22(imm), reg ;  add reg, %lo10(imm), reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
class NativeMovConstReg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
inline NativeMovConstReg* nativeMovConstReg_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
class NativeMovConstReg: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    add_offset             = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    instruction_size       = 8 * BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  // (The [set_]data accessor respects oop_type relocs also.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  intptr_t data() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  void set_data(intptr_t x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  // report the destination register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  Register destination() { return inv_rd(long_at(sethi_offset)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  friend inline NativeMovConstReg* nativeMovConstReg_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
    NativeMovConstReg* test = (NativeMovConstReg*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  friend NativeMovConstReg* nativeMovConstReg_before(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    NativeMovConstReg* test = (NativeMovConstReg*)(address - instruction_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   570
// An interface for accessing/manipulating native set_metadata imm, reg instructions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
// (used to manipulate inlined data references, etc.)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
   572
//      set_metadata imm, reg
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
//      == sethi %hi22(imm), reg; nop; add reg, %lo10(imm), reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
// Note that it is identical to NativeMovConstReg with the exception of a nop between the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
// 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
   577
// which overwrites the sethi during patching.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
class NativeMovConstRegPatching;
58932
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   579
inline NativeMovConstRegPatching* nativeMovConstRegPatching_at(address address);
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   580
class NativeMovConstRegPatching: public NativeInstruction {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    nop_offset             = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    add_offset             = nop_offset   + BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    instruction_size       = add_offset   + BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  // (The [set_]data accessor respects oop_type relocs also.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  int data() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  void  set_data(int x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  // report the destination register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  Register destination() { return inv_rd(long_at(sethi_offset)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  void  verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  void  print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  friend inline NativeMovConstRegPatching* nativeMovConstRegPatching_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    NativeMovConstRegPatching* test = (NativeMovConstRegPatching*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    return test;
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
  friend NativeMovConstRegPatching* nativeMovConstRegPatching_before(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    NativeMovConstRegPatching* test = (NativeMovConstRegPatching*)(address - instruction_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
// An interface for accessing/manipulating native memory ops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
//      ld* [reg + offset], reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
//      st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
//      sethi %hi(imm), reg; add reg, %lo(imm), reg; ld* [reg1 + reg], reg2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
//      sethi %hi(imm), reg; add reg, %lo(imm), reg; st* reg2, [reg1 + reg]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
// Ops covered: {lds,ldu,st}{w,b,h}, {ld,st}{d,x}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
class NativeMovRegMem;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
inline NativeMovRegMem* nativeMovRegMem_at (address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
class NativeMovRegMem: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    op3_mask_ld = 1 << Assembler::lduw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
                  1 << Assembler::ldub_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
                  1 << Assembler::lduh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
                  1 << Assembler::ldd_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
                  1 << Assembler::ldsw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
                  1 << Assembler::ldsb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
                  1 << Assembler::ldsh_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
                  1 << Assembler::ldx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    op3_mask_st = 1 << Assembler::stw_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
                  1 << Assembler::stb_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
                  1 << Assembler::sth_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
                  1 << Assembler::std_op3 |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
                  1 << Assembler::stx_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    op3_ldst_int_limit = Assembler::ldf_op3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    op3_mask_ldf = 1 << (Assembler::ldf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
                   1 << (Assembler::lddf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    op3_mask_stf = 1 << (Assembler::stf_op3  - op3_ldst_int_limit) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
                   1 << (Assembler::stdf_op3 - op3_ldst_int_limit),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    offset_width    = 13,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    sethi_offset    = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    add_offset      = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    ldst_offset     = add_offset + BytesPerInstWord
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  bool is_immediate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    // check if instruction is ld* [reg + offset], reg or st* reg, [reg + offset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    int i0 = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    return (is_op(i0, Assembler::ldst_op));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
58932
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   668
  address instruction_address() const { return addr_at(0); }
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   669
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   670
  int num_bytes_to_end_of_patch() const {
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   671
    return is_immediate()? BytesPerInstWord :
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   672
                           NativeMovConstReg::instruction_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  }
58932
8623f75be895 8233081: C1: PatchingStub for field access copies too much
mdoerr
parents: 58050
diff changeset
   674
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  intptr_t   offset() const                             {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
     return is_immediate()? inv_simm(long_at(0), offset_width) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
                            nativeMovConstReg_at(addr_at(0))->data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  void  set_offset(intptr_t x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    if (is_immediate()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
      guarantee(fits_in_simm(x, offset_width), "data block offset overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      set_long_at(0, set_simm(long_at(0), x, offset_width));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      nativeMovConstReg_at(addr_at(0))->set_data(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  void  add_offset_in_bytes(intptr_t radd_offset)     {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
      set_offset (offset() + radd_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  void print ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  // unit test stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  friend inline NativeMovRegMem* nativeMovRegMem_at (address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    NativeMovRegMem* test = (NativeMovRegMem*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
      test->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    return test;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
// An interface for accessing/manipulating native jumps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
//      jump_to addr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
//      == sethi %hi22(addr), temp ;  jumpl reg, %lo10(addr), G0 ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
//      jumpl_to addr, lreg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
//      == sethi %hi22(addr), temp ;  jumpl reg, %lo10(addr), lreg ;  <delay>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
class NativeJump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
inline NativeJump* nativeJump_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
class NativeJump: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  void guarantee_displacement(int disp, int width) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
    guarantee(fits_in_simm(disp, width + 2), "branch displacement overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
    sethi_offset           = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    jmpl_offset            = 7 * BytesPerInstWord,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
    instruction_size       = 9 * BytesPerInstWord  // includes delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  address next_instruction_address() const  { return addr_at(instruction_size); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  address jump_destination() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
    return (address) data64(instruction_address(), long_at(jmpl_offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  void set_jump_destination(address dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    set_data64_sethi( instruction_address(), (intptr_t)dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    set_long_at(jmpl_offset,  set_data32_simm13( long_at(jmpl_offset),  (intptr_t)dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  friend inline NativeJump* nativeJump_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    NativeJump* jump = (NativeJump*)address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
      jump->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
    return jump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  // Unit testing stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  static void test();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  // Insertion of native jump instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  static void insert(address code_pos, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  // MT-safe insertion of native jump at verified method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  static void check_verified_entry_alignment(address entry, address verified_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
    // nothing to do for sparc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  static void patch_verified_entry(address entry, address verified_entry, address dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
// Despite the name, handles only simple branches.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
class NativeGeneralJump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
inline NativeGeneralJump* nativeGeneralJump_at(address address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
class NativeGeneralJump: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    instruction_size                   = 8
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  address instruction_address() const       { return addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  address jump_destination()    const       { return addr_at(0) + branch_destination_offset(long_at(0)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  void set_jump_destination(address dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    int patched_instr = patch_branch_destination_offset(dest - addr_at(0), long_at(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    set_long_at(0, patched_instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  NativeInstruction *delay_slot_instr() { return nativeInstruction_at(addr_at(4));}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  void fill_delay_slot(int instr) { set_long_at(4, instr);}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  Assembler::Condition condition() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    int x = long_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    return (Assembler::Condition) Assembler::inv_cond(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  friend inline NativeGeneralJump* nativeGeneralJump_at(address address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    NativeGeneralJump* jump = (NativeGeneralJump*)(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
      jump->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    return jump;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  // Insertion of native general jump instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  static void insert_unconditional(address code_pos, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  static void replace_mt_safe(address instr_addr, address code_buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
class NativeIllegalInstruction: public NativeInstruction {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  enum Sparc_specific_constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    instruction_size            =    4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  // Insert illegal opcode as specific address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  static void insert(address code_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   813
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
   814
#endif // CPU_SPARC_NATIVEINST_SPARC_HPP