251 public:
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 barrier_type = 17, // GC barrier data
271 type_mask = 31 // A mask which selects only the above values
272 };
273
274 private:
275 unsigned short _value;
276
277 static const enum class RawBitsToken {} RAW_BITS{};
278
279 relocInfo(relocType type, RawBitsToken, int bits)
280 : _value(checked_cast<unsigned short>((type << nontype_width) + bits)) { }
281
282 static relocType check_relocType(relocType type) NOT_DEBUG({ return type; });
283
284 static void check_offset_and_format(int offset, int format) NOT_DEBUG_RETURN;
285
286 static int compute_bits(int offset, int format) {
287 check_offset_and_format(offset, format);
288 return (offset / offset_unit) + (format << offset_width);
289 }
290
292 relocInfo(relocType type, int offset, int format = 0)
293 : relocInfo(check_relocType(type), RAW_BITS, compute_bits(offset, format)) {}
294
295 #define APPLY_TO_RELOCATIONS(visitor) \
296 visitor(oop) \
297 visitor(metadata) \
298 visitor(virtual_call) \
299 visitor(opt_virtual_call) \
300 visitor(static_call) \
301 visitor(static_stub) \
302 visitor(runtime_call) \
303 visitor(runtime_call_w_cp) \
304 visitor(external_word) \
305 visitor(internal_word) \
306 visitor(poll) \
307 visitor(poll_return) \
308 visitor(section_word) \
309 visitor(trampoline_stub) \
310 visitor(post_call_nop) \
311 visitor(barrier) \
312
313
314 public:
315 enum : unsigned short{
316 value_width = sizeof(unsigned short) * BitsPerByte,
317 type_width = 5, // == log2(type_mask+1)
318 nontype_width = value_width - type_width,
319 datalen_width = nontype_width-1,
320 datalen_tag = 1 << datalen_width, // or-ed into _value
321 datalen_limit = 1 << datalen_width,
322 datalen_mask = (1 << datalen_width)-1
323 };
324
325 // accessors
326 public:
327 relocType type() const { return (relocType)((unsigned)_value >> nontype_width); }
328 int format() const { return format_mask==0? 0: format_mask &
329 ((unsigned)_value >> offset_width); }
330 int addr_offset() const { assert(!is_prefix(), "must have offset");
331 return (_value & offset_mask)*offset_unit; }
1039
1040 class barrier_Relocation : public Relocation {
1041
1042 public:
1043 // The uninitialized value used before the relocation has been patched.
1044 // Code assumes that the unpatched value is zero.
1045 static const int16_t unpatched = 0;
1046
1047 static RelocationHolder spec() {
1048 return RelocationHolder::construct<barrier_Relocation>();
1049 }
1050
1051 void copy_into(RelocationHolder& holder) const override;
1052
1053 private:
1054 friend class RelocIterator;
1055 friend class RelocationHolder;
1056 barrier_Relocation() : Relocation(relocInfo::barrier_type) { }
1057 };
1058
1059
1060 class virtual_call_Relocation : public CallRelocation {
1061
1062 public:
1063 // "cached_value" points to the first associated set-oop.
1064 // The oop_limit helps find the last associated set-oop.
1065 // (See comments at the top of this file.)
1066 static RelocationHolder spec(address cached_value, jint method_index = 0) {
1067 return RelocationHolder::construct<virtual_call_Relocation>(cached_value, method_index);
1068 }
1069
1070 void copy_into(RelocationHolder& holder) const override;
1071
1072 private:
1073 address _cached_value; // location of set-value instruction
1074 jint _method_index; // resolved method for a Java call
1075
1076 virtual_call_Relocation(address cached_value, int method_index)
1077 : CallRelocation(relocInfo::virtual_call_type),
1078 _cached_value(cached_value),
|
251 public:
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 barrier_type = 17, // GC barrier data
271 patchable_barrier_type = 18, // Patchable GC barrier
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
293 relocInfo(relocType type, int offset, int format = 0)
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(barrier) \
313 visitor(patchable_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; }
1041
1042 class barrier_Relocation : public Relocation {
1043
1044 public:
1045 // The uninitialized value used before the relocation has been patched.
1046 // Code assumes that the unpatched value is zero.
1047 static const int16_t unpatched = 0;
1048
1049 static RelocationHolder spec() {
1050 return RelocationHolder::construct<barrier_Relocation>();
1051 }
1052
1053 void copy_into(RelocationHolder& holder) const override;
1054
1055 private:
1056 friend class RelocIterator;
1057 friend class RelocationHolder;
1058 barrier_Relocation() : Relocation(relocInfo::barrier_type) { }
1059 };
1060
1061 class patchable_barrier_Relocation : public Relocation {
1062 private:
1063 static const int32_t unresolved = INT32_MAX;
1064
1065 int32_t _target_offset;
1066 uint16_t _metadata;
1067
1068 public:
1069 static RelocationHolder spec(uint16_t metadata) {
1070 return RelocationHolder::construct<patchable_barrier_Relocation>(metadata);
1071 }
1072
1073 patchable_barrier_Relocation(uint16_t metadata) : Relocation(relocInfo::patchable_barrier_type),
1074 _target_offset(unresolved), _metadata(metadata) { }
1075
1076 void pack_data_to(CodeSection* dest) override;
1077 void unpack_data() override;
1078
1079 void copy_into(RelocationHolder& holder) const override;
1080
1081 uint16_t metadata() const {
1082 return _metadata;
1083 }
1084 bool is_target_offset_resolved() const {
1085 return _target_offset != unresolved;
1086 }
1087 int32_t target_offset() const {
1088 assert(is_target_offset_resolved(), "Should be");
1089 return _target_offset;
1090 }
1091 void set_target_offset(int32_t target_offset);
1092
1093 private:
1094 friend class RelocIterator;
1095 friend class RelocationHolder;
1096 patchable_barrier_Relocation() : Relocation(relocInfo::patchable_barrier_type) { }
1097 };
1098
1099 class virtual_call_Relocation : public CallRelocation {
1100
1101 public:
1102 // "cached_value" points to the first associated set-oop.
1103 // The oop_limit helps find the last associated set-oop.
1104 // (See comments at the top of this file.)
1105 static RelocationHolder spec(address cached_value, jint method_index = 0) {
1106 return RelocationHolder::construct<virtual_call_Relocation>(cached_value, method_index);
1107 }
1108
1109 void copy_into(RelocationHolder& holder) const override;
1110
1111 private:
1112 address _cached_value; // location of set-value instruction
1113 jint _method_index; // resolved method for a Java call
1114
1115 virtual_call_Relocation(address cached_value, int method_index)
1116 : CallRelocation(relocInfo::virtual_call_type),
1117 _cached_value(cached_value),
|