Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move release/graal vm/23.1 branch forward to the latest 23.1.3 relase changes #8804

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
de23cc6
Deprecate ZeroExtendNode.inputAlwaysPositive.
mur47x111 Dec 22, 2023
b7df387
Move checkstyle file.
ansalond Feb 15, 2024
bccb1ad
Remove the GraalVM Component Updater (gu).
ansalond Feb 20, 2024
90d1b6a
Remove references to the removed `gu` component.
ansalond Feb 26, 2024
c7c4a97
[GR-52692] Backport to 23.1: CInterfaceWrapper Hooks
Nov 10, 2023
1ac5ba6
[GR-52692] Backport to 23.1: CInterfaceWrapper Hooks
Mar 19, 2024
3d0266b
use safe abs in loop opts
davleopo Jan 18, 2024
dbf260a
fix comment
davleopo Jan 23, 2024
432915f
loop ex: allow overflow in math.abs for stride !=1 checks, it does not
davleopo Jan 23, 2024
c9530f1
reuse loopex.absStrideIsOne
davleopo Jan 26, 2024
c2d9887
[GR-51294] Backport to 23.1: Deprecate ZeroExtendNode.inputAlwaysPosi…
mur47x111 Mar 27, 2024
412a582
[GR-51667] Backport to 23.1: Use safe abs in loop opts.
elkorchi Mar 28, 2024
b24ec38
basic array copy: less virtualization for illegal values
davleopo Mar 28, 2024
647e590
[GR-52947] Backport to 23.1: GH-8638: Correctness problem when System…
davleopo Mar 29, 2024
25d87bf
[GR-51274] Remove the GraalVM Component Updater (gu) and the installa…
ansalond Mar 29, 2024
c548ae6
Workaround CPU features Xcode 15 miscomp issue (GR-49301)
fangerer Oct 6, 2023
ff1e540
svm: fix placement of the NO_INLINE definition in cpuid.c
zapster Oct 9, 2023
bf168d1
svm: add comment about the reason for NO_INLINE
fangerer Oct 11, 2023
e0f1473
[GR-53048] Backport 23.1: Workaround CPU features Xcode 15 miscomp is…
fniephaus Apr 2, 2024
dda64b4
GR-53188 : release GraalVM 23.1.3
marwan-hallaoui Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

