Merge epsilon-gc-branch
authorshade
Wed, 18 Apr 2018 09:46:53 +0200
branchepsilon-gc-branch
changeset 56448 76d86de267b9
parent 56422 b09629f4b243 (diff)
parent 49763 1ccf5fae9664 (current diff)
child 56449 a628f1855f4c
Merge
src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
src/hotspot/cpu/s390/stubGenerator_s390.cpp
src/hotspot/cpu/s390/templateTable_s390.cpp
src/hotspot/cpu/sparc/stubGenerator_sparc.cpp
src/hotspot/cpu/sparc/templateTable_sparc.cpp
src/hotspot/cpu/x86/c1_Runtime1_x86.cpp
src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
src/hotspot/cpu/x86/templateTable_x86.cpp
src/hotspot/share/c1/c1_LIRGenerator.cpp
src/hotspot/share/gc/cms/vmStructs_parNew.hpp
src/hotspot/share/gc/g1/g1_globals.cpp
src/hotspot/share/gc/shared/barrierSet.hpp
src/hotspot/share/gc/shared/collectedHeap.hpp
src/hotspot/share/gc/shared/gcArguments.cpp
src/hotspot/share/memory/binaryTreeDictionary.cpp
src/hotspot/share/memory/freeList.cpp
src/hotspot/share/memory/universe.cpp
src/hotspot/share/opto/graphKit.cpp
src/hotspot/share/precompiled/precompiled.hpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/arguments.hpp
src/hotspot/share/runtime/commandLineFlagConstraintList.cpp
src/hotspot/share/runtime/commandLineFlagConstraintsGC.cpp
src/hotspot/share/runtime/commandLineFlagConstraintsGC.hpp
src/hotspot/share/runtime/commandLineFlagRangeList.cpp
src/hotspot/share/runtime/commandLineFlagWriteableList.cpp
src/hotspot/share/runtime/globals.cpp
src/hotspot/share/runtime/globals.hpp
src/hotspot/share/runtime/globals_extension.hpp
src/hotspot/share/utilities/vmError.cpp
src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java
src/java.security.jgss/unix/native/libj2gss/NativeFunc.c
src/java.security.jgss/unix/native/libj2gss/NativeFunc.h
test/hotspot/jtreg/TEST.groups
test/hotspot/jtreg/runtime/6626217/Test6626217.sh
test/hotspot/jtreg/runtime/6626217/many_loader1.java.foo
test/hotspot/jtreg/runtime/6626217/many_loader2.java.foo
test/langtools/tools/javac/diags/examples/PreviewPlural/Bar.java
test/langtools/tools/javac/diags/examples/PreviewPluralAdditional/Bar.java
test/langtools/tools/javac/diags/examples/PreviewPluralAdditional/PreviewPluralAdditional.java
--- a/src/hotspot/cpu/arm/templateTable_arm.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/cpu/arm/templateTable_arm.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -228,6 +228,16 @@
         }
       }
       break;
