128 bool is_register_loc() { return reg()->is_reg(); } 129 bool is_stack_loc() { return reg()->is_stack(); } 130 131 // Returns offset from sp. 132 int stack_offset() { 133 assert(is_stack_loc(), "must be stack location"); 134 return reg()->reg2stack(); 135 } 136 137 void print_on(outputStream* st) const; 138 void print() const { print_on(tty); } 139 }; 140 141 142 class OopMap: public ResourceObj { 143 friend class OopMapStream; 144 friend class VMStructs; 145 private: 146 int _pc_offset; 147 int _omv_count; 148 int _omv_data_size; 149 unsigned char* _omv_data; 150 CompressedWriteStream* _write_stream; 151 152 debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;) 153 154 // Accessors 155 unsigned char* omv_data() const { return _omv_data; } 156 void set_omv_data(unsigned char* value) { _omv_data = value; } 157 int omv_data_size() const { return _omv_data_size; } 158 void set_omv_data_size(int value) { _omv_data_size = value; } 159 int omv_count() const { return _omv_count; } 160 void set_omv_count(int value) { _omv_count = value; } 161 void increment_count() { _omv_count++; } 162 CompressedWriteStream* write_stream() const { return _write_stream; } 163 void set_write_stream(CompressedWriteStream* value) { _write_stream = value; } 164 165 private: 166 enum DeepCopyToken { _deep_copy_token }; 167 OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy 168 169 public: 170 OopMap(int frame_size, int arg_count); 171 172 // pc-offset handling 173 int offset() const { return _pc_offset; } 174 void set_offset(int o) { _pc_offset = o; } 175 176 // Check to avoid double insertion 177 debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; }) 178 179 // Construction 180 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd 181 // slots to hold 4-byte values like ints and floats in the LP64 build. 182 void set_oop ( VMReg local); 183 void set_value( VMReg local); 184 void set_narrowoop(VMReg local); 185 void set_dead ( VMReg local); 186 void set_callee_saved( VMReg local, VMReg caller_machine_register ); 187 void set_derived_oop ( VMReg local, VMReg derived_from_local_register ); 188 void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional); 189 190 int heap_size() const; 191 void copy_to(address addr); 192 OopMap* deep_copy(); 193 194 bool has_derived_pointer() const PRODUCT_RETURN0; 195 196 bool legal_vm_reg_name(VMReg local) { 197 return OopMapValue::legal_vm_reg_name(local); 198 } 199 200 // Printing 201 void print_on(outputStream* st) const; 202 void print() const { print_on(tty); } 203 }; 204 205 206 class OopMapSet : public ResourceObj { 207 friend class VMStructs; 208 private: 209 int _om_count; 210 int _om_size; 211 OopMap** _om_data; 212 213 int om_count() const { return _om_count; } 214 void set_om_count(int value) { _om_count = value; } 215 void increment_count() { _om_count++; } 216 int om_size() const { return _om_size; } 217 void set_om_size(int value) { _om_size = value; } 218 OopMap** om_data() const { return _om_data; } 219 void set_om_data(OopMap** value) { _om_data = value; } 220 void grow_om_data(); 221 void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; } 222 223 public: 224 OopMapSet(); 225 226 // returns the number of OopMaps in this OopMapSet 227 int size() const { return _om_count; } 228 // returns the OopMap at a given index 229 OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; } 230 231 // Collect OopMaps. 232 void add_gc_map(int pc, OopMap* map); 233 234 // Returns the only oop map. Used for reconstructing 235 // Adapter frames during deoptimization 236 OopMap* singular_oop_map(); 237 238 // returns OopMap in that is anchored to the pc 239 OopMap* find_map_at_offset(int pc_offset) const; 240 241 int heap_size() const; 242 void copy_to(address addr); 243 244 // Methods oops_do() and all_do() filter out NULL oops and 245 // oop == Universe::narrow_oop_base() before passing oops 246 // to closures. 247 248 // Iterates through frame for a compiled method 249 static void oops_do (const frame* fr, 250 const RegisterMap* reg_map, OopClosure* f); 251 static void update_register_map(const frame* fr, RegisterMap *reg_map); 252 253 // Iterates through frame for a compiled method for dead ones and values, too 254 static void all_do(const frame* fr, const RegisterMap* reg_map, 255 OopClosure* oop_fn, 256 void derived_oop_fn(oop* base, oop* derived), 257 OopClosure* value_fn); 258 259 // Printing 260 void print_on(outputStream* st) const; 261 void print() const { print_on(tty); } 262 }; 263 264 265 class OopMapStream : public StackObj { 266 private: 267 CompressedReadStream* _stream; 268 int _mask; 269 int _size; 270 int _position; 271 bool _valid_omv; 272 OopMapValue _omv; 273 void find_next(); 274 275 public: 276 OopMapStream(OopMap* oop_map); 277 OopMapStream(OopMap* oop_map, int oop_types_mask); 278 bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; } 279 void next() { find_next(); } 280 OopMapValue current() { return _omv; } 281 }; 282 283 284 // Derived pointer support. This table keeps track of all derived points on a 285 // stack. It is cleared before each scavenge/GC. During the traversal of all 286 // oops, it is filled in with references to all locations that contains a 287 // derived oop (assumed to be very few). When the GC is complete, the derived 288 // pointers are updated based on their base pointers new value and an offset. 289 #ifdef COMPILER2 290 class DerivedPointerTable : public AllStatic { 291 friend class VMStructs; 292 private: 293 static GrowableArray<DerivedPointerEntry*>* _list; 294 static bool _active; // do not record pointers for verify pass etc. 295 public: 296 static void clear(); // Called before scavenge/GC 297 static void add(oop *derived, oop *base); // Called during scavenge/GC | 128 bool is_register_loc() { return reg()->is_reg(); } 129 bool is_stack_loc() { return reg()->is_stack(); } 130 131 // Returns offset from sp. 132 int stack_offset() { 133 assert(is_stack_loc(), "must be stack location"); 134 return reg()->reg2stack(); 135 } 136 137 void print_on(outputStream* st) const; 138 void print() const { print_on(tty); } 139 }; 140 141 142 class OopMap: public ResourceObj { 143 friend class OopMapStream; 144 friend class VMStructs; 145 private: 146 int _pc_offset; 147 int _omv_count; 148 CompressedWriteStream* _write_stream; 149 150 debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;) 151 152 // Accessors 153 int omv_count() const { return _omv_count; } 154 void set_omv_count(int value) { _omv_count = value; } 155 void increment_count() { _omv_count++; } 156 CompressedWriteStream* write_stream() const { return _write_stream; } 157 void set_write_stream(CompressedWriteStream* value) { _write_stream = value; } 158 159 private: 160 enum DeepCopyToken { _deep_copy_token }; 161 OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy 162 163 public: 164 OopMap(int frame_size, int arg_count); 165 166 // pc-offset handling 167 int offset() const { return _pc_offset; } 168 void set_offset(int o) { _pc_offset = o; } 169 int count() const { return _omv_count; } 170 int data_size() const { return write_stream()->position(); } 171 address data() const { return write_stream()->buffer(); } 172 173 // Check to avoid double insertion 174 debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; }) 175 176 // Construction 177 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd 178 // slots to hold 4-byte values like ints and floats in the LP64 build. 179 void set_oop ( VMReg local); 180 void set_value( VMReg local); 181 void set_narrowoop(VMReg local); 182 void set_dead ( VMReg local); 183 void set_callee_saved( VMReg local, VMReg caller_machine_register ); 184 void set_derived_oop ( VMReg local, VMReg derived_from_local_register ); 185 void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional); 186 187 int heap_size() const; 188 void copy_data_to(address addr) const; 189 OopMap* deep_copy(); 190 191 bool legal_vm_reg_name(VMReg local) { 192 return OopMapValue::legal_vm_reg_name(local); 193 } 194 195 // Printing 196 void print_on(outputStream* st) const; 197 void print() const { print_on(tty); } 198 bool equals(const OopMap* other) const; 199 }; 200 201 202 class OopMapSet : public ResourceObj { 203 friend class VMStructs; 204 private: 205 int _om_count; 206 int _om_size; 207 OopMap** _om_data; 208 209 int om_count() const { return _om_count; } 210 void set_om_count(int value) { _om_count = value; } 211 void increment_count() { _om_count++; } 212 int om_size() const { return _om_size; } 213 void set_om_size(int value) { _om_size = value; } 214 OopMap** om_data() const { return _om_data; } 215 void set_om_data(OopMap** value) { _om_data = value; } 216 void grow_om_data(); 217 void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; } 218 219 public: 220 OopMapSet(); 221 222 // returns the number of OopMaps in this OopMapSet 223 int size() const { return _om_count; } 224 // returns the OopMap at a given index 225 OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; } 226 227 // Collect OopMaps. 228 void add_gc_map(int pc, OopMap* map); 229 230 // Returns the only oop map. Used for reconstructing 231 // Adapter frames during deoptimization 232 OopMap* singular_oop_map(); 233 234 // returns OopMap in that is anchored to the pc 235 OopMap* find_map_at_offset(int pc_offset) const; 236 237 int heap_size() const; 238 239 // Methods oops_do() and all_do() filter out NULL oops and 240 // oop == Universe::narrow_oop_base() before passing oops 241 // to closures. 242 243 // Iterates through frame for a compiled method 244 static void oops_do (const frame* fr, 245 const RegisterMap* reg_map, OopClosure* f); 246 static void update_register_map(const frame* fr, RegisterMap *reg_map); 247 248 // Iterates through frame for a compiled method for dead ones and values, too 249 static void all_do(const frame* fr, const RegisterMap* reg_map, 250 OopClosure* oop_fn, 251 void derived_oop_fn(oop* base, oop* derived), 252 OopClosure* value_fn); 253 254 // Printing 255 void print_on(outputStream* st) const; 256 void print() const { print_on(tty); } 257 }; 258 259 class ImmutableOopMapBuilder; 260 261 class ImmutableOopMap { 262 friend class OopMapStream; 263 friend class VMStructs; 264 friend class ImmutableOopMapBuilder; 265 private: 266 int _count; 267 address data_addr() const { return (address) this + sizeof(ImmutableOopMap); } 268 public: 269 ImmutableOopMap(const OopMap* oopmap); 270 271 bool has_derived_pointer() const PRODUCT_RETURN0; 272 int count() const { return _count; } 273 274 // Printing 275 void print_on(outputStream* st) const; 276 void print() const { print_on(tty); } 277 }; 278 279 class ImmutableOopMapSet; 280 class ImmutableOopMap; 281 class OopMapSet; 282 283 class ImmutableOopMapPair { 284 friend class VMStructs; 285 private: 286 int _pc; 287 int _offset; 288 public: 289 ImmutableOopMapPair(int pc, int offset) : _pc(pc), _offset(offset) { 290 assert(pc >= 0 && offset >= 0, "check"); 291 } 292 const ImmutableOopMap* get_from(const ImmutableOopMapSet* set) const; 293 294 int pc() const { return _pc; } 295 int offset() const { return _offset; } 296 }; 297 298 class ImmutableOopMapSet { 299 friend class VMStructs; 300 private: 301 int _count; 302 int _size; 303 304 address data() const { return (address) this + sizeof(*this) + sizeof(ImmutableOopMapPair) * _count; } 305 306 public: 307 ImmutableOopMapSet(const OopMapSet* oopmap_set, int size) : _count(oopmap_set->size()), _size(size) {} 308 309 ImmutableOopMap* oopmap_at_offset(int offset) const { 310 assert(offset >= 0 && offset < _size, "must be within boundaries"); 311 address addr = data() + offset; 312 return (ImmutableOopMap*) addr; 313 } 314 315 ImmutableOopMapPair* get_pairs() const { return (ImmutableOopMapPair*) ((address) this + sizeof(*this)); } 316 317 static ImmutableOopMapSet* build_from(const OopMapSet* oopmap_set); 318 319 const ImmutableOopMap* find_map_at_offset(int pc_offset) const; 320 321 const ImmutableOopMapPair* pair_at(int index) const { assert(index >= 0 && index < _count, "check"); return &get_pairs()[index]; } 322 323 int count() const { return _count; } 324 int size() const { return _size; } 325 326 void print_on(outputStream* st) const; 327 void print() const { print_on(tty); } 328 }; 329 330 class OopMapStream : public StackObj { 331 private: 332 CompressedReadStream* _stream; 333 int _mask; 334 int _size; 335 int _position; 336 bool _valid_omv; 337 OopMapValue _omv; 338 void find_next(); 339 340 public: 341 OopMapStream(OopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place); 342 OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place); 343 bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; } 344 void next() { find_next(); } 345 OopMapValue current() { return _omv; } 346 }; 347 348 349 // Derived pointer support. This table keeps track of all derived points on a 350 // stack. It is cleared before each scavenge/GC. During the traversal of all 351 // oops, it is filled in with references to all locations that contains a 352 // derived oop (assumed to be very few). When the GC is complete, the derived 353 // pointers are updated based on their base pointers new value and an offset. 354 #ifdef COMPILER2 355 class DerivedPointerTable : public AllStatic { 356 friend class VMStructs; 357 private: 358 static GrowableArray<DerivedPointerEntry*>* _list; 359 static bool _active; // do not record pointers for verify pass etc. 360 public: 361 static void clear(); // Called before scavenge/GC 362 static void add(oop *derived, oop *base); // Called during scavenge/GC |