Skip to content

Commit 2b957ae

Browse files
authored
Merge pull request #725 from jerboaa/mandrel-23.1.3-update
Mandrel 23.1.3 update
2 parents 6812ec7 + 424fda2 commit 2b957ae

File tree

489 files changed

+646
-64099
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

489 files changed

+646
-64099
lines changed

compiler/mx.compiler/suite.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"sourceinprojectwhitelist" : [],
55

66
"groupId" : "org.graalvm.compiler",
7-
"version" : "23.1.3.0",
8-
"release" : True,
7+
"version" : "23.1.3.1",
8+
"release" : False,
99
"url" : "http://www.graalvm.org/",
1010
"developer" : {
1111
"name" : "GraalVM Development",

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/asm/amd64/AMD64Assembler.java

+12
Original file line numberDiff line numberDiff line change
@@ -5097,6 +5097,18 @@ public void clflush(AMD64Address adr) {
50975097
emitOperandHelper(7, adr, 0);
50985098
}
50995099

5100+
public void wrpkru() {
5101+
emitByte(0x0F);
5102+
emitByte(0x01);
5103+
emitByte(0xEF);
5104+
}
5105+
5106+
public void rdpkru() {
5107+
emitByte(0x0F);
5108+
emitByte(0x01);
5109+
emitByte(0xEE);
5110+
}
5111+
51005112
public final void vpaddd(Register dst, Register nds, Register src, AVXSize size) {
51015113
VexRVMOp.VPADDD.emit(this, size, dst, nds, src);
51025114
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/core/amd64/AMD64LIRGenerator.java

+14
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,20 @@ public void emitSpeculationFence() {
10791079
append(new AMD64LFenceOp());
10801080
}
10811081

1082+
@Override
1083+
public void emitProtectionKeyRegisterWrite(Value value) {
1084+
RegisterValue rax = AMD64.rax.asValue(value.getValueKind());
1085+
emitMove(rax, value);
1086+
append(new AMD64WriteDataToUserPageKeyRegister(rax));
1087+
}
1088+
1089+
@Override
1090+
public Value emitProtectionKeyRegisterRead() {
1091+
AMD64ReadDataFromUserPageKeyRegister rdpkru = new AMD64ReadDataFromUserPageKeyRegister();
1092+
append(rdpkru);
1093+
return emitReadRegister(AMD64.rax, rdpkru.retVal.getValueKind());
1094+
}
1095+
10821096
@Override
10831097
public void emitZeroMemory(Value address, Value length, boolean isAligned) {
10841098
RegisterValue lengthReg = AMD64.rcx.asValue(length.getValueKind());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2023, 2024, 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 org.graalvm.compiler.core.amd64;
26+
27+
import jdk.vm.ci.amd64.AMD64;
28+
import jdk.vm.ci.amd64.AMD64Kind;
29+
import jdk.vm.ci.code.ValueUtil;
30+
import jdk.vm.ci.meta.AllocatableValue;
31+
import jdk.vm.ci.meta.Value;
32+
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
33+
import org.graalvm.compiler.core.common.LIRKind;
34+
import org.graalvm.compiler.lir.LIRInstructionClass;
35+
import org.graalvm.compiler.lir.Opcode;
36+
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
37+
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
38+
39+
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
40+
41+
/**
42+
* Reads the value of PKRU into EAX and clears EDX. ECX must be 0 when RDPKRU is executed;
43+
* otherwise, a general-protection exception (#GP) occurs. RDPKRU can be executed only if CR4.PKE =
44+
* 1; otherwise, an invalid-opcode exception (#UD) occurs. Software can discover the value of
45+
* CR4.PKE by examining CPUID.(EAX=07H,ECX=0H):ECX.OSPKE [bit 4]. On processors that support the
46+
* Intel 64 Architecture, the high-order 32-bits of RCX are ignored and the high-order 32-bits of
47+
* RDX and RAX are cleared.
48+
*/
49+
@Opcode("RDPKRU")
50+
public class AMD64ReadDataFromUserPageKeyRegister extends AMD64LIRInstruction {
51+
public static final LIRInstructionClass<AMD64ReadDataFromUserPageKeyRegister> TYPE = LIRInstructionClass.create(AMD64ReadDataFromUserPageKeyRegister.class);
52+
53+
// the result of the rdpkru is in eax
54+
@Def protected Value retVal;
55+
56+
// edx will be cleared
57+
@Temp({REG}) protected AllocatableValue edx;
58+
59+
// ecx must be zero
60+
@Temp({REG}) protected AllocatableValue zeroArg1;
61+
62+
public AMD64ReadDataFromUserPageKeyRegister() {
63+
super(TYPE);
64+
this.retVal = AMD64.rax.asValue(LIRKind.value(AMD64Kind.DWORD));
65+
this.edx = AMD64.rdx.asValue(LIRKind.value(AMD64Kind.DWORD));
66+
this.zeroArg1 = AMD64.rcx.asValue(LIRKind.value(AMD64Kind.DWORD));
67+
}
68+
69+
@Override
70+
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
71+
masm.xorl(ValueUtil.asRegister(zeroArg1), ValueUtil.asRegister(zeroArg1));
72+
masm.rdpkru();
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2023, 2024, 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 org.graalvm.compiler.core.amd64;
26+
27+
import jdk.vm.ci.amd64.AMD64;
28+
import jdk.vm.ci.amd64.AMD64Kind;
29+
import jdk.vm.ci.code.RegisterValue;
30+
import jdk.vm.ci.code.ValueUtil;
31+
import jdk.vm.ci.meta.AllocatableValue;
32+
import jdk.vm.ci.meta.Value;
33+
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
34+
import org.graalvm.compiler.core.common.LIRKind;
35+
import org.graalvm.compiler.lir.LIRInstructionClass;
36+
import org.graalvm.compiler.lir.Opcode;
37+
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
38+
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
39+
40+
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
41+
42+
/**
43+
* Writes the value of EAX into PKRU. ECX and EDX must be 0 when WRPKRU is executed; otherwise, a
44+
* general protection exception (#GP) occurs. WRPKRU can be executed only if CR4.PKE = 1; otherwise,
45+
* an invalid-opcode exception (#UD) occurs. Software can discover the value of CR4.PKE by examining
46+
* CPUID.(EAX=07H,ECX=0H):ECX.OSPKE [bit 4]. On processors that support the Intel 64 Architecture,
47+
* the high-order 32-bits of RCX, RDX and RAX are ignored.
48+
*/
49+
@Opcode("WRPKRU")
50+
public class AMD64WriteDataToUserPageKeyRegister extends AMD64LIRInstruction {
51+
public static final LIRInstructionClass<AMD64WriteDataToUserPageKeyRegister> TYPE = LIRInstructionClass.create(AMD64WriteDataToUserPageKeyRegister.class);
52+
53+
// the argument to wrpkru is in eax
54+
@Use protected Value arg;
55+
// ecx and edx need to be zero
56+
@Temp({REG}) protected AllocatableValue zeroArg1;
57+
@Temp({REG}) protected AllocatableValue zeroArg2;
58+
59+
public AMD64WriteDataToUserPageKeyRegister(RegisterValue arg) {
60+
super(TYPE);
61+
assert arg.getRegister().equals(AMD64.rax);
62+
this.arg = arg;
63+
zeroArg1 = AMD64.rcx.asValue(LIRKind.value(AMD64Kind.DWORD));
64+
zeroArg2 = AMD64.rdx.asValue(LIRKind.value(AMD64Kind.DWORD));
65+
}
66+
67+
@Override
68+
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
69+
masm.xorl(ValueUtil.asRegister(zeroArg1), ValueUtil.asRegister(zeroArg1));
70+
masm.xorl(ValueUtil.asRegister(zeroArg2), ValueUtil.asRegister(zeroArg2));
71+
masm.wrpkru();
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2023, 2024, 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 org.graalvm.compiler.core.amd64;
26+
27+
import jdk.vm.ci.meta.Value;
28+
import org.graalvm.compiler.core.common.type.IntegerStamp;
29+
import org.graalvm.compiler.graph.NodeClass;
30+
import org.graalvm.compiler.nodeinfo.NodeCycles;
31+
import org.graalvm.compiler.nodeinfo.NodeInfo;
32+
import org.graalvm.compiler.nodeinfo.NodeSize;
33+
import org.graalvm.compiler.nodes.FixedWithNextNode;
34+
import org.graalvm.compiler.nodes.spi.LIRLowerable;
35+
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
36+
37+
@NodeInfo(cycles = NodeCycles.CYCLES_1, size = NodeSize.SIZE_4)
38+
public class ReadProtectionKeyRegisterNode extends FixedWithNextNode implements LIRLowerable {
39+
public static final NodeClass<ReadProtectionKeyRegisterNode> TYPE = NodeClass.create(ReadProtectionKeyRegisterNode.class);
40+
41+
public ReadProtectionKeyRegisterNode() {
42+
super(TYPE, IntegerStamp.create(32));
43+
}
44+
45+
@Override
46+
public void generate(NodeLIRBuilderTool gen) {
47+
Value result = gen.getLIRGeneratorTool().emitProtectionKeyRegisterRead();
48+
gen.setResult(this, result);
49+
}
50+
51+
@NodeIntrinsic
52+
public static native int readProtectionKeyRegister();
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2023, 2024, 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 org.graalvm.compiler.core.amd64;
26+
27+
import org.graalvm.compiler.core.common.type.StampFactory;
28+
import org.graalvm.compiler.graph.NodeClass;
29+
import org.graalvm.compiler.nodeinfo.NodeCycles;
30+
import org.graalvm.compiler.nodeinfo.NodeInfo;
31+
import org.graalvm.compiler.nodeinfo.NodeSize;
32+
import org.graalvm.compiler.nodes.FixedWithNextNode;
33+
import org.graalvm.compiler.nodes.ValueNode;
34+
import org.graalvm.compiler.nodes.spi.LIRLowerable;
35+
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
36+
import org.graalvm.word.WordBase;
37+
38+
@NodeInfo(cycles = NodeCycles.CYCLES_16, size = NodeSize.SIZE_4)
39+
public class WriteProtectionKeyRegisterNode extends FixedWithNextNode implements LIRLowerable {
40+
public static final NodeClass<WriteProtectionKeyRegisterNode> TYPE = NodeClass.create(WriteProtectionKeyRegisterNode.class);
41+
42+
@Input protected ValueNode value;
43+
44+
public WriteProtectionKeyRegisterNode(ValueNode value) {
45+
super(TYPE, StampFactory.forVoid());
46+
this.value = value;
47+
}
48+
49+
@Override
50+
public void generate(NodeLIRBuilderTool gen) {
51+
gen.getLIRGeneratorTool().emitProtectionKeyRegisterWrite(gen.operand(value));
52+
}
53+
54+
@NodeIntrinsic
55+
public static native void writeProtectionKeyRegister(WordBase value);
56+
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ private static ValueNode signExtend(ValueNode input, LoopEx loop) {
187187
if (init >= 0 && extremum >= 0) {
188188
long shortestTrip = (extremum - init) / stride + 1;
189189
if (countedLoopInfo.constantMaxTripCount().equals(shortestTrip)) {
190-
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
190+
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
191191
}
192192
}
193193
}
194194
if (countedLoopInfo.getLimitCheckedIV() == inductionVariable &&
195195
inductionVariable.direction() == InductionVariable.Direction.Up &&
196196
(countedLoopInfo.getOverFlowGuard() != null || countedLoopInfo.counterNeverOverflows())) {
197-
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
197+
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
198198
}
199199
}
200200
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/gen/LIRGeneratorTool.java

+18
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,24 @@ default void emitConvertZeroToNull(AllocatableValue result, Value input) {
581581
*/
582582
void emitSpeculationFence();
583583

584+
/**
585+
* Write value to the protection key register.
586+
*
587+
* @param value to be written
588+
*/
589+
default void emitProtectionKeyRegisterWrite(Value value) {
590+
throw new GraalError("Emitting code to write a value to the protection key register is not currently supported on %s", target().arch);
591+
}
592+
593+
/**
594+
* Read contents of the protection key register.
595+
*
596+
* @return value read from the register
597+
*/
598+
default Value emitProtectionKeyRegisterRead() {
599+
throw new GraalError("Emitting code to read the contents of the protection key register is not currently supported on %s", target().arch);
600+
}
601+
584602
default VirtualStackSlot allocateStackMemory(int sizeInBytes, int alignmentInBytes) {
585603
return getResult().getFrameMapBuilder().allocateStackMemory(sizeInBytes, alignmentInBytes);
586604
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/loop/phases/LoopPredicationPhase.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ protected void run(StructuredGraph graph, MidTierContext context) {
112112
final InductionVariable counter = counted.getLimitCheckedIV();
113113
final Condition condition = ((CompareNode) counted.getLimitTest().condition()).condition().asCondition();
114114
final boolean inverted = loop.counted().isInverted();
115-
if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) &&
116-
!counted.isUnsignedCheck() &&
117-
((condition != NE && condition != EQ) || (counter.isConstantStride() && Math.abs(counter.constantStride()) == 1)) &&
115+
if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) && !counted.isUnsignedCheck() &&
116+
((condition != NE && condition != EQ) || (counter.isConstantStride() && LoopEx.absStrideIsOne(counter))) &&
118117
(loop.loopBegin().isMainLoop() || loop.loopBegin().isSimpleLoop())) {
119118
NodeIterable<GuardNode> guards = loop.whole().nodes().filter(GuardNode.class);
120119
if (LoopPredicationMainPath.getValue(graph.getOptions())) {

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/calc/SignExtendNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private static ValueNode canonical(SignExtendNode self, ValueNode forValue, int
124124
if ((inputStamp.mayBeSet() & (1L << (inputBits - 1))) == 0L) {
125125
// 0xxx -(sign-extend)-> 0000 0xxx
126126
// ==> 0xxx -(zero-extend)-> 0000 0xxx
127-
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, true);
127+
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, false);
128128
}
129129
}
130130
if (forValue instanceof NarrowNode) {

0 commit comments

Comments
 (0)