Skip to content

Commit 499d9e1

Browse files
committed
[JSC] Simplify PerfLog
https://bugs.webkit.org/show_bug.cgi?id=269352 rdar://122939072 Reviewed by Justin Michaud. This patch simplifies PerfLog's content. 1. We should emit very simple name for each logging 2. We use LinkBuffer::Profile as a prefix (like, "FTL: function#<hash>") 3. Add option to specify the directory for JITDump. "/tmp" is the default. * Source/JavaScriptCore/assembler/LinkBuffer.cpp: (JSC::profileName): (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::logJITCodeForPerf): (JSC::LinkBuffer::finalizeCodeWithDisassemblyImpl): (JSC::LinkBuffer::dumpProfileStatistics): * Source/JavaScriptCore/assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::finalizeCodeWithoutDisassembly): (JSC::LinkBuffer::finalizeCodeWithDisassembly): * Source/JavaScriptCore/assembler/PerfLog.cpp: (JSC::PerfLog::PerfLog): * Source/JavaScriptCore/assembler/testmasm.cpp: (JSC::compile): * Source/JavaScriptCore/b3/B3Compile.cpp: (JSC::B3::compile): * Source/JavaScriptCore/b3/air/testair.cpp: * Source/JavaScriptCore/b3/testb3_6.cpp: (testEntrySwitchSimple): (testEntrySwitchNoEntrySwitch): (testEntrySwitchWithCommonPaths): (testEntrySwitchWithCommonPathsAndNonTrivialEntrypoint): (testEntrySwitchLoop): * Source/JavaScriptCore/bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpSimpleName const): * Source/JavaScriptCore/bytecode/CodeBlock.h: * Source/JavaScriptCore/bytecode/InlineAccess.cpp: (JSC::linkCodeInline): * Source/JavaScriptCore/bytecode/InlineCacheCompiler.cpp: (JSC::getByIdSlowPathCodeGenerator): (JSC::getByIdWithThisSlowPathCodeGenerator): (JSC::getByValSlowPathCodeGenerator): (JSC::getPrivateNameSlowPathCodeGenerator): (JSC::getByValWithThisSlowPathCodeGenerator): (JSC::putByIdSlowPathCodeGenerator): (JSC::putByValSlowPathCodeGenerator): (JSC::instanceOfSlowPathCodeGenerator): (JSC::delByIdSlowPathCodeGenerator): (JSC::delByValSlowPathCodeGenerator): (JSC::categoryName): (JSC::InlineCacheCompiler::regenerate): * Source/JavaScriptCore/bytecode/Repatch.cpp: (JSC::linkPolymorphicCall): * Source/JavaScriptCore/dfg/DFGOSRExit.cpp: (JSC::DFG::JSC_DEFINE_JIT_OPERATION): * Source/JavaScriptCore/dfg/DFGThunks.cpp: (JSC::DFG::osrExitGenerationThunkGenerator): (JSC::DFG::osrEntryThunkGenerator): * Source/JavaScriptCore/ftl/FTLLazySlowPath.cpp: (JSC::FTL::LazySlowPath::generate): * Source/JavaScriptCore/ftl/FTLLink.cpp: (JSC::FTL::link): * Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp: (JSC::FTL::compileStub): * Source/JavaScriptCore/ftl/FTLThunks.cpp: (JSC::FTL::genericGenerationThunkGenerator): (JSC::FTL::slowPathCallThunkGenerator): * Source/JavaScriptCore/jit/ExecutableAllocator.cpp: (JSC::jitWriteThunkGenerator): * Source/JavaScriptCore/jit/JIT.cpp: (JSC::JIT::consistencyCheckGenerator): (JSC::JIT::compileAndLinkWithoutFinalizing): (JSC::JIT::link): * Source/JavaScriptCore/jit/JITMathIC.h: (JSC::JITMathIC::generateOutOfLine): * Source/JavaScriptCore/jit/JITOpcodes.cpp: (JSC::JIT::valueIsFalseyGenerator): (JSC::JIT::valueIsTruthyGenerator): (JSC::JIT::op_throw_handlerGenerator): (JSC::JIT::op_enter_handlerGenerator): (JSC::JIT::op_check_traps_handlerGenerator): * Source/JavaScriptCore/jit/JITPropertyAccess.cpp: (JSC::JIT::generateOpResolveScopeThunk): (JSC::JIT::slow_op_resolve_scopeGenerator): (JSC::JIT::generateOpGetFromScopeThunk): (JSC::JIT::slow_op_get_from_scopeGenerator): (JSC::JIT::slow_op_put_to_scopeGenerator): * Source/JavaScriptCore/jit/JITStubRoutine.h: * Source/JavaScriptCore/jit/SlowPathCall.cpp: (JSC::JITSlowPathCall::generateThunk): * Source/JavaScriptCore/jit/SpecializedThunkJIT.h: (JSC::SpecializedThunkJIT::finalize): * Source/JavaScriptCore/jit/ThunkGenerator.h: * Source/JavaScriptCore/jit/ThunkGenerators.cpp: (JSC::handleExceptionGenerator): (JSC::handleExceptionWithCallFrameRollbackGenerator): (JSC::popThunkStackPreservesAndHandleExceptionGenerator): (JSC::checkExceptionGenerator): (JSC::throwExceptionFromCallGenerator): (JSC::throwExceptionFromCallSlowPathGenerator): (JSC::virtualThunkFor): (JSC::polymorphicThunkFor): (JSC::polymorphicRepatchThunk): (JSC::nativeForGenerator): (JSC::arityFixupGenerator): (JSC::unreachableGenerator): (JSC::stringGetByValGenerator): (JSC::boundFunctionCallGenerator): (JSC::remoteFunctionCallGenerator): (JSC::returnFromBaselineGenerator): * Source/JavaScriptCore/llint/LLIntThunks.cpp: (JSC::LLInt::generateThunkWithJumpTo): (JSC::LLInt::generateThunkWithJumpToPrologue): (JSC::LLInt::generateThunkWithJumpToLLIntReturnPoint): (JSC::LLInt::inPlaceInterpreterEntryThunk): (JSC::LLInt::inPlaceInterpreterEntryThunkSIMD): (JSC::LLInt::defaultCallThunk): (JSC::LLInt::getHostCallReturnValueThunk): (JSC::LLInt::createJSGateThunk): (JSC::LLInt::createWasmGateThunk): (JSC::LLInt::createTailCallGate): (JSC::LLInt::createWasmTailCallGate): (JSC::LLInt::loopOSREntryGateThunk): (JSC::LLInt::entryOSREntryGateThunk): (JSC::LLInt::wasmOSREntryGateThunk): (JSC::LLInt::exceptionHandlerGateThunk): (JSC::LLInt::returnFromLLIntGateThunk): (JSC::LLInt::tagGateThunk): (JSC::LLInt::untagGateThunk): (JSC::LLInt::jitCagePtrThunk): * Source/JavaScriptCore/runtime/OptionsList.h: * Source/JavaScriptCore/wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::work): (JSC::Wasm::BBQPlan::compileFunction): (JSC::Wasm::BBQPlan::didCompleteCompilation): * Source/JavaScriptCore/wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * Source/JavaScriptCore/wasm/WasmIPIntPlan.cpp: (JSC::Wasm::IPIntPlan::didCompleteCompilation): * Source/JavaScriptCore/wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::didCompleteCompilation): * Source/JavaScriptCore/wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * Source/JavaScriptCore/wasm/WasmOSREntryPlan.cpp: (JSC::Wasm::OSREntryPlan::work): * Source/JavaScriptCore/wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::catchInWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGeneratorImpl): * Source/JavaScriptCore/wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadImportTypeUse): (JSC::Wasm::wasmToJS): * Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp: (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * Source/JavaScriptCore/yarr/YarrJIT.cpp: * Source/WTF/wtf/text/ASCIILiteral.h: * Source/WebCore/cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::SelectorCodeGenerator::compile): Canonical link: https://commits.webkit.org/274632@main
1 parent c0bc711 commit 499d9e1

