Bug 1853438: Emit DEBUG_INFO records for the pc used by an IonIC r=iain

Differential Revision: https://phabricator.services.mozilla.com/D188401
This commit is contained in:
Denis Palmeiro 2023-09-22 13:59:46 +00:00
Родитель 39fa88ba42
Коммит 9c5ba26ca8
3 изменённых файлов: 74 добавлений и 14 удалений

Просмотреть файл

@ -54,7 +54,8 @@ IonCacheIRCompiler::IonCacheIRCompiler(JSContext* cx, TempAllocator& alloc,
ic_(ic),
ionScript_(ionScript),
savedLiveRegs_(false),
localTracingSlots_(0) {
localTracingSlots_(0),
perfSpewer_(ic->pc()) {
MOZ_ASSERT(ic_);
MOZ_ASSERT(ionScript_);
}

Просмотреть файл

@ -1019,13 +1019,63 @@ void PerfSpewer::saveProfile(JitCode* code, UniqueChars& desc,
CollectJitCodeInfo(desc, code, profilerRecord, lock);
}
IonICPerfSpewer::IonICPerfSpewer(jsbytecode* pc) {
if (!opcodes_.emplaceBack(pc)) {
AutoLockPerfSpewer lock;
opcodes_.clear();
DisablePerfSpewer(lock);
}
}
void IonICPerfSpewer::saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* profilerRecord,
AutoLockPerfSpewer& lock) {
#ifdef JS_ION_PERF
MOZ_ASSERT(opcodes_.length() == 1);
jsbytecode* pc = opcodes_[0].bytecodepc;
if (!pc) {
return;
}
const char* filename = script->filename();
if (!filename) {
return;
}
if (!IsPerfProfiling() || !FileExists(filename)) {
return;
}
JitDumpDebugRecord debug_record = {};
uint64_t n_records = 1;
debug_record.header.id = JIT_CODE_DEBUG_INFO;
debug_record.header.total_size =
sizeof(debug_record) +
n_records * (sizeof(JitDumpDebugEntry) + strlen(filename) + 1);
debug_record.header.timestamp = GetMonotonicTimestamp();
debug_record.code_addr = uint64_t(code->raw());
debug_record.nr_entry = n_records;
WriteToJitDumpFile(&debug_record, sizeof(debug_record), lock);
uint32_t lineno;
JS::LimitedColumnNumberZeroOrigin colno;
lineno = PCToLineNumber(script, pc, &colno);
WriteJitDumpDebugEntry(uint64_t(code->raw()), filename, lineno, colno, lock);
#endif
}
void IonICPerfSpewer::saveProfile(JSContext* cx, JSScript* script,
JitCode* code, const char* stubName) {
if (!PerfEnabled()) {
return;
}
UniqueChars desc = GetFunctionDesc("IonIC", cx, script, stubName);
PerfSpewer::saveProfile(code, desc, nullptr);
PerfSpewer::saveProfile(code, desc, script);
}
void BaselineICPerfSpewer::saveProfile(JitCode* code, const char* stubName) {

Просмотреть файл

@ -46,22 +46,25 @@ class PerfSpewer {
// Prologue/Epilogue, or to add operand info.
UniqueChars str;
OpcodeEntry(uint32_t offset_, unsigned opcode_, UniqueChars& str_,
jsbytecode* pc)
explicit OpcodeEntry(uint32_t offset_, unsigned opcode_, UniqueChars& str_,
jsbytecode* pc)
: offset(offset_), opcode(opcode_), bytecodepc(pc) {
str = std::move(str_);
}
OpcodeEntry(uint32_t offset_, unsigned opcode_, UniqueChars& str_)
explicit OpcodeEntry(uint32_t offset_, unsigned opcode_, UniqueChars& str_)
: offset(offset_), opcode(opcode_) {
str = std::move(str_);
}
OpcodeEntry(uint32_t offset_, UniqueChars& str_) : offset(offset_) {
explicit OpcodeEntry(uint32_t offset_, UniqueChars& str_)
: offset(offset_) {
str = std::move(str_);
}
OpcodeEntry(uint32_t offset_, unsigned opcode_)
explicit OpcodeEntry(uint32_t offset_, unsigned opcode_)
: offset(offset_), opcode(opcode_) {}
explicit OpcodeEntry(jsbytecode* pc) : bytecodepc(pc) {}
OpcodeEntry(OpcodeEntry&& copy) {
offset = copy.offset;
opcode = copy.opcode;
@ -165,24 +168,30 @@ class InlineCachePerfSpewer : public PerfSpewer {
JS::JitTier GetTier() override { return JS::JitTier::IC; }
const char* CodeName(unsigned op) override;
void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override {
// IC stubs have no source code to reference.
return;
}
public:
void recordInstruction(MacroAssembler& masm, CacheOp op);
};
class BaselineICPerfSpewer : public InlineCachePerfSpewer {
void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override {
// Baseline IC stubs are shared and have no source code to reference.
return;
}
public:
void saveProfile(JitCode* code, const char* stubName);
};
class IonICPerfSpewer : public InlineCachePerfSpewer {
public:
explicit IonICPerfSpewer(jsbytecode* pc);
void saveJitCodeSourceInfo(JSScript* script, JitCode* code,
JS::JitCodeRecord* record,
AutoLockPerfSpewer& lock) override;
void saveProfile(JSContext* cx, JSScript* script, JitCode* code,
const char* stubName);
};