Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0767142

Browse files
committed
Bug 1827914 - Add debug logging around self-hosted JIT code cache r=iain
Differential Revision: https://phabricator.services.mozilla.com/D237812
1 parent 9d102f7 commit 0767142

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

js/src/frontend/Stencil.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "vm/BindingKind.h" // BindingKind
5353
#include "vm/EnvironmentObject.h"
5454
#include "vm/GeneratorAndAsyncKind.h" // GeneratorKind, FunctionAsyncKind
55+
#include "vm/JSAtomUtils.h" // AtomToPrintableString
5556
#include "vm/JSContext.h" // JSContext
5657
#include "vm/JSFunction.h" // JSFunction, GetFunctionPrototype, NewFunctionWithProto
5758
#include "vm/JSObject.h" // JSObject, TenuredObject
@@ -2945,9 +2946,17 @@ bool CompilationStencil::delazifySelfHostedFunction(
29452946
// JitCode for reuse across the runtime. If the cache already contains an
29462947
// entry for this function, update the JitScript. If not, compile it now and
29472948
// store it in the cache.
2949+
UniqueChars nameStr;
2950+
if (JS_SHOULD_LOG(selfHosted, Debug)) {
2951+
nameStr = AtomToPrintableString(cx, name);
2952+
}
29482953
auto& jitCache = cx->runtime()->selfHostJitCache.ref();
29492954
auto v = jitCache.readonlyThreadsafeLookup(jitCacheKey);
29502955
if (v && v->value()->method()) {
2956+
JS_LOG(selfHosted, Debug,
2957+
"self_hosted_cache: reusing JIT code for script '%s'",
2958+
nameStr.get());
2959+
29512960
if (!cx->zone()->ensureJitZoneExists(cx)) {
29522961
return false;
29532962
}
@@ -2973,6 +2982,10 @@ bool CompilationStencil::delazifySelfHostedFunction(
29732982
} else if (jit::IsBaselineJitEnabled(cx) && script->canBaselineCompile() &&
29742983
!script->hasBaselineScript() &&
29752984
jit::CanBaselineInterpretScript(script)) {
2985+
JS_LOG(selfHosted, Debug,
2986+
"self_hosted_cache: new JIT code entry for script '%s'",
2987+
nameStr.get());
2988+
29762989
if (!cx->zone()->ensureJitZoneExists(cx)) {
29772990
return false;
29782991
}
@@ -2999,6 +3012,11 @@ bool CompilationStencil::delazifySelfHostedFunction(
29993012
if (!jitCache.put(jitCacheKey, baselineScript)) {
30003013
return false;
30013014
}
3015+
} else {
3016+
JS_LOG(selfHosted, Debug,
3017+
"self_hosted_cache: script '%s' is not eligible for Baseline "
3018+
"compilation",
3019+
nameStr.get());
30023020
}
30033021
}
30043022

js/src/vm/Logging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class LogModule {
9191
_(thenable) /* Thenable on standard proto*/ \
9292
_(startup) /* engine startup logging */ \
9393
_(teleporting) /* Shape Teleporting */ \
94+
_(selfHosted) /* self-hosted script logging */ \
9495
JITSPEW_CHANNEL_LIST(_) /* A module for each JitSpew channel. */
9596

9697
// Declare Log modules
@@ -106,6 +107,9 @@ FOR_EACH_JS_LOG_MODULE(DECLARE_MODULE);
106107

107108
// The core logging macro for the JS Engine.
108109
#ifdef JS_LOGGING
110+
# define JS_SHOULD_LOG(name, log_level) \
111+
name##Module.shouldLog(LogLevel::log_level)
112+
109113
# define JS_LOG(name, log_level, ...) \
110114
do { \
111115
if (name##Module.shouldLog(LogLevel::log_level)) { \

0 commit comments

Comments
 (0)