src/hotspot/share/code/relocInfo.hpp
author coleenp
Wed, 14 Mar 2018 07:27:19 -0400
changeset 49392 2956d0ece7a9
parent 49373 47b5652f2928
child 52857 7e268f863ff0
permissions -rw-r--r--
8199282: Remove ValueObj class for allocation subclassing for gc code Reviewed-by: stefank, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48486
bda5211e7876 8193927: Optimize scanning code for oops.
goetz
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, 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: 1217
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1217
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: 1217
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6432
diff changeset
    25
#ifndef SHARE_VM_CODE_RELOCINFO_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6432
diff changeset
    26
#define SHARE_VM_CODE_RELOCINFO_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6432
diff changeset
    27
37466
287c4ebd11b0 8153967: Remove top.hpp
stefank
parents: 36301
diff changeset
    28
#include "runtime/os.hpp"
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38133
diff changeset
    29
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6432
diff changeset
    30
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
    31
class nmethod;
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
    32
class CompiledMethod;
37466
287c4ebd11b0 8153967: Remove top.hpp
stefank
parents: 36301
diff changeset
    33
class Metadata;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    34
class NativeMovConstReg;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    35
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Types in this file:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//    relocInfo
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//      One element of an array of halfwords encoding compressed relocations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//      Also, the source of relocation types (relocInfo::oop_type, ...).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//    Relocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//      A flyweight object representing a single relocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//      It is fully unpacked from the compressed relocation array.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    43
//    metadata_Relocation, ... (subclasses of Relocation)
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    44
//      The location of some type-specific operations (metadata_addr, ...).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    45
//      Also, the source of relocation specs (metadata_Relocation::spec, ...).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//    oop_Relocation, ... (subclasses of Relocation)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
    47
//      oops in the code stream (strings, class loaders)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//      Also, the source of relocation specs (oop_Relocation::spec, ...).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//    RelocationHolder
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 49373
diff changeset
    50