"groupId" : "org.graalvm.compiler",
"version" : "23.1.3",
"release" : False,
"release" : True,
"url" : "http://www.graalvm.org/",
"developer" : {
"name" : "GraalVM Development",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5097,6 +5097,18 @@ public void clflush(AMD64Address adr) {
emitOperandHelper(7, adr, 0);
}

public void wrpkru() {
emitByte(0x0F);
emitByte(0x01);
emitByte(0xEF);
}

public void rdpkru() {
emitByte(0x0F);
emitByte(0x01);
emitByte(0xEE);
}

public final void vpaddd(Register dst, Register nds, Register src, AVXSize size) {
VexRVMOp.VPADDD.emit(this, size, dst, nds, src);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,20 @@ public void emitSpeculationFence() {
append(new AMD64LFenceOp());
}

@Override
public void emitProtectionKeyRegisterWrite(Value value) {
RegisterValue rax = AMD64.rax.asValue(value.getValueKind());
emitMove(rax, value);
append(new AMD64WriteDataToUserPageKeyRegister(rax));
}

@Override
public Value emitProtectionKeyRegisterRead() {
AMD64ReadDataFromUserPageKeyRegister rdpkru = new AMD64ReadDataFromUserPageKeyRegister();
append(rdpkru);
return emitReadRegister(AMD64.rax, rdpkru.retVal.getValueKind());
}

@Override
public void emitZeroMemory(Value address, Value length, boolean isAligned) {
RegisterValue lengthReg = AMD64.rcx.asValue(length.getValueKind());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2023, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package org.graalvm.compiler.core.amd64;

import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.amd64.AMD64Kind;
import jdk.vm.ci.code.ValueUtil;
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.Value;
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
import org.graalvm.compiler.core.common.LIRKind;
import org.graalvm.compiler.lir.LIRInstructionClass;
import org.graalvm.compiler.lir.Opcode;
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;

import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;

/**
* Reads the value of PKRU into EAX and clears EDX. ECX must be 0 when RDPKRU is executed;
* otherwise, a general-protection exception (#GP) occurs. RDPKRU can be executed only if CR4.PKE =
* 1; otherwise, an invalid-opcode exception (#UD) occurs. Software can discover the value of
* CR4.PKE by examining CPUID.(EAX=07H,ECX=0H):ECX.OSPKE [bit 4]. On processors that support the
* Intel 64 Architecture, the high-order 32-bits of RCX are ignored and the high-order 32-bits of
* RDX and RAX are cleared.
*/
@Opcode("RDPKRU")
public class AMD64ReadDataFromUserPageKeyRegister extends AMD64LIRInstruction {
public static final LIRInstructionClass<AMD64ReadDataFromUserPageKeyRegister> TYPE = LIRInstructionClass.create(AMD64ReadDataFromUserPageKeyRegister.class);

// the result of the rdpkru is in eax
@Def protected Value retVal;

// edx will be cleared
@Temp({REG}) protected AllocatableValue edx;

// ecx must be zero
@Temp({REG}) protected AllocatableValue zeroArg1;

public AMD64ReadDataFromUserPageKeyRegister() {
super(TYPE);
this.retVal = AMD64.rax.asValue(LIRKind.value(AMD64Kind.DWORD));
this.edx = AMD64.rdx.asValue(LIRKind.value(AMD64Kind.DWORD));
this.zeroArg1 = AMD64.rcx.asValue(LIRKind.value(AMD64Kind.DWORD));
}

@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
masm.xorl(ValueUtil.asRegister(zeroArg1), ValueUtil.asRegister(zeroArg1));
masm.rdpkru();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2023, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package org.graalvm.compiler.core.amd64;

import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.amd64.AMD64Kind;
import jdk.vm.ci.code.RegisterValue;
import jdk.vm.ci.code.ValueUtil;
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.Value;
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
import org.graalvm.compiler.core.common.LIRKind;
import org.graalvm.compiler.lir.LIRInstructionClass;
import org.graalvm.compiler.lir.Opcode;
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;

import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;

/**
* Writes the value of EAX into PKRU. ECX and EDX must be 0 when WRPKRU is executed; otherwise, a
* general protection exception (#GP) occurs. WRPKRU can be executed only if CR4.PKE = 1; otherwise,
* an invalid-opcode exception (#UD) occurs. Software can discover the value of CR4.PKE by examining
* CPUID.(EAX=07H,ECX=0H):ECX.OSPKE [bit 4]. On processors that support the Intel 64 Architecture,
* the high-order 32-bits of RCX, RDX and RAX are ignored.
*/
@Opcode("WRPKRU")
public class AMD64WriteDataToUserPageKeyRegister extends AMD64LIRInstruction {
public static final LIRInstructionClass<AMD64WriteDataToUserPageKeyRegister> TYPE = LIRInstructionClass.create(AMD64WriteDataToUserPageKeyRegister.class);

// the argument to wrpkru is in eax
@Use protected Value arg;
// ecx and edx need to be zero
@Temp({REG}) protected AllocatableValue zeroArg1;
@Temp({REG}) protected AllocatableValue zeroArg2;

public AMD64WriteDataToUserPageKeyRegister(RegisterValue arg) {
super(TYPE);
assert arg.getRegister().equals(AMD64.rax);
this.arg = arg;
zeroArg1 = AMD64.rcx.asValue(LIRKind.value(AMD64Kind.DWORD));
zeroArg2 = AMD64.rdx.asValue(LIRKind.value(AMD64Kind.DWORD));
}

@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
masm.xorl(ValueUtil.asRegister(zeroArg1), ValueUtil.asRegister(zeroArg1));
masm.xorl(ValueUtil.asRegister(zeroArg2), ValueUtil.asRegister(zeroArg2));
masm.wrpkru();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2023, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package org.graalvm.compiler.core.amd64;

import jdk.vm.ci.meta.Value;
import org.graalvm.compiler.core.common.type.IntegerStamp;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodeinfo.NodeCycles;
import org.graalvm.compiler.nodeinfo.NodeInfo;
import org.graalvm.compiler.nodeinfo.NodeSize;
import org.graalvm.compiler.nodes.FixedWithNextNode;
import org.graalvm.compiler.nodes.spi.LIRLowerable;
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;

@NodeInfo(cycles = NodeCycles.CYCLES_1, size = NodeSize.SIZE_4)
public class ReadProtectionKeyRegisterNode extends FixedWithNextNode implements LIRLowerable {
public static final NodeClass<ReadProtectionKeyRegisterNode> TYPE = NodeClass.create(ReadProtectionKeyRegisterNode.class);

public ReadProtectionKeyRegisterNode() {
super(TYPE, IntegerStamp.create(32));
}

@Override
public void generate(NodeLIRBuilderTool gen) {
Value result = gen.getLIRGeneratorTool().emitProtectionKeyRegisterRead();
gen.setResult(this, result);
}

@NodeIntrinsic
public static native int readProtectionKeyRegister();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2023, 2024, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package org.graalvm.compiler.core.amd64;

import org.graalvm.compiler.core.common.type.StampFactory;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodeinfo.NodeCycles;
import org.graalvm.compiler.nodeinfo.NodeInfo;
import org.graalvm.compiler.nodeinfo.NodeSize;
import org.graalvm.compiler.nodes.FixedWithNextNode;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.spi.LIRLowerable;
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
import org.graalvm.word.WordBase;

@NodeInfo(cycles = NodeCycles.CYCLES_16, size = NodeSize.SIZE_4)
public class WriteProtectionKeyRegisterNode extends FixedWithNextNode implements LIRLowerable {
public static final NodeClass<WriteProtectionKeyRegisterNode> TYPE = NodeClass.create(WriteProtectionKeyRegisterNode.class);

@Input protected ValueNode value;

public WriteProtectionKeyRegisterNode(ValueNode value) {
super(TYPE, StampFactory.forVoid());
this.value = value;
}

@Override
public void generate(NodeLIRBuilderTool gen) {
gen.getLIRGeneratorTool().emitProtectionKeyRegisterWrite(gen.operand(value));
}

@NodeIntrinsic
public static native void writeProtectionKeyRegister(WordBase value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ private static ValueNode signExtend(ValueNode input, LoopEx loop) {
if (init >= 0 && extremum >= 0) {
long shortestTrip = (extremum - init) / stride + 1;
if (countedLoopInfo.constantMaxTripCount().equals(shortestTrip)) {
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
}
}
}
if (countedLoopInfo.getLimitCheckedIV() == inductionVariable &&
inductionVariable.direction() == InductionVariable.Direction.Up &&
(countedLoopInfo.getOverFlowGuard() != null || countedLoopInfo.counterNeverOverflows())) {
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,24 @@ default void emitConvertZeroToNull(AllocatableValue result, Value input) {
*/
void emitSpeculationFence();

/**
* Write value to the protection key register.
*
* @param value to be written
*/
default void emitProtectionKeyRegisterWrite(Value value) {
throw new GraalError("Emitting code to write a value to the protection key register is not currently supported on %s", target().arch);
}

/**
* Read contents of the protection key register.
*
* @return value read from the register
*/
default Value emitProtectionKeyRegisterRead() {
throw new GraalError("Emitting code to read the contents of the protection key register is not currently supported on %s", target().arch);
}

default VirtualStackSlot allocateStackMemory(int sizeInBytes, int alignmentInBytes) {
return getResult().getFrameMapBuilder().allocateStackMemory(sizeInBytes, alignmentInBytes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ protected void run(StructuredGraph graph, MidTierContext context) {
final InductionVariable counter = counted.getLimitCheckedIV();
final Condition condition = ((CompareNode) counted.getLimitTest().condition()).condition().asCondition();
final boolean inverted = loop.counted().isInverted();
if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) &&
!counted.isUnsignedCheck() &&
((condition != NE && condition != EQ) || (counter.isConstantStride() && Math.abs(counter.constantStride()) == 1)) &&
if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) && !counted.isUnsignedCheck() &&
((condition != NE && condition != EQ) || (counter.isConstantStride() && LoopEx.absStrideIsOne(counter))) &&
(loop.loopBegin().isMainLoop() || loop.loopBegin().isSimpleLoop())) {
NodeIterable<GuardNode> guards = loop.whole().nodes().filter(GuardNode.class);
if (LoopPredicationMainPath.getValue(graph.getOptions())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static ValueNode canonical(SignExtendNode self, ValueNode forValue, int
if ((inputStamp.mayBeSet() & (1L << (inputBits - 1))) == 0L) {
// 0xxx -(sign-extend)-> 0000 0xxx
// ==> 0xxx -(zero-extend)-> 0000 0xxx
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, true);
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, false);
}
}
if (forValue instanceof NarrowNode) {
Expand Down