Skip to content

Commit 31e7b4a

Browse files
committed
Merge graalvm-community-jdk21u into mandrel/23.1
2 parents 87db9be + 4e39f63 commit 31e7b4a

File tree

22 files changed

+223
-94
lines changed

22 files changed

+223
-94
lines changed

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/PiNode.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
2828
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
2929

30+
import java.util.List;
31+
3032
import org.graalvm.compiler.core.common.type.AbstractPointerStamp;
3133
import org.graalvm.compiler.core.common.type.ObjectStamp;
3234
import org.graalvm.compiler.core.common.type.Stamp;
@@ -307,7 +309,9 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
307309
if (guardNode.hasNoUsages()) {
308310
return;
309311
}
310-
for (PiNode pi : guardNode.usages().filter(PiNode.class).snapshot()) {
312+
313+
List<PiNode> pis = guardNode.usages().filter(PiNode.class).snapshot();
314+
for (PiNode pi : pis) {
311315
if (!pi.isAlive()) {
312316
continue;
313317
}
@@ -317,6 +321,8 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
317321
}
318322

319323
/*
324+
* RECURSE CALL
325+
*
320326
* If there are PiNodes still anchored at this guard then either they must simplify away
321327
* because they are no longer necessary or this node must be replaced with a
322328
* ValueAnchorNode because the type injected by the PiNode is only true at this point in
@@ -330,6 +336,16 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
330336
tryEvacuate(tool, otherGuard, false);
331337
}
332338
}
339+
/*
340+
* A note on the RECURSE CALL above: When we have pis with input pis on the same guard
341+
* (which should actually be combined) it can be that the recurse call (processing the
342+
* same pis again) already deletes this node (very special stamp setups necessary).
343+
* Thus, it can be that pi is dead at this point already, so we have to check for this
344+
* again.
345+
*/
346+
if (!pi.isAlive()) {
347+
continue;
348+
}
333349
Node canonical = pi.canonical(tool);
334350
if (canonical != pi) {
335351
if (!canonical.isAlive()) {

regex/src/com.oracle.truffle.regex.test/src/com/oracle/truffle/regex/tregex/test/OracleDBTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,7 @@ public void generatedTests() {
13871387
test("()(a*\\1+)*", "", "aaa", 0, true, 0, 3, 0, 0, 3, 3);
13881388
test("(a(\\2b|)?)+\\1c", "", "aaabaaac", 0, true, 0, 8, 5, 6, 6, 6);
13891389
test("((|ab)+?w\\Z|^c)de()d", "", "ffffff", 0, false);
1390+
test("\u0282\\\ud807\udfdd+\u1cf2", "", "\u0282\ud807\udfdd\ud807\udfdd\u1cf2", 0, true, 0, 13);
13901391
test("(a{1100,1100})\\1", "i", "a".repeat(2400), 0, true, 0, 2200, 0, 1100);
13911392

13921393
/* GENERATED CODE END - KEEP THIS MARKER FOR AUTOMATIC UPDATES */

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/OracleDBRegexLexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ protected int parseCustomEscapeChar(char c, boolean inCharClass) {
424424
} else {
425425
// outside character classes, all escaped characters are simply treated as literals,
426426
// there are no escape sequences in oracleDB
427-
return c;
427+
return Character.isHighSurrogate(c) ? finishSurrogatePair(c) : c;
428428
}
429429
}
430430

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageHeapScanner.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ public TypeData computeTypeData(AnalysisType type) {
174174
return data;
175175
}
176176

177-
void markTypeInstantiated(AnalysisType type, ScanReason reason) {
177+
void markTypeReachable(AnalysisType type, ScanReason reason) {
178178
if (universe.sealed() && !type.isReachable()) {
179+
throw AnalysisError.typeNotFound(type);
180+
}
181+
type.registerAsReachable(reason);
182+
}
183+
184+
void markTypeInstantiated(AnalysisType type, ScanReason reason) {
185+
if (universe.sealed() && !type.isInstantiated()) {
179186
throw AnalysisError.shouldNotReachHere("Universe is sealed. New type reachable: " + type.toJavaName());
180187
}
181188
universe.getBigbang().registerTypeAsInHeap(type, reason);
@@ -254,7 +261,7 @@ protected ImageHeapConstant createImageHeapObject(JavaConstant constant, ScanRea
254261
newImageHeapConstant = createImageHeapInstance(constant, type, reason);
255262
AnalysisType typeFromClassConstant = (AnalysisType) constantReflection.asJavaType(constant);
256263
if (typeFromClassConstant != null) {
257-
typeFromClassConstant.registerAsReachable(reason);
264+
markTypeReachable(typeFromClassConstant, reason);
258265
}
259266
}
260267
return newImageHeapConstant;
@@ -277,7 +284,7 @@ private ImageHeapArray createImageHeapObjectArray(JavaConstant constant, Analysi
277284

278285
private ImageHeapInstance createImageHeapInstance(JavaConstant constant, AnalysisType type, ScanReason reason) {
279286
/* We are about to query the type's fields, the type must be marked as reachable. */
280-
type.registerAsReachable(reason);
287+
markTypeReachable(type, reason);
281288
ResolvedJavaField[] instanceFields = type.getInstanceFields(true);
282289
ImageHeapInstance instance = new ImageHeapInstance(type, constant, instanceFields.length);
283290
for (ResolvedJavaField javaField : instanceFields) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.oracle.svm.core.heap.PhysicalMemory;
3838
import com.oracle.svm.core.heap.ReferenceAccess;
3939
import com.oracle.svm.core.util.TimeUtils;
40+
import com.oracle.svm.core.util.UnsignedUtils;
4041
import com.oracle.svm.core.util.VMError;
4142

4243
/** Basic/legacy garbage collection policies. */
@@ -109,9 +110,7 @@ public final UnsignedWord getMaximumHeapSize() {
109110
int maximumHeapSizePercent = HeapParameters.getMaximumHeapSizePercent();
110111
/* Do not cache because `-Xmx` option parsing may not have happened yet. */
111112
UnsignedWord result = physicalMemorySize.unsignedDivide(100).multiply(maximumHeapSizePercent);
112-
if (result.belowThan(addressSpaceSize)) {
113-
return result;
114-
}
113+
return UnsignedUtils.min(result, addressSpaceSize);
115114
}
116115
return addressSpaceSize;
117116
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
* list. Memory for unaligned chunks is released immediately.
5656
*/
5757
final class HeapChunkProvider {
58+
/** These {@link OutOfMemoryError}s are only needed for legacy code, see GR-59639. */
59+
private static final OutOfMemoryError ALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an aligned heap chunk");
60+
private static final OutOfMemoryError UNALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an unaligned heap chunk");
61+
5862
/**
5963
* The head of the linked list of unused aligned chunks. Chunks are chained using
6064
* {@link HeapChunk#getNext}.
@@ -79,10 +83,6 @@ public UnsignedWord getBytesInUnusedChunks() {
7983
return numUnusedAlignedChunks.get().multiply(HeapParameters.getAlignedHeapChunkSize());
8084
}
8185

82-
private static final OutOfMemoryError ALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an aligned heap chunk");
83-
84-
private static final OutOfMemoryError UNALIGNED_OUT_OF_MEMORY_ERROR = new OutOfMemoryError("Could not allocate an unaligned heap chunk");
85-
8686
/** Acquire a new AlignedHeapChunk, either from the free list or from the operating system. */
8787
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
8888
AlignedHeader produceAlignedChunk() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ public static int getHeapChunkHeaderPadding() {
109109

110110
static int getMaximumYoungGenerationSizePercent() {
111111
int result = SerialAndEpsilonGCOptions.MaximumYoungGenerationSizePercent.getValue();
112-
VMError.guarantee((result >= 0) && (result <= 100), "MaximumYoungGenerationSizePercent should be in [0 ..100]");
112+
VMError.guarantee(result >= 0 && result <= 100, "MaximumYoungGenerationSizePercent should be in [0..100]");
113113
return result;
114114
}
115115

116116
static int getMaximumHeapSizePercent() {
117117
int result = SerialAndEpsilonGCOptions.MaximumHeapSizePercent.getValue();
118-
VMError.guarantee((result >= 0) && (result <= 100), "MaximumHeapSizePercent should be in [0 ..100]");
118+
VMError.guarantee(result >= 0 && result <= 100, "MaximumHeapSizePercent should be in [0..100]");
119119
return result;
120120
}
121121

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,14 @@ void setIdentityHashInField(Object o) {
194194
@Uninterruptible(reason = "Prevent a GC interfering with the object's identity hash state.", callerMustBe = true)
195195
@Override
196196
public void setIdentityHashFromAddress(Pointer ptr, Word currentHeader) {
197-
if (GraalDirectives.inIntrinsic()) {
198-
ReplacementsUtil.staticAssert(!hasFixedIdentityHashField(), "must always access field");
199-
} else {
200-
VMError.guarantee(!hasFixedIdentityHashField());
201-
assert !hasIdentityHashFromAddress(currentHeader);
202-
}
197+
VMError.guarantee(!hasFixedIdentityHashField());
198+
assert !hasIdentityHashFromAddress(currentHeader) : "must not already have a hashcode";
199+
203200
UnsignedWord fromAddressState = IDHASH_STATE_FROM_ADDRESS.shiftLeft(IDHASH_STATE_SHIFT);
204201
UnsignedWord newHeader = currentHeader.and(IDHASH_STATE_BITS.not()).or(fromAddressState);
205202
writeHeaderToObject(ptr.toObjectNonNull(), newHeader);
206-
if (!GraalDirectives.inIntrinsic()) {
207-
assert hasIdentityHashFromAddress(readHeaderFromObject(ptr));
208-
}
203+
204+
assert hasIdentityHashFromAddress(readHeaderFromPointer(ptr));
209205
}
210206

211207
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)

substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
*/
2525
package com.oracle.svm.core.windows;
2626

27+
import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE;
28+
2729
import org.graalvm.nativeimage.c.struct.SizeOf;
2830
import org.graalvm.word.UnsignedWord;
2931
import org.graalvm.word.WordFactory;
3032

33+
import com.oracle.svm.core.Uninterruptible;
3134
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
3235
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
3336
import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport;
@@ -37,6 +40,7 @@
3740
class WindowsPhysicalMemorySupportImpl implements PhysicalMemorySupport {
3841

3942
@Override
43+
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
4044
public UnsignedWord size() {
4145
SysinfoAPI.MEMORYSTATUSEX memStatusEx = UnsafeStackValue.get(SysinfoAPI.MEMORYSTATUSEX.class);
4246
memStatusEx.set_dwLength(SizeOf.get(SysinfoAPI.MEMORYSTATUSEX.class));

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,9 @@ private static CCharPointer startsWith(CCharPointer input, CCharPointer prefix)
429429

430430
@Fold
431431
public static int getOptionIndex(RuntimeOptionKey<?> key) {
432-
for (int i = 0; i < OPTIONS.length; i++) {
433-
if (OPTIONS[i] == key) {
432+
RuntimeOptionKey<?>[] options = OPTIONS;
433+
for (int i = 0; i < options.length; i++) {
434+
if (options[i] == key) {
434435
return i;
435436
}
436437
}

0 commit comments

Comments
 (0)