42 files changed

Lines changed: 262 additions & 207 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/assembler/LinkBuffer.cpp‎

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "JITCode.h"
3434
#include "Options.h"
3535
#include "PerfLog.h"
36+
#include "WasmCallee.h"
3637
#include <wtf/TZoneMallocInlines.h>
3738

3839
namespace JSC {
@@ -42,31 +43,76 @@ size_t LinkBuffer::s_profileCummulativeLinkedCounts[LinkBuffer::numberOfProfiles
4243

4344
WTF_MAKE_TZONE_ALLOCATED_IMPL(LinkBuffer);
4445

45-
LinkBuffer::CodeRef<LinkBufferPtrTag> LinkBuffer::finalizeCodeWithoutDisassemblyImpl()
46+
static const char* profileName(LinkBuffer::Profile profile)
47+
{
48+
#define RETURN_LINKBUFFER_PROFILE_NAME(name) case LinkBuffer::Profile::name: return #name;
49+
switch (profile) {
50+
FOR_EACH_LINKBUFFER_PROFILE(RETURN_LINKBUFFER_PROFILE_NAME)
51+
}
52+
RELEASE_ASSERT_NOT_REACHED();
53+
#undef RETURN_LINKBUFFER_PROFILE_NAME
54+
return "";
55+
}
56+
57+
LinkBuffer::CodeRef<LinkBufferPtrTag> LinkBuffer::finalizeCodeWithoutDisassemblyImpl(ASCIILiteral simpleName)
4658
{
4759
performFinalization();
4860

4961
ASSERT(m_didAllocate);
50-
if (m_executableMemory)
51-
return CodeRef<LinkBufferPtrTag>(*m_executableMemory);
52-
53-
return CodeRef<LinkBufferPtrTag>::createSelfManagedCodeRef(m_code);
62+
CodeRef<LinkBufferPtrTag> codeRef(m_executableMemory ? CodeRef<LinkBufferPtrTag>(*m_executableMemory) : CodeRef<LinkBufferPtrTag>::createSelfManagedCodeRef(m_code));
63+
64+
if (UNLIKELY(Options::logJITCodeForPerf()))
65+
logJITCodeForPerf(codeRef, simpleName);
66+
67+
return codeRef;
5468
}
5569

56-
LinkBuffer::CodeRef<LinkBufferPtrTag> LinkBuffer::finalizeCodeWithDisassemblyImpl(bool dumpDisassembly, const char* format, ...)
70+
void LinkBuffer::logJITCodeForPerf(CodeRef<LinkBufferPtrTag>& codeRef, ASCIILiteral simpleName)
5771
{
58-
CodeRef<LinkBufferPtrTag> result = finalizeCodeWithoutDisassemblyImpl();
59-
6072
#if OS(LINUX) || OS(DARWIN)
61-
if (Options::logJITCodeForPerf()) {
62-
StringPrintStream out;
63-
va_list argList;
64-
va_start(argList, format);
65-
out.vprintf(format, argList);
66-
va_end(argList);
67-
PerfLog::log(out.toCString(), result.code().untaggedPtr<const uint8_t*>(), result.size());
73+
auto dumpSimpleName = [&](StringPrintStream& out, ASCIILiteral simpleName) {
74+
if (simpleName.isNull())
75+
out.print("unspecified");
76+
else
77+
out.print(simpleName);
78+
};
79+
80+
StringPrintStream out;
81+
out.print(profileName(m_profile), ": ");
82+
switch (m_profile) {
83+
case Profile::Baseline:
84+
case Profile::DFG:
85+
case Profile::FTL: {
86+
if (m_ownerUID)
87+
static_cast<CodeBlock*>(m_ownerUID)->dumpSimpleName(out);
88+
else
89+
dumpSimpleName(out, simpleName);
90+
break;
91+
}
92+
#if ENABLE(WEBASSEMBLY)
93+
case Profile::WasmOMG:
94+
case Profile::WasmBBQ: {
95+
if (m_ownerUID)
96+
out.print(makeString(static_cast<Wasm::Callee*>(m_ownerUID)->indexOrName()));
97+
else
98+
dumpSimpleName(out, simpleName);
99+
break;
68100
}
69101
#endif
102+
default:
103+
dumpSimpleName(out, simpleName);
104+
break;
105+
}
106+
PerfLog::log(out.toCString(), codeRef.code().untaggedPtr<const uint8_t*>(), codeRef.size());
107+
#else
108+
UNUSED_PARAM(codeRef);
109+
UNUSED_PARAM(simpleName);
110+
#endif
111+
}
112+
113+
LinkBuffer::CodeRef<LinkBufferPtrTag> LinkBuffer::finalizeCodeWithDisassemblyImpl(bool dumpDisassembly, ASCIILiteral simpleName, const char* format, ...)
114+
{
115+
CodeRef<LinkBufferPtrTag> result = finalizeCodeWithoutDisassemblyImpl(simpleName);
70116

71117
if (!dumpDisassembly && !Options::logJIT())
72118
return result;
@@ -578,19 +624,10 @@ void LinkBuffer::dumpProfileStatistics(std::optional<PrintStream*> outStream)
578624
Stat sortedStats[numberOfProfiles];
579625
PrintStream& out = outStream ? *outStream.value() : WTF::dataFile();
580626

581-
#define RETURN_LINKBUFFER_PROFILE_NAME(name) case Profile::name: return #name;
582-
auto name = [] (Profile profile) -> const char* {
583-
switch (profile) {
584-
FOR_EACH_LINKBUFFER_PROFILE(RETURN_LINKBUFFER_PROFILE_NAME)
585-
}
586-
RELEASE_ASSERT_NOT_REACHED();
587-
};
588-
#undef RETURN_LINKBUFFER_PROFILE_NAME
589-
590627
size_t totalOfAllProfilesSize = 0;
591628
auto dumpStat = [&] (const Stat& stat) {
592629
char formattedName[21];
593-
snprintf(formattedName, 21, "%20s", name(stat.profile));
630+
snprintf(formattedName, 21, "%20s", profileName(stat.profile));
594631

595632
const char* largerUnit = nullptr;
596633
double sizeInLargerUnit = stat.size;

‎Source/JavaScriptCore/assembler/LinkBuffer.h‎

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class LinkBuffer {
7878
public:
7979

8080
#define FOR_EACH_LINKBUFFER_PROFILE(v) \
81-
v(BaselineJIT) \
81+
v(Baseline) \
8282
v(DFG) \
8383
v(FTL) \
8484
v(DFGOSREntry) \
@@ -90,10 +90,6 @@ class LinkBuffer {
9090
v(LLIntThunk) \
9191
v(DFGThunk) \
9292
v(FTLThunk) \
93-
v(BoundFunctionThunk) \
94-
v(RemoteFunctionThunk) \
95-
v(SpecializedThunk) \
96-
v(VirtualThunk) \
9793
v(WasmThunk) \
9894
v(ExtraCTIThunk) \
9995
v(WasmOMG) \
@@ -115,24 +111,15 @@ class LinkBuffer {
115111
static constexpr unsigned numberOfProfilesExcludingTotal = numberOfProfiles - 1;
116112

117113
LinkBuffer(MacroAssembler& macroAssembler, void* ownerUID, Profile profile = Profile::Uncategorized, JITCompilationEffort effort = JITCompilationMustSucceed)
118-
: m_size(0)
119-
, m_didAllocate(false)
120-
#ifndef NDEBUG
121-
, m_completed(false)
122-
#endif
114+
: m_ownerUID(ownerUID)
123115
, m_profile(profile)
124116
{
125-
UNUSED_PARAM(ownerUID);
126117
linkCode(macroAssembler, effort);
127118
}
128119

129120
template<PtrTag tag>
130121
LinkBuffer(MacroAssembler& macroAssembler, CodePtr<tag> code, size_t size, Profile profile = Profile::Uncategorized, JITCompilationEffort effort = JITCompilationMustSucceed, bool shouldPerformBranchCompaction = true)
131122
: m_size(size)
132-
, m_didAllocate(false)
133-
#ifndef NDEBUG
134-
, m_completed(false)
135-
#endif
136123
, m_profile(profile)
137124
, m_code(code.template retagged<LinkBufferPtrTag>())
138125
{
@@ -302,17 +289,17 @@ class LinkBuffer {
302289
// displaying disassembly.
303290

304291
template<PtrTag tag>
305-
CodeRef<tag> finalizeCodeWithoutDisassembly()
292+
CodeRef<tag> finalizeCodeWithoutDisassembly(ASCIILiteral simpleName)
306293
{
307-
return finalizeCodeWithoutDisassemblyImpl().template retagged<tag>();
294+
return finalizeCodeWithoutDisassemblyImpl(simpleName).template retagged<tag>();
308295
}
309296

310297
template<PtrTag tag, typename... Args>
311-
CodeRef<tag> finalizeCodeWithDisassembly(bool dumpDisassembly, const char* format, Args... args)
298+
CodeRef<tag> finalizeCodeWithDisassembly(bool dumpDisassembly, ASCIILiteral simpleName, const char* format, Args... args)
312299
{
313300
ALLOW_NONLITERAL_FORMAT_BEGIN
314301
IGNORE_WARNINGS_BEGIN("format-security")
315-
return finalizeCodeWithDisassemblyImpl(dumpDisassembly, format, args...).template retagged<tag>();
302+
return finalizeCodeWithDisassemblyImpl(dumpDisassembly, simpleName, format, args...).template retagged<tag>();
316303
IGNORE_WARNINGS_END
317304
ALLOW_NONLITERAL_FORMAT_END
318305
}
@@ -345,8 +332,8 @@ ALLOW_NONLITERAL_FORMAT_END
345332
void setIsThunk() { m_isThunk = true; }
346333

347334
private:
348-
JS_EXPORT_PRIVATE CodeRef<LinkBufferPtrTag> finalizeCodeWithoutDisassemblyImpl();
349-
JS_EXPORT_PRIVATE CodeRef<LinkBufferPtrTag> finalizeCodeWithDisassemblyImpl(bool dumpDisassembly, const char* format, ...) WTF_ATTRIBUTE_PRINTF(3, 4);
335+
JS_EXPORT_PRIVATE CodeRef<LinkBufferPtrTag> finalizeCodeWithoutDisassemblyImpl(ASCIILiteral);
336+
JS_EXPORT_PRIVATE CodeRef<LinkBufferPtrTag> finalizeCodeWithDisassemblyImpl(bool dumpDisassembly, ASCIILiteral, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
350337

351338
#if ENABLE(BRANCH_COMPACTION)
352339
int executableOffsetFor(int location)
@@ -404,18 +391,21 @@ ALLOW_NONLITERAL_FORMAT_END
404391
static void dumpCode(void* code, size_t);
405392
#endif
406393

394+
void logJITCodeForPerf(CodeRef<LinkBufferPtrTag>&, ASCIILiteral);
395+
407396
RefPtr<ExecutableMemoryHandle> m_executableMemory;
408-
size_t m_size;
397+
size_t m_size { 0 };
398+
void* m_ownerUID { nullptr };
409399
#if ENABLE(BRANCH_COMPACTION)
410400
AssemblerData m_assemblerStorage;
411401
#if CPU(ARM64E)
412402
AssemblerData m_assemblerHashesStorage;
413403
#endif
414404
bool m_shouldPerformBranchCompaction { true };
415405
#endif
416-
bool m_didAllocate;
406+
bool m_didAllocate { false };
417407
#ifndef NDEBUG
418-
bool m_completed;
408+
bool m_completed { false };
419409
#endif
420410
#if ASSERT_ENABLED
421411
bool m_isJumpIsland { false };
@@ -432,13 +422,13 @@ ALLOW_NONLITERAL_FORMAT_END
432422
static size_t s_profileCummulativeLinkedCounts[numberOfProfiles];
433423
};
434424

435-
#define FINALIZE_CODE_IF(condition, linkBufferReference, resultPtrTag, ...) \
436-
(UNLIKELY((condition) || JSC::Options::logJIT() || JSC::Options::logJITCodeForPerf()) \
437-
? (linkBufferReference).finalizeCodeWithDisassembly<resultPtrTag>((condition), __VA_ARGS__) \
438-
: (linkBufferReference).finalizeCodeWithoutDisassembly<resultPtrTag>())
425+
#define FINALIZE_CODE_IF(condition, linkBufferReference, resultPtrTag, simpleName, ...) \
426+
(UNLIKELY((condition) || JSC::Options::logJIT()) \
427+
? (linkBufferReference).finalizeCodeWithDisassembly<resultPtrTag>((condition), simpleName, __VA_ARGS__) \
428+
: (linkBufferReference).finalizeCodeWithoutDisassembly<resultPtrTag>(simpleName))
439429

440-
#define FINALIZE_CODE_FOR(codeBlock, linkBufferReference, resultPtrTag, ...) \
441-
FINALIZE_CODE_IF((shouldDumpDisassemblyFor(codeBlock) || Options::asyncDisassembly()), linkBufferReference, resultPtrTag, __VA_ARGS__)
430+
#define FINALIZE_CODE_FOR(codeBlock, linkBufferReference, resultPtrTag, simpleName, ...) \
431+
FINALIZE_CODE_IF((shouldDumpDisassemblyFor(codeBlock) || Options::asyncDisassembly()), linkBufferReference, resultPtrTag, simpleName, __VA_ARGS__)
442432

443433
// Use this to finalize code, like so:
444434
//
@@ -456,20 +446,20 @@ ALLOW_NONLITERAL_FORMAT_END
456446
// Note that the format string and print arguments are only evaluated when dumpDisassembly
457447
// is true, so you can hide expensive disassembly-only computations inside there.
458448

459-
#define FINALIZE_CODE(linkBufferReference, resultPtrTag, ...) \
460-
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly()), linkBufferReference, resultPtrTag, __VA_ARGS__)
449+
#define FINALIZE_CODE(linkBufferReference, resultPtrTag, simpleName, ...) \
450+
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly()), linkBufferReference, resultPtrTag, simpleName, __VA_ARGS__)
461451

462452
#define FINALIZE_DFG_CODE(linkBufferReference, resultPtrTag, ...) \
463-
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpDFGDisassembly()), linkBufferReference, resultPtrTag, __VA_ARGS__)
453+
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpDFGDisassembly()), linkBufferReference, resultPtrTag, nullptr, __VA_ARGS__)
464454

465-
#define FINALIZE_REGEXP_CODE(linkBufferReference, resultPtrTag, dataLogFArgumentsForHeading) \
466-
FINALIZE_CODE_IF(JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpRegExpDisassembly(), linkBufferReference, resultPtrTag, dataLogFArgumentsForHeading)
455+
#define FINALIZE_REGEXP_CODE(linkBufferReference, resultPtrTag, simpleName, dataLogFArgumentsForHeading) \
456+
FINALIZE_CODE_IF(JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpRegExpDisassembly(), linkBufferReference, resultPtrTag, simpleName, dataLogFArgumentsForHeading)
467457

468-
#define FINALIZE_WASM_CODE(linkBufferReference, resultPtrTag, ...) \
469-
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpWasmDisassembly()), linkBufferReference, resultPtrTag, __VA_ARGS__)
458+
#define FINALIZE_WASM_CODE(linkBufferReference, resultPtrTag, simpleName, ...) \
459+
FINALIZE_CODE_IF((JSC::Options::asyncDisassembly() || JSC::Options::dumpDisassembly() || Options::dumpWasmDisassembly()), linkBufferReference, resultPtrTag, simpleName, __VA_ARGS__)
470460

