252 enum relocType {
253 none = 0, // Used when no relocation should be generated
254 oop_type = 1, // embedded oop
255 virtual_call_type = 2, // a standard inline cache call for a virtual send
256 opt_virtual_call_type = 3, // a virtual call that has been statically bound (i.e., no IC cache)
257 static_call_type = 4, // a static send
258 static_stub_type = 5, // stub-entry for static send (takes care of interpreter case)
259 runtime_call_type = 6, // call to fixed external routine
260 external_word_type = 7, // reference to fixed external address
261 internal_word_type = 8, // reference within the current code blob
262 section_word_type = 9, // internal, but a cross-section reference
263 poll_type = 10, // polling instruction for safepoints
264 poll_return_type = 11, // polling instruction for safepoints at return
265 metadata_type = 12, // metadata that used to be oops
266 trampoline_stub_type = 13, // stub-entry for trampoline
267 runtime_call_w_cp_type = 14, // Runtime call which may load its target from the constant pool
268 data_prefix_tag = 15, // tag for a prefix (carries data arguments)
269 post_call_nop_type = 16, // A tag for post call nop relocations
270 entry_guard_type = 17, // A tag for an nmethod entry barrier guard value
271 barrier_type = 18, // GC barrier data
272 type_mask = 31 // A mask which selects only the above values
273 };
274
275 private:
276 unsigned short _value;
277
278 static const enum class RawBitsToken {} RAW_BITS{};
279
280 relocInfo(relocType type, RawBitsToken, int bits)
281 : _value(checked_cast<unsigned short>((type << nontype_width) + bits)) { }
282
283 static relocType check_relocType(relocType type) NOT_DEBUG({ return type; });
284
285 static void check_offset_and_format(int offset, int format) NOT_DEBUG_RETURN;
286
287 static int compute_bits(int offset, int format) {
288 check_offset_and_format(offset, format);
289 return (offset / offset_unit) + (format << offset_width);
290 }
291
294 : relocInfo(check_relocType(type), RAW_BITS, compute_bits(offset, format)) {}
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(runtime_call_w_cp) \
305 visitor(external_word) \
306 visitor(internal_word) \
307 visitor(poll) \
308 visitor(poll_return) \
309 visitor(section_word) \
310 visitor(trampoline_stub) \
311 visitor(post_call_nop) \
312 visitor(entry_guard) \
313 visitor(barrier) \
314
315
316 public:
317 enum : unsigned short{
318 value_width = sizeof(unsigned short) * BitsPerByte,
319 type_width = 5, // == log2(type_mask+1)
320 nontype_width = value_width - type_width,
321 datalen_width = nontype_width-1,
322 datalen_tag = 1 << datalen_width, // or-ed into _value
323 datalen_limit = 1 << datalen_width,
324 datalen_mask = (1 << datalen_width)-1
325 };
326
327 // accessors
328 public:
329 relocType type() const { return (relocType)((unsigned)_value >> nontype_width); }
330 int format() const { return format_mask==0? 0: format_mask &
331 ((unsigned)_value >> offset_width); }
332 int addr_offset() const { assert(!is_prefix(), "must have offset");
333 return (_value & offset_mask)*offset_unit; }
1054
1055 class barrier_Relocation : public Relocation {
1056
1057 public:
1058 // The uninitialized value used before the relocation has been patched.
1059 // Code assumes that the unpatched value is zero.
1060 static const int16_t unpatched = 0;
1061
1062 static RelocationHolder spec() {
1063 return RelocationHolder::construct<barrier_Relocation>();
1064 }
1065
1066 void copy_into(RelocationHolder& holder) const override;
1067
1068 private:
1069 friend class RelocIterator;
1070 friend class RelocationHolder;
1071 barrier_Relocation() : Relocation(relocInfo::barrier_type) { }
1072 };
1073
1074
1075 class virtual_call_Relocation : public CallRelocation {
1076
1077 public:
1078 // "cached_value" points to the first associated set-oop.
1079 // The oop_limit helps find the last associated set-oop.
1080 // (See comments at the top of this file.)
1081 static RelocationHolder spec(address cached_value, jint method_index = 0) {
1082 return RelocationHolder::construct<virtual_call_Relocation>(cached_value, method_index);
1083 }
1084
1085 void copy_into(RelocationHolder& holder) const override;
1086
1087 private:
1088 address _cached_value; // location of set-value instruction
1089 jint _method_index; // resolved method for a Java call
1090
1091 virtual_call_Relocation(address cached_value, int method_index)
1092 : CallRelocation(relocInfo::virtual_call_type),
1093 _cached_value(cached_value),
|
252 enum relocType {
253 none = 0, // Used when no relocation should be generated
254 oop_type = 1, // embedded oop
255 virtual_call_type = 2, // a standard inline cache call for a virtual send
256 opt_virtual_call_type = 3, // a virtual call that has been statically bound (i.e., no IC cache)
257 static_call_type = 4, // a static send
258 static_stub_type = 5, // stub-entry for static send (takes care of interpreter case)
259 runtime_call_type = 6, // call to fixed external routine
260 external_word_type = 7, // reference to fixed external address
261 internal_word_type = 8, // reference within the current code blob
262 section_word_type = 9, // internal, but a cross-section reference
263 poll_type = 10, // polling instruction for safepoints
264 poll_return_type = 11, // polling instruction for safepoints at return
265 metadata_type = 12, // metadata that used to be oops
266 trampoline_stub_type = 13, // stub-entry for trampoline
267 runtime_call_w_cp_type = 14, // Runtime call which may load its target from the constant pool
268 data_prefix_tag = 15, // tag for a prefix (carries data arguments)
269 post_call_nop_type = 16, // A tag for post call nop relocations
270 entry_guard_type = 17, // A tag for an nmethod entry barrier guard value
271 barrier_type = 18, // GC barrier data
272 patchable_barrier_type = 19, // Patchable GC barrier
273 type_mask = 31 // A mask which selects only the above values
274 };
275
276 private:
277 unsigned short _value;
278
279 static const enum class RawBitsToken {} RAW_BITS{};
280
281 relocInfo(relocType type, RawBitsToken, int bits)
282 : _value(checked_cast<unsigned short>((type << nontype_width) + bits)) { }
283
284 static relocType check_relocType(relocType type) NOT_DEBUG({ return type; });
285
286 static void check_offset_and_format(int offset, int format) NOT_DEBUG_RETURN;
287
288 static int compute_bits(int offset, int format) {
289 check_offset_and_format(offset, format);
290 return (offset / offset_unit) + (format << offset_width);
291 }
292
295 : relocInfo(check_relocType(type), RAW_BITS, compute_bits(offset, format)) {}
296
297 #define APPLY_TO_RELOCATIONS(visitor) \
298 visitor(oop) \
299 visitor(metadata) \
300 visitor(virtual_call) \
301 visitor(opt_virtual_call) \
302 visitor(static_call) \
303 visitor(static_stub) \
304 visitor(runtime_call) \
305 visitor(runtime_call_w_cp) \
306 visitor(external_word) \
307 visitor(internal_word) \
308 visitor(poll) \
309 visitor(poll_return) \
310 visitor(section_word) \
311 visitor(trampoline_stub) \
312 visitor(post_call_nop) \
313 visitor(entry_guard) \
314 visitor(barrier) \
315 visitor(patchable_barrier) \
316
317
318 public:
319 enum : unsigned short{
320 value_width = sizeof(unsigned short) * BitsPerByte,
321 type_width = 5, // == log2(type_mask+1)
322 nontype_width = value_width - type_width,
323 datalen_width = nontype_width-1,
324 datalen_tag = 1 << datalen_width, // or-ed into _value
325 datalen_limit = 1 << datalen_width,
326 datalen_mask = (1 << datalen_width)-1
327 };
328
329 // accessors
330 public:
331 relocType type() const { return (relocType)((unsigned)_value >> nontype_width); }
332 int format() const { return format_mask==0? 0: format_mask &
333 ((unsigned)_value >> offset_width); }
334 int addr_offset() const { assert(!is_prefix(), "must have offset");
335 return (_value & offset_mask)*offset_unit; }
1056
1057 class barrier_Relocation : public Relocation {
1058
1059 public:
1060 // The uninitialized value used before the relocation has been patched.
1061 // Code assumes that the unpatched value is zero.
1062 static const int16_t unpatched = 0;
1063
1064 static RelocationHolder spec() {
1065 return RelocationHolder::construct<barrier_Relocation>();
1066 }
1067
1068 void copy_into(RelocationHolder& holder) const override;
1069
1070 private:
1071 friend class RelocIterator;
1072 friend class RelocationHolder;
1073 barrier_Relocation() : Relocation(relocInfo::barrier_type) { }
1074 };
1075
1076 class patchable_barrier_Relocation : public Relocation {
1077 public:
1078 jint _metadata;
1079 jint _target_offset;
1080
1081 static RelocationHolder spec(int metadata) {
1082 return RelocationHolder::construct<patchable_barrier_Relocation>(metadata);
1083 }
1084
1085 patchable_barrier_Relocation(int metadata) : Relocation(relocInfo::patchable_barrier_type),
1086 _metadata(metadata), _target_offset(0) { }
1087
1088 void pack_data_to(CodeSection* dest) override;
1089 void unpack_data() override;
1090
1091 void copy_into(RelocationHolder& holder) const override;
1092
1093 jint metadata() const { return _metadata; }
1094 jint target_offset() const { return _target_offset; }
1095
1096 void set_target_offset(jint target_offset);
1097
1098 private:
1099 friend class RelocIterator;
1100 friend class RelocationHolder;
1101 patchable_barrier_Relocation() : Relocation(relocInfo::patchable_barrier_type) { }
1102 };
1103
1104 class virtual_call_Relocation : public CallRelocation {
1105
1106 public:
1107 // "cached_value" points to the first associated set-oop.
1108 // The oop_limit helps find the last associated set-oop.
1109 // (See comments at the top of this file.)
1110 static RelocationHolder spec(address cached_value, jint method_index = 0) {
1111 return RelocationHolder::construct<virtual_call_Relocation>(cached_value, method_index);
1112 }
1113
1114 void copy_into(RelocationHolder& holder) const override;
1115
1116 private:
1117 address _cached_value; // location of set-value instruction
1118 jint _method_index; // resolved method for a Java call
1119
1120 virtual_call_Relocation(address cached_value, int method_index)
1121 : CallRelocation(relocInfo::virtual_call_type),
1122 _cached_value(cached_value),
|