-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-51536] Backport changes from nds/foreign-upcall to include in the…
… next release PullRequest: graal/16773
- Loading branch information
Showing
4 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...reign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_Utils_BaseAndScale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 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 com.oracle.svm.core.foreign; | ||
|
||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.RecomputeFieldValue; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
import com.oracle.svm.core.config.ConfigurationValues; | ||
import com.oracle.svm.core.fieldvaluetransformer.FieldValueTransformerWithAvailability; | ||
import com.oracle.svm.core.util.VMError; | ||
|
||
import jdk.internal.foreign.Utils; | ||
import jdk.vm.ci.meta.JavaKind; | ||
|
||
@TargetClass(className = "jdk.internal.foreign.Utils", innerClass = "BaseAndScale", onlyWith = ForeignFunctionsEnabled.class) | ||
final class Target_jdk_internal_foreign_Utils_BaseAndScale { | ||
@Alias // | ||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = BaseFieldRecomputer.class) // | ||
int base; | ||
} | ||
|
||
final class BaseFieldRecomputer implements FieldValueTransformerWithAvailability { | ||
|
||
@Override | ||
public ValueAvailability valueAvailability() { | ||
return ValueAvailability.BeforeAnalysis; | ||
} | ||
|
||
@Override | ||
public Object transform(Object receiver, Object originalValue) { | ||
JavaKind kind; | ||
if (receiver == Utils.BaseAndScale.BYTE) { | ||
kind = JavaKind.Byte; | ||
} else if (receiver == Utils.BaseAndScale.CHAR) { | ||
kind = JavaKind.Char; | ||
} else if (receiver == Utils.BaseAndScale.SHORT) { | ||
kind = JavaKind.Short; | ||
} else if (receiver == Utils.BaseAndScale.INT) { | ||
kind = JavaKind.Int; | ||
} else if (receiver == Utils.BaseAndScale.LONG) { | ||
kind = JavaKind.Long; | ||
} else if (receiver == Utils.BaseAndScale.FLOAT) { | ||
kind = JavaKind.Float; | ||
} else if (receiver == Utils.BaseAndScale.DOUBLE) { | ||
kind = JavaKind.Double; | ||
} else { | ||
throw VMError.shouldNotReachHere("Unexpected BaseAndScale instance: " + receiver); | ||
} | ||
return ConfigurationValues.getObjectLayout().getArrayBaseOffset(kind); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...reign/src/com/oracle/svm/core/foreign/Target_jdk_internal_foreign_abi_AbstractLinker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 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 com.oracle.svm.core.foreign; | ||
|
||
import com.oracle.svm.core.annotate.Alias; | ||
import com.oracle.svm.core.annotate.RecomputeFieldValue; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
import jdk.internal.foreign.abi.AbstractLinker; | ||
|
||
@TargetClass(AbstractLinker.class) | ||
public final class Target_jdk_internal_foreign_abi_AbstractLinker { | ||
@Alias // | ||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.foreign.abi.SoftReferenceCache") // | ||
private Target_jdk_internal_foreign_abi_SoftReferenceCache DOWNCALL_CACHE; | ||
|
||
@Alias // | ||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClassName = "jdk.internal.foreign.abi.SoftReferenceCache") // | ||
private Target_jdk_internal_foreign_abi_SoftReferenceCache UPCALL_CACHE; | ||
} | ||
|
||
@TargetClass(className = "jdk.internal.foreign.abi.SoftReferenceCache") | ||
final class Target_jdk_internal_foreign_abi_SoftReferenceCache { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters