src/hotspot/cpu/s390/relocInfo_s390.hpp
changeset 47216 71c04702a3d5
parent 42065 6032b31e3719
child 48486 bda5211e7876
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2016 SAP SE. All rights reserved.
       
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5  *
       
     6  * This code is free software; you can redistribute it and/or modify it
       
     7  * under the terms of the GNU General Public License version 2 only, as
       
     8  * published by the Free Software Foundation.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    21  * or visit www.oracle.com if you need additional information or have any
       
    22  * questions.
       
    23  *
       
    24  */
       
    25 
       
    26 #ifndef CPU_S390_VM_RELOCINFO_S390_HPP
       
    27 #define CPU_S390_VM_RELOCINFO_S390_HPP
       
    28 
       
    29 //----------------------------
       
    30 //  relocInfo layout
       
    31 //----------------------------
       
    32 
       
    33 // This description should be contained in code/relocInfo.hpp
       
    34 // but was put here to minimize shared code diffs.
       
    35 
       
    36 // Relocation information for a nmethod is stored in compressed
       
    37 // form in an array of element type short int (16 bits).
       
    38 // Each array element constitutes one relocInfo record.
       
    39 // The layout of one such record is described here.
       
    40 
       
    41 // +------------+---+---+------------------------------+
       
    42 // |    type    |  fmt  |      offset/offset_unit      |
       
    43 // +------------+---+---+------------------------------+
       
    44 //
       
    45 // |<-- value_width (16) ----------------------------->|
       
    46 // |<type_width>|<-- nontype_width (12) -------------->|
       
    47 //      (4)
       
    48 // |            |<--+-->|<-- offset_width (10) ------->|
       
    49 //              /       \
       
    50 //             /   (2)   \
       
    51 //            /<--format->\
       
    52 //            |    width  |
       
    53 
       
    54 
       
    55 // only for type == data_prefix_tag:
       
    56 // +------------+---+---+------------------------------+
       
    57 // |    type    |   |              data                |
       
    58 // +------------+---+---+------------------------------+
       
    59 // |     15     |<->|<-- datalen_width (11) ---------->|
       
    60 //                |
       
    61 //                +--datalen_tag (1)
       
    62 
       
    63 // relocType
       
    64 //   The type field holds a value of relocType (which is
       
    65 //   an enum of all possible relocation types). Currently,
       
    66 //   there are 16 distinct relocation types, requiring
       
    67 //   type_width to be (at least) 4.
       
    68 // relocFormat
       
    69 //   The format field holds a value of relocFormat (which is
       
    70 //   an enum of all possible relocation formats). Currently,
       
    71 //   there are 4 distinct relocation formats, requiring
       
    72 //   format_width to be (at least) 2.
       
    73 // offset
       
    74 //   Each relocInfo is related to one specific address in the CodeBlob.
       
    75 //   The address always points to the first byte of the target instruction.
       
    76 //   It does NOT refer directly to the relocation subfield or embedded constant.
       
    77 //   offset contains the distance of this relocInfo from the previous one.
       
    78 //   offset is scaled by offset_unit (the platform-specific instruction
       
    79 //   alignment requirement) to maximize the encodable distance.
       
    80 //   To obtain the absolute address in the CodeBlob the relocInfo is
       
    81 //   related to, you have to iterate over all relocInfos from the
       
    82 //   beginning, and then use RelocIterator::addr() to get the address.
       
    83 
       
    84 // relocType == data_prefix_tag
       
    85 //   These are relocInfo records containing inline data that belongs to
       
    86 //   the next non-data relocInfo record. Usage of that inline data is
       
    87 //   specific and private to that relocInfo record.
       
    88 //   For details refer to code/relocInfo.hpp
       
    89 
       
    90 
       
    91   // machine-dependent parts of class relocInfo
       
    92  private:
       
    93   enum {
       
    94     // Instructions are HW (2-byte) aligned on z/Architecture.
       
    95     offset_unit        =  2,
       
    96 
       
    97     // Encodes Assembler::disp32_operand vs. Assembler::imm64_operand.
       
    98     // (Assembler::call32_operand is used on call instructions only.)
       
    99     format_width       =  2
       
   100   };
       
   101 
       
   102  public:
       
   103 
       
   104   enum relocFormat {
       
   105     no_format           = 0,
       
   106     uncompressed_format = 0,  // Relocation is for a regular oop.
       
   107     compressed_format   = 1,  // Relocation is for a narrow (compressed) oop or klass.
       
   108                               // Similar to relocInfo::narrow_oop_in_const.
       
   109     pcrel_addr_format   = 2,  // Relocation is for the target LOCATION of a pc-relative instruction.
       
   110     pcrel_data_format   = 3   // Relocation is for the target data of a pc-relative instruction.
       
   111   };
       
   112 
       
   113   // Store the new target address into an oop_Relocation cell, if any.
       
   114   // Return indication if update happened.
       
   115   static bool update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb);
       
   116 
       
   117 #endif // CPU_S390_VM_RELOCINFO_S390_HPP