//      A value type which acts as a union holding a Relocation object.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//      Represents a relocation spec passed into a CodeBuffer during assembly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//    RelocIterator
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//      A StackObj which iterates over the relocations associated with
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//      a range of code addresses.  Can be used to operate a copy of code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//    BoundRelocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//      An _internal_ type shared by packers and unpackers of relocations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//      It pastes together a RelocationHolder with some pointers into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
//      code and relocInfo streams.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// Notes on relocType:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// These hold enough information to read or write a value embedded in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// the instructions of an CodeBlob.  They're used to update:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//   1) embedded oops     (isOop()          == true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//   2) inline caches     (isIC()           == true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
//   3) runtime calls     (isRuntimeCall()  == true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//   4) internal word ref (isInternalWord() == true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//   5) external word ref (isExternalWord() == true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// when objects move (GC) or if code moves (compacting the code heap).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// They are also used to patch the code (if a call site must change)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// A relocInfo is represented in 16 bits:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//   4 bits indicating the relocation type
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//  12 bits indicating the offset from the previous relocInfo address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// The offsets accumulate along the relocInfo stream to encode the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// address within the CodeBlob, which is named RelocIterator::addr().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// The address of a particular relocInfo always points to the first
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// byte of the relevant instruction (and not to any of its subfields
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// or embedded immediate constants).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// The offset value is scaled appropriately for the target machine.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// (See relocInfo_<arch>.hpp for the offset scaling.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// On some machines, there may also be a "format" field which may provide
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
// additional information about the format of the instruction stream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// at the corresponding code address.  The format value is usually zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// Any machine (such as Intel) whose instructions can sometimes contain
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// more than one relocatable constant needs format codes to distinguish
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// which operand goes with a given relocation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
// If the target machine needs N format bits, the offset has 12-N bits,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
// the format is encoded between the offset and the type, and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// relocInfo_<arch>.hpp file has manifest constants for the format codes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// If the type is "data_prefix_tag" then the offset bits are further encoded,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// and in fact represent not a code-stream offset but some inline data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
// The data takes the form of a counted sequence of halfwords, which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// precedes the actual relocation record.  (Clients never see it directly.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// The interpetation of this extra data depends on the relocation type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// On machines that have 32-bit immediate fields, there is usually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// little need for relocation "prefix" data, because the instruction stream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// is a perfectly reasonable place to store the value.  On machines in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// which 32-bit values must be "split" across instructions, the relocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// data is the "true" specification of the value, which is then applied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// to some field of the instruction (22 or 13 bits, on SPARC).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// Whenever the location of the CodeBlob changes, any PC-relative
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// relocations, and any internal_word_type relocations, must be reapplied.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// After the GC runs, oop_type relocations must be reapplied.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// Here are meanings of the types:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// relocInfo::none -- a filler record
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
//   Value:  none
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
//   Instruction: The corresponding code address is ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
//   Data:  Any data prefix and format code are ignored
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
//   (This means that any relocInfo can be disabled by setting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
//   its type to none.  See relocInfo::remove.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
//
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   126
// relocInfo::oop_type, relocInfo::metadata_type -- a reference to an oop or meta data
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
//   Value:  an oop, or else the address (handle) of an oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
//   Instruction types: memory (load), set (load address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
//   Data:  []       an oop stored in 4 bytes of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
//          [n]      n is the index of an oop in the CodeBlob's oop pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
//          [[N]n l] and l is a byte offset to be applied to the oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
//          [Nn Ll]  both index and offset may be 32 bits if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
//   Here is a special hack, used only by the old compiler:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
//          [[N]n 00] the value is the __address__ of the nth oop in the pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
//   (Note that the offset allows optimal references to class variables.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
// relocInfo::internal_word_type -- an address within the same CodeBlob
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// relocInfo::section_word_type -- same, but can refer to another section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
//   Value:  an address in the CodeBlob's code or constants section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
//   Instruction types: memory (load), set (load address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
//   Data:  []     stored in 4 bytes of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
//          [[L]l] a relative offset (see [About Offsets] below)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
//   In the case of section_word_type, the offset is relative to a section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
//   base address, and the section number (e.g., SECT_INSTS) is encoded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
//   into the low two bits of the offset L.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
// relocInfo::external_word_type -- a fixed address in the runtime system
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
//   Value:  an address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
//   Instruction types: memory (load), set (load address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
//   Data:  []   stored in 4 bytes of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
//          [n]  the index of a "well-known" stub (usual case on RISC)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
//          [Ll] a 32-bit address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// relocInfo::runtime_call_type -- a fixed subroutine in the runtime system
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
//   Value:  an address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
//   Instruction types: PC-relative call (or a PC-relative branch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
//   Data:  []   stored in 4 bytes of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// relocInfo::static_call_type -- a static call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
//   Value:  an CodeBlob, a stub, or a fixup routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
//   Instruction types: a call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
//   Data:  []
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
//   The identity of the callee is extracted from debugging information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
//   //%note reloc_3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
// relocInfo::virtual_call_type -- a virtual call site (which includes an inline
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
//                                 cache)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
//   Value:  an CodeBlob, a stub, the interpreter, or a fixup routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
//   Instruction types: a call, plus some associated set-oop instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
//   Data:  []       the associated set-oops are adjacent to the call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
//          [n]      n is a relative offset to the first set-oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
//          [[N]n l] and l is a limit within which the set-oops occur
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
//          [Nn Ll]  both n and l may be 32 bits if necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
//   The identity of the callee is extracted from debugging information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
// relocInfo::opt_virtual_call_type -- a virtual call site that is statically bound
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
//    Same info as a static_call_type. We use a special type, so the handling of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
//    virtuals and statics are separated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
//   The offset n points to the first set-oop.  (See [About Offsets] below.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
//   In turn, the set-oop instruction specifies or contains an oop cell devoted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
//   exclusively to the IC call, which can be patched along with the call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
//   The locations of any other set-oops are found by searching the relocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
//   information starting at the first set-oop, and continuing until all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
//   relocations up through l have been inspected.  The value l is another
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
//   relative offset.  (Both n and l are relative to the call's first byte.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
//   The limit l of the search is exclusive.  However, if it points within
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
//   the call (e.g., offset zero), it is adjusted to point after the call and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
//   any associated machine-specific delay slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
//   Since the offsets could be as wide as 32-bits, these conventions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
//   put no restrictions whatever upon code reorganization.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
//   The compiler is responsible for ensuring that transition from a clean
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
//   state to a monomorphic compiled state is MP-safe.  This implies that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
//   the system must respond well to intermediate states where a random
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
//   subset of the set-oops has been correctly from the clean state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
//   upon entry to the VEP of the compiled method.  In the case of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
//   machine (Intel) with a single set-oop instruction, the 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
//   immediate field must not straddle a unit of memory coherence.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
//   //%note reloc_3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
// relocInfo::static_stub_type -- an extra stub for each static_call_type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
//   Value:  none
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
//   Instruction types: a virtual call:  { set_oop; jump; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
//   Data:  [[N]n]  the offset of the associated static_call reloc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
//   This stub becomes the target of a static call which must be upgraded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
//   to a virtual call (because the callee is interpreted).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
//   See [About Offsets] below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
//   //%note reloc_2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
//
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   216
// relocInfo::poll_[return_]type -- a safepoint poll
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   217
//   Value:  none
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   218
//   Instruction types: memory load or test
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   219
//   Data:  none
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   220
//
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// For example:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
//   INSTRUCTIONS                        RELOC: TYPE    PREFIX DATA
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
//   ------------                               ----    -----------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
// sethi      %hi(myObject),  R               oop_type [n(myObject)]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// ld      [R+%lo(myObject)+fldOffset], R2    oop_type [n(myObject) fldOffset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
// add R2, 1, R2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// st  R2, [R+%lo(myObject)+fldOffset]        oop_type [n(myObject) fldOffset]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
//%note reloc_1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// This uses 4 instruction words, 8 relocation halfwords,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// and an entry (which is sharable) in the CodeBlob's oop pool,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// for a total of 36 bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
// Note that the compiler is responsible for ensuring the "fldOffset" when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
// added to "%lo(myObject)" does not overflow the immediate fields of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
// memory instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
// [About Offsets] Relative offsets are supplied to this module as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
// positive byte offsets, but they may be internally stored scaled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
// and/or negated, depending on what is most compact for the target
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// system.  Since the object pointed to by the offset typically
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// precedes the relocation address, it is profitable to store
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
// these negative offsets as positive numbers, but this decision
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
// is internal to the relocation information abstractions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
class Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
class CodeBuffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
class CodeSection;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48486
diff changeset
   254