471-
#define FINALIZE_WASM_CODE_FOR_MODE(mode, linkBufferReference, resultPtrTag, ...) \
472-
FINALIZE_CODE_IF(shouldDumpDisassemblyFor(mode), linkBufferReference, resultPtrTag, __VA_ARGS__)
461+
#define FINALIZE_WASM_CODE_FOR_MODE(mode, linkBufferReference, resultPtrTag, simpleName, ...) \
462+
FINALIZE_CODE_IF(shouldDumpDisassemblyFor(mode), linkBufferReference, resultPtrTag, simpleName, __VA_ARGS__)
473463

474464

475465

‎Source/JavaScriptCore/assembler/PerfLog.cpp‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,21 @@ static inline uint32_t getCurrentThreadID()
155155
PerfLog::PerfLog()
156156
{
157157
{
158-
std::array<char, 1024> filename;
159-
snprintf(filename.data(), filename.size() - 1, "./jit-%d.dump", getCurrentProcessID());
160-
filename[filename.size() - 1] = '\0';
161-
m_fd = open(filename.data(), O_CREAT | O_TRUNC | O_RDWR, 0666);
158+
StringPrintStream filename;
159+
if (auto* optionalDirectory = Options::jitDumpDirectory())
160+
filename.print(optionalDirectory);
161+
else
162+
filename.print("/tmp");
163+
filename.print("/jit-", getCurrentProcessID(), ".dump");
164+
m_fd = open(filename.toCString().data(), O_CREAT | O_TRUNC | O_RDWR, 0666);
162165
RELEASE_ASSERT(m_fd != -1);
163166

167+
#if OS(LINUX)
164168
// Linux perf command records this mmap operation in perf.data as a metadata to the JIT perf annotations.
165169
// We do not use this mmap-ed memory region actually.
166170
m_marker = mmap(nullptr, pageSize(), PROT_READ | PROT_EXEC, MAP_PRIVATE, m_fd, 0);
167171
RELEASE_ASSERT(m_marker != MAP_FAILED);
172+
#endif
168173

169174
m_file = fdopen(m_fd, "wb");
170175
RELEASE_ASSERT(m_file);

‎Source/JavaScriptCore/assembler/testmasm.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ MacroAssemblerCodeRef<JSEntryPtrTag> compile(Generator&& generate)
262262
CCallHelpers jit;
263263
generate(jit);
264264
LinkBuffer linkBuffer(jit, nullptr);
265-
return FINALIZE_CODE(linkBuffer, JSEntryPtrTag, "testmasm compilation");
265+
return FINALIZE_CODE(linkBuffer, JSEntryPtrTag, nullptr, "testmasm compilation");
266266
}
267267

268268
template<typename T, typename... Arguments>

‎Source/JavaScriptCore/b3/B3Compile.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Compilation compile(Procedure& proc)
4646
generate(proc, jit);
4747
LinkBuffer linkBuffer(jit, nullptr);
4848

49-
return Compilation(FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "Compilation"), proc.releaseByproducts());
49+
return Compilation(FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "Compilation"), proc.releaseByproducts());
5050
}
5151

