Skip to content

Commit

Permalink
Bug 1847469 - Part 11: Use column number types in JSScript. r=iain
Browse files Browse the repository at this point in the history
  • Loading branch information
arai-a committed Aug 16, 2023
1 parent 4dd112d commit d8f4eed
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 81 deletions.
2 changes: 1 addition & 1 deletion js/src/debugger/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ bool DebuggerScript::CallData::getStartLine() {

bool DebuggerScript::CallData::getStartColumn() {
args.rval().setNumber(referent.get().match(
[](BaseScript*& s) { return s->column(); },
[](BaseScript*& s) { return s->column().zeroOriginValue(); },
[](WasmInstanceObject*&) {
return JS::WasmFunctionIndex::DefaultBinarySourceColumnNumberZeroOrigin;
}));
Expand Down
2 changes: 1 addition & 1 deletion js/src/frontend/BytecodeCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ static bool DelazifyCanonicalScriptedFunctionImpl(JSContext* cx,
JS::CompileOptions options(cx);
options.setMutedErrors(lazy->mutedErrors())
.setFileAndLine(lazy->filename(), lazy->lineno())
.setColumn(lazy->column())
.setColumn(lazy->column().zeroOriginValue())
.setScriptSourceOffset(lazy->sourceStart())
.setNoScriptRval(false)
.setSelfHostingMode(false)
Expand Down
21 changes: 12 additions & 9 deletions js/src/jit/BaselineBailouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ bool BaselineStackBuilder::initFrame() {
}

JitSpew(JitSpew_BaselineBailouts, " Unpacking %s:%u:%u",
script_->filename(), script_->lineno(), script_->column());
script_->filename(), script_->lineno(),
script_->column().zeroOriginValue());
JitSpew(JitSpew_BaselineBailouts, " [BASELINE-JS FRAME]");

// Write the previous frame pointer value. For the outermost frame we reuse
Expand Down Expand Up @@ -1494,7 +1495,7 @@ bool BaselineStackBuilder::buildOneFrame() {
" Resuming %s pc offset %d (op %s) (line %u) of %s:%u:%u",
resumeAfter() ? "after" : "at", (int)pcOff, CodeName(op_),
PCToLineNumber(script_, pc()), script_->filename(), script_->lineno(),
script_->column());
script_->column().zeroOriginValue());
JitSpew(JitSpew_BaselineBailouts, " Bailout kind: %s",
BailoutKindString(bailoutKind()));
#endif
Expand Down Expand Up @@ -1580,7 +1581,8 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation,
JitSpew(JitSpew_BaselineBailouts,
"Bailing to baseline %s:%u:%u (IonScript=%p) (FrameType=%d)",
iter.script()->filename(), iter.script()->lineno(),
iter.script()->column(), (void*)iter.ionScript(), (int)prevFrameType);
iter.script()->column().zeroOriginValue(), (void*)iter.ionScript(),
(int)prevFrameType);

