8301326: Optimize compiler/uncommontrap/TestDeoptOOM.java test

Reviewed-by: rcastanedalo, thartmann
This commit is contained in:
Axel Boldt-Christmas 2023-01-31 07:54:20 +00:00
parent 9cc0171ed5
commit cdb4ba9657

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. 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
@ -67,19 +67,24 @@ public class TestDeoptOOM {
static LinkedList ll;
static void consume_all_memory() {
int size = 128 * 1024 * 1024;
while(size > 0) {
try {
while(true) {
ll = new LinkedList(ll, size);
}
} catch(OutOfMemoryError oom) {
static void alloc_in_chunks(int size) {
try {
while(true) {
ll = new LinkedList(ll, size);
}
size = size / 2;
} catch(OutOfMemoryError oom) {
}
}
static void consume_all_memory() {
// O(MiB) allocations
alloc_in_chunks(1024*1024);
// O(KiB) allocations
alloc_in_chunks(1024);
// O(B) allocations
alloc_in_chunks(1);
}
static void free_memory() {
ll = null;
}