Skip to content

Commit 307e0d6

Browse files
committed
Fix internal root tracing should also be settable at runtime.
1 parent 6ff51e1 commit 307e0d6

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

truffle/src/com.oracle.truffle.api.library/snapshot.sigtest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ meth public abstract java.lang.Object readDelegateExport(java.lang.Object)
124124

125125
CLSS public abstract com.oracle.truffle.api.library.LibraryFactory<%0 extends com.oracle.truffle.api.library.Library>
126126
cons protected init(java.lang.Class<{com.oracle.truffle.api.library.LibraryFactory%0}>,java.util.List<com.oracle.truffle.api.library.Message>)
127-
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="26.0")
127+
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="")
128128
cons protected init(java.lang.Class<{com.oracle.truffle.api.library.LibraryFactory%0}>,java.util.List<com.oracle.truffle.api.library.Message>,boolean)
129129
meth protected !varargs com.oracle.truffle.api.utilities.FinalBitSet createMessageBitSet(com.oracle.truffle.api.library.Message[])
130130
meth protected abstract java.lang.Class<?> getDefaultClass(java.lang.Object)

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void initializeOwningRoot(InternalResourceRoots.Root root) {
163163
case UNVERSIONED -> findStandaloneResourceRoot(root.path());
164164
case VERSIONED -> null;
165165
};
166-
if (path != null && InternalResourceRoots.TRACE_INTERNAL_RESOURCE_EVENTS) {
166+
if (path != null && InternalResourceRoots.isTraceInternalResourceEvents()) {
167167
/*
168168
* The path for the VERSIONED resource is logged when the resource is requested.
169169
* Computation of this path is expensive and involves a call to
@@ -254,7 +254,7 @@ private Path installResource(Function<InternalResource, InternalResource.Env> re
254254
}
255255
Path target = owningRoot.path().resolve(Path.of(sanitize(id), sanitize(resourceId), sanitize(versionHash)));
256256
if (!Files.exists(target)) {
257-
if (InternalResourceRoots.TRACE_INTERNAL_RESOURCE_EVENTS) {
257+
if (InternalResourceRoots.isTraceInternalResourceEvents()) {
258258
InternalResourceRoots.logInternalResourceEvent("Resolved a directory for the internal resource %s::%s to: %s, unpacking resource files.", id, resourceId, target);
259259
}
260260
Path parent = target.getParent();
@@ -282,7 +282,7 @@ private Path installResource(Function<InternalResource, InternalResource.Env> re
282282
}
283283
}
284284
} else {
285-
if (InternalResourceRoots.TRACE_INTERNAL_RESOURCE_EVENTS) {
285+
if (InternalResourceRoots.isTraceInternalResourceEvents()) {
286286
InternalResourceRoots.logInternalResourceEvent("Resolved a directory for the internal resource %s::%s to: %s, using existing resource files.",
287287
id, resourceId, target);
288288
}

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class InternalResourceRoots {
6565
private static final String PROPERTY_RESOURCE_PATH = "polyglot.engine.resourcePath";
6666
private static final String PROPERTY_USER_RESOURCE_CACHE = "polyglot.engine.userResourceCache";
6767
private static final Map<Collection<EngineAccessor.AbstractClassLoaderSupplier>, InternalResourceRoots> runtimeCaches = new ConcurrentHashMap<>();
68-
static final boolean TRACE_INTERNAL_RESOURCE_EVENTS = Boolean.getBoolean("polyglotimpl.TraceInternalResources");
68+
private static final boolean TRACE_INTERNAL_RESOURCE_EVENTS = Boolean.getBoolean("polyglotimpl.TraceInternalResources");
6969

7070
static String overriddenComponentRootProperty(String componentId) {
7171
StringBuilder builder = new StringBuilder(PROPERTY_RESOURCE_PATH);
@@ -253,7 +253,7 @@ private static Pair<Path, Root.Kind> findDefaultRoot() {
253253
root = findCacheRootDefault();
254254
kind = Root.Kind.VERSIONED;
255255
}
256-
if (TRACE_INTERNAL_RESOURCE_EVENTS) {
256+
if (isTraceInternalResourceEvents()) {
257257
logInternalResourceEvent("Resolved the root directory for the internal resource cache to: %s, determined by the %s with the value %s.",
258258
root.path(), root.hint(), root.hintValue());
259259
}
@@ -347,8 +347,16 @@ private static ResolvedCacheFolder findCacheRootDefault() {
347347
return container.resolve("org.graalvm.polyglot");
348348
}
349349

350+
static boolean isTraceInternalResourceEvents() {
351+
/*
352+
* In AOT we want to enable tracing if its enabled in the built image or using the option at
353+
* runtime.
354+
*/
355+
return TRACE_INTERNAL_RESOURCE_EVENTS || (TruffleOptions.AOT && Boolean.getBoolean("polyglotimpl.TraceInternalResources"));
356+
}
357+
350358
static void logInternalResourceEvent(String message, Object... args) {
351-
assert TRACE_INTERNAL_RESOURCE_EVENTS : "need to check for TRACE_INTERNAL_RESOURCE_EVENTS before use";
359+
assert isTraceInternalResourceEvents() : "need to check for TRACE_INTERNAL_RESOURCE_EVENTS before use";
352360
PolyglotEngineImpl.logFallback(String.format("[engine][resource] " + message + "%n", args));
353361
}
354362

0 commit comments

Comments
 (0)