5252
} } // namespace JSC::B3

‎Source/JavaScriptCore/b3/air/testair.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ std::unique_ptr<Compilation> compile(B3::Procedure& proc)
9797
LinkBuffer linkBuffer(jit, nullptr);
9898

9999
return makeUnique<Compilation>(
100-
FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testair compilation"), proc.releaseByproducts());
100+
FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testair compilation"), proc.releaseByproducts());
101101
}
102102

103103
template<typename T, typename... Arguments>

‎Source/JavaScriptCore/b3/testb3_6.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ void testEntrySwitchSimple()
19441944
CodeLocationLabel<JITCompilationPtrTag> labelTwo = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(1));
19451945
CodeLocationLabel<JITCompilationPtrTag> labelThree = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(2));
19461946

1947-
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testb3 compilation");
1947+
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testb3 compilation");
19481948

19491949
CHECK(invoke<int>(labelOne, 1, 2) == 3);
19501950
CHECK(invoke<int>(labelTwo, 1, 2) == -1);
@@ -1977,7 +1977,7 @@ void testEntrySwitchNoEntrySwitch()
19771977
CodeLocationLabel<JITCompilationPtrTag> labelTwo = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(1));
19781978
CodeLocationLabel<JITCompilationPtrTag> labelThree = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(2));
19791979

