/* * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. 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. *
*/
allocation_t* a = _allocations; if (a != NULL) {
_allocations = a->next;
check_marked_range(a->p, a->word_size);
_freeblocks.add_block(a->p, a->word_size); delete a;
DEBUG_ONLY(_freeblocks.verify();)
}
}
bool allocate() {
size_t word_size = MAX2(_rgen_allocations.get(), _freeblocks.MinWordSize);
MetaWord* p = _freeblocks.remove_block(word_size); if (p != NULL) {
_allocated_words.increment_by(word_size);
allocation_t* a = new allocation_t;
a->p = p; a->word_size = word_size;
a->next = _allocations;
_allocations = a;
DEBUG_ONLY(_freeblocks.verify();)
mark_range(p, word_size); returntrue;
} returnfalse;
}
void test_all_marked_ranges() { for (allocation_t* a = _allocations; a != NULL; a = a->next) {
check_marked_range(a->p, a->word_size);
}
}
void test_loop() { // We loop and in each iteration execute one of three operations: // - allocation from fbl // - deallocation to fbl of a previously allocated block // - feeding a new larger block into the fbl (mimicks chunk retiring) // When we have fed all large blocks into the fbl (feedbuffer empty), we // switch to draining the fbl completely (only allocs) bool forcefeed = false; bool draining = false; bool stop = false; int iter = 100000; // safety stop while (!stop && iter > 0) {
iter --; int surprise = (int)os::random() % 10; if (!draining && (surprise >= 7 || forcefeed)) {
forcefeed = false; if (feed_some()) {
_num_feeds++;
} else { // We fed all input memory into the fbl. Now lets proceed until the fbl is drained.
draining = true;
}
} elseif (!draining && surprise < 1) {
deallocate_top();
_num_deallocs++;
} else { if (allocate()) {
_num_allocs++;
} else { if (draining) {
stop = _freeblocks.total_size() < 512;
} else {
forcefeed = true;
}
}
} if ((iter % 1000) == 0) {
DEBUG_ONLY(_freeblocks.verify();)
test_all_marked_ranges();
LOG("a %d (" SIZE_FORMAT "), d %d, f %d", _num_allocs, _allocated_words.get(), _num_deallocs, _num_feeds); #ifdef LOG_PLEASE
_freeblocks.print(tty, true);
tty->cr(); #endif
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.