Skip to content

Commit

Permalink
Backed out changeset a3d7dc555a4b (bug 1821688) for causing bustages …
Browse files Browse the repository at this point in the history
…on PerfSpewer.h. CLOSED TREE
  • Loading branch information
Marian-Vasile Laza committed Mar 10, 2023
1 parent 2981ee6 commit 3a959c6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 85 deletions.
8 changes: 3 additions & 5 deletions js/src/jit/IonCacheIRCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ JitCode* IonCacheIRCompiler::compile(IonICStub* stub) {
return nullptr;
}

CacheKind stubKind = stub->stubInfo()->kind();
perfSpewer_.saveProfile(newStubCode, CacheKindNames[uint8_t(stubKind)]);

for (CodeOffset offset : nextCodeOffsets_) {
Assembler::PatchDataWithValueCheck(CodeLocationLabel(newStubCode, offset),
ImmPtr(stub->nextCodeRawPtr()),
Expand Down Expand Up @@ -1813,11 +1816,6 @@ void IonIC::attachCacheIRStub(JSContext* cx, const CacheIRWriter& writer,
return;
}

// Record the stub code if perf spewer is enabled.
CacheKind stubKind = newStub->stubInfo()->kind();
compiler.perfSpewer().saveProfile(cx, script(), code,
CacheKindNames[uint8_t(stubKind)]);

// Add an entry to the profiler's code table, so that the profiler can
// identify this as Ion code.
if (ionScript->hasProfilingInstrumentation()) {
Expand Down
87 changes: 39 additions & 48 deletions js/src/jit/PerfSpewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ void PerfSpewer::recordOffset(MacroAssembler& masm, const char* msg) {
}
}

void PerfSpewer::saveJitCodeIRInfo(JitCode* code,
void PerfSpewer::saveJitCodeIRInfo(const char* desc, JitCode* code,
JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock) {
#ifdef JS_ION_PERF
Expand Down Expand Up @@ -766,7 +766,9 @@ void PerfSpewer::saveJitCodeIRInfo(JitCode* code,
opcodes_.clear();

#ifdef JS_ION_PERF
if (IsPerfProfiling()) {
if (desc && IsPerfProfiling()) {
// Add the desc as the last line in the file so as to not confuse objdump
fprintf(scriptFile, "%s\n", desc);
fclose(scriptFile);
}
#endif
Expand Down Expand Up @@ -925,80 +927,69 @@ void IonPerfSpewer::saveJitCodeSourceInfo(JSScript* script, JitCode* code,
}
}

static UniqueChars GetFunctionDesc(const char* tierName, JSContext* cx,
JSScript* script,
const char* stubName = nullptr) {
MOZ_ASSERT(script && tierName && cx);
static UniqueChars GetFunctionDesc(bool ion, JSContext* cx, JSScript* script) {
UniqueChars funName;
if (script->function() && script->function()->displayAtom()) {
funName = AtomToPrintableString(cx, script->function()->displayAtom());
}

if (stubName) {
return JS_smprintf("%s: %s : %s (%s:%u:%u)", tierName, stubName,
funName ? funName.get() : "*", script->filename(),
script->lineno(), script->column());
}
return JS_smprintf("%s: %s (%s:%u:%u)", tierName,
return JS_smprintf("%s: %s (%s:%u:%u)", ion ? "Ion" : "Baseline",
funName ? funName.get() : "*", script->filename(),
script->lineno(), script->column());
}

void PerfSpewer::saveDebugInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock) {
MOZ_ASSERT(code);
if (PerfIREnabled()) {
saveJitCodeIRInfo(code, profilerRecord, lock);
} else if (PerfSrcEnabled() && script) {
saveJitCodeSourceInfo(script, code, profilerRecord, lock);
void IonPerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code) {
if (!PerfEnabled()) {
return;
}
}

void PerfSpewer::saveProfile(JitCode* code, UniqueChars& desc,
JSScript* script) {
MOZ_ASSERT(PerfEnabled());
MOZ_ASSERT(code && desc);
AutoLockPerfSpewer lock;

JS::JitCodeRecord* profilerRecord = CreateProfilerEntry(lock);

saveDebugInfo(script, code, profilerRecord, lock);
UniqueChars desc = GetFunctionDesc(/*ion = */ true, cx, script);
if (PerfIREnabled()) {
saveJitCodeIRInfo(desc.get(), code, profilerRecord, lock);
} else if (PerfSrcEnabled()) {
saveJitCodeSourceInfo(script, code, profilerRecord, lock);
}

CollectJitCodeInfo(desc, code, profilerRecord, lock);
}

void IonICPerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code, const char* stubName) {
void BaselinePerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code) {
if (!PerfEnabled()) {
return;
}
UniqueChars desc = GetFunctionDesc("IonIC", cx, script, stubName);
PerfSpewer::saveProfile(code, desc, nullptr);
}
AutoLockPerfSpewer lock;

void BaselineICPerfSpewer::saveProfile(JitCode* code, const char* stubName) {
if (!PerfEnabled()) {
return;
JS::JitCodeRecord* profilerRecord = CreateProfilerEntry(lock);

UniqueChars desc = GetFunctionDesc(/*ion = */ false, cx, script);
if (PerfIREnabled()) {
saveJitCodeIRInfo(desc.get(), code, profilerRecord, lock);
} else if (PerfSrcEnabled()) {
saveJitCodeSourceInfo(script, code, profilerRecord, lock);
}
UniqueChars desc = JS_smprintf("BaselineIC: %s", stubName);
PerfSpewer::saveProfile(code, desc, nullptr);

CollectJitCodeInfo(desc, code, profilerRecord, lock);
}

void BaselinePerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code) {
void InlineCachePerfSpewer::saveProfile(JitCode* code, const char* icname) {
if (!PerfEnabled()) {
return;
}
UniqueChars desc = GetFunctionDesc("Baseline", cx, script);
PerfSpewer::saveProfile(code, desc, script);
}
AutoLockPerfSpewer lock;

void IonPerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code) {
if (!PerfEnabled()) {
return;
JS::JitCodeRecord* profilerRecord = CreateProfilerEntry(lock);

UniqueChars desc = JS_smprintf("%s: %s", TierName(), icname);
if (PerfIREnabled()) {
saveJitCodeIRInfo(desc.get(), code, profilerRecord, lock);
}
UniqueChars desc = GetFunctionDesc("Ion", cx, script);
PerfSpewer::saveProfile(code, desc, script);

CollectJitCodeInfo(desc, code, profilerRecord, lock);
}

void js::jit::CollectPerfSpewerJitCodeProfile(JitCode* code, const char* msg) {
Expand Down
47 changes: 15 additions & 32 deletions js/src/jit/PerfSpewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,16 @@ class PerfSpewer {

virtual const char* CodeName(unsigned op) = 0;

void saveDebugInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock);

void saveProfile(JitCode* code, UniqueChars& desc, JSScript* script);

void saveJitCodeIRInfo(JitCode* code, JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock);

virtual void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) = 0;

public:
PerfSpewer() = default;

static void Init();

void recordOffset(MacroAssembler& masm, const char*);

static void Init();
void saveJitCodeIRInfo(const char* desc, JitCode* code,
JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock);

static void CollectJitCodeInfo(UniqueChars& function_name, JitCode* code,
JS::JitCodeRecord*, AutoLockPerfSpewer& lock);
Expand Down Expand Up @@ -126,9 +117,9 @@ class IonPerfSpewer : public PerfSpewer {
void recordInstruction(MacroAssembler& masm, LInstruction* ins);
void saveProfile(JSContext* cx, JSScript* script, JitCode* code);

virtual void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override;
void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock);
};

class BaselinePerfSpewer : public PerfSpewer {
Expand All @@ -140,35 +131,27 @@ class BaselinePerfSpewer : public PerfSpewer {
CompilerFrameInfo& frame);
void saveProfile(JSContext* cx, JSScript* script, JitCode* code);

virtual void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override;
void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock);
};

class InlineCachePerfSpewer : public PerfSpewer {
JS::JitTier GetTier() override { return JS::JitTier::IC; }
virtual const char* CodeName(unsigned op) override;
virtual const char* TierName() = 0;

public:
void recordInstruction(MacroAssembler& masm, CacheOp op);

virtual void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override {
// IC stubs have no source code to reference.
return;
}
void saveProfile(JitCode* code, const char* name);
};

class BaselineICPerfSpewer : public InlineCachePerfSpewer {
public:
void saveProfile(JitCode* code, const char* stubName);
virtual const char* TierName() override { return "BaselineIC"; }
};

class IonICPerfSpewer : public InlineCachePerfSpewer {
public:
void saveProfile(JSContext* cx, JSScript* script, JitCode* code,
const char* stubName);
virtual const char* TierName() override { return "IonIC"; }
};

class PerfSpewerRangeRecorder {
Expand Down

0 comments on commit 3a959c6

Please sign in to comment.