1980-
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testb3 compilation");
1980+
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testb3 compilation");
19811981

19821982
CHECK_EQ(invoke<int>(labelOne, 1, 2), 3);
19831983
CHECK_EQ(invoke<int>(labelTwo, 1, 2), 3);
@@ -2064,7 +2064,7 @@ void testEntrySwitchWithCommonPaths()
20642064
CodeLocationLabel<JITCompilationPtrTag> labelTwo = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(1));
20652065
CodeLocationLabel<JITCompilationPtrTag> labelThree = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(2));
20662066

2067-
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testb3 compilation");
2067+
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testb3 compilation");
20682068

20692069
CHECK_EQ(invoke<int>(labelOne, 1, 2, 10), 3);
20702070
CHECK_EQ(invoke<int>(labelTwo, 1, 2, 10), -1);
@@ -2181,7 +2181,7 @@ void testEntrySwitchWithCommonPathsAndNonTrivialEntrypoint()
21812181
CodeLocationLabel<JITCompilationPtrTag> labelTwo = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(1));
21822182
CodeLocationLabel<JITCompilationPtrTag> labelThree = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(2));
21832183

2184-
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testb3 compilation");
2184+
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testb3 compilation");
21852185

21862186
CHECK_EQ(invoke<int>(labelOne, 1, 2, 10, false), 3);
21872187
CHECK_EQ(invoke<int>(labelTwo, 1, 2, 10, false), -1);
@@ -2258,7 +2258,7 @@ void testEntrySwitchLoop()
22582258
CodeLocationLabel<JITCompilationPtrTag> labelOne = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(0));
22592259
CodeLocationLabel<JITCompilationPtrTag> labelTwo = linkBuffer.locationOf<JITCompilationPtrTag>(proc.code().entrypointLabel(1));
22602260