class relocInfo {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  enum relocType {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    none                    =  0, // Used when no relocation should be generated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    oop_type                =  1, // embedded oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    virtual_call_type       =  2, // a standard inline cache call for a virtual send
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    opt_virtual_call_type   =  3, // a virtual call that has been statically bound (i.e., no IC cache)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    static_call_type        =  4, // a static send
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    static_stub_type        =  5, // stub-entry for static send  (takes care of interpreter case)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    runtime_call_type       =  6, // call to fixed external routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    external_word_type      =  7, // reference to fixed external address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    internal_word_type      =  8, // reference within the current code blob
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    section_word_type       =  9, // internal, but a cross-section reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    poll_type               = 10, // polling instruction for safepoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    poll_return_type        = 11, // polling instruction for safepoints at return
18446
635eae7b22fc 8017308: Remove unused breakpoint relocation type
goetz
parents: 13728
diff changeset
   270
    metadata_type           = 12, // metadata that used to be oops
22813
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
   271
    trampoline_stub_type    = 13, // stub-entry for trampoline
42064
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
   272
    runtime_call_w_cp_type  = 14, // Runtime call which may load its target from the constant pool
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    data_prefix_tag         = 15, // tag for a prefix (carries data arguments)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    type_mask               = 15  // A mask which selects only the above values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  unsigned short _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  enum RawBitsToken { RAW_BITS };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  relocInfo(relocType type, RawBitsToken ignore, int bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    : _value((type << nontype_width) + bits) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  relocInfo(relocType type, RawBitsToken ignore, int off, int f)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    : _value((type << nontype_width) + (off / (unsigned)offset_unit) + (f << offset_width)) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  relocInfo(relocType type, int offset, int format = 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
#ifndef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    (*this) = relocInfo(type, RAW_BITS, offset, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // Put a bunch of assertions out-of-line.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  #define APPLY_TO_RELOCATIONS(visitor) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    visitor(oop) \
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   301
    visitor(metadata) \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    visitor(virtual_call) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    visitor(opt_virtual_call) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    visitor(static_call) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    visitor(static_stub) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    visitor(runtime_call) \
42064
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
   307
    visitor(runtime_call_w_cp) \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    visitor(external_word) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    visitor(internal_word) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    visitor(poll) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    visitor(poll_return) \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    visitor(section_word) \
22813
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
   313
    visitor(trampoline_stub) \
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    value_width             = sizeof(unsigned short) * BitsPerByte,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    type_width              = 4,   // == log2(type_mask+1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    nontype_width           = value_width - type_width,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    datalen_width           = nontype_width-1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    datalen_tag             = 1 << datalen_width,  // or-ed into _value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    datalen_limit           = 1 << datalen_width,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    datalen_mask            = (1 << datalen_width)-1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  relocType  type()       const { return (relocType)((unsigned)_value >> nontype_width); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  int  format()           const { return format_mask==0? 0: format_mask &
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
                                         ((unsigned)_value >> offset_width); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  int  addr_offset()      const { assert(!is_prefix(), "must have offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
                                  return (_value & offset_mask)*offset_unit; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  const short* data()     const { assert(is_datalen(), "must have data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
                                  return (const short*)(this + 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  int          datalen()  const { assert(is_datalen(), "must have data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
                                  return (_value & datalen_mask); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  int         immediate() const { assert(is_immediate(), "must have immed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                                  return (_value & datalen_mask); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  static int addr_unit()        { return offset_unit; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  static int offset_limit()     { return (1 << offset_width) * offset_unit; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  void set_type(relocType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  void set_format(int format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  void remove() { set_type(none); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  bool is_none()                const { return type() == none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  bool is_prefix()              const { return type() == data_prefix_tag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  bool is_datalen()             const { assert(is_prefix(), "must be prefix");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
                                        return (_value & datalen_tag) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  bool is_immediate()           const { assert(is_prefix(), "must be prefix");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
                                        return (_value & datalen_tag) == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  // Occasionally records of type relocInfo::none will appear in the stream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // We do not bother to filter these out, but clients should ignore them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  // These records serve as "filler" in three ways:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  //  - to skip large spans of unrelocated code (this is rare)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  //  - to pad out the relocInfo array to the required oop alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  //  - to disable old relocation information which is no longer applicable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  inline friend relocInfo filler_relocInfo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  // Every non-prefix relocation may be preceded by at most one prefix,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  // which supplies 1 or more halfwords of associated data.  Conventionally,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  // an int is represented by 0, 1, or 2 halfwords, depending on how
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  // many bits are required to represent the value.  (In addition,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  // if the sole halfword is a 10-bit unsigned number, it is made
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  // "immediate" in the prefix header word itself.  This optimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // is invisible outside this module.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
22827
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 22813
diff changeset
   377
  inline friend relocInfo prefix_relocInfo(int datalen);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  // an immediate relocInfo optimizes a prefix with one 10-bit unsigned value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  static relocInfo immediate_relocInfo(int data0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    assert(fits_into_immediate(data0), "data0 in limits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
    return relocInfo(relocInfo::data_prefix_tag, RAW_BITS, data0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  static bool fits_into_immediate(int data0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    return (data0 >= 0 && data0 < datalen_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  // Support routines for compilers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // This routine takes an infant relocInfo (unprefixed) and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // edits in its prefix, if any.  It also updates dest.locs_end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  void initialize(CodeSection* dest, Relocation* reloc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // This routine updates a prefix and returns the limit pointer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  // It tries to compress the prefix from 32 to 16 bits, and if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // successful returns a reduced "prefix_limit" pointer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  relocInfo* finish_prefix(short* prefix_limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // bit-packers for the data array:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // As it happens, the bytes within the shorts are ordered natively,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // but the shorts within the word are ordered big-endian.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // This is an arbitrary choice, made this way mainly to ease debugging.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  static int data0_from_int(jint x)         { return x >> value_width; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  static int data1_from_int(jint x)         { return (short)x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  static jint jint_from_data(short* data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    return (data[0] << value_width) + (unsigned short)data[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  static jint short_data_at(int n, short* data, int datalen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    return datalen > n ? data[n] : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  static jint jint_data_at(int n, short* data, int datalen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    return datalen > n+1 ? jint_from_data(&data[n]) : short_data_at(n, data, datalen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // Update methods for relocation information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  // (since code is dynamically patched, we also need to dynamically update the relocation info)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  // Both methods takes old_type, so it is able to performe sanity checks on the information removed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  static void change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  static void remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  // Machine dependent stuff
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38133
diff changeset
   427
#include CPU_HEADER(relocInfo)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  // Derived constant, based on format_width which is PD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    offset_width       = nontype_width - format_width,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    offset_mask        = (1<<offset_width) - 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    format_mask        = (1<<format_width) - 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  enum {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   438
#ifdef _LP64
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   439
    // for use in format
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   440
    // format_width must be at least 1 on _LP64
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   441
    narrow_oop_in_const = 1,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   442
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    // Conservatively large estimate of maximum length (in shorts)
18446
635eae7b22fc 8017308: Remove unused breakpoint relocation type
goetz
parents: 13728
diff changeset
   444
    // of any relocation record.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    // Extended format is length prefix, data words, and tag/offset suffix.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    length_limit       = 1 + 1 + (3*BytesPerWord/BytesPerShort) + 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    have_format        = format_width > 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
#define FORWARD_DECLARE_EACH_CLASS(name)              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
class name##_Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
APPLY_TO_RELOCATIONS(FORWARD_DECLARE_EACH_CLASS)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
#undef FORWARD_DECLARE_EACH_CLASS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
inline relocInfo filler_relocInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  return relocInfo(relocInfo::none, relocInfo::offset_limit() - relocInfo::offset_unit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
22827
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 22813
diff changeset
   462
inline relocInfo prefix_relocInfo(int datalen = 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
// Holder for flyweight relocation objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
// Although the flyweight subclasses are of varying sizes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
// the holder is "one size fits all".
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48486
diff changeset
   471
class RelocationHolder {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  friend class Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  friend class CodeSection;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  // this preallocated memory must accommodate all subclasses of Relocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  // (this number is assertion-checked in Relocation::operator new)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  enum { _relocbuf_size = 5 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  void* _relocbuf[ _relocbuf_size ];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  Relocation* reloc() const { return (Relocation*) &_relocbuf[0]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  inline relocInfo::relocType type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  // Add a constant offset to a relocation.  Helper for class Address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  RelocationHolder plus(int offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  inline RelocationHolder();                // initializes type to none
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  inline RelocationHolder(Relocation* r);   // make a copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  static const RelocationHolder none;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
// A RelocIterator iterates through the relocation information of a CodeBlob.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
// It is a variable BoundRelocation which is able to take on successive
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
// values as it is advanced through a code stream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
// Usage:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
//   RelocIterator iter(nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
//   while (iter.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
//     iter.reloc()->some_operation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
//   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
// or:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
//   RelocIterator iter(nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
//   while (iter.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
//     switch (iter.type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
//      case relocInfo::oop_type          :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
//      case relocInfo::ic_type           :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
//      case relocInfo::prim_type         :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
//      case relocInfo::uncommon_type     :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
//      case relocInfo::runtime_call_type :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
//      case relocInfo::internal_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
//      case relocInfo::external_word_type:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
//      ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
//     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
//   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
class RelocIterator : public StackObj {
6432
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   519
  enum { SECT_LIMIT = 3 };  // must be equal to CodeBuffer::SECT_LIMIT, checked in ctor
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  friend class Relocation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  friend class relocInfo;       // for change_reloc_info_for_address only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  typedef relocInfo::relocType relocType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
 private:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   525
  address         _limit;   // stop producing relocations after this _addr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   526
  relocInfo*      _current; // the current relocation information
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   527
  relocInfo*      _end;     // end marker; we're done iterating when _current == _end
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   528
  CompiledMethod* _code;    // compiled method containing _addr
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   529
  address         _addr;    // instruction to which the relocation applies
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   530
  short           _databuf; // spare buffer for compressed data
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   531
  short*          _data;    // pointer to the relocation's data
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   532
  short           _datalen; // number of halfwords in _data
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   533
  char            _format;  // position within the instruction
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  // Base addresses needed to compute targets of section_word_type relocs.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   536
  address _section_start[SECT_LIMIT];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   537
  address _section_end  [SECT_LIMIT];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  void set_has_current(bool b) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    _datalen = !b ? -1 : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    debug_only(_data = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  void set_current(relocInfo& ri) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    _current = &ri;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    set_has_current(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  RelocationHolder _rh; // where the current relocation is allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  relocInfo* current() const { assert(has_current(), "must have current");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
                               return _current; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  void set_limits(address begin, address limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  void advance_over_prefix();    // helper method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
6432
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   557
  void initialize_misc();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   559
  void initialize(CompiledMethod* nm, address begin, address limit);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  RelocIterator() { initialize_misc(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  // constructor
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   565
  RelocIterator(CompiledMethod* nm, address begin = NULL, address limit = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  // get next reloc info, return !eos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  bool next() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    _current++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    assert(_current <= _end, "must not overrun relocInfo");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    if (_current == _end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
      set_has_current(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    set_has_current(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    if (_current->is_prefix()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      advance_over_prefix();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      assert(!current()->is_prefix(), "only one prefix at a time");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    _addr += _current->addr_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    if (_limit != NULL && _addr >= _limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      set_has_current(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    if (relocInfo::have_format)  _format = current()->format();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  address      limit()        const { return _limit; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  void     set_limit(address x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  relocType    type()         const { return current()->type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  int          format()       const { return (relocInfo::have_format) ? current()->format() : 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  address      addr()         const { return _addr; }
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   600
  CompiledMethod*     code()  const { return _code; }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   601
  nmethod*     code_as_nmethod() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  short*       data()         const { return _data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  int          datalen()      const { return _datalen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  bool     has_current()      const { return _datalen >= 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  void       set_addr(address addr) { _addr = addr; }
6432
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   607
  bool   addr_in_const()      const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  address section_start(int n) const {
6432
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   610
    assert(_section_start[n], "must be initialized");
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   611
    return _section_start[n];
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   612
  }
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   613
  address section_end(int n) const {
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   614
    assert(_section_end[n], "must be initialized");
d36e09b60939 6961697: move nmethod constants section before instruction section
twisti
parents: 5702
diff changeset
   615
    return _section_end[n];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  // The address points to the affected displacement part of the instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  // For RISC, this is just the whole instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  // For Intel, this is an unaligned 32-bit word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  // type-specific relocation accessors:  oop_Relocation* oop_reloc(), etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  #define EACH_TYPE(name)                               \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  inline name##_Relocation* name##_reloc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  APPLY_TO_RELOCATIONS(EACH_TYPE)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  #undef EACH_TYPE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  // generic relocation accessor; switches on type to call the above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  Relocation* reloc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  void print_current();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
// A Relocation is a flyweight object allocated within a RelocationHolder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
// It represents the relocation data of relocation record.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
// So, the RelocIterator unpacks relocInfos into Relocations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48486
diff changeset
   642
class Relocation {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  friend class RelocationHolder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  static void guarantee_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  // When a relocation has been created by a RelocIterator,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  // this field is non-null.  It allows the relocation to know
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  // its context, such as the address to which it applies.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  RelocIterator* _binding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  RelocIterator* binding() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    assert(_binding != NULL, "must be bound");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    return _binding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  void set_binding(RelocIterator* b) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    assert(_binding == NULL, "must be unbound");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    _binding = b;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    assert(_binding != NULL, "must now be bound");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  Relocation() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    _binding = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  static RelocationHolder newHolder() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    return RelocationHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
 public:
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 18446
diff changeset
   674
  void* operator new(size_t size, const RelocationHolder& holder) throw() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    if (size > sizeof(holder._relocbuf)) guarantee_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    assert((void* const *)holder.reloc() == &holder._relocbuf[0], "ptrs must agree");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
    return holder.reloc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  // make a generic relocation for a given type (if possible)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  static RelocationHolder spec_simple(relocInfo::relocType rtype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  // here is the type-specific hook which writes relocation data:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  virtual void pack_data_to(CodeSection* dest) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  // here is the type-specific hook which reads (unpacks) relocation data:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  virtual void unpack_data() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    assert(datalen()==0 || type()==relocInfo::none, "no data here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  // Helper functions for pack_data_to() and unpack_data().
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  // Most of the compression logic is confined here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  // (The "immediate data" mechanism of relocInfo works independently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  // of this stuff, and acts to further compress most 1-word data prefixes.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  // A variable-width int is encoded as a short if it will fit in 16 bits.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  // The decoder looks at datalen to decide whether to unpack short or jint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  // Most relocation records are quite simple, containing at most two ints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  static bool is_short(jint x) { return x == (short)x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  static short* add_short(short* p, int x)  { *p++ = x; return p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  static short* add_jint (short* p, jint x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    *p++ = relocInfo::data0_from_int(x); *p++ = relocInfo::data1_from_int(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  static short* add_var_int(short* p, jint x) {   // add a variable-width int
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    if (is_short(x))  p = add_short(p, x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    else              p = add_jint (p, x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  static short* pack_1_int_to(short* p, jint x0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
    // Format is one of:  [] [x] [Xx]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
    if (x0 != 0)  p = add_var_int(p, x0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  int unpack_1_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
    assert(datalen() <= 2, "too much data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    return relocInfo::jint_data_at(0, data(), datalen());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  // With two ints, the short form is used only if both ints are short.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  short* pack_2_ints_to(short* p, jint x0, jint x1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    // Format is one of:  [] [x y?] [Xx Y?y]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    if (x0 == 0 && x1 == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
      // no halfwords needed to store zeroes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
    } else if (is_short(x0) && is_short(x1)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      // 1-2 halfwords needed to store shorts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
      p = add_short(p, x0); if (x1!=0) p = add_short(p, x1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
      // 3-4 halfwords needed to store jints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
      p = add_jint(p, x0);             p = add_var_int(p, x1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    return p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  void unpack_2_ints(jint& x0, jint& x1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    int    dlen = datalen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
    short* dp  = data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    if (dlen <= 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
      x0 = relocInfo::short_data_at(0, dp, dlen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
      x1 = relocInfo::short_data_at(1, dp, dlen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
      assert(dlen <= 4, "too much data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
      x0 = relocInfo::jint_data_at(0, dp, dlen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
      x1 = relocInfo::jint_data_at(2, dp, dlen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
 protected:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   752
  // platform-independent utility for patching constant section
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   753
  void       const_set_data_value    (address x);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   754
  void       const_verify_data_value (address x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  // platform-dependent utilities for decoding and patching instructions
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   756
  void       pd_set_data_value       (address x, intptr_t off, bool verify_only = false); // a set or mem-ref
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   757
  void       pd_verify_data_value    (address x, intptr_t off) { pd_set_data_value(x, off, true); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  address    pd_call_destination     (address orig_addr = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  void       pd_set_call_destination (address x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  // this extracts the address of an address in the code stream instead of the reloc data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  address* pd_address_in_code       ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  // this extracts an address from the code stream instead of the reloc data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  address  pd_get_address_from_code ();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  // these convert from byte offsets, to scaled offsets, to addresses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  static jint scaled_offset(address x, address base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    int byte_offset = x - base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    int offset = -byte_offset / relocInfo::addr_unit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    assert(address_from_scaled_offset(offset, base) == x, "just checkin'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  static jint scaled_offset_null_special(address x, address base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
    // Some relocations treat offset=0 as meaning NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    // Handle this extra convention carefully.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    if (x == NULL)  return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    assert(x != base, "offset must not be zero");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    return scaled_offset(x, base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  static address address_from_scaled_offset(jint offset, address base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
    int byte_offset = -( offset * relocInfo::addr_unit() );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    return base + byte_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  // helpers for mapping between old and new addresses after a move or resize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  address old_addr_for(address newa, const CodeBuffer* src, CodeBuffer* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  address new_addr_for(address olda, const CodeBuffer* src, CodeBuffer* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  void normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  // accessors which only make sense for a bound Relocation
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   793
  address         addr()            const { return binding()->addr(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   794
  CompiledMethod* code()            const { return binding()->code(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   795
  nmethod*        code_as_nmethod() const { return binding()->code_as_nmethod(); }
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
   796
  bool            addr_in_const()   const { return binding()->addr_in_const(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  short*   data()         const { return binding()->data(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  int      datalen()      const { return binding()->datalen(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  int      format()       const { return binding()->format(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  virtual relocInfo::relocType type()            { return relocInfo::none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  // is it a call instruction?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  virtual bool is_call()                         { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  // is it a data movement instruction?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  virtual bool is_data()                         { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  // some relocations can compute their own values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  virtual address  value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  // all relocations are able to reassert their values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  virtual void set_value(address x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  virtual void clear_inline_cache()              { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  // This method assumes that all virtual/static (inline) caches are cleared (since for static_call_type and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  // ic_call_type is not always posisition dependent (depending on the state of the cache)). However, this is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  // probably a reasonable assumption, since empty caches simplifies code reloacation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  virtual void fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
// certain inlines must be deferred until class Relocation is defined:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
inline RelocationHolder::RelocationHolder() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  // initialize the vtbl, just to keep things type-safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  new(*this) Relocation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
inline RelocationHolder::RelocationHolder(Relocation* r) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  // wordwise copy from r (ok if it copies garbage after r)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  for (int i = 0; i < _relocbuf_size; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    _relocbuf[i] = ((void**)r)[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
relocInfo::relocType RelocationHolder::type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  return reloc()->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
// A DataRelocation always points at a memory or load-constant instruction..
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
// It is absolute on most machines, and the constant is split on RISCs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
// The specific subtypes are oop, external_word, and internal_word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
// By convention, the "value" does not include a separately reckoned "offset".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
class DataRelocation : public Relocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  bool          is_data()                      { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  // both target and offset must be computed somehow from relocation data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
  virtual int    offset()                      { return 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  address         value()                      = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  void        set_value(address x)             { set_value(x, offset()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  void        set_value(address x, intptr_t o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
    if (addr_in_const())
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   860
      const_set_data_value(x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
      pd_set_data_value(x, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
  }
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   864
  void        verify_value(address x) {
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   865
    if (addr_in_const())
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
   866
      const_verify_data_value(x);
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   867
    else
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   868
      pd_verify_data_value(x, offset());
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   869
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  // The "o" (displacement) argument is relevant only to split relocations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  // on RISC machines.  In some CPUs (SPARC), the set-hi and set-lo ins'ns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  // can encode more than 32 bits between them.  This allows compilers to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  // share set-hi instructions between addresses that differ by a small
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
  // offset (e.g., different static variables in the same class).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  // On such machines, the "x" argument to set_value on all set-lo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  // instructions must be the same as the "x" argument for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  // corresponding set-hi instructions.  The "o" arguments for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  // set-hi instructions are ignored, and must not affect the high-half
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  // immediate constant.  The "o" arguments for the set-lo instructions are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  // added into the low-half immediate constant, and must not overflow it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
// A CallRelocation always points at a call instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
// It is PC-relative on most machines.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
class CallRelocation : public Relocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  bool is_call() { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  address  destination()                    { return pd_call_destination(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  void     set_destination(address x); // pd_set_call_destination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  void     fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  address  value()                          { return destination();  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  void     set_value(address x)             { set_destination(x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
class oop_Relocation : public DataRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  relocInfo::relocType type() { return relocInfo::oop_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  // encode in one of these formats:  [] [n] [n l] [Nn l] [Nn Ll]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  // an oop in the CodeBlob's oop pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  static RelocationHolder spec(int oop_index, int offset = 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    assert(oop_index > 0, "must be a pool-resident oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    new(rh) oop_Relocation(oop_index, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  // an oop in the instruction stream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  static RelocationHolder spec_for_immediate() {
48486
bda5211e7876 8193927: Optimize scanning code for oops.
goetz
parents: 47216
diff changeset
   912
    // If no immediate oops are generated, we can skip some walks over nmethods.
bda5211e7876 8193927: Optimize scanning code for oops.
goetz
parents: 47216
diff changeset
   913
    // Assert that they don't get generated accidently!
bda5211e7876 8193927: Optimize scanning code for oops.
goetz
parents: 47216
diff changeset
   914
    assert(relocInfo::mustIterateImmediateOopsInCode(),
bda5211e7876 8193927: Optimize scanning code for oops.
goetz
parents: 47216
diff changeset
   915
           "Must return true so we will search for oops as roots etc. in the code.");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    const int oop_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
    const int offset    = 0;    // if you want an offset, use the oop pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
    new(rh) oop_Relocation(oop_index, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  jint _oop_index;                  // if > 0, index into CodeBlob::oop_at
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  jint _offset;                     // byte offset to apply to the oop itself
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
  oop_Relocation(int oop_index, int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
    _oop_index = oop_index; _offset = offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  oop_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  int oop_index() { return _oop_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  int offset()    { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  // data is packed in "2_ints" format:  [i o] or [Ii Oo]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  void pack_data_to(CodeSection* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  void fix_oop_relocation();        // reasserts oop value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
8724
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   944
  void verify_oop_relocation();
693c6b883b54 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 8107
diff changeset
   945
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  address value()  { return (address) *oop_addr(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  bool oop_is_immediate()  { return oop_index() == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  oop* oop_addr();                  // addr or &pool[jint_data]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  oop  oop_value();                 // *oop_addr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
  // Note:  oop_value transparently converts Universe::non_oop_word to NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   955
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   956
// copy of oop_Relocation for now but may delete stuff in both/either
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   957
class metadata_Relocation : public DataRelocation {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   958
  relocInfo::relocType type() { return relocInfo::metadata_type; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   959
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   960
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   961
  // encode in one of these formats:  [] [n] [n l] [Nn l] [Nn Ll]
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   962
  // an metadata in the CodeBlob's metadata pool
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   963
  static RelocationHolder spec(int metadata_index, int offset = 0) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   964
    assert(metadata_index > 0, "must be a pool-resident metadata");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   965
    RelocationHolder rh = newHolder();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   966
    new(rh) metadata_Relocation(metadata_index, offset);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   967
    return rh;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   968
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   969
  // an metadata in the instruction stream
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   970
  static RelocationHolder spec_for_immediate() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   971
    const int metadata_index = 0;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   972
    const int offset    = 0;    // if you want an offset, use the metadata pool
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   973
    RelocationHolder rh = newHolder();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   974
    new(rh) metadata_Relocation(metadata_index, offset);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   975
    return rh;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   976
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   977
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   978
 private:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   979
  jint _metadata_index;            // if > 0, index into nmethod::metadata_at
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   980
  jint _offset;                     // byte offset to apply to the metadata itself
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   981
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   982
  metadata_Relocation(int metadata_index, int offset) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   983
    _metadata_index = metadata_index; _offset = offset;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   984
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   985
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   986
  friend class RelocIterator;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   987
  metadata_Relocation() { }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   988
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   989
  // Fixes a Metadata pointer in the code. Most platforms embeds the
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   990
  // Metadata pointer in the code at compile time so this is empty
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   991
  // for them.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   992
  void pd_fix_value(address x);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   993
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   994
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   995
  int metadata_index() { return _metadata_index; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   996
  int offset()    { return _offset; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   997
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   998
  // data is packed in "2_ints" format:  [i o] or [Ii Oo]
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
   999
  void pack_data_to(CodeSection* dest);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1000
  void unpack_data();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1001
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1002
  void fix_metadata_relocation();        // reasserts metadata value
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1003
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1004
  void verify_metadata_relocation();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1005
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1006
  address value()  { return (address) *metadata_addr(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1007
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1008
  bool metadata_is_immediate()  { return metadata_index() == 0; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1009
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1010
  Metadata**   metadata_addr();                  // addr or &pool[jint_data]
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1011
  Metadata*    metadata_value();                 // *metadata_addr
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1012
  // Note:  metadata_value transparently converts Universe::non_metadata_word to NULL.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1013
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1014
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1015
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
class virtual_call_Relocation : public CallRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  relocInfo::relocType type() { return relocInfo::virtual_call_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1020
  // "cached_value" points to the first associated set-oop.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  // The oop_limit helps find the last associated set-oop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  // (See comments at the top of this file.)
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1023
  static RelocationHolder spec(address cached_value, jint method_index = 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
    RelocationHolder rh = newHolder();
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1025
    new(rh) virtual_call_Relocation(cached_value, method_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1029
 private:
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1030
  address _cached_value; // location of set-value instruction
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1031
  jint    _method_index; // resolved method for a Java call
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1032
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1033
  virtual_call_Relocation(address cached_value, int method_index) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1034
    _cached_value = cached_value;
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1035
    _method_index = method_index;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1036
    assert(cached_value != NULL, "first oop address must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  virtual_call_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 9124
diff changeset
  1043
  address cached_value();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1045
  int     method_index() { return _method_index; }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1046
  Method* method_value();
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1047
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  // data is packed as scaled offsets in "2_ints" format:  [f l] or [Ff Ll]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  // oop_limit is set to 0 if the limit falls somewhere within the call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  // When unpacking, a zero oop_limit is taken to refer to the end of the call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
  // (This has the effect of bringing in the call's delay slot on SPARC.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
  void pack_data_to(CodeSection* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
  void clear_inline_cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
class opt_virtual_call_Relocation : public CallRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  relocInfo::relocType type() { return relocInfo::opt_virtual_call_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
 public:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1063
  static RelocationHolder spec(int method_index = 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    RelocationHolder rh = newHolder();
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1065
    new(rh) opt_virtual_call_Relocation(method_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
 private:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1070
  jint _method_index; // resolved method for a Java call
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1071
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1072
  opt_virtual_call_Relocation(int method_index) {
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1073
    _method_index = method_index;
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1074
  }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1075
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  friend class RelocIterator;
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1077
  opt_virtual_call_Relocation() {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
 public:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1080
  int     method_index() { return _method_index; }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1081
  Method* method_value();
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1082
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1083
  void pack_data_to(CodeSection* dest);
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1084
  void unpack_data();
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1085
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  void clear_inline_cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
  // find the matching static_stub
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1089
  address static_stub(bool is_aot);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
class static_call_Relocation : public CallRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
  relocInfo::relocType type() { return relocInfo::static_call_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
 public:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1097
  static RelocationHolder spec(int method_index = 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    RelocationHolder rh = newHolder();
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1099
    new(rh) static_call_Relocation(method_index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
 private:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1104
  jint _method_index; // resolved method for a Java call
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1105
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1106
  static_call_Relocation(int method_index) {
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1107
    _method_index = method_index;
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1108
  }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1109
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  friend class RelocIterator;
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1111
  static_call_Relocation() {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
 public:
35086
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1114
  int     method_index() { return _method_index; }
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1115
  Method* method_value();
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1116
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1117
  void pack_data_to(CodeSection* dest);
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1118
  void unpack_data();
bbf32241d851 8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents: 33160
diff changeset
  1119
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
  void clear_inline_cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  // find the matching static_stub
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1123
  address static_stub(bool is_aot);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
class static_stub_Relocation : public Relocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  relocInfo::relocType type() { return relocInfo::static_stub_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
 public:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1130
  static RelocationHolder spec(address static_call, bool is_aot = false) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
    RelocationHolder rh = newHolder();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1132
    new(rh) static_stub_Relocation(static_call, is_aot);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
 private:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
  1137
  address _static_call;  // location of corresponding static_call
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1138
  bool _is_aot;          // trampoline to aot code
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1140
  static_stub_Relocation(address static_call, bool is_aot) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
    _static_call = static_call;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1142
    _is_aot = is_aot;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  static_stub_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  void clear_inline_cache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  address static_call() { return _static_call; }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42064
diff changeset
  1152
  bool is_aot() { return _is_aot; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  // data is packed as a scaled offset in "1_int" format:  [c] or [Cc]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
  void pack_data_to(CodeSection* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
class runtime_call_Relocation : public CallRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  relocInfo::relocType type() { return relocInfo::runtime_call_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
  static RelocationHolder spec() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
    new(rh) runtime_call_Relocation();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  runtime_call_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
42064
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1176
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1177
class runtime_call_w_cp_Relocation : public CallRelocation {
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1178
  relocInfo::relocType type() { return relocInfo::runtime_call_w_cp_type; }
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1179
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1180
 public:
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1181
  static RelocationHolder spec() {
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1182
    RelocationHolder rh = newHolder();
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1183
    new(rh) runtime_call_w_cp_Relocation();
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1184
    return rh;
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1185
  }
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1186
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1187
 private:
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1188
  friend class RelocIterator;
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1189
  runtime_call_w_cp_Relocation() { _offset = -4; /* <0 = invalid */ }
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1190
  // On z/Architecture, runtime calls are either a sequence
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1191
  // of two instructions (load destination of call from constant pool + do call)
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1192
  // or a pc-relative call. The pc-relative call is faster, but it can only
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1193
  // be used if the destination of the call is not too far away.
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1194
  // In order to be able to patch a pc-relative call back into one using
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1195
  // the constant pool, we have to remember the location of the call's destination
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1196
  // in the constant pool.
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1197
  int _offset;
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1198
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1199
 public:
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1200
  void set_constant_pool_offset(int offset) { _offset = offset; }
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1201
  int get_constant_pool_offset() { return _offset; }
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1202
  void pack_data_to(CodeSection * dest);
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1203
  void unpack_data();
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1204
};
a530dbabe64f 8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents: 40010
diff changeset
  1205
22813
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1206
// Trampoline Relocations.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1207
// A trampoline allows to encode a small branch in the code, even if there
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1208
// is the chance that this branch can not reach all possible code locations.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1209
// If the relocation finds that a branch is too far for the instruction
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1210
// in the code, it can patch it to jump to the trampoline where is
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1211
// sufficient space for a far branch. Needed on PPC.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1212
class trampoline_stub_Relocation : public Relocation {
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1213
  relocInfo::relocType type() { return relocInfo::trampoline_stub_type; }
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1214
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1215
 public:
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1216
  static RelocationHolder spec(address static_call) {
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1217
    RelocationHolder rh = newHolder();
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1218
    return (new (rh) trampoline_stub_Relocation(static_call));
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1219
  }
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1220
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1221
 private:
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1222
  address _owner;    // Address of the NativeCall that owns the trampoline.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1223
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1224
  trampoline_stub_Relocation(address owner) {
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1225
    _owner = owner;
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1226
  }
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1227
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1228
  friend class RelocIterator;
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1229
  trampoline_stub_Relocation() { }
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1230
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1231
 public:
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1232
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1233
  // Return the address of the NativeCall that owns the trampoline.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1234
  address owner() { return _owner; }
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1235
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1236
  void pack_data_to(CodeSection * dest);
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1237
  void unpack_data();
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1238
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1239
  // Find the trampoline stub for a call.
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1240
  static address get_trampoline_for(address call, nmethod* code);
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1241
};
422557569a6b 8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents: 18446
diff changeset
  1242
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
class external_word_Relocation : public DataRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
  relocInfo::relocType type() { return relocInfo::external_word_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
  static RelocationHolder spec(address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
    assert(target != NULL, "must not be null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    new(rh) external_word_Relocation(target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  // Use this one where all 32/64 bits of the target live in the code stream.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  // The target must be an intptr_t, and must be absolute (not relative).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  static RelocationHolder spec_for_immediate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
    new(rh) external_word_Relocation(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
9111
c100c09c66f2 6777083: assert(target != __null,"must not be null")
never
parents: 8724
diff changeset
  1262
  // Some address looking values aren't safe to treat as relocations
c100c09c66f2 6777083: assert(target != __null,"must not be null")
never
parents: 8724
diff changeset
  1263
  // and should just be treated as constants.
c100c09c66f2 6777083: assert(target != __null,"must not be null")
never
parents: 8724
diff changeset
  1264
  static bool can_be_relocated(address target) {
36301
cb578d8c6cba 8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents: 35086
diff changeset
  1265
    assert(target == NULL || (uintptr_t)target >= (uintptr_t)os::vm_page_size(), INTPTR_FORMAT, (intptr_t)target);
cb578d8c6cba 8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents: 35086
diff changeset
  1266
    return target != NULL;
9111
c100c09c66f2 6777083: assert(target != __null,"must not be null")
never
parents: 8724
diff changeset
  1267
  }
c100c09c66f2 6777083: assert(target != __null,"must not be null")
never
parents: 8724
diff changeset
  1268
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  address _target;                  // address in runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  external_word_Relocation(address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
    _target = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  external_word_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
  // data is packed as a well-known address in "1_int" format:  [a] or [Aa]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
  // The function runtime_address_to_index is used to turn full addresses
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
  // to short indexes, if they are pre-registered by the stub mechanism.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
  // If the "a" value is 0 (i.e., _target is NULL), the address is stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
  // in the code stream.  See external_word_Relocation::target().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  void pack_data_to(CodeSection* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  void fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
  address  target();        // if _target==NULL, fetch addr from code stream
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
  address  value()          { return target(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
class internal_word_Relocation : public DataRelocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  relocInfo::relocType type() { return relocInfo::internal_word_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
  static RelocationHolder spec(address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
    assert(target != NULL, "must not be null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
    new(rh) internal_word_Relocation(target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  // use this one where all the bits of the target can fit in the code stream:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  static RelocationHolder spec_for_immediate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
    new(rh) internal_word_Relocation(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  internal_word_Relocation(address target) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
    _target  = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
    _section = -1;  // self-relative
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  address _target;                  // address in CodeBlob
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  int     _section;                 // section providing base address, if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
  internal_word_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  // bit-width of LSB field in packed offset, if section >= 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
  enum { section_width = 2 }; // must equal CodeBuffer::sect_bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  // data is packed as a scaled offset in "1_int" format:  [o] or [Oo]
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
  // If the "o" value is 0 (i.e., _target is NULL), the offset is stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
  // in the code stream.  See internal_word_Relocation::target().
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  // If _section is not -1, it is appended to the low bits of the offset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  void pack_data_to(CodeSection* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
  void fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
  address  target();        // if _target==NULL, fetch addr from code stream
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
  int      section()        { return _section;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
  address  value()          { return target();   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
class section_word_Relocation : public internal_word_Relocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
  relocInfo::relocType type() { return relocInfo::section_word_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
  static RelocationHolder spec(address target, int section) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
    RelocationHolder rh = newHolder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
    new(rh) section_word_Relocation(target, section);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
    return rh;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  section_word_Relocation(address target, int section) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
    assert(target != NULL, "must not be null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
    assert(section >= 0, "must be a valid section");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
    _target  = target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
    _section = section;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
  //void pack_data_to -- inherited
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
  void unpack_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
  friend class RelocIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  section_word_Relocation() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
class poll_Relocation : public Relocation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  bool          is_data()                      { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
  relocInfo::relocType type() { return relocInfo::poll_type; }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  1369
  void     fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29180
diff changeset
  1372
class poll_return_Relocation : public poll_Relocation {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
  relocInfo::relocType type() { return relocInfo::poll_return_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
// We know all the xxx_Relocation classes, so now we can define these:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
#define EACH_CASE(name)                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
inline name##_Relocation* RelocIterator::name##_reloc() {       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
  assert(type() == relocInfo::name##_type, "type must agree");  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  /* The purpose of the placed "new" is to re-use the same */   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  /* stack storage for each new iteration. */                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  name##_Relocation* r = new(_rh) name##_Relocation();          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
  r->set_binding(this);                                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
  r->name##_Relocation::unpack_data();                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
  return r;                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
APPLY_TO_RELOCATIONS(EACH_CASE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
#undef EACH_CASE
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37466
diff changeset
  1390
inline RelocIterator::RelocIterator(CompiledMethod* nm, address begin, address limit) {
5686
5435e77aa3df 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1217
diff changeset
  1391
  initialize(nm, begin, limit);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6432
diff changeset
  1394
#endif // SHARE_VM_CODE_RELOCINFO_HPP