if (excInfo) {
if (excInfo->catchingException()) {
Expand Down Expand Up @@ -1625,7 +1627,7 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation,
if (iter.maybeCallee()) {
JitSpew(JitSpew_BaselineBailouts, " Callee function (%s:%u:%u)",
iter.script()->filename(), iter.script()->lineno(),
iter.script()->column());
iter.script()->column().zeroOriginValue());
} else {
JitSpew(JitSpew_BaselineBailouts, " No callee!");
}
Expand Down Expand Up @@ -1729,9 +1731,9 @@ static void HandleLexicalCheckFailure(JSContext* cx, HandleScript outerScript,
HandleScript innerScript) {
JitSpew(JitSpew_IonBailouts,
"Lexical check failure %s:%u:%u, inlined into %s:%u:%u",
innerScript->filename(), innerScript->lineno(), innerScript->column(),
outerScript->filename(), outerScript->lineno(),
outerScript->column());
innerScript->filename(), innerScript->lineno(),
innerScript->column().zeroOriginValue(), outerScript->filename(),
outerScript->lineno(), outerScript->column().zeroOriginValue());

if (!innerScript->failedLexicalCheck()) {
innerScript->setFailedLexicalCheck();
Expand Down Expand Up @@ -1958,9 +1960,10 @@ bool jit::FinishBailoutToBaseline(BaselineBailoutInfo* bailoutInfoArg) {
JitSpew(JitSpew_BaselineBailouts,
" Restored outerScript=(%s:%u:%u,%u) innerScript=(%s:%u:%u,%u) "
"(bailoutKind=%u)",
outerScript->filename(), outerScript->lineno(), outerScript->column(),
outerScript->filename(), outerScript->lineno(),
outerScript->column().zeroOriginValue(),
outerScript->getWarmUpCount(), innerScript->filename(),
innerScript->lineno(), innerScript->column(),
innerScript->lineno(), innerScript->column().zeroOriginValue(),
innerScript->getWarmUpCount(), (unsigned)bailoutKind);

BailoutAction action = BailoutAction::InvalidateImmediately;
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit/BaselineCacheIRCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2573,7 +2573,7 @@ ICAttachResult js::jit::AttachBaselineCacheIRStub(
JitSpew(JitSpew_BaselineICFallback,
"Tried attaching identical stub for (%s:%u:%u)",
outerScript->filename(), outerScript->lineno(),
outerScript->column());
outerScript->column().zeroOriginValue());
return ICAttachResult::DuplicateStub;
}

Expand Down
12 changes: 7 additions & 5 deletions js/src/jit/BaselineCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ MethodStatus BaselineCompiler::compile() {

Rooted<JSScript*> script(cx, handler.script());
JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%u:%u (%p)",
script->filename(), script->lineno(), script->column(), script.get());
script->filename(), script->lineno(),
script->column().zeroOriginValue(), script.get());

JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%u:%u",
script->filename(), script->lineno(), script->column());
script->filename(), script->lineno(),
script->column().zeroOriginValue());

AutoIncrementalTimer timer(cx->realm()->timers.baselineCompileTime);

Expand Down Expand Up @@ -285,7 +287,7 @@ MethodStatus BaselineCompiler::compile() {
JitSpew(JitSpew_BaselineScripts,
"Created BaselineScript %p (raw %p) for %s:%u:%u",
(void*)baselineScript.get(), (void*)code->raw(), script->filename(),
script->lineno(), script->column());
script->lineno(), script->column().zeroOriginValue());