2261-
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "testb3 compilation");
2261+
MacroAssemblerCodeRef<JITCompilationPtrTag> codeRef = FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, nullptr, "testb3 compilation");
22622262

22632263
CHECK(invoke<int>(labelOne, 0) == 1);
22642264
CHECK(invoke<int>(labelOne, 42) == 43);

‎Source/JavaScriptCore/bytecode/CodeBlock.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ void CodeBlock::dump(PrintStream& out) const
196196
dumpAssumingJITType(out, jitType());
197197
}
198198

199+
void CodeBlock::dumpSimpleName(PrintStream& out) const
200+
{
201+
out.print(inferredName(), "#", hashAsStringIfPossible());
202+
}
203+
199204
void CodeBlock::dumpSource()
200205
{
201206
dumpSource(WTF::dataFile());

‎Source/JavaScriptCore/bytecode/CodeBlock.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class CodeBlock : public JSCell {
152152
void dumpAssumingJITType(PrintStream&, JITType) const;
153153
JS_EXPORT_PRIVATE void dump(PrintStream&) const;
154154

155+
void dumpSimpleName(PrintStream&) const;
156+
155157
MetadataTable* metadataTable() const { return m_metadata.get(); }
156158

157159
unsigned numParameters() const { return m_numParameters; }

0 commit comments

Comments
 (0)