Skip to content

Commit e248837

Browse files
committed
Backup only the lower 128bits of the XMM callee save registers on Windows
1 parent 413a27f commit e248837

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Diff for: compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/SaveCalleeSaveRegisters.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static RegisterMap<AllocatableValue> saveAtEntry(LIR lir, LIRGeneratorTo
8080
List<Register> allocatables = lirGenRes.getRegisterConfig().getAllocatableRegisters().asList();
8181
RegisterMap<AllocatableValue> saveMap = new RegisterMap<>(arch);
8282
for (Register register : calleeSaveRegisters) {
83-
PlatformKind registerPlatformKind = arch.getLargestStorableKind(register.getRegisterCategory());
83+
PlatformKind registerPlatformKind = lirGenRes.getRegisterConfig().getCalleeSaveRegisterStorageKind(arch, register);
8484
LIRKind lirKind = LIRKind.value(registerPlatformKind);
8585
RegisterValue registerValue = register.asValue(lirKind);
8686
AllocatableValue saveVariable = allocatables.contains(registerValue.getRegister()) ? lirGen.newVariable(lirKind) : lirGenRes.getFrameMapBuilder().allocateSpillSlot(lirKind);

Diff for: substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,7 @@
6363
import static jdk.vm.ci.amd64.AMD64.xmm7;
6464
import static jdk.vm.ci.amd64.AMD64.xmm8;
6565
import static jdk.vm.ci.amd64.AMD64.xmm9;
66+
import static jdk.vm.ci.amd64.AMD64Kind.V128_QWORD;
6667

6768
import java.util.ArrayList;
6869
import java.util.Arrays;
@@ -85,6 +86,7 @@
8586
import jdk.graal.compiler.core.common.LIRKind;
8687
import jdk.vm.ci.amd64.AMD64;
8788
import jdk.vm.ci.amd64.AMD64Kind;
89+
import jdk.vm.ci.code.Architecture;
8890
import jdk.vm.ci.code.CallingConvention;
8991
import jdk.vm.ci.code.CallingConvention.Type;
9092
import jdk.vm.ci.code.Register;
@@ -234,6 +236,16 @@ public RegisterArray getCalleeSaveRegisters() {
234236
return calleeSaveRegisters;
235237
}
236238

239+
@Override
240+
public PlatformKind getCalleeSaveRegisterStorageKind(Architecture arch, Register calleeSaveRegister) {
241+
if (Platform.includedIn(Platform.WINDOWS.class)) {
242+
if (AMD64.XMM.equals(calleeSaveRegister.getRegisterCategory()) && calleeSaveRegister.encoding() >= xmm6.encoding() && calleeSaveRegister.encoding() <= xmm15.encoding()) {
243+
return V128_QWORD;
244+
}
245+
}
246+
return SubstrateRegisterConfig.super.getCalleeSaveRegisterStorageKind(arch, calleeSaveRegister);
247+
}
248+
237249
@Override
238250
public RegisterArray getCallerSaveRegisters() {
239251
return getAllocatableRegisters();
@@ -405,7 +417,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT
405417
kinds = Arrays.copyOf(kinds, kinds.length + 1);
406418
locations = Arrays.copyOf(locations, locations.length + 1);
407419
kinds[kinds.length - 1] = JavaKind.Int;
408-
locations[locations.length - 1] = AMD64.rax.asValue(LIRKind.value(AMD64Kind.DWORD));
420+
locations[locations.length - 1] = rax.asValue(LIRKind.value(AMD64Kind.DWORD));
409421
if (type.customABI()) {
410422
var extendsParametersAssignment = Arrays.copyOf(type.fixedParameterAssignment, type.fixedParameterAssignment.length + 1);
411423
extendsParametersAssignment[extendsParametersAssignment.length - 1] = AssignedLocation.forRegister(rax, JavaKind.Long);

0 commit comments

Comments
 (0)