src/hotspot/share/gc/shared/collectedHeap.hpp
changeset 50882 80abf702eed8
parent 50578 e2a7f431f65c
child 51625 c265860d5d45
equal deleted inserted replaced
50881:a21cad3fa448 50882:80abf702eed8
    93 //
    93 //
    94 class CollectedHeap : public CHeapObj<mtInternal> {
    94 class CollectedHeap : public CHeapObj<mtInternal> {
    95   friend class VMStructs;
    95   friend class VMStructs;
    96   friend class JVMCIVMStructs;
    96   friend class JVMCIVMStructs;
    97   friend class IsGCActiveMark; // Block structured external access to _is_gc_active
    97   friend class IsGCActiveMark; // Block structured external access to _is_gc_active
       
    98   friend class MemAllocator;
    98 
    99 
    99  private:
   100  private:
   100 #ifdef ASSERT
   101 #ifdef ASSERT
   101   static int       _fire_out_of_memory_count;
   102   static int       _fire_out_of_memory_count;
   102 #endif
   103 #endif
   139   virtual void accumulate_statistics_all_tlabs();
   140   virtual void accumulate_statistics_all_tlabs();
   140 
   141 
   141   // Reinitialize tlabs before resuming mutators.
   142   // Reinitialize tlabs before resuming mutators.
   142   virtual void resize_all_tlabs();
   143   virtual void resize_all_tlabs();
   143 
   144 
   144   // Allocate from the current thread's TLAB, with broken-out slow path.
       
   145   inline static HeapWord* allocate_from_tlab(Klass* klass, size_t size, TRAPS);
       
   146   static HeapWord* allocate_from_tlab_slow(Klass* klass, size_t size, TRAPS);
       
   147 
       
   148   inline static HeapWord* allocate_outside_tlab(Klass* klass, size_t size,
       
   149                                                 bool* gc_overhead_limit_was_exceeded, TRAPS);
       
   150 
       
   151   // Raw memory allocation facilities
   145   // Raw memory allocation facilities
   152   // The obj and array allocate methods are covers for these methods.
   146   // The obj and array allocate methods are covers for these methods.
   153   // mem_allocate() should never be
   147   // mem_allocate() should never be
   154   // called to allocate TLABs, only individual objects.
   148   // called to allocate TLABs, only individual objects.
   155   virtual HeapWord* mem_allocate(size_t size,
   149   virtual HeapWord* mem_allocate(size_t size,
   156                                  bool* gc_overhead_limit_was_exceeded) = 0;
   150                                  bool* gc_overhead_limit_was_exceeded) = 0;
   157 
   151 
   158   // Allocate an uninitialized block of the given size, or returns NULL if
       
   159   // this is impossible.
       
   160   inline static HeapWord* common_mem_allocate_noinit(Klass* klass, size_t size, TRAPS);
       
   161 
       
   162   // Like allocate_init, but the block returned by a successful allocation
       
   163   // is guaranteed initialized to zeros.
       
   164   inline static HeapWord* common_mem_allocate_init(Klass* klass, size_t size, TRAPS);
       
   165 
       
   166   // Helper functions for (VM) allocation.
       
   167   inline static void post_allocation_setup_common(Klass* klass, HeapWord* obj);
       
   168   inline static void post_allocation_setup_no_klass_install(Klass* klass,
       
   169                                                             HeapWord* objPtr);
       
   170 
       
   171   inline static void post_allocation_setup_obj(Klass* klass, HeapWord* obj, int size);
       
   172 
       
   173   inline static void post_allocation_setup_array(Klass* klass,
       
   174                                                  HeapWord* obj, int length);
       
   175 
       
   176   inline static void post_allocation_setup_class(Klass* klass, HeapWord* obj, int size);
       
   177 
       
   178   // Clears an allocated object.
       
   179   inline static void init_obj(HeapWord* obj, size_t size);
       
   180 
       
   181   // Filler object utilities.
   152   // Filler object utilities.
   182   static inline size_t filler_array_hdr_size();
   153   static inline size_t filler_array_hdr_size();
   183   static inline size_t filler_array_min_size();
   154   static inline size_t filler_array_min_size();
   184 
   155 
   185   DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
   156   DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
   192   // Fill with a single object (either an int array or a java.lang.Object).
   163   // Fill with a single object (either an int array or a java.lang.Object).
   193   static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
   164   static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
   194 
   165 
   195   virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
   166   virtual void trace_heap(GCWhen::Type when, const GCTracer* tracer);
   196 
   167 
   197   // Internal allocation methods.
       
   198   inline static HeapWord* common_allocate_memory(Klass* klass, int size,
       
   199                                                  void (*post_setup)(Klass*, HeapWord*, int),
       
   200                                                  int size_for_post, bool init_memory,
       
   201                                                  TRAPS);
       
   202 
       
   203   // Internal allocation method for common obj/class/array allocations.
       
   204   inline static HeapWord* allocate_memory(Klass* klass, int size,
       
   205                                           void (*post_setup)(Klass*, HeapWord*, int),
       
   206                                           int size_for_post, bool init_memory,
       
   207                                           TRAPS);
       
   208 
       
   209   // Verification functions
   168   // Verification functions
   210   virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
       
   211     PRODUCT_RETURN;
       
   212   virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
   169   virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
   213     PRODUCT_RETURN;
   170     PRODUCT_RETURN;
   214   debug_only(static void check_for_valid_allocation_state();)
   171   debug_only(static void check_for_valid_allocation_state();)
   215 
   172 
   216  public:
   173  public:
   326      }
   283      }
   327     _gc_cause = v;
   284     _gc_cause = v;
   328   }
   285   }
   329   GCCause::Cause gc_cause() { return _gc_cause; }
   286   GCCause::Cause gc_cause() { return _gc_cause; }
   330 
   287 
   331   // General obj/array allocation facilities.
   288   virtual oop obj_allocate(Klass* klass, int size, TRAPS);
   332   inline static oop obj_allocate(Klass* klass, int size, TRAPS);
   289   virtual oop array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS);
   333   inline static oop array_allocate(Klass* klass, int size, int length, TRAPS);
   290   virtual oop class_allocate(Klass* klass, int size, TRAPS);
   334   inline static oop array_allocate_nozero(Klass* klass, int size, int length, TRAPS);
       
   335   inline static oop class_allocate(Klass* klass, int size, TRAPS);
       
   336 
       
   337   // Raw memory allocation. This may or may not use TLAB allocations to satisfy the
       
   338   // allocation. A GC implementation may override this function to satisfy the allocation
       
   339   // in any way. But the default is to try a TLAB allocation, and otherwise perform
       
   340   // mem_allocate.
       
   341   virtual HeapWord* obj_allocate_raw(Klass* klass, size_t size,
       
   342                                      bool* gc_overhead_limit_was_exceeded, TRAPS);
       
   343 
   291 
   344   // Utilities for turning raw memory into filler objects.
   292   // Utilities for turning raw memory into filler objects.
   345   //
   293   //
   346   // min_fill_size() is the smallest region that can be filled.
   294   // min_fill_size() is the smallest region that can be filled.
   347   // fill_with_objects() can fill arbitrary-sized regions of the heap using
   295   // fill_with_objects() can fill arbitrary-sized regions of the heap using