+    case BarrierSet::Epsilon:
+      {
+        if (is_null) {
+          __ store_heap_oop_null(new_val, obj);
+        } else {
+          __ store_heap_oop(new_val, obj); // blows new_val:
+          new_val = noreg;
+        }
+      }
+      break;
 #endif // INCLUDE_ALL_GCS
     case BarrierSet::CardTableBarrierSet:
       {
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -1464,6 +1464,9 @@
     case BarrierSet::G1BarrierSet:
       G1BarrierSet_pre_barrier(addr_opr, pre_val, do_load, patch, info);
       break;
+    case BarrierSet::Epsilon:
+      // No barriers
+      break;
 #endif // INCLUDE_ALL_GCS
     case BarrierSet::CardTableBarrierSet:
       // No pre barriers
@@ -1480,6 +1483,9 @@
     case BarrierSet::G1BarrierSet:
       G1BarrierSet_post_barrier(addr,  new_val);
       break;
+    case BarrierSet::Epsilon:
+      // No barriers
+      break;
 #endif // INCLUDE_ALL_GCS
     case BarrierSet::CardTableBarrierSet:
       CardTableBarrierSet_post_barrier(addr,  new_val);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonArguments.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/epsilon/epsilonArguments.hpp"
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "gc/epsilon/epsilonCollectorPolicy.hpp"
+#include "gc/shared/gcArguments.inline.hpp"
+#include "runtime/globals.hpp"
+#include "runtime/globals_extension.hpp"
+#include "runtime/vm_version.hpp"
+
+size_t EpsilonArguments::conservative_max_heap_alignment() {
+  return UseLargePages ? os::large_page_size() : os::vm_page_size();
+}
+
+void EpsilonArguments::initialize() {
+  GCArguments::initialize();
+
+  assert(UseEpsilonGC, "Error");
+
+  // Forcefully exit when OOME is detected. Nothing we can do at that point.
+  if (FLAG_IS_DEFAULT(ExitOnOutOfMemoryError)) {
+    FLAG_SET_DEFAULT(ExitOnOutOfMemoryError, true);
+  }
+
+#if INCLUDE_ALL_GCS
+  if (EpsilonMaxTLABSize < MinTLABSize) {
+    warning("EpsilonMaxTLABSize < MinTLABSize, adjusting it to " SIZE_FORMAT, MinTLABSize);
+    EpsilonMaxTLABSize = MinTLABSize;
+  }
+#endif
+}
+
+CollectedHeap* EpsilonArguments::create_heap() {
+  return create_heap_with_policy<EpsilonHeap, EpsilonCollectorPolicy>();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonArguments.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_GC_EPSILON_EPSILONARGUMENTS_HPP
+#define SHARE_GC_EPSILON_EPSILONARGUMENTS_HPP
+
+#include "gc/shared/gcArguments.hpp"
+
+class CollectedHeap;
+
+class EpsilonArguments : public GCArguments {
+public:
+  virtual void initialize();
+  virtual size_t conservative_max_heap_alignment();
+  virtual CollectedHeap* create_heap();
+};
+
+#endif // SHARE_GC_EPSILON_EPSILONARGUMENTS_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonBarrierSet.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_BARRIERSET_HPP
+#define SHARE_VM_GC_EPSILON_BARRIERSET_HPP
+
+#include "gc/shared/collectorPolicy.hpp"
+#include "gc/shared/modRefBarrierSetAssembler.hpp"
+#include "gc/shared/barrierSet.hpp"
+
+// No interaction with application is required for Epsilon, and therefore
+// the barrier set is mostly empty.
+class EpsilonBarrierSet: public BarrierSet {
+  friend class VMStructs;
+
+public:
+  EpsilonBarrierSet() : BarrierSet(make_barrier_set_assembler<ModRefBarrierSetAssembler>(), BarrierSet::FakeRtti(BarrierSet::Epsilon)) {};
+  virtual void print_on(outputStream *st) const {}
+
+  template <DecoratorSet decorators, typename BarrierSetT = EpsilonBarrierSet>
+  class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {};
+
+protected:
+  virtual void write_ref_array_work(MemRegion mr) {}
+};
+
+template<>
+struct BarrierSet::GetName<EpsilonBarrierSet> {
+  static const BarrierSet::Name value = BarrierSet::Epsilon;
+};
+
+template<>
+struct BarrierSet::GetType<BarrierSet::Epsilon> {
+  typedef EpsilonBarrierSet type;
+};
+
+#endif // SHARE_VM_GC_EPSILON_BARRIERSET_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonCollectorPolicy.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_COLLECTORPOLICY_HPP
+#define SHARE_VM_GC_EPSILON_COLLECTORPOLICY_HPP
+
+#include "gc/shared/collectorPolicy.hpp"
+
+class EpsilonCollectorPolicy: public CollectorPolicy {
+protected:
+  virtual void initialize_alignments() {
+    size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
+    _space_alignment = page_size;
+    _heap_alignment = page_size;
+  }
+
+public:
+  EpsilonCollectorPolicy() : CollectorPolicy() {};
+};
+
+#endif // SHARE_VM_GC_EPSILON_COLLECTORPOLICY_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "gc/epsilon/epsilonMemoryPool.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/resourceArea.hpp"
+
+jint EpsilonHeap::initialize() {
+  size_t init_byte_size = _policy->initial_heap_byte_size();
+  size_t max_byte_size = _policy->max_heap_byte_size();
+  size_t align = _policy->heap_alignment();
+
+  ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,  align);
+  _virtual_space.initialize(heap_rs, init_byte_size);
+
+  MemRegion committed_region((HeapWord*)_virtual_space.low(), (HeapWord*)_virtual_space.high());
+  MemRegion reserved_region((HeapWord*)_virtual_space.low_boundary(), (HeapWord*)_virtual_space.high_boundary());
+
+  initialize_reserved_region(reserved_region.start(), reserved_region.end());
+
+  _space = new ContiguousSpace();
+  _space->initialize(committed_region, true, true);
+
+  set_barrier_set(new EpsilonBarrierSet());
+
+  _max_tlab_size = MIN2(CollectedHeap::max_tlab_size(), EpsilonMaxTLABSize / HeapWordSize);
+
+  _monitoring_support = new EpsilonMonitoringSupport(this);
+  _last_counter_update = 0;
+  _last_heap_print = 0;
+
+  _step_counter_update = MIN2<size_t>(max_byte_size / 16, EpsilonUpdateCountersStep);
+  _step_heap_print = (EpsilonPrintHeapStep == 0) ? SIZE_MAX : (max_byte_size / EpsilonPrintHeapStep);
+
+  if (init_byte_size != max_byte_size) {
+    log_info(gc)("Initialized with " SIZE_FORMAT "M heap, resizeable to up to " SIZE_FORMAT "M heap with " SIZE_FORMAT "M steps",
+                 init_byte_size / M, max_byte_size / M, EpsilonMinHeapExpand / M);
+  } else {
+    log_info(gc)("Initialized with " SIZE_FORMAT "M non-resizeable heap", init_byte_size / M);
+  }
+  if (UseTLAB) {
+    log_info(gc)("Using TLAB allocation; min: " SIZE_FORMAT "K, max: " SIZE_FORMAT "K",
+                                ThreadLocalAllocBuffer::min_size()*HeapWordSize / K,
+                                _max_tlab_size*HeapWordSize / K);
+  } else {
+    log_info(gc)("Not using TLAB allocation");
+  }
+
+  return JNI_OK;
+}
+
+void EpsilonHeap::post_initialize() {
+  CollectedHeap::post_initialize();
+}
+
+void EpsilonHeap::initialize_serviceability() {
+  _pool = new EpsilonMemoryPool(this);
+  _memory_manager.add_pool(_pool);
+}
+
+GrowableArray<GCMemoryManager*> EpsilonHeap::memory_managers() {
+  GrowableArray<GCMemoryManager*> memory_managers(1);
+  memory_managers.append(&_memory_manager);
+  return memory_managers;
+}
+
+GrowableArray<MemoryPool*> EpsilonHeap::memory_pools() {
+  GrowableArray<MemoryPool*> memory_pools(3);
+  memory_pools.append(_pool);
+  return memory_pools;
+}
+
+size_t EpsilonHeap::unsafe_max_tlab_alloc(Thread* thr) const {
+  // This is the only way we can control TLAB sizes without having safepoints.
+  // Implement exponential expansion within [MinTLABSize; _max_tlab_size], based
+  // on previously "used" TLAB size.
+
+  size_t size = MIN2(_max_tlab_size * HeapWordSize, MAX2(MinTLABSize, thr->tlab().used() * HeapWordSize * 2));
+
+  if (log_is_enabled(Trace, gc)) {
+    ResourceMark rm;
+    log_trace(gc)(
+            "Selecting TLAB size for \"%s\" (Desired: " SIZE_FORMAT "K, Used: " SIZE_FORMAT "K) -> " SIZE_FORMAT "K",
+            Thread::current()->name(),
+            thr->tlab().desired_size() * HeapWordSize / K,
+            thr->tlab().used() * HeapWordSize / K,
+            size / K);
+  }
+
+  return size;
+}
+
+EpsilonHeap* EpsilonHeap::heap() {
+  CollectedHeap* heap = Universe::heap();
+  assert(heap != NULL, "Uninitialized access to EpsilonHeap::heap()");
+  assert(heap->kind() == CollectedHeap::Epsilon, "Not a EpsilonHeap");
+  return (EpsilonHeap*)heap;
+}
+
+HeapWord* EpsilonHeap::allocate_work(size_t size) {
+  HeapWord* res = _space->par_allocate(size);
+
+  while (res == NULL) {
+    // Allocation failed, attempt expansion, and retry:
+    MutexLockerEx ml(Heap_lock);
+
+    size_t space_left = max_capacity() - capacity();
+    size_t want_space = MAX2(size, EpsilonMinHeapExpand);
+
+    if (want_space < space_left) {
+      // Enough space to expand in bulk:
+      bool expand = _virtual_space.expand_by(want_space);
+      assert(expand, "Should be able to expand");
+    } else if (size < space_left) {
+      // No space to expand in bulk, and this allocation is still possible,
+      // take all the space left:
+      bool expand = _virtual_space.expand_by(space_left);
+      assert(expand, "Should be able to expand");
+    } else {
+      // No space left:
+      return NULL;
+    }
+
+    _space->set_end((HeapWord *) _virtual_space.high());
+    res = _space->par_allocate(size);
+  }
+
+  size_t used = _space->used();
+  if (used - _last_counter_update >= _step_counter_update) {
+    _last_counter_update = used;
+    _monitoring_support->update_counters();
+  }
+
+  if (used - _last_heap_print >= _step_heap_print) {
+    log_info(gc)("Heap: " SIZE_FORMAT "M reserved, " SIZE_FORMAT "M committed, " SIZE_FORMAT "M used",
+                 max_capacity() / M, capacity() / M, used / M);
+    _last_heap_print = used;
+  }
+
+  return res;
+}
+
+HeapWord* EpsilonHeap::allocate_new_tlab(size_t size) {
+  return allocate_work(size);
+}
+
+HeapWord* EpsilonHeap::mem_allocate(size_t size, bool *gc_overhead_limit_was_exceeded) {
+  *gc_overhead_limit_was_exceeded = false;
+  return allocate_work(size);
+}
+
+void EpsilonHeap::collect(GCCause::Cause cause) {
+  log_info(gc)("GC request for \"%s\" is ignored", GCCause::to_string(cause));
+  _monitoring_support->update_counters();
+}
+
+void EpsilonHeap::do_full_collection(bool clear_all_soft_refs) {
+  log_info(gc)("Full GC request for \"%s\" is ignored", GCCause::to_string(gc_cause()));
+  _monitoring_support->update_counters();
+}
+
+void EpsilonHeap::safe_object_iterate(ObjectClosure *cl) {
+  _space->safe_object_iterate(cl);
+}
+
+void EpsilonHeap::print_on(outputStream *st) const {
+  st->print_cr("Epsilon Heap");
+
+  // Cast away constness:
+  ((VirtualSpace)_virtual_space).print_on(st);
+
+  st->print_cr("Allocation space:");
+  _space->print_on(st);
+}
+
+void EpsilonHeap::print_tracing_info() const {
+  Log(gc) log;
+  size_t allocated_kb = used() / K;
+  log.info("Total allocated: " SIZE_FORMAT " KB",
+           allocated_kb);
+  log.info("Average allocation rate: " SIZE_FORMAT " KB/sec",
+           (size_t)(allocated_kb * NANOSECS_PER_SEC / os::elapsed_counter()));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
+#define SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
+
+#include "gc/shared/collectedHeap.hpp"
+#include "gc/shared/softRefPolicy.hpp"
+#include "gc/shared/space.hpp"
+#include "services/memoryManager.hpp"
+#include "gc/epsilon/epsilonCollectorPolicy.hpp"
+#include "gc/epsilon/epsilonMonitoringSupport.hpp"
+#include "gc/epsilon/epsilonBarrierSet.hpp"
+#include "gc/epsilon/epsilon_globals.hpp"
+
+class EpsilonHeap : public CollectedHeap {
+private:
+  EpsilonCollectorPolicy* _policy;
+  SoftRefPolicy _soft_ref_policy;
+  EpsilonMonitoringSupport* _monitoring_support;
+  MemoryPool* _pool;
+  GCMemoryManager _memory_manager;
+  ContiguousSpace* _space;
+  VirtualSpace _virtual_space;
+  size_t _max_tlab_size;
+  size_t _last_counter_update;
+  size_t _last_heap_print;
+  size_t _step_counter_update;
+  size_t _step_heap_print;
+public:
+  EpsilonHeap(EpsilonCollectorPolicy* p) :
+          _policy(p),
+          _memory_manager("Epsilon Heap", "") {};
+
+  virtual Name kind() const {
+    return CollectedHeap::Epsilon;
+  }
+
+  virtual const char* name() const {
+    return "Epsilon";
+  }
+
+  virtual jint initialize();
+
+  virtual void post_initialize();
+
+  virtual void initialize_serviceability();
+  virtual GrowableArray<GCMemoryManager*> memory_managers();
+  virtual GrowableArray<MemoryPool*> memory_pools();
+
+  static EpsilonHeap* heap();
+
+  virtual size_t capacity()     const { return _virtual_space.committed_size(); }
+  virtual size_t used()         const { return _space->used(); }
+  virtual size_t max_capacity() const { return _virtual_space.reserved_size(); }
+
+  virtual bool is_maximal_no_gc() const {
+    // No GC is going to happen, unless we are at capacity.
+    // At which point we will fail anyway.
+    return used() == capacity();
+  }
+
+  virtual bool is_in(const void* p) const { return _space->is_in(p); }
+
+  virtual bool is_scavengable(oop obj) {
+    // No GC is going to happen, therefore no objects ever move.
+    return false;
+  }
+
+  HeapWord* allocate_work(size_t size);
+  virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
+  virtual HeapWord* allocate_new_tlab(size_t size);
+
+  // TLAB allocations
+  virtual bool supports_tlab_allocation()           const { return UseTLAB; }
+  virtual size_t tlab_capacity(Thread* thr)         const { return capacity(); }
+  virtual size_t tlab_used(Thread* thr)             const { return used(); }
+  virtual size_t max_tlab_size()                    const { return _max_tlab_size; }
+  virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
+
+  virtual void collect(GCCause::Cause cause);
+  virtual void do_full_collection(bool clear_all_soft_refs);
+
+  virtual AdaptiveSizePolicy* size_policy() {
+    // No such thing for Epsilon
+    return NULL;
+  }
+
+  virtual CollectorPolicy* collector_policy() const {
+    return _policy;
+  }
+
+  virtual SoftRefPolicy* soft_ref_policy() {
+    return &_soft_ref_policy;
+  }
+
+  virtual void object_iterate(ObjectClosure* cl) {
+    safe_object_iterate(cl);
+  }
+
+  virtual void safe_object_iterate(ObjectClosure* cl);
+
+  virtual HeapWord* block_start(const void* addr) const {
+    // No support for block parsing.
+    return NULL;
+  }
+
+  virtual size_t block_size(const HeapWord* addr) const {
+    // No support for block parsing.
+    return 0;
+  }
+
+  virtual bool block_is_obj(const HeapWord* addr) const {
+    // No support for block parsing.
+    return false;
+  }
+
+  virtual jlong millis_since_last_gc() {
+    // Report time since the VM start
+    return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
+  }
+
+  virtual void print_gc_threads_on(outputStream* st) const {
+    // No GC threads.
+  }
+
+  virtual void gc_threads_do(ThreadClosure* tc) const {
+    // No GC threads.
+  }
+
+  virtual void print_on(outputStream* st) const;
+  virtual void print_tracing_info() const;
+
+  virtual void prepare_for_verify() {
+    // No heap verification.
+  }
+
+  virtual void verify(VerifyOption option) {
+    // No heap verification.
+  }
+
+};
+
+#endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonMemoryPool.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "epsilonMemoryPool.hpp"
+
+EpsilonDummyMemoryPool::EpsilonDummyMemoryPool() :
+        CollectedMemoryPool("Epsilon Dummy",
+                            0,
+                            0,
+                            false /* support_usage_threshold */) {}
+
+EpsilonMemoryPool::EpsilonMemoryPool(EpsilonHeap* heap) :
+        _heap(heap),
+        CollectedMemoryPool("Epsilon Heap",
+                            heap->capacity(),
+                            heap->max_capacity(),
+                            false) {
+  assert(UseEpsilonGC, "sanity");
+}
+
+MemoryUsage EpsilonMemoryPool::get_memory_usage() {
+  size_t initial_sz = initial_size();
+  size_t max_sz     = max_size();
+  size_t used       = used_in_bytes();
+  size_t committed  = committed_in_bytes();
+
+  return MemoryUsage(initial_sz, used, committed, max_sz);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonMemoryPool.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_EPSILONMEMORYPOOL_HPP
+#define SHARE_VM_GC_EPSILON_EPSILONMEMORYPOOL_HPP
+
+#include "utilities/macros.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "services/memoryPool.hpp"
+#include "services/memoryUsage.hpp"
+#endif // INCLUDE_ALL_GCS
+
+class EpsilonDummyMemoryPool : public CollectedMemoryPool {
+public:
+  EpsilonDummyMemoryPool();
+  MemoryUsage get_memory_usage()      { return MemoryUsage(0, 0, 0, 0); }
+  size_t used_in_bytes()              { return 0; }
+  size_t max_size() const             { return 0; }
+};
+
+class EpsilonMemoryPool : public CollectedMemoryPool {
+private:
+  EpsilonHeap* _heap;
+
+public:
+  EpsilonMemoryPool(EpsilonHeap* heap);
+
+  size_t committed_in_bytes() {
+    return _heap->capacity();
+  }
+  size_t used_in_bytes() {
+    return _heap->used();
+  }
+  size_t max_size() const {
+    return _heap->max_capacity();
+  }
+  MemoryUsage get_memory_usage();
+};
+
+#endif // SHARE_VM_GC_EPSILON_EPSILONMEMORYPOOL_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/epsilon/epsilonMonitoringSupport.hpp"
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "gc/shared/generationCounters.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/resourceArea.hpp"
+#include "services/memoryService.hpp"
+
+class EpsilonSpaceCounters: public CHeapObj<mtGC> {
+  friend class VMStructs;
+
+private:
+  PerfVariable* _capacity;
+  PerfVariable* _used;
+  char*         _name_space;
+
+public:
+  EpsilonSpaceCounters(const char* name,
+                 int ordinal,
+                 size_t max_size,
+                 size_t initial_capacity,
+                 GenerationCounters* gc) {
+
+    if (UsePerfData) {
+      EXCEPTION_MARK;
+      ResourceMark rm;
+
+      const char* cns = PerfDataManager::name_space(gc->name_space(), "space", ordinal);
+
+      _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC);
+      strcpy(_name_space, cns);
+
+      const char* cname = PerfDataManager::counter_name(_name_space, "name");
+      PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
+
+      cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
+      PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, (jlong)max_size, CHECK);
+
+      cname = PerfDataManager::counter_name(_name_space, "capacity");
+      _capacity = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK);
+
+      cname = PerfDataManager::counter_name(_name_space, "used");
+      _used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, (jlong) 0, CHECK);
+
+      cname = PerfDataManager::counter_name(_name_space, "initCapacity");
+      PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK);
+    }
+  }
+
+  ~EpsilonSpaceCounters() {
+    if (_name_space != NULL) {
+      FREE_C_HEAP_ARRAY(char, _name_space);
+    }
+  }
+
+  inline void update_all(size_t capacity, size_t used) {
+    _capacity->set_value(capacity);
+    _used->set_value(used);
+  }
+};
+
+class EpsilonGenerationCounters : public GenerationCounters {
+private:
+  EpsilonHeap* _heap;
+public:
+  EpsilonGenerationCounters(EpsilonHeap* heap) :
+          GenerationCounters("Heap", 1, 1, 0, heap->max_capacity(), heap->capacity()),
+          _heap(heap)
+  {};
+
+  virtual void update_all() {
+    _current_size->set_value(_heap->capacity());
+  }
+};
+
+EpsilonMonitoringSupport::EpsilonMonitoringSupport(EpsilonHeap* heap) {
+  _heap_counters  = new EpsilonGenerationCounters(heap);
+  _space_counters = new EpsilonSpaceCounters("Heap", 0, heap->max_capacity(), 0, _heap_counters);
+}
+
+void EpsilonMonitoringSupport::update_counters() {
+  MemoryService::track_memory_usage();
+
+  if (UsePerfData) {
+    EpsilonHeap* heap = EpsilonHeap::heap();
+    size_t used = heap->used();
+    size_t capacity = heap->capacity();
+    _heap_counters->update_all();
+    _space_counters->update_all(capacity, used);
+    MetaspaceCounters::update_performance_counters();
+    CompressedClassSpaceCounters::update_performance_counters();
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_EPSILONMONITORINGSUPPORT_HPP
+#define SHARE_VM_GC_EPSILON_EPSILONMONITORINGSUPPORT_HPP
+
+#include "memory/allocation.hpp"
+
+class GenerationCounters;
+class EpsilonSpaceCounters;
+class EpsilonHeap;
+
+class EpsilonMonitoringSupport : public CHeapObj<mtGC> {
+private:
+  GenerationCounters*   _heap_counters;
+  EpsilonSpaceCounters* _space_counters;
+
+public:
+  EpsilonMonitoringSupport(EpsilonHeap* heap);
+  void update_counters();
+};
+
+#endif // SHARE_VM_GC_EPSILON_EPSILONMONITORINGSUPPORT_HPP
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilon_globals.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc/epsilon/epsilon_globals.hpp"
+
+EPSILON_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \
+         MATERIALIZE_PD_DEVELOPER_FLAG, \
+         MATERIALIZE_PRODUCT_FLAG, \
+         MATERIALIZE_PD_PRODUCT_FLAG,     \
+         MATERIALIZE_DIAGNOSTIC_FLAG, \
+         MATERIALIZE_PD_DIAGNOSTIC_FLAG, \
+         MATERIALIZE_EXPERIMENTAL_FLAG, \
+         MATERIALIZE_NOTPRODUCT_FLAG,  \
+         MATERIALIZE_MANAGEABLE_FLAG, \
+         MATERIALIZE_PRODUCT_RW_FLAG, \
+         IGNORE_RANGE, \
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/epsilon_globals.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_EPSILON_GLOBALS_HPP
+#define SHARE_VM_GC_EPSILON_GLOBALS_HPP
+
+#include "runtime/globals.hpp"
+//
+// Defines all globals flags used by the Epsilon GC.
+//
+
+#define EPSILON_FLAGS(develop, \
+                 develop_pd, \
+                 product, \
+                 product_pd, \
+                 diagnostic, \
+                 diagnostic_pd, \
+                 experimental, \
+                 notproduct, \
+                 manageable, \
+                 product_rw, \
+                 range, \
+                 constraint, \
+                 writeable) \
+                                                                            \
+  experimental(size_t, EpsilonPrintHeapStep, 100,                           \
+          "Print heap occupancy stats with this number of steps. "          \
+          "0 turns the printing off.")                                      \
+          range(0, max_intx)                                                \
+                                                                            \
+  experimental(size_t, EpsilonUpdateCountersStep, 1 * M,                    \
+          "Update heap heap occupancy counters after allocating this much " \
+          "memory. Higher values would make allocations faster at "         \
+          "the expense of lower resolution in heap counters.")              \
+          range(1, max_intx)                                                \
+                                                                            \
+  experimental(size_t, EpsilonMaxTLABSize, 4 * M,                           \
+          "Max TLAB size to use with Epsilon GC. Larger value improves "    \
+          "performance at the expense of per-thread memory waste. This "    \
+          "asks TLAB machinery to cap TLAB sizes at this value.")           \
+          range(1, max_intx)                                                \
+                                                                            \
+  experimental(size_t, EpsilonMinHeapExpand, 128 * M,                       \
+          "Min expansion step for heap. Larger value improves performance " \
+          "at the potential expense of memory waste.")                      \
+          range(1, max_intx)
+
+EPSILON_FLAGS(DECLARE_DEVELOPER_FLAG, \
+         DECLARE_PD_DEVELOPER_FLAG, \
+         DECLARE_PRODUCT_FLAG, \
+         DECLARE_PD_PRODUCT_FLAG, \
+         DECLARE_DIAGNOSTIC_FLAG, \
+         DECLARE_PD_DIAGNOSTIC_FLAG, \
+         DECLARE_EXPERIMENTAL_FLAG, \
+         DECLARE_NOTPRODUCT_FLAG, \
+         DECLARE_MANAGEABLE_FLAG, \
+         DECLARE_PRODUCT_RW_FLAG, \
+         IGNORE_RANGE, \
+         IGNORE_CONSTRAINT, \
+         IGNORE_WRITEABLE)
+
+#endif // SHARE_VM_GC_EPSILON_GLOBALS_HPP
--- a/src/hotspot/share/gc/shared/barrierSetConfig.hpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/gc/shared/barrierSetConfig.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -29,7 +29,8 @@
 
 #if INCLUDE_ALL_GCS
 #define FOR_EACH_CONCRETE_INCLUDE_ALL_GC_BARRIER_SET_DO(f) \
-  f(G1BarrierSet)
+  f(G1BarrierSet)                                          \
+  f(Epsilon)
 #else
 #define FOR_EACH_CONCRETE_INCLUDE_ALL_GC_BARRIER_SET_DO(f)
 #endif
--- a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -32,6 +32,7 @@
 
 #if INCLUDE_ALL_GCS
 #include "gc/g1/g1BarrierSet.inline.hpp" // G1 support
+#include "gc/epsilon/epsilonBarrierSet.hpp" // Epsilon support
 #endif
 
 #endif // SHARE_VM_GC_SHARED_BARRIERSETCONFIG_INLINE_HPP
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -190,7 +190,8 @@
     Serial,
     Parallel,
     CMS,
-    G1
+    G1,
+    Epsilon,
   };
 
   static inline size_t filler_array_max_size() {
--- a/src/hotspot/share/gc/shared/gcConfig.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcConfig.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -32,6 +32,7 @@
 #include "gc/parallel/parallelArguments.hpp"
 #include "gc/cms/cmsArguments.hpp"
 #include "gc/g1/g1Arguments.hpp"
+#include "gc/epsilon/epsilonArguments.hpp"
 #endif // INCLUDE_ALL_GCS
 
 struct SupportedGC {
@@ -48,6 +49,7 @@
 static ParallelArguments parallelArguments;
 static CMSArguments      cmsArguments;
 static G1Arguments       g1Arguments;
+static EpsilonArguments  epsilonArguments;
 #endif // INCLUDE_ALL_GCS
 
 // Table of supported GCs, for translating between command
@@ -59,6 +61,7 @@
   SupportedGC(UseParallelOldGC,   CollectedHeap::Parallel, parallelArguments),
   SupportedGC(UseConcMarkSweepGC, CollectedHeap::CMS,      cmsArguments),
   SupportedGC(UseG1GC,            CollectedHeap::G1,       g1Arguments),
+  SupportedGC(UseEpsilonGC,       CollectedHeap::Epsilon,  epsilonArguments),
 #endif // INCLUDE_ALL_GCS
 };
 
--- a/src/hotspot/share/opto/graphKit.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/opto/graphKit.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -1570,6 +1570,7 @@
       break;
 
     case BarrierSet::CardTableBarrierSet:
+    case BarrierSet::Epsilon:
       break;
 
     default      :
@@ -1585,6 +1586,7 @@
       return true; // Can move it if no safepoint
 
     case BarrierSet::CardTableBarrierSet:
+    case BarrierSet::Epsilon:
       return true; // There is no pre-barrier
 
     default      :
@@ -1612,6 +1614,9 @@
       write_barrier_post(store, obj, adr, adr_idx, val, use_precise);
       break;
 
+    case BarrierSet::Epsilon:
+      break;
+
     default      :
       ShouldNotReachHere();
 
--- a/src/hotspot/share/precompiled/precompiled.hpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/precompiled/precompiled.hpp	Wed Apr 18 09:46:53 2018 +0200
@@ -295,6 +295,7 @@
 # include "gc/cms/parOopClosures.hpp"
 # include "gc/cms/promotionInfo.hpp"
 # include "gc/cms/yieldingWorkgroup.hpp"
+# include "gc/epsilon/epsilon_globals.hpp"
 # include "gc/g1/dirtyCardQueue.hpp"
 # include "gc/g1/g1BlockOffsetTable.hpp"
 # include "gc/g1/g1OopClosures.hpp"
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/runtime/arguments.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -568,6 +568,7 @@
 static AliasedFlag const aliased_jvm_flags[] = {
   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
+  { "UseNoGC",                  "UseEpsilonGC" },
   { NULL, NULL}
 };
 
--- a/src/hotspot/share/utilities/vmError.cpp	Mon Apr 16 11:21:32 2018 -0700
+++ b/src/hotspot/share/utilities/vmError.cpp	Wed Apr 18 09:46:53 2018 +0200
@@ -309,6 +309,7 @@
   if (UseParallelGC)      return "parallel gc";
   if (UseConcMarkSweepGC) return "concurrent mark sweep gc";
   if (UseSerialGC)        return "serial gc";
+  if (UseEpsilonGC)       return "epsilon gc";
   return "ERROR in GC mode";
 }
 
--- a/test/hotspot/jtreg/TEST.groups	Mon Apr 16 11:21:32 2018 -0700
+++ b/test/hotspot/jtreg/TEST.groups	Wed Apr 18 09:46:53 2018 +0200
@@ -58,6 +58,9 @@
 hotspot_native_sanity = \
   native_sanity
 
+hotspot_gc_epsilon = \
+  gc/epsilon/
+
 tier1_common = \
   sanity/BasicVMTest.java \
   gtest/GTestWrapper.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/AbstractEpsilonTest.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+
+public class AbstractEpsilonTest {
+  public static boolean isEpsilonEnabled() {
+    for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
+      if (bean.getName().contains("Epsilon")) {
+        return true;
+      }
+    }
+    return false;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestAlwaysPretouch.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestAlwaysPretouch
+ * @summary Basic sanity test for Epsilon
+ * @run main/othervm -Xmx1g -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestAlwaysPretouch
+ */
+
+public class TestAlwaysPretouch {
+  public static void main(String[] args) throws Exception {
+    // everything should happen before entry point
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestByteArrays.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestByteArrays
+ * @library /test/lib
+ * @summary Epsilon is able to allocate arrays, and does not corrupt their state
+ *
+ * @run main/othervm -Xmx1g                                        -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xint                                  -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp                         -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ *
+ * @run main/othervm -Xmx1g                                        -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xint                                  -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp                         -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestByteArrays
+ */
+
+import java.util.Random;
+
+public class TestByteArrays extends AbstractEpsilonTest {
+
+  static long SEED = Long.getLong("seed", System.nanoTime());
+  static int COUNT = Integer.getInteger("count", 3000); // ~500 MB allocation
+
+  static byte[][] arr;
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    Random r = new Random(SEED);
+
+    arr = new byte[COUNT * 100][];
+    for (int c = 0; c < COUNT; c++) {
+      arr[c] = new byte[c * 100];
+      for (int v = 0; v < c; v++) {
+        arr[c][v] = (byte)(r.nextInt(255) & 0xFF);
+      }
+    }
+
+    r = new Random(SEED);
+    for (int c = 0; c < COUNT; c++) {
+      byte[] b = arr[c];
+      if (b.length != (c * 100)) {
+        throw new IllegalStateException("Failure: length = " + b.length + ", need = " + (c*100));
+      }
+      for (int v = 0; v < c; v++) {
+        byte actual = b[v];
+        byte expected = (byte)(r.nextInt(255) & 0xFF);
+        if (actual != expected) {
+          throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);
+        }
+      }
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestDieDefault.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestDieDefault
+ * @summary Epsilon GC should die on heap exhaustion
+ * @library /test/lib
+ * @run main TestDieDefault
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDieDefault extends AbstractEpsilonTest {
+
+  public static void passWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    OutputAnalyzer out = new OutputAnalyzer(pb.start());
+    out.shouldNotContain("OutOfMemoryError");
+    out.shouldHaveExitValue(0);
+  }
+
+  public static void failWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    OutputAnalyzer out = new OutputAnalyzer(pb.start());
+    out.shouldContain("OutOfMemoryError");
+    if (out.getExitValue() == 0) {
+      throw new IllegalStateException("Should have failed with non-zero exit code");
+    }
+  }
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    passWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-Dcount=1",
+             TestDieDefault.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             TestDieDefault.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xint",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             TestDieDefault.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             TestDieDefault.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=1",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             TestDieDefault.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=4",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             TestDieDefault.Workload.class.getName());
+  }
+
+  public static class Workload {
+    static int COUNT = Integer.getInteger("count", 1_000_000_000); // ~24 GB allocation
+
+    static volatile Object sink;
+
+    public static void main(String... args) {
+      for (int c = 0; c < COUNT; c++) {
+        sink = new Object();
+      }
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestDieWithHeapDump.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestDieWithHeapDump
+ * @summary Epsilon GC should die on heap exhaustion with error handler attached
+ * @library /test/lib
+ * @run main TestDieWithHeapDump
+ */
+
+import java.io.*;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDieWithHeapDump extends AbstractEpsilonTest {
+
+  public static void passWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    OutputAnalyzer out = new OutputAnalyzer(pb.start());
+    out.shouldNotContain("OutOfMemoryError");
+    out.shouldHaveExitValue(0);
+  }
+
+  public static void failWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    Process p = pb.start();
+    OutputAnalyzer out = new OutputAnalyzer(p);
+    out.shouldContain("OutOfMemoryError");
+    if (out.getExitValue() == 0) {
+      throw new IllegalStateException("Should have failed with non-zero exit code");
+    }
+    String heapDump = "java_pid" + p.pid() + ".hprof";
+    if (!new File(heapDump).exists()) {
+      throw new IllegalStateException("Should have produced the heap dump at: " + heapDump);
+    }
+  }
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    passWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-Dcount=1",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xint",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=1",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=4",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:+HeapDumpOnOutOfMemoryError",
+             TestDieWithHeapDump.Workload.class.getName());
+  }
+
+  public static class Workload {
+    static int COUNT = Integer.getInteger("count", 1_000_000_000); // ~24 GB allocation
+
+    static volatile Object sink;
+
+    public static void main(String... args) {
+      for (int c = 0; c < COUNT; c++) {
+        sink = new Object();
+      }
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestDieWithOnError
+ * @summary Epsilon GC should die on heap exhaustion with error handler attached
+ * @library /test/lib
+ * @run main TestDieWithOnError
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDieWithOnError extends AbstractEpsilonTest {
+
+  static String ON_ERR_MSG = "Epsilon error handler message";
+
+  public static void passWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    OutputAnalyzer out = new OutputAnalyzer(pb.start());
+    out.shouldNotContain("OutOfMemoryError");
+    out.stdoutShouldNotMatch("^" + ON_ERR_MSG);
+    out.shouldHaveExitValue(0);
+  }
+
+  public static void failWith(String... args) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+    OutputAnalyzer out = new OutputAnalyzer(pb.start());
+    out.shouldContain("OutOfMemoryError");
+    if (out.getExitValue() == 0) {
+      throw new IllegalStateException("Should have failed with non-zero exit code");
+    }
+    out.stdoutShouldMatch("^" + ON_ERR_MSG);
+  }
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    passWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-Dcount=1",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xint",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=1",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+
+    failWith("-Xmx128m",
+             "-Xbatch",
+             "-Xcomp",
+             "-XX:TieredStopAtLevel=4",
+             "-XX:+UnlockExperimentalVMOptions",
+             "-XX:+UseEpsilonGC",
+             "-XX:OnOutOfMemoryError=echo " + ON_ERR_MSG,
+             TestDieWithOnError.Workload.class.getName());
+  }
+
+  public static class Workload {
+    static int COUNT = Integer.getInteger("count", 1_000_000_000); // ~24 GB allocation
+
+    static volatile Object sink;
+
+    public static void main(String... args) {
+      for (int c = 0; c < COUNT; c++) {
+        sink = new Object();
+      }
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabled.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestAlwaysPretouch
+ * @library /test/lib
+ * @summary Basic sanity test for Epsilon
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestEpsilonEnabled
+ */
+
+import jdk.test.lib.Platform;
+
+public class TestEpsilonEnabled extends AbstractEpsilonTest {
+  public static void main(String[] args) throws Exception {
+    if (Platform.isDebugBuild() && !isEpsilonEnabled()) {
+      throw new IllegalStateException("Debug builds should have Epsilon enabled");
+    }
+    if (!Platform.isDebugBuild() && isEpsilonEnabled()) {
+      throw new IllegalStateException("Non-debug builds should have Epsilon disabled");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestEpsilonEnabledNoGC.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestAlwaysPretouch
+ * @library /test/lib
+ * @summary Basic sanity test for Epsilon
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseNoGC TestEpsilonEnabled
+ */
+
+import jdk.test.lib.Platform;
+
+public class TestEpsilonEnabled extends AbstractEpsilonTest {
+  public static void main(String[] args) throws Exception {
+    if (Platform.isDebugBuild() && !isEpsilonEnabled()) {
+      throw new IllegalStateException("Debug builds should have Epsilon enabled");
+    }
+    if (!Platform.isDebugBuild() && isEpsilonEnabled()) {
+      throw new IllegalStateException("Non-debug builds should have Epsilon disabled");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestHelloWorld.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestHelloWorld
+ * @summary Basic sanity test for Epsilon
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestHelloWorld
+ */
+
+import java.util.LinkedList;
+
+public class TestHelloWorld {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestLogTrace.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestLogTrace
+ * @summary Basic sanity test for Epsilon
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc=trace TestLogTrace
+ */
+
+import java.util.LinkedList;
+
+public class TestLogTrace {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestManyThreads.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestManyThreads
+ *
+ * @run main/othervm -Xmx128m -Xss512k                                        -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xint                                  -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp                         -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ *
+ * @run main/othervm -Xmx128m -Xss512k                                        -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xint                                  -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp                         -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ * @run main/othervm -Xmx128m -Xss512k -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestManyThreads
+ */
+
+import java.util.concurrent.atomic.*;
+
+public class TestManyThreads extends AbstractEpsilonTest {
+
+  static int COUNT = Integer.getInteger("count", 128);  // 128 * 4M max tlabs = 512M, would overflow without TLAB sizing
+
+  static volatile Object sink;
+  static volatile Throwable failed;
+  static final AtomicInteger allocated = new AtomicInteger();
+
+  public static void workload() {
+    try {
+      sink = new Object();
+      allocated.incrementAndGet();
+      Thread.sleep(3600 * 1000);
+    } catch (Throwable e) {
+      failed = e;
+    }
+  }
+
+  public static void main(String[] args) throws Throwable {
+    if (!isEpsilonEnabled()) return;
+
+    for (int c = 0; c < COUNT; c++) {
+      Thread t = new Thread(TestManyThreads::workload);
+      t.setDaemon(true);
+      t.start();
+    }
+
+    while ((failed == null) && (allocated.get() != COUNT)) {
+        Thread.sleep(100);
+    }
+
+    if (failed != null) {
+      throw failed;
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test TestMemoryMXBeans
+ * @key gc
+ * @summary Test JMX memory beans
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC          -Xmx1g TestMemoryMXBeans   -1 1024
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xms1g   -Xmx1g TestMemoryMXBeans 1024 1024
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xms128m -Xmx1g TestMemoryMXBeans  128 1024
+ */
+
+import java.lang.management.*;
+import java.util.*;
+
+public class TestMemoryMXBeans extends AbstractEpsilonTest {
+
+    static volatile Object sink;
+
+    public static void main(String[] args) throws Exception {
+        if (!isEpsilonEnabled()) return;
+
+        if (args.length < 2) {
+            throw new IllegalStateException("Should provide expected heap sizes");
+        }
+
+        long initSize = 1L * Integer.parseInt(args[0]) * 1024 * 1024;
+        long maxSize =  1L * Integer.parseInt(args[1]) * 1024 * 1024;
+
+        testMemoryBean(initSize, maxSize);
+        testAllocs();
+    }
+
+    public static void testMemoryBean(long initSize, long maxSize) {
+        MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
+        long heapInit = memoryMXBean.getHeapMemoryUsage().getInit();
+        long heapMax = memoryMXBean.getHeapMemoryUsage().getMax();
+        long nonHeapInit = memoryMXBean.getNonHeapMemoryUsage().getInit();
+        long nonHeapMax = memoryMXBean.getNonHeapMemoryUsage().getMax();
+
+        if (initSize > 0 && heapInit != initSize) {
+            throw new IllegalStateException("Init heap size is wrong: " + heapInit + " vs " + initSize);
+        }
+        if (maxSize > 0 && heapMax != maxSize) {
+            throw new IllegalStateException("Max heap size is wrong: " + heapMax + " vs " + maxSize);
+        }
+    }
+
+    public static void testAllocs() {
+        MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
+        long heapUsed1 = memoryMXBean.getHeapMemoryUsage().getUsed();
+        sink = new int[1024*1024];
+        long heapUsed2 = memoryMXBean.getHeapMemoryUsage().getUsed();
+
+        long diff = heapUsed2 - heapUsed1;
+        if (!(8 + 4*1024*1024 <= diff && diff <= 16 + 4*1024*1024)) {
+           throw new IllegalStateException("Allocation did not change used space right: " + diff);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestMemoryPools.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test TestMemoryPools
+ * @key gc
+ * @summary Test JMX memory pools
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xmx1g -Xms1g TestMemoryPools
+ */
+
+import java.lang.management.*;
+import java.util.*;
+
+public class TestMemoryPools extends AbstractEpsilonTest {
+
+    public static void main(String[] args) throws Exception {
+        if (!isEpsilonEnabled()) return;
+
+        List<MemoryManagerMXBean> mms = ManagementFactory.getMemoryManagerMXBeans();
+        if (mms == null) {
+            throw new RuntimeException("getMemoryManagerMXBeans is null");
+        }
+        if (mms.isEmpty()) {
+            throw new RuntimeException("getMemoryManagerMXBeans is empty");
+        }
+        for (MemoryManagerMXBean mmBean : mms) {
+            String[] names = mmBean.getMemoryPoolNames();
+            if (names == null) {
+                throw new RuntimeException("getMemoryPoolNames() is null");
+            }
+            if (names.length == 0) {
+                throw new RuntimeException("getMemoryPoolNames() is empty");
+            }
+            for (String name : names) {
+                if (name == null) {
+                    throw new RuntimeException("pool name is null");
+                }
+                if (name.length() == 0) {
+                    throw new RuntimeException("pool name is empty");
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestObjects.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestObjects
+ * @summary Epsilon is able to allocate objects, and does not corrupt their state
+ *
+ * @run main/othervm -Xmx128m                                        -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xint                                  -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp                         -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ *
+ * @run main/othervm -Xmx128m                                        -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xint                                  -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp                         -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ * @run main/othervm -Xmx128m -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestObjects
+ */
+
+import java.util.Random;
+
+public class TestObjects extends AbstractEpsilonTest {
+
+  static long SEED = Long.getLong("seed", System.nanoTime());
+  static int COUNT = Integer.getInteger("count", 1_000_000); // ~24 MB allocation
+
+  static MyObject[] arr;
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    Random r = new Random(SEED);
+
+    arr = new MyObject[COUNT];
+    for (int c = 0; c < COUNT; c++) {
+      arr[c] = new MyObject(r.nextInt());
+    }
+
+    r = new Random(SEED);
+    for (int c = 0; c < COUNT; c++) {
+      int expected = r.nextInt();
+      int actual = arr[c].id();
+      if (expected != actual) {
+        throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);
+      }
+    }
+  }
+
+  public static class MyObject {
+    int id;
+    public MyObject(int id) {
+      this.id = id;
+    }
+    public int id() {
+      return id;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestPrintHeapSteps.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestPrintSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=0    TestPrintHeapSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=1    TestPrintHeapSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=1000 TestPrintHeapSteps
+ */
+
+public class TestPrintHeapSteps {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestRefArrays.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestRefArrays
+ * @library /test/lib
+ * @summary Epsilon is able to allocate arrays, and does not corrupt their state
+ *
+ * @run main/othervm -Xmx1g                                        -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xint                                  -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp                         -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:+UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ *
+ * @run main/othervm -Xmx1g                                        -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xint                                  -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp                         -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ * @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=4 -XX:-UseTLAB -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC TestRefArrays
+ */
+
+import java.util.Random;
+
+public class TestRefArrays extends AbstractEpsilonTest {
+
+  static long SEED = Long.getLong("seed", System.nanoTime());
+  static int COUNT = Integer.getInteger("count", 1000); // ~500 MB allocation
+
+  static MyObject[][] arr;
+
+  public static void main(String[] args) throws Exception {
+    if (!isEpsilonEnabled()) return;
+
+    Random r = new Random(SEED);
+
+    arr = new MyObject[COUNT * 100][];
+    for (int c = 0; c < COUNT; c++) {
+      arr[c] = new MyObject[c * 100];
+      for (int v = 0; v < c; v++) {
+        arr[c][v] = new MyObject(r.nextInt());
+      }
+    }
+
+    r = new Random(SEED);
+    for (int c = 0; c < COUNT; c++) {
+      MyObject[] b = arr[c];
+      if (b.length != (c * 100)) {
+        throw new IllegalStateException("Failure: length = " + b.length + ", need = " + (c*100));
+      }
+      for (int v = 0; v < c; v++) {
+        int actual = b[v].id();
+        int expected = r.nextInt();
+        if (actual != expected) {
+          throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);
+        }
+      }
+    }
+  }
+
+  public static class MyObject {
+    int id;
+    public MyObject(int id) {
+      this.id = id;
+    }
+    public int id() {
+      return id;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestUpdateCountersSteps.java	Wed Apr 18 09:46:53 2018 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=1    TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=10   TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=100  TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=1000 TestUpdateCountersSteps
+ */
+
+public class TestUpdateCountersSteps {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}