1 /*
   2  * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #ifndef SHARE_GC_Z_ZCOLLECTEDHEAP_HPP
  25 #define SHARE_GC_Z_ZCOLLECTEDHEAP_HPP
  26 
  27 #include "gc/shared/collectedHeap.hpp"
  28 #include "gc/shared/softRefPolicy.hpp"
  29 #include "gc/z/zBarrierSet.hpp"
  30 #include "gc/z/zHeap.hpp"
  31 #include "gc/z/zInitialize.hpp"
  32 #include "gc/z/zRuntimeWorkers.hpp"
  33 
  34 class ZDirector;
  35 class ZDriver;
  36 class ZStat;
  37 
  38 class ZCollectedHeap : public CollectedHeap {
  39   friend class VMStructs;
  40 
  41 private:
  42   SoftRefPolicy     _soft_ref_policy;
  43   ZBarrierSet       _barrier_set;
  44   ZInitialize       _initialize;
  45   ZHeap             _heap;
  46   ZDirector*        _director;
  47   ZDriver*          _driver;
  48   ZStat*            _stat;
  49   ZRuntimeWorkers   _runtime_workers;
  50 
  51   virtual HeapWord* allocate_new_tlab(size_t min_size,
  52                                       size_t requested_size,
  53                                       size_t* actual_size);
  54 
  55 public:
  56   static ZCollectedHeap* heap();
  57 
  58   ZCollectedHeap();
  59   virtual Name kind() const;
  60   virtual const char* name() const;
  61   virtual jint initialize();
  62   virtual void initialize_serviceability();
  63   virtual void stop();
  64 
  65   virtual SoftRefPolicy* soft_ref_policy();
  66 
  67   virtual size_t max_capacity() const;
  68   virtual size_t capacity() const;
  69   virtual size_t used() const;
  70   virtual size_t unused() const;
  71 
  72   virtual bool is_maximal_no_gc() const;
  73   virtual bool is_in(const void* p) const;
  74 
  75   virtual uint32_t hash_oop(oop obj) const;
  76 
  77   virtual oop array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS);
  78   virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
  79   virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
  80                                                        size_t size,
  81                                                        Metaspace::MetadataType mdtype);
  82   virtual void collect(GCCause::Cause cause);
  83   virtual void collect_as_vm_thread(GCCause::Cause cause);
  84   virtual void do_full_collection(bool clear_all_soft_refs);
  85 
  86   virtual bool supports_tlab_allocation() const;
  87   virtual size_t tlab_capacity(Thread* thr) const;
  88   virtual size_t tlab_used(Thread* thr) const;
  89   virtual size_t max_tlab_size() const;
  90   virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
  91 
  92   virtual bool can_elide_tlab_store_barriers() const;
  93   virtual bool can_elide_initializing_store_barrier(oop new_obj);
  94   virtual bool card_mark_must_follow_store() const;
  95 
  96   virtual GrowableArray<GCMemoryManager*> memory_managers();
  97   virtual GrowableArray<MemoryPool*> memory_pools();
  98 
  99   virtual void object_iterate(ObjectClosure* cl);
 100 
 101   virtual void keep_alive(oop obj);
 102 
 103   virtual void register_nmethod(nmethod* nm);
 104   virtual void unregister_nmethod(nmethod* nm);
 105   virtual void flush_nmethod(nmethod* nm);
 106   virtual void verify_nmethod(nmethod* nmethod);
 107 
 108   virtual WorkGang* safepoint_workers();
 109 
 110   virtual void gc_threads_do(ThreadClosure* tc) const;
 111 
 112   virtual VirtualSpaceSummary create_heap_space_summary();
 113 
 114   virtual void safepoint_synchronize_begin();
 115   virtual void safepoint_synchronize_end();
 116 
 117   virtual void print_on(outputStream* st) const;
 118   virtual void print_on_error(outputStream* st) const;
 119   virtual void print_extended_on(outputStream* st) const;
 120   virtual void print_tracing_info() const;
 121   virtual bool print_location(outputStream* st, void* addr) const;
 122 
 123   virtual void prepare_for_verify();
 124   virtual void verify(VerifyOption option /* ignored */);
 125   virtual bool is_oop(oop object) const;
 126   virtual bool supports_concurrent_gc_breakpoints() const;
 127 };
 128 
 129 #endif // SHARE_GC_Z_ZCOLLECTEDHEAP_HPP