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