mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1839396 part 16.0 - Add JSContext* argument to Sprinter::putString. r=mgaudet
`putString` requires a JSContext, and it is taken out of Sprinter, which does not make much sense. Making it explicit that a JSContext is required to print JSString would make things simpler for users instead of failing during the execution. Differential Revision: https://phabricator.services.mozilla.com/D187202
This commit is contained in:
parent
da63680af6
commit
a69f5a1ceb
@ -143,7 +143,7 @@ class JS_PUBLIC_API Sprinter final : public GenericPrinter {
|
||||
}
|
||||
virtual size_t index() const override { return length(); }
|
||||
|
||||
void putString(JSString* str);
|
||||
void putString(JSContext* cx, JSString* str);
|
||||
|
||||
size_t length() const;
|
||||
|
||||
|
@ -1714,7 +1714,7 @@ static bool DisassembleNative(JSContext* cx, unsigned argc, Value* vp) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
sprinter.putString(sresult);
|
||||
sprinter.putString(cx, sresult);
|
||||
|
||||
if (args.length() > 1 && args[1].isString()) {
|
||||
RootedString str(cx, args[1].toString());
|
||||
|
@ -457,12 +457,12 @@ UniqueChars LAllocation::toString() const {
|
||||
break;
|
||||
case MIRType::String:
|
||||
// If a JSContext is a available, output the actual string
|
||||
if (JSContext* maybeCx = TlsContext.get()) {
|
||||
Sprinter spr(maybeCx);
|
||||
if (JSContext* cx = TlsContext.get()) {
|
||||
Sprinter spr(cx);
|
||||
if (!spr.init()) {
|
||||
oomUnsafe.crash("LAllocation::toString()");
|
||||
}
|
||||
spr.putString(c->toString());
|
||||
spr.putString(cx, c->toString());
|
||||
buf = spr.release();
|
||||
} else {
|
||||
buf = JS_smprintf("string");
|
||||
|
@ -509,8 +509,8 @@ void IonPerfSpewer::recordInstruction(MacroAssembler& masm, LInstruction* ins) {
|
||||
}
|
||||
|
||||
#ifdef JS_JITSPEW
|
||||
static void PrintStackValue(StackValue* stackVal, CompilerFrameInfo& frame,
|
||||
Sprinter& buf) {
|
||||
static void PrintStackValue(JSContext* cx, StackValue* stackVal,
|
||||
CompilerFrameInfo& frame, Sprinter& buf) {
|
||||
switch (stackVal->kind()) {
|
||||
/****** Constant ******/
|
||||
case StackValue::Constant: {
|
||||
@ -521,7 +521,7 @@ static void PrintStackValue(StackValue* stackVal, CompilerFrameInfo& frame,
|
||||
buf.printf("obj:%p", constantVal.toObjectOrNull());
|
||||
} else if (constantVal.isString()) {
|
||||
buf.put("str:");
|
||||
buf.putString(constantVal.toString());
|
||||
buf.putString(cx, constantVal.toString());
|
||||
} else if (constantVal.isNumber()) {
|
||||
buf.printf("num:%f", constantVal.toNumber());
|
||||
} else if (constantVal.isSymbol()) {
|
||||
@ -594,7 +594,7 @@ void BaselinePerfSpewer::recordInstruction(JSContext* cx, MacroAssembler& masm,
|
||||
// Emit the name used for these ops
|
||||
Rooted<PropertyName*> name(cx, script->getName(pc));
|
||||
buf.put(" ");
|
||||
buf.putString(name);
|
||||
buf.putString(cx, name);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
@ -604,7 +604,7 @@ void BaselinePerfSpewer::recordInstruction(JSContext* cx, MacroAssembler& masm,
|
||||
for (unsigned i = 1; i <= numOperands; i++) {
|
||||
buf.put(" (");
|
||||
StackValue* stackVal = frame.peek(-int(i));
|
||||
PrintStackValue(stackVal, frame, buf);
|
||||
PrintStackValue(cx, stackVal, frame, buf);
|
||||
|
||||
if (i < numOperands) {
|
||||
buf.put("),");
|
||||
|
@ -1307,7 +1307,7 @@ static bool PrintShapeProperties(JSContext* cx, Sprinter* sp,
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
sp->putString(str);
|
||||
sp->putString(cx, str);
|
||||
if (i > 1) {
|
||||
sp->put(", ");
|
||||
}
|
||||
@ -2190,7 +2190,7 @@ bool ExpressionDecompiler::write(JSString* str) {
|
||||
if (str == cx->names().dot_newTarget_) {
|
||||
return write("new.target");
|
||||
}
|
||||
sprinter.putString(str);
|
||||
sprinter.putString(cx, str);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4163,7 +4163,7 @@ static bool AnalyzeEntrainedVariablesInScript(JSContext* cx,
|
||||
buf.printf("Script ");
|
||||
|
||||
if (JSAtom* name = script->function()->displayAtom()) {
|
||||
buf.putString(name);
|
||||
buf.putString(cx, name);
|
||||
buf.printf(" ");
|
||||
}
|
||||
|
||||
@ -4171,7 +4171,7 @@ static bool AnalyzeEntrainedVariablesInScript(JSContext* cx,
|
||||
script->lineno());
|
||||
|
||||
if (JSAtom* name = innerScript->function()->displayAtom()) {
|
||||
buf.putString(name);
|
||||
buf.putString(cx, name);
|
||||
buf.printf(" ");
|
||||
}
|
||||
|
||||
@ -4180,7 +4180,7 @@ static bool AnalyzeEntrainedVariablesInScript(JSContext* cx,
|
||||
for (PropertyNameSet::Range r = remainingNames.all(); !r.empty();
|
||||
r.popFront()) {
|
||||
buf.printf(" ");
|
||||
buf.putString(r.front());
|
||||
buf.putString(cx, r.front());
|
||||
}
|
||||
|
||||
JS::UniqueChars str = buf.release();
|
||||
|
@ -249,11 +249,11 @@ void Sprinter::put(const char* s, size_t len) {
|
||||
bp[len] = '\0';
|
||||
}
|
||||
|
||||
void Sprinter::putString(JSString* s) {
|
||||
MOZ_ASSERT(maybeCx);
|
||||
void Sprinter::putString(JSContext* cx, JSString* s) {
|
||||
MOZ_ASSERT(cx);
|
||||
InvariantChecker ic(this);
|
||||
|
||||
JSLinearString* linear = s->ensureLinear(maybeCx);
|
||||
JSLinearString* linear = s->ensureLinear(cx);
|
||||
if (!linear) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user