hotspot/src/share/vm/compiler/oopMap.hpp
changeset 33160 c59f1676d27e
parent 33063 9e222337a81e
child 33589 7cbd1b2c139b
equal deleted inserted replaced
33159:89b942323bd1 33160:c59f1676d27e
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   182 
   182 
   183   int heap_size() const;
   183   int heap_size() const;
   184   void copy_data_to(address addr) const;
   184   void copy_data_to(address addr) const;
   185   OopMap* deep_copy();
   185   OopMap* deep_copy();
   186 
   186 
       
   187   bool has_derived_pointer() const PRODUCT_RETURN0;
       
   188 
   187   bool legal_vm_reg_name(VMReg local) {
   189   bool legal_vm_reg_name(VMReg local) {
   188      return OopMapValue::legal_vm_reg_name(local);
   190      return OopMapValue::legal_vm_reg_name(local);
   189   }
   191   }
   190 
   192 
   191   // Printing
   193   // Printing
   348 #ifdef ASSERT
   350 #ifdef ASSERT
   349   int stream_position() const           { return _stream->position(); }
   351   int stream_position() const           { return _stream->position(); }
   350 #endif
   352 #endif
   351 };
   353 };
   352 
   354 
       
   355 class ImmutableOopMapBuilder {
       
   356 private:
       
   357   class Mapping;
       
   358 
       
   359 private:
       
   360   const OopMapSet* _set;
       
   361   const OopMap* _empty;
       
   362   const OopMap* _last;
       
   363   int _empty_offset;
       
   364   int _last_offset;
       
   365   int _offset;
       
   366   int _required;
       
   367   Mapping* _mapping;
       
   368   ImmutableOopMapSet* _new_set;
       
   369 
       
   370   /* Used for bookkeeping when building ImmutableOopMaps */
       
   371   class Mapping : public ResourceObj {
       
   372   public:
       
   373     enum kind_t { OOPMAP_UNKNOWN = 0, OOPMAP_NEW = 1, OOPMAP_EMPTY = 2, OOPMAP_DUPLICATE = 3 };
       
   374 
       
   375     kind_t _kind;
       
   376     int _offset;
       
   377     int _size;
       
   378     const OopMap* _map;
       
   379     const OopMap* _other;
       
   380 
       
   381     Mapping() : _kind(OOPMAP_UNKNOWN), _offset(-1), _size(-1), _map(NULL) {}
       
   382 
       
   383     void set(kind_t kind, int offset, int size, const OopMap* map = 0, const OopMap* other = 0) {
       
   384       _kind = kind;
       
   385       _offset = offset;
       
   386       _size = size;
       
   387       _map = map;
       
   388       _other = other;
       
   389     }
       
   390   };
       
   391 
       
   392 public:
       
   393   ImmutableOopMapBuilder(const OopMapSet* set);
       
   394 
       
   395   int heap_size();
       
   396   ImmutableOopMapSet* build();
       
   397   ImmutableOopMapSet* generate_into(address buffer);
       
   398 private:
       
   399   bool is_empty(const OopMap* map) const {
       
   400     return map->count() == 0;
       
   401   }
       
   402 
       
   403   bool is_last_duplicate(const OopMap* map) {
       
   404     if (_last != NULL && _last->count() > 0 && _last->equals(map)) {
       
   405       return true;
       
   406     }
       
   407     return false;
       
   408   }
       
   409 
       
   410 #ifdef ASSERT
       
   411   void verify(address buffer, int size, const ImmutableOopMapSet* set);
       
   412 #endif
       
   413 
       
   414   bool has_empty() const {
       
   415     return _empty_offset != -1;
       
   416   }
       
   417 
       
   418   int size_for(const OopMap* map) const;
       
   419   void fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
       
   420   int fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
       
   421   void fill(ImmutableOopMapSet* set, int size);
       
   422 };
       
   423 
   353 
   424 
   354 // Derived pointer support. This table keeps track of all derived points on a
   425 // Derived pointer support. This table keeps track of all derived points on a
   355 // stack.  It is cleared before each scavenge/GC.  During the traversal of all
   426 // stack.  It is cleared before each scavenge/GC.  During the traversal of all
   356 // oops, it is filled in with references to all locations that contains a
   427 // oops, it is filled in with references to all locations that contains a
   357 // derived oop (assumed to be very few).  When the GC is complete, the derived
   428 // derived oop (assumed to be very few).  When the GC is complete, the derived
   358 // pointers are updated based on their base pointers new value and an offset.
   429 // pointers are updated based on their base pointers new value and an offset.
   359 #ifdef COMPILER2
   430 #if defined(COMPILER2) || INCLUDE_JVMCI
   360 class DerivedPointerTable : public AllStatic {
   431 class DerivedPointerTable : public AllStatic {
   361   friend class VMStructs;
   432   friend class VMStructs;
   362  private:
   433  private:
   363    static GrowableArray<DerivedPointerEntry*>* _list;
   434    static GrowableArray<DerivedPointerEntry*>* _list;
   364    static bool _active;                      // do not record pointers for verify pass etc.
   435    static bool _active;                      // do not record pointers for verify pass etc.
   390     if (_active) {
   461     if (_active) {
   391       DerivedPointerTable::set_active(true);
   462       DerivedPointerTable::set_active(true);
   392     }
   463     }
   393   }
   464   }
   394 };
   465 };
   395 #endif // COMPILER2
   466 #endif // COMPILER2 || INCLUDE_JVMCI
   396 
   467 
   397 #endif // SHARE_VM_COMPILER_OOPMAP_HPP
   468 #endif // SHARE_VM_COMPILER_OOPMAP_HPP