Skip to content

Commit 5e1e23c

Browse files
committed
Reintroduce HeapPolicy, HeapPolicyOptions as proxies for legacy code.
1 parent d0953b0 commit 5e1e23c

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/HeapParameters.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
import org.graalvm.word.UnsignedWord;
3535
import org.graalvm.word.WordFactory;
3636

37+
import com.oracle.svm.core.SubstrateGCOptions;
3738
import com.oracle.svm.core.SubstrateUtil;
3839
import com.oracle.svm.core.annotate.Uninterruptible;
3940
import com.oracle.svm.core.option.HostedOptionKey;
4041
import com.oracle.svm.core.option.RuntimeOptionKey;
42+
import com.oracle.svm.core.option.RuntimeOptionValues;
4143
import com.oracle.svm.core.util.UserError;
4244
import com.oracle.svm.core.util.VMError;
4345

@@ -131,6 +133,14 @@ public static int getMaxSurvivorSpaces() {
131133
* Memory configuration
132134
*/
133135

136+
public static void setMaximumHeapSize(UnsignedWord value) {
137+
RuntimeOptionValues.singleton().update(SubstrateGCOptions.MaxHeapSize, value.rawValue());
138+
}
139+
140+
public static void setMinimumHeapSize(UnsignedWord value) {
141+
RuntimeOptionValues.singleton().update(SubstrateGCOptions.MinHeapSize, value.rawValue());
142+
}
143+
134144
static int getMaximumYoungGenerationSizePercent() {
135145
int result = Options.MaximumYoungGenerationSizePercent.getValue();
136146
VMError.guarantee((result >= 0) && (result <= 100), "MaximumYoungGenerationSizePercent should be in [0 ..100]");
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.genscavenge;
26+
27+
import org.graalvm.compiler.api.replacements.Fold;
28+
import org.graalvm.word.UnsignedWord;
29+
30+
/**
31+
* Only for compatibility with legacy code, replaced by {@link CollectionPolicy} and
32+
* {@link HeapParameters}.
33+
*/
34+
public final class HeapPolicy {
35+
public static UnsignedWord getMaximumHeapSize() {
36+
return GCImpl.getPolicy().getMaximumHeapSize();
37+
}
38+
39+
public static UnsignedWord getMinimumHeapSize() {
40+
return GCImpl.getPolicy().getMinimumHeapSize();
41+
}
42+
43+
public static void setMaximumHeapSize(UnsignedWord value) {
44+
HeapParameters.setMaximumHeapSize(value);
45+
}
46+
47+
public static void setMinimumHeapSize(UnsignedWord value) {
48+
HeapParameters.setMinimumHeapSize(value);
49+
}
50+
51+
@Fold
52+
public static UnsignedWord getAlignedHeapChunkSize() {
53+
return HeapParameters.getAlignedHeapChunkSize();
54+
}
55+
56+
@Fold
57+
public static UnsignedWord getLargeArrayThreshold() {
58+
return HeapParameters.getLargeArrayThreshold();
59+
}
60+
61+
private HeapPolicy() {
62+
}
63+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.oracle.svm.core.genscavenge;
26+
27+
import com.oracle.svm.core.option.HostedOptionKey;
28+
29+
/**
30+
* Only for compatibility with legacy code, replaced by {@link HeapParameters.Options}.
31+
*/
32+
public final class HeapPolicyOptions {
33+
public static final HostedOptionKey<Long> AlignedHeapChunkSize = HeapParameters.Options.AlignedHeapChunkSize;
34+
35+
private HeapPolicyOptions() {
36+
}
37+
}

0 commit comments

Comments
 (0)