baselineScript->copyRetAddrEntries(handler.retAddrEntries().begin());
baselineScript->copyOSREntries(handler.osrEntries().begin());
Expand All @@ -310,8 +312,8 @@ MethodStatus BaselineCompiler::compile() {
{
JitSpew(JitSpew_Profiling,
"Added JitcodeGlobalEntry for baseline script %s:%u:%u (%p)",
script->filename(), script->lineno(), script->column(),
baselineScript.get());
script->filename(), script->lineno(),
script->column().zeroOriginValue(), baselineScript.get());

// Generate profiling string.
UniqueChars str = GeckoProfilerRuntime::allocProfileString(cx, script);
Expand Down
5 changes: 3 additions & 2 deletions js/src/jit/BaselineDebugModeOSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static void SpewPatchBaselineFrame(const uint8_t* oldReturnAddress,
JitSpew(JitSpew_BaselineDebugModeOSR,
"Patch return %p -> %p on BaselineJS frame (%s:%u:%u) from %s at %s",
oldReturnAddress, newReturnAddress, script->filename(),
script->lineno(), script->column(),
script->lineno(), script->column().zeroOriginValue(),
RetAddrEntryKindToString(frameKind), CodeName(JSOp(*pc)));
}

Expand Down Expand Up @@ -411,7 +411,8 @@ static bool RecompileBaselineScriptForDebugMode(
}

JitSpew(JitSpew_BaselineDebugModeOSR, "Recompiling (%s:%u:%u) for %s",
script->filename(), script->lineno(), script->column(),
script->filename(), script->lineno(),
script->column().zeroOriginValue(),
observing ? "DEBUGGING" : "NORMAL EXECUTION");

AutoKeepJitScripts keepJitScripts(cx);
Expand Down
7 changes: 4 additions & 3 deletions js/src/jit/BaselineIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...) {
JitSpew(
JitSpew_BaselineICFallback,
"Fallback hit for (%s:%u:%u) (pc=%zu,line=%u,uses=%u,stubs=%zu): %s",
script->filename(), script->lineno(), script->column(),
script->pcToOffset(pc), PCToLineNumber(script, pc),
script->getWarmUpCount(), stub->numOptimizedStubs(), fmtbuf);
script->filename(), script->lineno(),
script->column().zeroOriginValue(), script->pcToOffset(pc),
PCToLineNumber(script, pc), script->getWarmUpCount(),
stub->numOptimizedStubs(), fmtbuf);
}
}
#endif // JS_JITSPEW
Expand Down
7 changes: 4 additions & 3 deletions js/src/jit/BytecodeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ bool BytecodeAnalysis::init(TempAllocator& alloc) {
JitSpew(
JitSpew_IonAbort,
"Disabling Warp support for %s:%d:%d due to Yield being in a loop",
script_->filename(), script_->lineno(), script_->column());
script_->filename(), script_->lineno(),
script_->column().zeroOriginValue());
script_->disableIon();
}
}
Expand All @@ -335,8 +336,8 @@ void BytecodeAnalysis::checkWarpSupport(JSOp op) {
#undef DEF_CASE
if (script_->canIonCompile()) {
JitSpew(JitSpew_IonAbort, "Disabling Warp support for %s:%d:%d due to %s",
script_->filename(), script_->lineno(), script_->column(),
CodeName(op));
script_->filename(), script_->lineno(),
script_->column().zeroOriginValue(), CodeName(op));
script_->disableIon();
}
break;
Expand Down
5 changes: 3 additions & 2 deletions js/src/jit/CacheIRHealth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ void CacheIRHealth::spewShapeInformation(AutoStructuredSpewer& spew,
{
spew->property("filename", baseScript->filename());
spew->property("line", baseScript->lineno());
spew->property("column", baseScript->column());
spew->property("column",
baseScript->column().zeroOriginValue());
}
spew->endObject();
}
Expand Down Expand Up @@ -305,7 +306,7 @@ void CacheIRHealth::spewScriptFinalWarmUpCount(JSContext* cx,

spew->property("filename", filename);
spew->property("line", script->lineno());
spew->property("column", script->column());
spew->property("column", script->column().zeroOriginValue());
spew->property("finalWarmUpCount", warmUpCount);
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/jit/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14102,7 +14102,7 @@ bool CodeGenerator::generate() {
JitSpew(JitSpew_Codegen, "# Emitting code for script %s:%u:%u",
gen->outerInfo().script()->filename(),
gen->outerInfo().script()->lineno(),
gen->outerInfo().script()->column());
gen->outerInfo().script()->column().zeroOriginValue());

// Initialize native code table with an entry to the start of
// top-level script.
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit/InterpreterEntryTrampoline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ JitCode* JitRuntime::generateEntryTrampolineForScript(JSContext* cx,
JitSpew(JitSpew_Codegen,
"# Emitting Interpreter Entry Trampoline for %s (%s:%u:%u)",
funName ? funName.get() : "*", script->filename(), script->lineno(),
script->column());
script->column().zeroOriginValue());
}

TempAllocator temp(&cx->tempLifoAlloc());
Expand Down
26 changes: 15 additions & 11 deletions js/src/jit/Ion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,8 @@ static AbortReason IonCompile(JSContext* cx, HandleScript script,
JitSpew(JitSpew_IonSyncLogs,
"Can't log script %s:%u:%u"
". (Compiled on background thread.)",
script->filename(), script->lineno(), script->column());
script->filename(), script->lineno(),
script->column().zeroOriginValue());

IonCompileTask* task = alloc->new_<IonCompileTask>(cx, *mirGen, snapshot);
if (!task) {
Expand Down Expand Up @@ -1786,7 +1787,7 @@ static bool ScriptIsTooLarge(JSContext* cx, JSScript* script) {
JitSpew(JitSpew_IonAbort,
"Script too large (%zu bytes) (%zu locals/args) @ %s:%u:%u",
script->length(), numLocalsAndArgs, script->filename(),
script->lineno(), script->column());
script->lineno(), script->column().zeroOriginValue());
return true;
}

