Skip to content

Commit

Permalink
[GR-26395] Periodic update of the graal import.
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4088
  • Loading branch information
OracleLabsAutomation committed Dec 14, 2023
2 parents ca74b40 + f294bc3 commit 5a199d8
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 43 deletions.
3 changes: 2 additions & 1 deletion ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ local common_json = import "../common.json";
[name]: jdk_base + common_json.jdks[name] + { jdk_version:: parse_labsjdk_version(self), jdk_name:: "jdk-latest"}
for name in ["oraclejdk-latest"] + variants("labsjdk-ce-latest") + variants("labsjdk-ee-latest")
},
assert std.assertEqual(std.objectFields(common_json.jdks), std.objectFields(jdks_data)),
# We do not want to expose galahad-jdk
assert std.assertEqual([x for x in std.objectFields(common_json.jdks) if x != "galahad-jdk"], std.objectFields(jdks_data)),
# Verify oraclejdk-latest and labsjdk-ee-latest versions match
assert
local _labsjdk = common_json.jdks["labsjdk-ee-latest"];
Expand Down
30 changes: 16 additions & 14 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.3.1",
"mx_version": "7.4.1",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "22", "build_id": "jdk-22+25", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk11": {"name": "jpg-jdk", "version": "11.0.11", "build_id": "9", "release": true, "platformspecific": true, "extrabundles": ["static-libs"] },

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "8", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
Expand Down Expand Up @@ -35,20 +37,20 @@
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },

"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-sulong", "platformspecific": true },
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-sulong", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "25", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+25-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+25-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+25-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+25-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "26", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+26-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+26-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+26-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+26-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+26-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+26-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
4 changes: 2 additions & 2 deletions mx.truffleruby/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
"name": "regex",
"subdir": True,
"version": "f363b55797fe85ea6aa24218364b57f3c71aeb56",
"version": "f0e8373ec294b7af06e70a5d2e12488ce99e6cdb",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand All @@ -29,7 +29,7 @@
{
"name": "sulong",
"subdir": True,
"version": "f363b55797fe85ea6aa24218364b57f3c71aeb56",
"version": "f0e8373ec294b7af06e70a5d2e12488ce99e6cdb",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/truffleruby/interop/InteropNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,27 @@ static long getBufferSize(Object receiver,

}

@CoreMethod(names = "read_buffer", onSingleton = true, required = 3, lowerFixnum = { 2, 3 })
public abstract static class ReadBufferNode extends CoreMethodArrayArgumentsNode {

@Specialization(limit = "getInteropCacheLimit()")
static RubyString readBuffer(Object receiver, long byteOffset, int length,
@CachedLibrary("receiver") InteropLibrary interop,
@Cached TranslateInteropExceptionNode translateInteropException,
@Cached TruffleString.FromByteArrayNode fromByteArrayNode,
@Bind("this") Node node) {
byte[] bytes = new byte[length];
try {
interop.readBuffer(receiver, byteOffset, bytes, 0, length);
} catch (InteropException e) {
throw translateInteropException.execute(node, e);
}

return createString(node, fromByteArrayNode, bytes, Encodings.BINARY);
}

}

@CoreMethod(names = "read_buffer_byte", onSingleton = true, required = 2)
public abstract static class ReadBufferByteNode extends CoreMethodArrayArgumentsNode {

Expand Down
62 changes: 45 additions & 17 deletions src/processor/java/org/truffleruby/processor/CoreModuleChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CoreModuleChecks {
this.processor = processor;
}

void checks(int[] lowerFixnum, CoreMethod coreMethod, TypeElement klass, boolean hasZeroArgument) {
void checks(int[] lowerFixnum, CoreMethod coreMethod, TypeElement klass, boolean hasSelfArgument) {
byte[] lowerArgs = null;
List<ExecutableElement> specializationMethods = new ArrayList<>();

Expand All @@ -54,13 +54,11 @@ void checks(int[] lowerFixnum, CoreMethod coreMethod, TypeElement klass, boolean
specializationMethods.add(specializationMethod);

lowerArgs = checkLowerFixnumArguments(specializationMethod, lowerArgs);

if (coreMethod != null) {
checkAmbiguousOptionalArguments(
coreMethod,
specializationMethod,
specializationAnnotation);
checkCoreMethodArguments(coreMethod, specializationMethod, specializationAnnotation,
hasSelfArgument);
}

}

klassIt = processor
Expand All @@ -81,8 +79,8 @@ void checks(int[] lowerFixnum, CoreMethod coreMethod, TypeElement klass, boolean
// Verify against the lowerFixnum annotation
for (int i = 0; i < lowerArgs.length; i++) {
boolean shouldLower = lowerArgs[i] == 0b01; // int without long
if (shouldLower && !contains(lowerFixnum, hasZeroArgument ? i : i + 1)) {
processor.error("should use lowerFixnum for argument " + (hasZeroArgument ? i : i + 1), klass);
if (shouldLower && !contains(lowerFixnum, hasSelfArgument ? i : i + 1)) {
processor.error("should use lowerFixnum for argument " + (hasSelfArgument ? i : i + 1), klass);
}
}
}
Expand Down Expand Up @@ -133,10 +131,11 @@ private static boolean contains(int[] array, int value) {
return false;
}

private void checkAmbiguousOptionalArguments(
private void checkCoreMethodArguments(
CoreMethod coreMethod,
ExecutableElement specializationMethod,
Specialization specializationAnnotation) {
Specialization specializationAnnotation,
boolean hasSelfArgument) {
List<? extends VariableElement> parameters = specializationMethod.getParameters();
int n = getLastParameterIndex(parameters);

Expand All @@ -145,21 +144,24 @@ private void checkAmbiguousOptionalArguments(
processor.error("last argument must be a RootCallTarget for alwaysInlined ", specializationMethod);
return;
}
n--;
// All other arguments are packed as Object[]
return;
}

if (coreMethod.needsBlock() && !coreMethod.alwaysInlined()) {
final int parametersCount = getParametersCount(parameters);
int expectedParametersCount = coreMethod.required() + coreMethod.optional();
if (hasSelfArgument) {
expectedParametersCount++;
}

if (coreMethod.needsBlock()) {
if (n < 0) {
processor.error("invalid block method parameter position for", specializationMethod);
return;
}
checkParameterBlock(parameters.get(n));
n--; // Ignore block argument.
}

if (coreMethod.alwaysInlined()) {
// All other arguments are packed as Object[]
return;
expectedParametersCount++;
}

if (coreMethod.rest()) {
Expand All @@ -173,6 +175,13 @@ private void checkAmbiguousOptionalArguments(
return;
}
n--; // ignore final Object[] argument
expectedParametersCount++;
}

if (parametersCount != expectedParametersCount) {
processor.error("expected " + expectedParametersCount + " parameters for this @CoreMethod but there are " +
parametersCount, specializationMethod);
return;
}

for (int i = 0; i < coreMethod.optional(); i++, n--) {
Expand Down Expand Up @@ -221,6 +230,25 @@ private static int getLastParameterIndex(List<? extends VariableElement> paramet
return n;
}

private int getParametersCount(List<? extends VariableElement> parameters) {
int last = getLastParameterIndex(parameters);
int count = last + 1;

if (count > 0) {
var type = parameters.get(0).asType();
if (processor.isSameType(type, processor.nodeType)) {
if (processor.isSameType(type, processor.virtualFrameType)) {
return count - 2;
} else {
return count - 1;
}
} else if (processor.isSameType(type, processor.virtualFrameType)) {
return count - 1;
}
}
return count;
}

private void checkParameterUnguarded(Specialization specializationAnnotation, VariableElement parameter) {
String name = parameter.getSimpleName().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class CoreModuleProcessor extends TruffleRubyProcessor {
TypeMirror rubyProcType;
TypeMirror rootCallTargetType;
// node types
TypeMirror nodeType;
TypeMirror rubyNodeType;
TypeMirror rubyBaseNodeType;
TypeMirror primitiveNodeType;
Expand All @@ -108,6 +109,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
notProvidedType = elementUtils.getTypeElement("org.truffleruby.language.NotProvided").asType();
rubyProcType = elementUtils.getTypeElement("org.truffleruby.core.proc.RubyProc").asType();
rootCallTargetType = elementUtils.getTypeElement("com.oracle.truffle.api.RootCallTarget").asType();
nodeType = elementUtils.getTypeElement("com.oracle.truffle.api.nodes.Node").asType();
rubyNodeType = elementUtils.getTypeElement("org.truffleruby.language.RubyNode").asType();
rubyBaseNodeType = elementUtils.getTypeElement("org.truffleruby.language.RubyBaseNode").asType();
primitiveNodeType = elementUtils.getTypeElement("org.truffleruby.builtins.PrimitiveNode").asType();
Expand Down Expand Up @@ -188,23 +190,19 @@ private void processCoreModule(TypeElement coreModuleElement) throws IOException
if (coreMethod != null) {
// Do not use needsSelf=true in module functions, it is either the module/class or the instance.
// Usage of needsSelf is quite rare for singleton methods (except constructors).
boolean needsSelf = coreMethod.constructor() ||
boolean hasSelfArgument = coreMethod.constructor() ||
(!coreMethod.isModuleFunction() && !coreMethod.onSingleton() &&
coreMethod.needsSelf());

CoreMethod checkAmbiguous = !coreMethod.alwaysInlined() &&
(coreMethod.optional() > 0 || coreMethod.needsBlock())
? coreMethod
: null;
coreModuleChecks.checks(coreMethod.lowerFixnum(), checkAmbiguous, klass, needsSelf);
coreModuleChecks.checks(coreMethod.lowerFixnum(), coreMethod, klass, hasSelfArgument);
if (!inherits(e.asType(), coreMethodNodeType) &&
!inherits(e.asType(), alwaysInlinedMethodNodeType)) {
error(e +
" should inherit from CoreMethodArrayArgumentsNode, CoreMethodNode, AlwaysInlinedMethodNode",
e);
}
processCoreMethod(stream, rubyStream, coreModuleElement, coreModule, klass, coreMethod,
needsSelf);
hasSelfArgument);
}
}
}
Expand Down Expand Up @@ -287,7 +285,7 @@ private void processCoreMethod(
CoreModule coreModule,
TypeElement klass,
CoreMethod coreMethod,
boolean needsSelf) {
boolean hasSelfArgument) {
final StringJoiner names = new StringJoiner(", ");
for (String name : coreMethod.names()) {
names.add(quote(name));
Expand All @@ -312,7 +310,7 @@ private void processCoreMethod(

int numberOfArguments = getNumberOfArguments(coreMethod);
String[] argumentNamesFromAnnotation = coreMethod.argumentNames();
final List<String> argumentNames = getArgumentNames(klass, argumentNamesFromAnnotation, needsSelf,
final List<String> argumentNames = getArgumentNames(klass, argumentNamesFromAnnotation, hasSelfArgument,
coreMethod.alwaysInlined(),
numberOfArguments);

Expand Down

0 comments on commit 5a199d8

Please sign in to comment.