--- /dev/null 2017-02-09 18:28:35.238523416 +0100 +++ new/src/share/vm/gc/epsilon/epsilonCollectedHeap.cpp 2017-02-12 23:18:05.501414642 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * + * 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 "utilities/copy.hpp" +#include "gc/shared/collectedHeap.hpp" +#include "epsilonCollectedHeap.hpp" +#include "epsilonBarrierSet.hpp" + +jint EpsilonCollectedHeap::initialize() { + size_t max_byte_size = _policy->max_heap_byte_size(); + + ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size, + _policy->heap_alignment()); + + _start = (HeapWord *) heap_rs.base(); + _current = _start; + _end = (HeapWord *) (heap_rs.base() + heap_rs.size()); + + size_t size = pointer_delta(_end, _start); + + initialize_reserved_region(_start, _end); + os::commit_memory((char*)_start, size*HeapWordSize, _policy->heap_alignment(), false); + + log_info(gc)("Heap space: [" PTR_FORMAT ", " PTR_FORMAT "] (" SIZE_FORMAT "M)", + p2i(_start), p2i(_end), size*HeapWordSize / M); + + // eagerly zero out everything, or don't bother, let TLAB zeroing do its thing. +// log_info(gc)("Clearing " SIZE_FORMAT "M", size * HeapWordSize / M); +// Copy::zero_to_words(_start, size); + + EpsilonBarrierSet* bs = new EpsilonBarrierSet(); + set_barrier_set(bs); + + log_info(gc)("Ready to go. See you at your next OutOfMemoryException."); + + return JNI_OK; +} + +HeapWord* EpsilonCollectedHeap::allocate_new_tlab(size_t size) { + bool trap; + return mem_allocate(size, &trap); +} + +HeapWord* EpsilonCollectedHeap::mem_allocate(size_t size, bool *gc_overhead_limit_was_exceeded) { + HeapWord* res = _current; + if (_current + size > _end) { + log_warning(gc)("Heap is exhausted, you sick bastard. Goodbye."); + vm_abort(false); + } + _current += size; + *gc_overhead_limit_was_exceeded = false; + return res; +}