Expand Down Expand Up @@ -1831,7 +1832,8 @@ static MethodStatus Compile(JSContext* cx, HandleScript script,

if (!CanIonCompileScript(cx, script)) {
JitSpew(JitSpew_IonAbort, "Aborted compilation of %s:%u:%u",
script->filename(), script->lineno(), script->column());
script->filename(), script->lineno(),
script->column().zeroOriginValue());
return Method_CantCompile;
}

Expand Down Expand Up @@ -2096,8 +2098,9 @@ static bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame,
JitSpew(JitSpew_BaselineOSR,
"WarmUpCounter for %s:%u:%u reached %d at pc %p, trying to switch to "
"Ion!",
script->filename(), script->lineno(), script->column(),
(int)script->getWarmUpCount(), (void*)pc);
script->filename(), script->lineno(),
script->column().zeroOriginValue(), (int)script->getWarmUpCount(),
(void*)pc);

MethodStatus stat;
if (isLoopHead) {
Expand Down Expand Up @@ -2291,8 +2294,8 @@ static void InvalidateActivation(JS::GCContext* gcx,
JitSpew(JitSpew_IonInvalidate,
"#%zu %s JS frame @ %p, %s:%u:%u (fun: %p, script: %p, pc %p)",
frameno, type, frame.fp(), script->maybeForwardedFilename(),
script->lineno(), script->column(), frame.maybeCallee(), script,
frame.resumePCinCurrentFrame());
script->lineno(), script->column().zeroOriginValue(),
frame.maybeCallee(), script, frame.resumePCinCurrentFrame());
break;
}
case FrameType::BaselineStub:
Expand Down Expand Up @@ -2466,7 +2469,7 @@ void jit::Invalidate(JSContext* cx, const RecompileInfoVector& invalid,

JitSpew(JitSpew_IonInvalidate, " Invalidate %s:%u:%u, IonScript %p",
info.script()->filename(), info.script()->lineno(),
info.script()->column(), ionScript);
info.script()->column().zeroOriginValue(), ionScript);

// Keep the ion script alive during the invalidation and flag this
// ionScript as being invalidated. This increment is removed by the
Expand Down Expand Up @@ -2552,8 +2555,8 @@ void jit::Invalidate(JSContext* cx, JSScript* script, bool resetUses,
}

// Construct the descriptive string.
UniqueChars buf =
JS_smprintf("%s:%u:%u", filename, script->lineno(), script->column());
UniqueChars buf = JS_smprintf("%s:%u:%u", filename, script->lineno(),
script->column().zeroOriginValue());

// Ignore the event on allocation failure.
if (buf) {
Expand Down Expand Up @@ -2587,7 +2590,8 @@ void jit::FinishInvalidation(JS::GCContext* gcx, JSScript* script) {

void jit::ForbidCompilation(JSContext* cx, JSScript* script) {
JitSpew(JitSpew_IonAbort, "Disabling Ion compilation of script %s:%u:%u",
script->filename(), script->lineno(), script->column());
script->filename(), script->lineno(),
script->column().zeroOriginValue());

CancelOffThreadIonCompile(script);

Expand Down
4 changes: 2 additions & 2 deletions js/src/jit/JitcodeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,15 +1007,15 @@ bool JitcodeIonTable::WriteIonTable(CompactBufferWriter& writer,
JitSpew(JitSpew_Profiling,
"Writing native to bytecode map for %s:%u:%u (%zu entries)",
scriptList[0].script->filename(), scriptList[0].script->lineno(),
scriptList[0].script->column(),
scriptList[0].script->column().zeroOriginValue(),
mozilla::PointerRangeSize(start, end));

JitSpew(JitSpew_Profiling, " ScriptList of size %u",
unsigned(scriptList.length()));
for (uint32_t i = 0; i < scriptList.length(); i++) {
JitSpew(JitSpew_Profiling, " Script %u - %s:%u:%u", i,
scriptList[i].script->filename(), scriptList[i].script->lineno(),
scriptList[i].script->column());
scriptList[i].script->column().zeroOriginValue());
}

// Write out runs first. Keep a vector tracking the positive offsets from
Expand Down
Loading

0 comments on commit d8f4eed

Please sign in to comment.