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

[GR-18411] Address Truffle warnings #3787

Merged
merged 7 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.38.0",
"mx_version": "7.40.0",

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

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down Expand Up @@ -45,13 +45,13 @@

"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},

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

"eclipse": {
Expand Down
4 changes: 2 additions & 2 deletions doc/contributor/how-to-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode

@Specialization
protected RubyHash initialize(RubyHash hash, NotProvided defaultValue, RubyProc block,
@Shared @Cached PropagateSharingNode propagateSharingNode) {
@Cached @Shared PropagateSharingNode propagateSharingNode) {
// ...
}

@Specialization(guards = "wasProvided(defaultValue)")
protected RubyHash initialize(RubyHash hash, Object defaultValue, Nil block,
@Shared @Cached PropagateSharingNode propagateSharingNode) {
@Cached @Shared PropagateSharingNode propagateSharingNode) {
// ...
}

Expand Down
4 changes: 2 additions & 2 deletions mx.truffleruby/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{
"name": "regex",
"subdir": True,
"version": "9461021a0d01a9a224a2fa7363a78dd44e974ce9",
"version": "d5e3b52521239695cfb42093c50ad2faeaad9360",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand All @@ -31,7 +31,7 @@
{
"name": "sulong",
"subdir": True,
"version": "9461021a0d01a9a224a2fa7363a78dd44e974ce9",
"version": "d5e3b52521239695cfb42093c50ad2faeaad9360",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand Down
4 changes: 4 additions & 0 deletions src/main/c/rubysignal/src/rubysignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ JNIEXPORT void JNICALL Java_org_truffleruby_signal_LibRubySignal_setupLocale(JNI
setlocale(LC_CTYPE, "");
}

JNIEXPORT void JNICALL Java_org_truffleruby_signal_LibRubySignal_setupLocaleOnlyCTYPE(JNIEnv *env, jclass clazz) {
setlocale(LC_CTYPE, "");
}

static void empty_handler(int sig) {
}

Expand Down
26 changes: 18 additions & 8 deletions src/main/java/org/truffleruby/RubyLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.lang.ref.Cleaner;
import java.util.Arrays;
import java.util.Map;
Expand Down Expand Up @@ -40,7 +41,6 @@
import com.oracle.truffle.api.strings.InternalByteArray;
import com.oracle.truffle.api.strings.TruffleString;
import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.ProcessProperties;
import org.graalvm.options.OptionDescriptors;
import org.prism.Parser;
import org.truffleruby.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -290,9 +290,9 @@ private RubyThread getOrCreateForeignThread(RubyContext context, Thread thread)

private static final RubyObjectType objectType = new RubyObjectType();

public final Shape basicObjectShape = createShape(RubyBasicObject.class);
public final Shape moduleShape = createShape(RubyModule.class);
public final Shape classShape = createShape(RubyClass.class);
public final Shape basicObjectShape = createShape(RubyBasicObject.class, RubyBasicObject.LOOKUP);
public final Shape moduleShape = createShape(RubyModule.class, RubyModule.LOOKUP);
public final Shape classShape = createShape(RubyClass.class, RubyModule.LOOKUP);

public final Shape arrayShape = createShape(RubyArray.class);
public final Shape atomicReferenceShape = createShape(RubyAtomicReference.class);
Expand Down Expand Up @@ -338,7 +338,7 @@ private RubyThread getOrCreateForeignThread(RubyContext context, Thread thread)
public final Shape classVariableShape = Shape
.newBuilder()
.allowImplicitCastIntToLong(true)
.layout(ClassVariableStorage.class)
.layout(ClassVariableStorage.class, ClassVariableStorage.LOOKUP)
.build();

public final ThreadLocal<ParsingParameters> parsingRequestParams = new ThreadLocal<>();
Expand Down Expand Up @@ -831,13 +831,18 @@ private void setupLocale(Env env, String rubyHome) {
// CRuby does setlocale(LC_CTYPE, "") because this is needed to get the locale encoding with nl_langinfo(CODESET).
// This means every locale category except LC_CTYPE remains the initial "C".
// LC_CTYPE is set according to environment variables (LC_ALL, LC_CTYPE, LANG).
// HotSpot does setlocale(LC_ALL, "") and Native Image does nothing.
// HotSpot and Native Image with UseSystemLocale=true (the default) do setlocale(LC_ALL, "").
// We match CRuby by doing setlocale(LC_ALL, "C") and setlocale(LC_CTYPE, "").
// This also affects C functions that depend on the locale in C extensions, so best to follow CRuby here.
// Change the strict minimum if embedded because setlocale() is process-wide.
if (env.getOptions().get(OptionsCatalog.EMBEDDED_KEY)) {
if (ImageInfo.inImageRuntimeCode()) {
ProcessProperties.setLocale("LC_CTYPE", "");
// Only do this on Native Image, to handle the case of the embedder setting UseSystemLocale=false.
LibRubySignal.loadLibrary(rubyHome, Platform.LIB_SUFFIX);
LibRubySignal.setupLocaleOnlyCTYPE();
} else {
// Nothing to do, JVM and Native Image UseSystemLocale=true already did setlocale(LC_ALL, "")
// so there is no need to setlocale(LC_CTYPE, "").
}
} else {
LibRubySignal.loadLibrary(rubyHome, Platform.LIB_SUFFIX);
Expand Down Expand Up @@ -879,10 +884,15 @@ public PathToTStringCache getPathToTStringCache() {
}

private static Shape createShape(Class<? extends RubyDynamicObject> layoutClass) {
return createShape(layoutClass, RubyDynamicObject.LOOKUP);
}

private static Shape createShape(Class<? extends RubyDynamicObject> layoutClass, MethodHandles.Lookup lookup) {
assert lookup.lookupClass().isAssignableFrom(layoutClass) : layoutClass;
return Shape
.newBuilder()
.allowImplicitCastIntToLong(true)
.layout(layoutClass)
.layout(layoutClass, lookup)
.dynamicType(RubyLanguage.objectType)
.build();
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/truffleruby/cext/CExtNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static RubyArray rbEncCodePointLen(Object string,
@Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode,
@Cached TruffleString.CodePointAtByteIndexNode codePointAtByteIndexNode,
@Cached InlinedBranchProfile errorProfile,
@Bind("this") Node node) {
@Bind Node node) {
var tstring = strings.getTString(node, string);
var encoding = strings.getEncoding(node, string);
var tencoding = encoding.tencoding;
Expand Down Expand Up @@ -1642,7 +1642,7 @@ static Object rbTrEncMbcCaseFold(int flags, Object string, Object advance_p, Obj
@Cached TranslateInteropExceptionNode translateInteropExceptionNode,
@Cached TruffleString.FromByteArrayNode fromByteArrayNode,
@Cached TruffleString.GetInternalByteArrayNode byteArrayNode,
@Bind("this") Node node) {
@Bind Node node) {
var tstring = strings.getTString(node, string);
var encoding = strings.getEncoding(node, string);
var bytes = TStringUtils.getBytesOrFail(tstring, encoding, byteArrayNode);
Expand Down Expand Up @@ -1705,7 +1705,7 @@ Object rbEncMinLen(RubyEncoding value) {
public abstract static class RbEncMbLenNode extends CoreMethodArrayArgumentsNode {
@Specialization
static Object rbEncMbLen(Object string,
@Bind("this") Node node,
@Bind Node node,
@Cached RubyStringLibrary strings,
@Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode) {
var tstring = strings.getTString(node, string);
Expand All @@ -1718,7 +1718,7 @@ static Object rbEncMbLen(Object string,
public abstract static class RbEncPreciseMbclenNode extends CoreMethodArrayArgumentsNode {
@Specialization
static int rbEncPreciseMbclen(Object string,
@Bind("this") Node node,
@Bind Node node,
@Cached RubyStringLibrary strings,
@Cached TruffleString.ByteLengthOfCodePointNode byteLengthOfCodePointNode) {
var tstring = strings.getTString(node, string);
Expand All @@ -1732,7 +1732,7 @@ public abstract static class RbEncStrlen extends CoreMethodArrayArgumentsNode {

@Specialization
static int rbEncStrlen(Object string,
@Bind("this") Node node,
@Bind Node node,
@Cached RubyStringLibrary strings,
@Cached TruffleString.CodePointLengthNode codePointLengthNode) {
var tstring = strings.getTString(node, string);
Expand Down Expand Up @@ -1764,7 +1764,7 @@ static int rbEncMbcToCodepoint(Object string,
@Cached TruffleString.CodePointAtByteIndexNode codePointAtByteIndexNode,
@Cached TruffleString.GetInternalByteArrayNode byteArrayNode,
@Cached InlinedConditionProfile brokenProfile,
@Bind("this") Node node) {
@Bind Node node) {
var tstring = strings.getTString(node, string);
var encoding = strings.getEncoding(node, string);
int codepoint = codePointAtByteIndexNode.execute(tstring, 0, encoding.tencoding,
Expand Down Expand Up @@ -2039,7 +2039,7 @@ static RubyString format(Object format, Object stringReader, RubyArray argArray,
@Cached InlinedBranchProfile exceptionProfile,
@Cached InlinedConditionProfile resizeProfile,
@Cached IndirectCallNode formatNode,
@Bind("this") Node node) {
@Bind Node node) {
var tstring = libFormat.getTString(node, format);
var encoding = libFormat.getEncoding(node, format);
final Object[] arguments = arrayToObjectArrayNode.executeToObjectArray(argArray);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/truffleruby/cext/ValueWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected boolean isPointer() {
static void toNative(ValueWrapper wrapper,
@Cached AllocateHandleNode createNativeHandleNode,
@Cached @Exclusive InlinedBranchProfile createHandleProfile,
@Bind("$node") Node node) {
@Bind Node node) {
if (!wrapper.isPointer()) {
createHandleProfile.enter(node);
createNativeHandleNode.execute(node, wrapper);
Expand All @@ -116,7 +116,7 @@ static void toNative(ValueWrapper wrapper,
static long asPointer(ValueWrapper wrapper,
@Cached KeepAliveNode keepAliveNode,
@Cached @Exclusive InlinedBranchProfile taggedObjectProfile,
@Bind("$node") Node node) {
@Bind Node node) {
long handle = wrapper.getHandle();
assert handle != ValueWrapperManager.UNSET_HANDLE;

Expand Down Expand Up @@ -147,7 +147,7 @@ protected boolean isMemberReadable(String member) {
@ExportMessage
static Object readMember(ValueWrapper wrapper, String member,
@Cached @Exclusive InlinedBranchProfile errorProfile,
@Bind("$node") Node node) throws UnknownIdentifierException {
@Bind Node node) throws UnknownIdentifierException {
if ("value".equals(member)) {
if (wrapper.object != null) {
return wrapper.object;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/truffleruby/cext/ValueWrapperManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected boolean isExecutable() {
@ExportMessage
protected Object execute(Object[] arguments,
@Cached UnwrapNode unwrapNode,
@Bind("$node") Node node) {
@Bind Node node) {
return unwrapNode.execute(node, arguments[0]);
}
}
Expand Down Expand Up @@ -419,7 +419,7 @@ protected boolean isExecutable() {
public Object execute(Object[] arguments,
@Cached UnwrapNode unwrapNode,
@Cached SymbolToIDNode symbolTOIDNode,
@Bind("$node") Node node) {
@Bind Node node) {
return symbolTOIDNode.execute(unwrapNode.execute(node, arguments[0]));
}
}
Expand Down Expand Up @@ -452,7 +452,7 @@ protected boolean isExecutable() {
@ExportMessage
protected boolean execute(Object[] arguments,
@Cached IsNativeObjectNode isNativeObjectNode,
@Bind("$node") Node node) {
@Bind Node node) {
return isNativeObjectNode.execute(node, arguments[0]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/truffleruby/cext/WrapNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ValueWrapper wrapImmutable(ImmutableRubyObject value,
static ValueWrapper wrapValue(RubyDynamicObject value,
@CachedLibrary("value") DynamicObjectLibrary objectLibrary,
@Cached @Shared InlinedBranchProfile noHandleProfile,
@Bind("this") Node node) {
@Bind Node node) {
ValueWrapper wrapper = (ValueWrapper) objectLibrary.getOrDefault(value, Layouts.VALUE_WRAPPER_IDENTIFIER, null);
if (wrapper == null) {
noHandleProfile.enter(node);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/truffleruby/core/TruffleSystemNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static Object javaGetEnv(Object name,
@Cached ToJavaStringNode toJavaStringNode,
@Cached FromJavaStringNode fromJavaStringNode,
@Cached InlinedConditionProfile nullValueProfile,
@Bind("this") Node node) {
@Bind Node node) {
final String javaName = toJavaStringNode.execute(node, name);
final String value = getEnv(javaName);

Expand Down Expand Up @@ -187,7 +187,7 @@ static Object getJavaProperty(Object property,
@Cached RubyStringLibrary strings,
@Cached TruffleString.FromJavaStringNode fromJavaStringNode,
@Cached ToJavaStringNode toJavaStringNode,
@Bind("this") Node node) {
@Bind Node node) {
String value = getProperty(toJavaStringNode.execute(node, property));
if (value == null) {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/truffleruby/core/VMPrimitiveNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Object vmRaiseException(RubyException exception,
static Object foreignException(Object exception,
@CachedLibrary("exception") InteropLibrary interopLibrary,
@Cached TranslateInteropExceptionNode translateInteropExceptionNode,
@Bind("this") Node node) {
@Bind Node node) {
try {
throw interopLibrary.throwException(exception);
} catch (UnsupportedMessageException e) {
Expand Down
Loading
Loading