mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 913586 (Part 6) - Update Maybe users in js. r=luke
--HG-- extra : rebase_source : c5d23a7874de49e61b43f79b8eda744db0523c6e
This commit is contained in:
parent
92762da113
commit
9867e42134
@ -36,7 +36,7 @@ nsresult CentralizedAdminPrefManagerInit()
|
||||
nsresult rv;
|
||||
|
||||
// If the sandbox is already created, no need to create it again.
|
||||
if (!autoconfigSb.empty())
|
||||
if (autoconfigSb)
|
||||
return NS_OK;
|
||||
|
||||
// Grab XPConnect.
|
||||
@ -58,16 +58,16 @@ nsresult CentralizedAdminPrefManagerInit()
|
||||
|
||||
// Unwrap, store and root the sandbox.
|
||||
NS_ENSURE_STATE(sandbox->GetJSObject());
|
||||
autoconfigSb.construct(cx, js::UncheckedUnwrap(sandbox->GetJSObject()));
|
||||
autoconfigSb.emplace(cx, js::UncheckedUnwrap(sandbox->GetJSObject()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CentralizedAdminPrefManagerFinish()
|
||||
{
|
||||
if (!autoconfigSb.empty()) {
|
||||
if (autoconfigSb) {
|
||||
AutoSafeJSContext cx;
|
||||
autoconfigSb.destroy();
|
||||
autoconfigSb.reset();
|
||||
JS_MaybeGC(cx);
|
||||
}
|
||||
return NS_OK;
|
||||
@ -108,12 +108,12 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoCompartment ac(cx, autoconfigSb.ref());
|
||||
JSAutoCompartment ac(cx, *autoconfigSb);
|
||||
|
||||
nsAutoCString script(js_buffer, length);
|
||||
JS::RootedValue v(cx);
|
||||
rv = xpc->EvalInSandboxObject(NS_ConvertASCIItoUTF16(script), filename, cx,
|
||||
autoconfigSb.ref(), &v);
|
||||
*autoconfigSb, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -271,9 +271,9 @@ js::GenerateAsmJSFunctionPrologue(MacroAssembler &masm, unsigned framePushed,
|
||||
// Overflow checks are omitted by CodeGenerator in some cases (leaf
|
||||
// functions with small framePushed). Perform overflow-checking after
|
||||
// pushing framePushed to catch cases with really large frames.
|
||||
if (!labels->overflowThunk.empty()) {
|
||||
if (labels->overflowThunk) {
|
||||
// If framePushed is zero, we don't need a thunk to adjust StackPointer.
|
||||
Label *target = framePushed ? labels->overflowThunk.addr() : &labels->overflowExit;
|
||||
Label *target = framePushed ? labels->overflowThunk.ptr() : &labels->overflowExit;
|
||||
masm.branchPtr(Assembler::AboveOrEqual,
|
||||
AsmJSAbsoluteAddress(AsmJSImm_StackLimit),
|
||||
StackPointer,
|
||||
@ -330,11 +330,11 @@ js::GenerateAsmJSFunctionEpilogue(MacroAssembler &masm, unsigned framePushed,
|
||||
masm.bind(&labels->profilingEpilogue);
|
||||
GenerateProfilingEpilogue(masm, framePushed, AsmJSExit::None, &labels->profilingReturn);
|
||||
|
||||
if (!labels->overflowThunk.empty() && labels->overflowThunk.ref().used()) {
|
||||
if (labels->overflowThunk && labels->overflowThunk->used()) {
|
||||
// The general throw stub assumes that only sizeof(AsmJSFrame) bytes
|
||||
// have been pushed. The overflow check occurs after incrementing by
|
||||
// framePushed, so pop that before jumping to the overflow exit.
|
||||
masm.bind(labels->overflowThunk.addr());
|
||||
masm.bind(labels->overflowThunk.ptr());
|
||||
masm.addPtr(Imm32(framePushed), StackPointer);
|
||||
masm.jump(&labels->overflowExit);
|
||||
}
|
||||
|
@ -1959,7 +1959,7 @@ class FunctionCompiler
|
||||
JS_ASSERT(locals_.count() == argTypes.length() + varInitializers_.length());
|
||||
|
||||
alloc_ = lifo_.new_<TempAllocator>(&lifo_);
|
||||
ionContext_.construct(m_.cx(), alloc_);
|
||||
ionContext_.emplace(m_.cx(), alloc_);
|
||||
|
||||
graph_ = lifo_.new_<MIRGraph>(alloc_);
|
||||
info_ = lifo_.new_<CompileInfo>(locals_.count(), SequentialExecution);
|
||||
@ -1995,15 +1995,15 @@ class FunctionCompiler
|
||||
/******************************* For consistency of returns in a function */
|
||||
|
||||
bool hasAlreadyReturned() const {
|
||||
return !alreadyReturned_.empty();
|
||||
return alreadyReturned_.isSome();
|
||||
}
|
||||
|
||||
RetType returnedType() const {
|
||||
return alreadyReturned_.ref();
|
||||
return *alreadyReturned_;
|
||||
}
|
||||
|
||||
void setReturnedType(RetType retType) {
|
||||
alreadyReturned_.construct(retType);
|
||||
alreadyReturned_.emplace(retType);
|
||||
}
|
||||
|
||||
/************************* Read-only interface (after local scope setup) */
|
||||
|
@ -260,15 +260,15 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
|
||||
Maybe<Parser<SyntaxParseHandler> > syntaxParser;
|
||||
if (canLazilyParse) {
|
||||
syntaxParser.construct(cx, alloc, options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ false,
|
||||
(Parser<SyntaxParseHandler> *) nullptr,
|
||||
(LazyScript *) nullptr);
|
||||
syntaxParser.emplace(cx, alloc, options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ false,
|
||||
(Parser<SyntaxParseHandler> *) nullptr,
|
||||
(LazyScript *) nullptr);
|
||||
}
|
||||
|
||||
Parser<FullParseHandler> parser(cx, alloc, options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ true,
|
||||
canLazilyParse ? &syntaxParser.ref() : nullptr, nullptr);
|
||||
canLazilyParse ? syntaxParser.ptr() : nullptr, nullptr);
|
||||
parser.sct = sct;
|
||||
parser.ss = ss;
|
||||
|
||||
@ -301,10 +301,10 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
// reset when this occurs.
|
||||
Maybe<ParseContext<FullParseHandler> > pc;
|
||||
|
||||
pc.construct(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr, &globalsc,
|
||||
(Directives *) nullptr, staticLevel, /* bodyid = */ 0,
|
||||
/* blockScopeDepth = */ 0);
|
||||
if (!pc.ref().init(parser.tokenStream))
|
||||
pc.emplace(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr, &globalsc,
|
||||
(Directives *) nullptr, staticLevel, /* bodyid = */ 0,
|
||||
/* blockScopeDepth = */ 0);
|
||||
if (!pc->init(parser.tokenStream))
|
||||
return nullptr;
|
||||
|
||||
/* If this is a direct call to eval, inherit the caller's strictness. */
|
||||
@ -331,7 +331,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
*/
|
||||
JSFunction *fun = evalCaller->functionOrCallerFunction();
|
||||
Directives directives(/* strict = */ fun->strict());
|
||||
ObjectBox *funbox = parser.newFunctionBox(/* fn = */ nullptr, fun, pc.addr(),
|
||||
ObjectBox *funbox = parser.newFunctionBox(/* fn = */ nullptr, fun, pc.ptr(),
|
||||
directives, fun->generatorKind());
|
||||
if (!funbox)
|
||||
return nullptr;
|
||||
@ -365,16 +365,16 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
|
||||
// Destroying the parse context will destroy its free
|
||||
// variables, so check if any deoptimization is needed.
|
||||
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, pc.ref()))
|
||||
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, *pc))
|
||||
return nullptr;
|
||||
|
||||
pc.destroy();
|
||||
pc.construct(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr,
|
||||
&globalsc, (Directives *) nullptr, staticLevel, /* bodyid = */ 0,
|
||||
script->bindings.numBlockScoped());
|
||||
if (!pc.ref().init(parser.tokenStream))
|
||||
pc.reset();
|
||||
pc.emplace(&parser, (GenericParseContext *) nullptr, (ParseNode *) nullptr,
|
||||
&globalsc, (Directives *) nullptr, staticLevel, /* bodyid = */ 0,
|
||||
script->bindings.numBlockScoped());
|
||||
if (!pc->init(parser.tokenStream))
|
||||
return nullptr;
|
||||
JS_ASSERT(parser.pc == pc.addr());
|
||||
JS_ASSERT(parser.pc == pc.ptr());
|
||||
|
||||
pn = parser.statement();
|
||||
}
|
||||
@ -387,7 +387,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
// Accumulate the maximum block scope depth, so that EmitTree can assert
|
||||
// when emitting JSOP_GETLOCAL that the local is indeed within the fixed
|
||||
// part of the stack frame.
|
||||
script->bindings.updateNumBlockScoped(pc.ref().blockScopeDepth);
|
||||
script->bindings.updateNumBlockScoped(pc->blockScopeDepth);
|
||||
|
||||
if (canHaveDirectives) {
|
||||
if (!parser.maybeParseDirective(/* stmtList = */ nullptr, pn, &canHaveDirectives))
|
||||
@ -406,7 +406,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
parser.handler.freeTree(pn);
|
||||
}
|
||||
|
||||
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, pc.ref()))
|
||||
if (!MaybeCheckEvalFreeVariables(cx, evalCaller, scopeChain, parser, *pc))
|
||||
return nullptr;
|
||||
|
||||
if (!SetDisplayURL(cx, parser.tokenStream, ss))
|
||||
@ -437,7 +437,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
|
||||
// frame.
|
||||
InternalHandle<Bindings*> bindings(script, &script->bindings);
|
||||
if (!Bindings::initWithTemporaryStorage(cx, bindings, 0, 0, nullptr,
|
||||
pc.ref().blockScopeDepth))
|
||||
pc->blockScopeDepth))
|
||||
return nullptr;
|
||||
|
||||
if (!JSScript::fullyInitFromEmitter(cx, script, &bce))
|
||||
@ -555,11 +555,11 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
|
||||
|
||||
Maybe<Parser<SyntaxParseHandler> > syntaxParser;
|
||||
if (canLazilyParse) {
|
||||
syntaxParser.construct(cx, &cx->tempLifoAlloc(),
|
||||
options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ false,
|
||||
(Parser<SyntaxParseHandler> *) nullptr,
|
||||
(LazyScript *) nullptr);
|
||||
syntaxParser.emplace(cx, &cx->tempLifoAlloc(),
|
||||
options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ false,
|
||||
(Parser<SyntaxParseHandler> *) nullptr,
|
||||
(LazyScript *) nullptr);
|
||||
}
|
||||
|
||||
JS_ASSERT(!options.forEval);
|
||||
@ -567,7 +567,7 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyComp
|
||||
Parser<FullParseHandler> parser(cx, &cx->tempLifoAlloc(),
|
||||
options, srcBuf.get(), srcBuf.length(),
|
||||
/* foldConstants = */ true,
|
||||
canLazilyParse ? &syntaxParser.ref() : nullptr, nullptr);
|
||||
canLazilyParse ? syntaxParser.ptr() : nullptr, nullptr);
|
||||
parser.sct = &sct;
|
||||
parser.ss = ss;
|
||||
|
||||
|
@ -399,37 +399,37 @@ class CompartmentsIterT
|
||||
: zone(rt)
|
||||
{
|
||||
if (zone.done())
|
||||
comp.construct();
|
||||
comp.emplace();
|
||||
else
|
||||
comp.construct(zone);
|
||||
comp.emplace(zone);
|
||||
}
|
||||
|
||||
CompartmentsIterT(JSRuntime *rt, ZoneSelector selector)
|
||||
: zone(rt, selector)
|
||||
{
|
||||
if (zone.done())
|
||||
comp.construct();
|
||||
comp.emplace();
|
||||
else
|
||||
comp.construct(zone);
|
||||
comp.emplace(zone);
|
||||
}
|
||||
|
||||
bool done() const { return zone.done(); }
|
||||
|
||||
void next() {
|
||||
JS_ASSERT(!done());
|
||||
JS_ASSERT(!comp.ref().done());
|
||||
comp.ref().next();
|
||||
if (comp.ref().done()) {
|
||||
comp.destroy();
|
||||
JS_ASSERT(!comp->done());
|
||||
comp->next();
|
||||
if (comp->done()) {
|
||||
comp.reset();
|
||||
zone.next();
|
||||
if (!zone.done())
|
||||
comp.construct(zone);
|
||||
comp.emplace(zone);
|
||||
}
|
||||
}
|
||||
|
||||
JSCompartment *get() const {
|
||||
JS_ASSERT(!done());
|
||||
return comp.ref();
|
||||
return *comp;
|
||||
}
|
||||
|
||||
operator JSCompartment *() const { return get(); }
|
||||
|
@ -1661,12 +1661,12 @@ irregexp::CompilePattern(JSContext *cx, RegExpShared *shared, RegExpCompileData
|
||||
is_ascii ? NativeRegExpMacroAssembler::ASCII
|
||||
: NativeRegExpMacroAssembler::JSCHAR;
|
||||
|
||||
ctx.construct(cx, (jit::TempAllocator *) nullptr);
|
||||
native_assembler.construct(&alloc, shared, cx->runtime(), mode, (data->capture_count + 1) * 2);
|
||||
assembler = native_assembler.addr();
|
||||
ctx.emplace(cx, (jit::TempAllocator *) nullptr);
|
||||
native_assembler.emplace(&alloc, shared, cx->runtime(), mode, (data->capture_count + 1) * 2);
|
||||
assembler = native_assembler.ptr();
|
||||
} else {
|
||||
interpreted_assembler.construct(&alloc, shared, (data->capture_count + 1) * 2);
|
||||
assembler = interpreted_assembler.addr();
|
||||
interpreted_assembler.emplace(&alloc, shared, (data->capture_count + 1) * 2);
|
||||
assembler = interpreted_assembler.ptr();
|
||||
}
|
||||
|
||||
// Inserted here, instead of in Assembler, because it depends on information
|
||||
|
@ -3384,8 +3384,8 @@ CodeGenerator::generateBody()
|
||||
|
||||
mozilla::Maybe<ScriptCountBlockState> blockCounts;
|
||||
if (counts) {
|
||||
blockCounts.construct(&counts->block(i), &masm);
|
||||
if (!blockCounts.ref().init())
|
||||
blockCounts.emplace(&counts->block(i), &masm);
|
||||
if (!blockCounts->init())
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3402,7 +3402,7 @@ CodeGenerator::generateBody()
|
||||
IonSpewFin(IonSpew_Codegen);
|
||||
|
||||
if (counts)
|
||||
blockCounts.ref().visitInstruction(*iter);
|
||||
blockCounts->visitInstruction(*iter);
|
||||
|
||||
if (iter->safepoint() && pushedArgumentSlots_.length()) {
|
||||
if (!markArgumentSlots(iter->safepoint()))
|
||||
@ -4851,10 +4851,10 @@ CodeGenerator::visitIsNullOrLikeUndefined(LIsNullOrLikeUndefined *lir)
|
||||
nullOrLikeUndefined = ool->label1();
|
||||
notNullOrLikeUndefined = ool->label2();
|
||||
} else {
|
||||
label1.construct();
|
||||
label2.construct();
|
||||
nullOrLikeUndefined = label1.addr();
|
||||
notNullOrLikeUndefined = label2.addr();
|
||||
label1.emplace();
|
||||
label2.emplace();
|
||||
nullOrLikeUndefined = label1.ptr();
|
||||
notNullOrLikeUndefined = label2.ptr();
|
||||
}
|
||||
|
||||
Register tag = masm.splitTagForTest(value);
|
||||
@ -5561,10 +5561,10 @@ CodeGenerator::visitNotV(LNotV *lir)
|
||||
ifTruthy = ool->label1();
|
||||
ifFalsy = ool->label2();
|
||||
} else {
|
||||
ifTruthyLabel.construct();
|
||||
ifFalsyLabel.construct();
|
||||
ifTruthy = ifTruthyLabel.addr();
|
||||
ifFalsy = ifFalsyLabel.addr();
|
||||
ifTruthyLabel.emplace();
|
||||
ifFalsyLabel.emplace();
|
||||
ifTruthy = ifTruthyLabel.ptr();
|
||||
ifFalsy = ifFalsyLabel.ptr();
|
||||
}
|
||||
|
||||
testValueTruthyKernel(ToValue(lir, LNotV::Input), lir->temp1(), lir->temp2(),
|
||||
@ -6549,7 +6549,7 @@ CodeGenerator::generateAsmJS(AsmJSFunctionLabels *labels)
|
||||
sps_.disable();
|
||||
|
||||
if (!omitOverRecursedCheck())
|
||||
labels->overflowThunk.construct();
|
||||
labels->overflowThunk.emplace();
|
||||
|
||||
GenerateAsmJSFunctionPrologue(masm, frameSize(), labels);
|
||||
|
||||
|
@ -210,7 +210,7 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
|
||||
if (!icx->temp) {
|
||||
JS_ASSERT(cx);
|
||||
alloc_.construct(cx);
|
||||
alloc_.emplace(cx);
|
||||
}
|
||||
|
||||
moveResolver_.setAllocator(*icx->temp);
|
||||
@ -228,9 +228,9 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
sps_(nullptr)
|
||||
{
|
||||
constructRoot(cx);
|
||||
ionContext_.construct(cx, (js::jit::TempAllocator *)nullptr);
|
||||
alloc_.construct(cx);
|
||||
moveResolver_.setAllocator(*ionContext_.ref().temp);
|
||||
ionContext_.emplace(cx, (js::jit::TempAllocator *)nullptr);
|
||||
alloc_.emplace(cx);
|
||||
moveResolver_.setAllocator(*ionContext_->temp);
|
||||
#ifdef JS_CODEGEN_ARM
|
||||
initWithAllocator();
|
||||
m_buffer.id = GetIonContext()->getNextAssemblerId();
|
||||
@ -241,8 +241,8 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
// We have to update the SPS pc when this IC stub calls into
|
||||
// the VM.
|
||||
spsPc_ = pc;
|
||||
spsInstrumentation_.construct(&cx->runtime()->spsProfiler, &spsPc_);
|
||||
sps_ = spsInstrumentation_.addr();
|
||||
spsInstrumentation_.emplace(&cx->runtime()->spsProfiler, &spsPc_);
|
||||
sps_ = spsInstrumentation_.ptr();
|
||||
sps_->setPushed(script);
|
||||
}
|
||||
}
|
||||
@ -271,7 +271,7 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
}
|
||||
|
||||
void constructRoot(JSContext *cx) {
|
||||
autoRooter_.construct(cx, this);
|
||||
autoRooter_.emplace(cx, this);
|
||||
}
|
||||
|
||||
MoveResolver &moveResolver() {
|
||||
|
@ -3844,20 +3844,20 @@ TryAddTypeBarrierForWrite(TempAllocator &alloc, types::CompilerConstraintList *c
|
||||
// potentially be removed.
|
||||
property.freeze(constraints);
|
||||
|
||||
if (aggregateProperty.empty()) {
|
||||
aggregateProperty.construct(property);
|
||||
if (!aggregateProperty) {
|
||||
aggregateProperty.emplace(property);
|
||||
} else {
|
||||
if (!aggregateProperty.ref().maybeTypes()->isSubset(property.maybeTypes()) ||
|
||||
!property.maybeTypes()->isSubset(aggregateProperty.ref().maybeTypes()))
|
||||
if (!aggregateProperty->maybeTypes()->isSubset(property.maybeTypes()) ||
|
||||
!property.maybeTypes()->isSubset(aggregateProperty->maybeTypes()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JS_ASSERT(!aggregateProperty.empty());
|
||||
JS_ASSERT(aggregateProperty);
|
||||
|
||||
MIRType propertyType = aggregateProperty.ref().knownMIRType(constraints);
|
||||
MIRType propertyType = aggregateProperty->knownMIRType(constraints);
|
||||
switch (propertyType) {
|
||||
case MIRType_Boolean:
|
||||
case MIRType_Int32:
|
||||
@ -3883,7 +3883,7 @@ TryAddTypeBarrierForWrite(TempAllocator &alloc, types::CompilerConstraintList *c
|
||||
if ((*pvalue)->type() != MIRType_Value)
|
||||
return false;
|
||||
|
||||
types::TemporaryTypeSet *types = aggregateProperty.ref().maybeTypes()->clone(alloc.lifoAlloc());
|
||||
types::TemporaryTypeSet *types = aggregateProperty->maybeTypes()->clone(alloc.lifoAlloc());
|
||||
if (!types)
|
||||
return false;
|
||||
|
||||
|
@ -33,8 +33,8 @@ CodeGeneratorShared::ensureMasm(MacroAssembler *masmArg)
|
||||
{
|
||||
if (masmArg)
|
||||
return *masmArg;
|
||||
maybeMasm_.construct();
|
||||
return maybeMasm_.ref();
|
||||
maybeMasm_.emplace();
|
||||
return *maybeMasm_;
|
||||
}
|
||||
|
||||
CodeGeneratorShared::CodeGeneratorShared(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masmArg)
|
||||
|
@ -2237,7 +2237,7 @@ ArenaLists::refillFreeList(ThreadSafeContext *cx, AllocKind thingKind)
|
||||
mozilla::Maybe<AutoLockHelperThreadState> lock;
|
||||
JSRuntime *rt = zone->runtimeFromAnyThread();
|
||||
if (rt->exclusiveThreadsPresent()) {
|
||||
lock.construct();
|
||||
lock.emplace();
|
||||
while (rt->isHeapBusy())
|
||||
HelperThreadState().wait(GlobalHelperThreadState::PRODUCER);
|
||||
}
|
||||
@ -2529,7 +2529,7 @@ GCRuntime::decommitArenasFromAvailableList(Chunk **availableListHeadp)
|
||||
*/
|
||||
Maybe<AutoUnlockGC> maybeUnlock;
|
||||
if (!isHeapBusy())
|
||||
maybeUnlock.construct(rt);
|
||||
maybeUnlock.emplace(rt);
|
||||
ok = MarkPagesUnused(aheader->getArena(), ArenaSize);
|
||||
}
|
||||
|
||||
|
@ -329,10 +329,10 @@ JO(JSContext *cx, HandleObject obj, StringifyContext *scx)
|
||||
props = &scx->propertyList;
|
||||
} else {
|
||||
JS_ASSERT_IF(scx->replacer, scx->propertyList.length() == 0);
|
||||
ids.construct(cx);
|
||||
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, ids.addr()))
|
||||
ids.emplace(cx);
|
||||
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, ids.ptr()))
|
||||
return false;
|
||||
props = ids.addr();
|
||||
props = ids.ptr();
|
||||
}
|
||||
|
||||
/* My kingdom for not-quite-initialized-from-the-start references. */
|
||||
|
@ -54,8 +54,8 @@ js::AutoEnterPolicy::recordEnter(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
{
|
||||
if (allowed()) {
|
||||
context = cx;
|
||||
enteredProxy.construct(proxy);
|
||||
enteredId.construct(id);
|
||||
enteredProxy.emplace(proxy);
|
||||
enteredId.emplace(id);
|
||||
enteredAction = act;
|
||||
prev = cx->runtime()->enteredPolicy;
|
||||
cx->runtime()->enteredPolicy = this;
|
||||
@ -65,7 +65,7 @@ js::AutoEnterPolicy::recordEnter(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
void
|
||||
js::AutoEnterPolicy::recordLeave()
|
||||
{
|
||||
if (!enteredProxy.empty()) {
|
||||
if (enteredProxy) {
|
||||
JS_ASSERT(context->runtime()->enteredPolicy == this);
|
||||
context->runtime()->enteredPolicy = prev;
|
||||
}
|
||||
@ -77,8 +77,8 @@ js::assertEnteredPolicy(JSContext *cx, JSObject *proxy, jsid id,
|
||||
{
|
||||
MOZ_ASSERT(proxy->is<ProxyObject>());
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy);
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredProxy.ref().get() == proxy);
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredId.ref().get() == id);
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredProxy->get() == proxy);
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredId->get() == id);
|
||||
MOZ_ASSERT(cx->runtime()->enteredPolicy->enteredAction & act);
|
||||
}
|
||||
#endif
|
||||
|
@ -47,9 +47,9 @@ Wrapper::New(JSContext *cx, JSObject *obj, JSObject *parent, const Wrapper *hand
|
||||
RootedValue priv(cx, ObjectValue(*obj));
|
||||
mozilla::Maybe<WrapperOptions> opts;
|
||||
if (!options) {
|
||||
opts.construct();
|
||||
opts.ref().selectDefaultClass(obj->isCallable());
|
||||
options = opts.addr();
|
||||
opts.emplace();
|
||||
opts->selectDefaultClass(obj->isCallable());
|
||||
options = opts.ptr();
|
||||
}
|
||||
return NewProxyObject(cx, handler, priv, options->proto(), parent, *options);
|
||||
}
|
||||
@ -152,12 +152,12 @@ js::TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject
|
||||
|
||||
ErrorCopier::~ErrorCopier()
|
||||
{
|
||||
JSContext *cx = ac.ref().context()->asJSContext();
|
||||
if (ac.ref().origin() != cx->compartment() && cx->isExceptionPending()) {
|
||||
JSContext *cx = ac->context()->asJSContext();
|
||||
if (ac->origin() != cx->compartment() && cx->isExceptionPending()) {
|
||||
RootedValue exc(cx);
|
||||
if (cx->getPendingException(&exc) && exc.isObject() && exc.toObject().is<ErrorObject>()) {
|
||||
cx->clearPendingException();
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
Rooted<ErrorObject*> errObj(cx, &exc.toObject().as<ErrorObject>());
|
||||
JSObject *copyobj = js_CopyErrorObject(cx, errObj);
|
||||
if (copyobj)
|
||||
|
@ -30,13 +30,13 @@ class MOZ_STACK_CLASS WrapperOptions : public ProxyOptions {
|
||||
explicit WrapperOptions(JSContext *cx) : ProxyOptions(false, nullptr),
|
||||
proto_()
|
||||
{
|
||||
proto_.construct(cx);
|
||||
proto_.emplace(cx);
|
||||
}
|
||||
|
||||
inline JSObject *proto() const;
|
||||
WrapperOptions &setProto(JSObject *protoArg) {
|
||||
JS_ASSERT(!proto_.empty());
|
||||
proto_.ref() = protoArg;
|
||||
JS_ASSERT(proto_);
|
||||
*proto_ = protoArg;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler
|
||||
inline JSObject *
|
||||
WrapperOptions::proto() const
|
||||
{
|
||||
return proto_.empty() ? Wrapper::defaultProto : proto_.ref();
|
||||
return proto_ ? *proto_ : Wrapper::defaultProto;
|
||||
}
|
||||
|
||||
/* Base class for all cross compartment wrapper handlers. */
|
||||
|
@ -350,7 +350,7 @@ ShellInterruptCallback(JSContext *cx)
|
||||
return true;
|
||||
|
||||
bool result;
|
||||
RootedValue interruptFunc(cx, gInterruptFunc.ref());
|
||||
RootedValue interruptFunc(cx, *gInterruptFunc);
|
||||
if (!interruptFunc.isNull()) {
|
||||
JS::AutoSaveExceptionState savedExc(cx);
|
||||
JSAutoCompartment ac(cx, &interruptFunc.toObject());
|
||||
@ -960,8 +960,8 @@ class AutoNewContext
|
||||
JS::ContextOptionsRef(newcx).setDontReportUncaught(true);
|
||||
js::SetDefaultObjectForContext(newcx, JS::CurrentGlobalOrNull(cx));
|
||||
|
||||
newRequest.construct(newcx);
|
||||
newCompartment.construct(newcx, JS::CurrentGlobalOrNull(cx));
|
||||
newRequest.emplace(newcx);
|
||||
newCompartment.emplace(newcx, JS::CurrentGlobalOrNull(cx));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -973,8 +973,8 @@ class AutoNewContext
|
||||
bool throwing = JS_IsExceptionPending(newcx);
|
||||
if (throwing)
|
||||
JS_GetPendingException(newcx, &exc);
|
||||
newCompartment.destroy();
|
||||
newRequest.destroy();
|
||||
newCompartment.reset();
|
||||
newRequest.reset();
|
||||
if (throwing)
|
||||
JS_SetPendingException(oldcx, exc);
|
||||
DestroyContext(newcx, false);
|
||||
@ -2426,7 +2426,7 @@ Clone(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
if (obj && obj->is<CrossCompartmentWrapperObject>()) {
|
||||
obj = UncheckedUnwrap(obj);
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
args[0].setObject(*obj);
|
||||
}
|
||||
if (obj && obj->is<JSFunction>()) {
|
||||
@ -2608,7 +2608,7 @@ EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
|
||||
JSObject *unwrapped = UncheckedUnwrap(sobj, true, &flags);
|
||||
if (flags & Wrapper::CROSS_COMPARTMENT) {
|
||||
sobj = unwrapped;
|
||||
ac.construct(cx, sobj);
|
||||
ac.emplace(cx, sobj);
|
||||
}
|
||||
|
||||
sobj = GetInnerObject(sobj);
|
||||
@ -2666,7 +2666,7 @@ EvalInFrame(JSContext *cx, unsigned argc, jsval *vp)
|
||||
if (saveCurrent) {
|
||||
if (!sfc.save())
|
||||
return false;
|
||||
ac.construct(cx, DefaultObjectForContextOrNull(cx));
|
||||
ac.emplace(cx, DefaultObjectForContextOrNull(cx));
|
||||
}
|
||||
|
||||
AutoStableStringChars stableChars(cx);
|
||||
@ -3110,7 +3110,7 @@ CancelExecution(JSRuntime *rt)
|
||||
gServiceInterrupt = true;
|
||||
JS_RequestInterruptCallback(rt);
|
||||
|
||||
if (!gInterruptFunc.ref().get().isNull()) {
|
||||
if (!gInterruptFunc->get().isNull()) {
|
||||
static const char msg[] = "Script runs for too long, terminating.\n";
|
||||
fputs(msg, stderr);
|
||||
}
|
||||
@ -3157,7 +3157,7 @@ Timeout(JSContext *cx, unsigned argc, Value *vp)
|
||||
JS_ReportError(cx, "Second argument must be a timeout function");
|
||||
return false;
|
||||
}
|
||||
gInterruptFunc.ref() = value;
|
||||
*gInterruptFunc = value;
|
||||
}
|
||||
|
||||
args.rval().setUndefined();
|
||||
@ -3228,7 +3228,7 @@ SetInterruptCallback(JSContext *cx, unsigned argc, Value *vp)
|
||||
JS_ReportError(cx, "Argument must be a function");
|
||||
return false;
|
||||
}
|
||||
gInterruptFunc.ref() = value;
|
||||
*gInterruptFunc = value;
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
@ -6213,13 +6213,13 @@ main(int argc, char **argv, char **envp)
|
||||
if (!SetRuntimeOptions(rt, op))
|
||||
return 1;
|
||||
|
||||
gInterruptFunc.construct(rt, NullValue());
|
||||
gInterruptFunc.emplace(rt, NullValue());
|
||||
|
||||
JS_SetGCParameter(rt, JSGC_MAX_BYTES, 0xffffffff);
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
Maybe<JS::AutoDisableGenerationalGC> noggc;
|
||||
if (op.getBoolOption("no-ggc"))
|
||||
noggc.construct(rt);
|
||||
noggc.emplace(rt);
|
||||
#endif
|
||||
|
||||
size_t availMem = op.getIntOption("available-memory");
|
||||
@ -6261,15 +6261,14 @@ main(int argc, char **argv, char **envp)
|
||||
|
||||
KillWatchdog();
|
||||
|
||||
gInterruptFunc.destroy();
|
||||
gInterruptFunc.reset();
|
||||
|
||||
MOZ_ASSERT_IF(!CanUseExtraThreads(), workerThreads.empty());
|
||||
for (size_t i = 0; i < workerThreads.length(); i++)
|
||||
PR_JoinThread(workerThreads[i]);
|
||||
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
if (!noggc.empty())
|
||||
noggc.destroy();
|
||||
noggc.reset();
|
||||
#endif
|
||||
|
||||
JS_DestroyRuntime(rt);
|
||||
|
@ -558,7 +558,7 @@ Debugger::slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool frame
|
||||
RootedValue handler(cx, frameobj->getReservedSlot(JSSLOT_DEBUGFRAME_ONPOP_HANDLER));
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, dbg->object);
|
||||
ac.emplace(cx, dbg->object);
|
||||
|
||||
RootedValue completion(cx);
|
||||
if (!dbg->newCompletionValue(cx, status, value, &completion)) {
|
||||
@ -834,7 +834,7 @@ JSTrapStatus
|
||||
Debugger::handleUncaughtExceptionHelper(Maybe<AutoCompartment> &ac,
|
||||
MutableHandleValue *vp, bool callHook)
|
||||
{
|
||||
JSContext *cx = ac.ref().context()->asJSContext();
|
||||
JSContext *cx = ac->context()->asJSContext();
|
||||
if (cx->isExceptionPending()) {
|
||||
if (callHook && uncaughtExceptionHook) {
|
||||
RootedValue exc(cx);
|
||||
@ -852,7 +852,7 @@ Debugger::handleUncaughtExceptionHelper(Maybe<AutoCompartment> &ac,
|
||||
cx->clearPendingException();
|
||||
}
|
||||
}
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
return JSTRAP_ERROR;
|
||||
}
|
||||
|
||||
@ -937,12 +937,12 @@ Debugger::receiveCompletionValue(Maybe<AutoCompartment> &ac, bool ok,
|
||||
HandleValue val,
|
||||
MutableHandleValue vp)
|
||||
{
|
||||
JSContext *cx = ac.ref().context()->asJSContext();
|
||||
JSContext *cx = ac->context()->asJSContext();
|
||||
|
||||
JSTrapStatus status;
|
||||
RootedValue value(cx);
|
||||
resultToCompletion(cx, ok, val, &status, &value);
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
return newCompletionValue(cx, status, value, vp);
|
||||
}
|
||||
|
||||
@ -954,16 +954,16 @@ Debugger::parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value
|
||||
if (!ok)
|
||||
return handleUncaughtException(ac, vp, callHook);
|
||||
if (rv.isUndefined()) {
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
if (rv.isNull()) {
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
return JSTRAP_ERROR;
|
||||
}
|
||||
|
||||
/* Check that rv is {return: val} or {throw: val}. */
|
||||
JSContext *cx = ac.ref().context()->asJSContext();
|
||||
JSContext *cx = ac->context()->asJSContext();
|
||||
Rooted<JSObject*> obj(cx);
|
||||
RootedShape shape(cx);
|
||||
RootedId returnId(cx, NameToId(cx->names().return_));
|
||||
@ -989,7 +989,7 @@ Debugger::parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value
|
||||
if (!NativeGet(cx, obj, obj, shape, &v) || !unwrapDebuggeeValue(cx, &v))
|
||||
return handleUncaughtException(ac, &v, callHook);
|
||||
|
||||
ac.destroy();
|
||||
ac.reset();
|
||||
if (!cx->compartment()->wrap(cx, &v)) {
|
||||
vp.setUndefined();
|
||||
return JSTRAP_ERROR;
|
||||
@ -1022,7 +1022,7 @@ Debugger::fireDebuggerStatement(JSContext *cx, MutableHandleValue vp)
|
||||
JS_ASSERT(hook->isCallable());
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, object);
|
||||
ac.emplace(cx, object);
|
||||
|
||||
ScriptFrameIter iter(cx);
|
||||
|
||||
@ -1048,7 +1048,7 @@ Debugger::fireExceptionUnwind(JSContext *cx, MutableHandleValue vp)
|
||||
cx->clearPendingException();
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, object);
|
||||
ac.emplace(cx, object);
|
||||
|
||||
JS::AutoValueArray<2> argv(cx);
|
||||
argv[0].setUndefined();
|
||||
@ -1074,7 +1074,7 @@ Debugger::fireEnterFrame(JSContext *cx, AbstractFramePtr frame, MutableHandleVal
|
||||
JS_ASSERT(hook->isCallable());
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, object);
|
||||
ac.emplace(cx, object);
|
||||
|
||||
RootedValue scriptFrame(cx);
|
||||
if (!getScriptFrame(cx, frame, &scriptFrame))
|
||||
@ -1093,7 +1093,7 @@ Debugger::fireNewScript(JSContext *cx, HandleScript script)
|
||||
JS_ASSERT(hook->isCallable());
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, object);
|
||||
ac.emplace(cx, object);
|
||||
|
||||
JSObject *dsobj = wrapScript(cx, script);
|
||||
if (!dsobj) {
|
||||
@ -1248,7 +1248,7 @@ Debugger::onTrap(JSContext *cx, MutableHandleValue vp)
|
||||
Debugger *dbg = bp->debugger;
|
||||
if (dbg->enabled && dbg->debuggees.lookup(scriptGlobal)) {
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, dbg->object);
|
||||
ac.emplace(cx, dbg->object);
|
||||
|
||||
RootedValue scriptFrame(cx);
|
||||
if (!dbg->getScriptFrame(cx, iter, &scriptFrame))
|
||||
@ -1359,7 +1359,7 @@ Debugger::onSingleStep(JSContext *cx, MutableHandleValue vp)
|
||||
Debugger *dbg = Debugger::fromChildJSObject(frame);
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, dbg->object);
|
||||
ac.emplace(cx, dbg->object);
|
||||
|
||||
const Value &handler = frame->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER);
|
||||
RootedValue rval(cx);
|
||||
@ -1383,7 +1383,7 @@ Debugger::fireNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global, Muta
|
||||
JS_ASSERT(hook->isCallable());
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, object);
|
||||
ac.emplace(cx, object);
|
||||
|
||||
RootedValue wrappedGlobal(cx, ObjectValue(*global));
|
||||
if (!wrapDebuggeeValue(cx, &wrappedGlobal))
|
||||
@ -4389,11 +4389,11 @@ CheckThisFrame(JSContext *cx, const CallArgs &args, const char *fnname, bool che
|
||||
{ \
|
||||
AbstractFramePtr f = AbstractFramePtr::FromRaw(thisobj->getPrivate()); \
|
||||
if (f.isScriptFrameIterData()) { \
|
||||
maybeIter.construct(*(ScriptFrameIter::Data *)(f.raw())); \
|
||||
maybeIter.emplace(*(ScriptFrameIter::Data *)(f.raw())); \
|
||||
} else { \
|
||||
maybeIter.construct(cx, ScriptFrameIter::ALL_CONTEXTS, \
|
||||
ScriptFrameIter::GO_THROUGH_SAVED); \
|
||||
ScriptFrameIter &iter = maybeIter.ref(); \
|
||||
maybeIter.emplace(cx, ScriptFrameIter::ALL_CONTEXTS, \
|
||||
ScriptFrameIter::GO_THROUGH_SAVED); \
|
||||
ScriptFrameIter &iter = *maybeIter; \
|
||||
while (iter.isIon() || iter.abstractFramePtr() != f) \
|
||||
++iter; \
|
||||
AbstractFramePtr data = iter.copyDataAsAbstractFramePtr(); \
|
||||
@ -4402,7 +4402,7 @@ CheckThisFrame(JSContext *cx, const CallArgs &args, const char *fnname, bool che
|
||||
thisobj->setPrivate(data.raw()); \
|
||||
} \
|
||||
} \
|
||||
ScriptFrameIter &iter = maybeIter.ref()
|
||||
ScriptFrameIter &iter = *maybeIter
|
||||
|
||||
#define THIS_FRAME_OWNER(cx, argc, vp, fnname, args, thisobj, frame, dbg) \
|
||||
THIS_FRAME(cx, argc, vp, fnname, args, thisobj, frame); \
|
||||
@ -4901,9 +4901,9 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName, const Value &code
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
if (iter)
|
||||
ac.construct(cx, iter->scopeChain());
|
||||
ac.emplace(cx, iter->scopeChain());
|
||||
else
|
||||
ac.construct(cx, scope);
|
||||
ac.emplace(cx, scope);
|
||||
|
||||
RootedValue thisv(cx);
|
||||
Rooted<Env *> env(cx);
|
||||
@ -5398,7 +5398,7 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
||||
Rooted<PropertyDescriptor> desc(cx);
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
|
||||
ErrorCopier ec(ac);
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||
@ -5435,7 +5435,7 @@ DebuggerObject_getOwnPropertyNames(JSContext *cx, unsigned argc, Value *vp)
|
||||
AutoIdVector keys(cx);
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
ErrorCopier ec(ac);
|
||||
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, &keys))
|
||||
return false;
|
||||
@ -5488,7 +5488,7 @@ DebuggerObject_defineProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
if (!cx->compartment()->wrap(cx, &desc))
|
||||
return false;
|
||||
|
||||
@ -5529,7 +5529,7 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (!cx->compartment()->wrap(cx, descs[i]))
|
||||
return false;
|
||||
@ -5560,7 +5560,7 @@ DebuggerObject_deleteProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
ErrorCopier ec(ac);
|
||||
|
||||
bool succeeded;
|
||||
@ -5578,7 +5578,7 @@ DebuggerObject_sealHelper(JSContext *cx, unsigned argc, Value *vp, SealHelperOp
|
||||
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, name, args, obj);
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
ErrorCopier ec(ac);
|
||||
bool ok;
|
||||
if (op == Seal) {
|
||||
@ -5627,7 +5627,7 @@ DebuggerObject_isSealedHelper(JSContext *cx, unsigned argc, Value *vp, SealHelpe
|
||||
THIS_DEBUGOBJECT_REFERENT(cx, argc, vp, name, args, obj);
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
ErrorCopier ec(ac);
|
||||
bool r;
|
||||
if (op == Seal) {
|
||||
@ -5721,7 +5721,7 @@ ApplyOrCall(JSContext *cx, unsigned argc, Value *vp, ApplyOrCallMode mode)
|
||||
* (Rewrapping always takes place in the destination compartment.)
|
||||
*/
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
ac.emplace(cx, obj);
|
||||
if (!cx->compartment()->wrap(cx, &calleev) || !cx->compartment()->wrap(cx, &thisv))
|
||||
return false;
|
||||
|
||||
@ -6127,7 +6127,7 @@ DebuggerEnv_names(JSContext *cx, unsigned argc, Value *vp)
|
||||
AutoIdVector keys(cx);
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
ac.emplace(cx, env);
|
||||
ErrorCopier ec(ac);
|
||||
if (!GetPropertyNames(cx, env, JSITER_HIDDEN, &keys))
|
||||
return false;
|
||||
@ -6161,7 +6161,7 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
ac.emplace(cx, env);
|
||||
|
||||
/* This can trigger resolve hooks. */
|
||||
ErrorCopier ec(ac);
|
||||
@ -6192,7 +6192,7 @@ DebuggerEnv_getVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
RootedValue v(cx);
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
ac.emplace(cx, env);
|
||||
|
||||
/* This can trigger getters. */
|
||||
ErrorCopier ec(ac);
|
||||
@ -6233,7 +6233,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
ac.emplace(cx, env);
|
||||
if (!cx->compartment()->wrap(cx, &v))
|
||||
return false;
|
||||
|
||||
|
@ -423,11 +423,11 @@ GlobalHelperThreadState::ensureInitialized()
|
||||
|
||||
for (size_t i = 0; i < threadCount; i++) {
|
||||
HelperThread &helper = threads[i];
|
||||
helper.threadData.construct(static_cast<JSRuntime *>(nullptr));
|
||||
helper.threadData.emplace(static_cast<JSRuntime *>(nullptr));
|
||||
helper.thread = PR_CreateThread(PR_USER_THREAD,
|
||||
HelperThread::ThreadMain, &helper,
|
||||
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, HELPER_STACK_SIZE);
|
||||
if (!helper.thread || !helper.threadData.ref().init())
|
||||
if (!helper.thread || !helper.threadData->init())
|
||||
CrashAtUnhandlableOOM("GlobalHelperThreadState::ensureInitialized");
|
||||
}
|
||||
|
||||
@ -813,8 +813,7 @@ HelperThread::destroy()
|
||||
PR_JoinThread(thread);
|
||||
}
|
||||
|
||||
if (!threadData.empty())
|
||||
threadData.destroy();
|
||||
threadData.reset();
|
||||
}
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
@ -852,7 +851,7 @@ HelperThread::handleAsmJSWorkload()
|
||||
|
||||
do {
|
||||
AutoUnlockHelperThreadState unlock;
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.addr(), asmData->runtime);
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.ptr(), asmData->runtime);
|
||||
|
||||
jit::IonContext icx(asmData->mir->compartment->runtime(),
|
||||
asmData->mir->compartment,
|
||||
@ -922,7 +921,7 @@ HelperThread::handleIonWorkload()
|
||||
|
||||
{
|
||||
AutoUnlockHelperThreadState unlock;
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.addr(),
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.ptr(),
|
||||
ionBuilder->script()->runtimeFromAnyThread());
|
||||
jit::IonContext ictx(jit::CompileRuntime::get(rt),
|
||||
jit::CompileCompartment::get(ionBuilder->script()->compartment()),
|
||||
@ -998,7 +997,7 @@ void
|
||||
ExclusiveContext::setHelperThread(HelperThread *thread)
|
||||
{
|
||||
helperThread_ = thread;
|
||||
perThreadData = thread->threadData.addr();
|
||||
perThreadData = thread->threadData.ptr();
|
||||
}
|
||||
|
||||
frontend::CompileError &
|
||||
@ -1031,7 +1030,7 @@ HelperThread::handleParseWorkload()
|
||||
|
||||
{
|
||||
AutoUnlockHelperThreadState unlock;
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.addr(),
|
||||
PerThreadData::AutoEnterRuntime enter(threadData.ptr(),
|
||||
parseTask->exclusiveContextGlobal->runtimeFromAnyThread());
|
||||
SourceBufferHolder srcBuf(parseTask->chars, parseTask->length,
|
||||
SourceBufferHolder::NoOwnership);
|
||||
@ -1187,7 +1186,7 @@ HelperThread::threadLoop()
|
||||
JS::AutoSuppressGCAnalysis nogc;
|
||||
AutoLockHelperThreadState lock;
|
||||
|
||||
js::TlsPerThreadData.set(threadData.addr());
|
||||
js::TlsPerThreadData.set(threadData.ptr());
|
||||
|
||||
// Compute the thread's stack limit, for over-recursed checks.
|
||||
uintptr_t stackLimit = GetNativeStackBase();
|
||||
@ -1196,8 +1195,8 @@ HelperThread::threadLoop()
|
||||
#else
|
||||
stackLimit -= HELPER_STACK_QUOTA;
|
||||
#endif
|
||||
for (size_t i = 0; i < ArrayLength(threadData.ref().nativeStackLimit); i++)
|
||||
threadData.ref().nativeStackLimit[i] = stackLimit;
|
||||
for (size_t i = 0; i < ArrayLength(threadData->nativeStackLimit); i++)
|
||||
threadData->nativeStackLimit[i] = stackLimit;
|
||||
|
||||
while (true) {
|
||||
JS_ASSERT(idle());
|
||||
|
@ -304,11 +304,11 @@ RegExpObject::createNoStatics(ExclusiveContext *cx, HandleAtom source, RegExpFla
|
||||
Maybe<CompileOptions> dummyOptions;
|
||||
Maybe<TokenStream> dummyTokenStream;
|
||||
if (!tokenStream) {
|
||||
dummyOptions.construct(cx->asJSContext());
|
||||
dummyTokenStream.construct(cx, dummyOptions.ref(),
|
||||
dummyOptions.emplace(cx->asJSContext());
|
||||
dummyTokenStream.emplace(cx, *dummyOptions,
|
||||
(const jschar *) nullptr, 0,
|
||||
(frontend::StrictModeGetter *) nullptr);
|
||||
tokenStream = dummyTokenStream.addr();
|
||||
tokenStream = dummyTokenStream.ptr();
|
||||
}
|
||||
|
||||
if (!irregexp::ParsePatternSyntax(*tokenStream, alloc, source))
|
||||
|
@ -202,7 +202,7 @@ AutoRooterGetterSetter::AutoRooterGetterSetter(ThreadSafeContext *cx, uint8_t at
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
{
|
||||
if (attrs & (JSPROP_GETTER | JSPROP_SETTER))
|
||||
inner.construct(cx, attrs, pgetter, psetter);
|
||||
inner.emplace(cx, attrs, pgetter, psetter);
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
|
@ -341,11 +341,11 @@ class MOZ_STACK_CLASS ComponentLoaderInfo {
|
||||
return mScriptChannel->GetURI(getter_AddRefs(mResolvedURI));
|
||||
}
|
||||
|
||||
nsAutoCString& Key() { return mKey.ref(); }
|
||||
nsAutoCString& Key() { return *mKey; }
|
||||
nsresult EnsureKey() {
|
||||
ENSURE_DEPS(ResolvedURI);
|
||||
mKey.construct();
|
||||
return mResolvedURI->GetSpec(mKey.ref());
|
||||
mKey.emplace();
|
||||
return mResolvedURI->GetSpec(*mKey);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1113,7 +1113,7 @@ mozJSComponentLoader::Import(const nsACString& registryLocation,
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (targetObject) {
|
||||
ac.construct(cx, targetObject);
|
||||
ac.emplace(cx, targetObject);
|
||||
}
|
||||
|
||||
RootedObject global(cx);
|
||||
|
@ -185,7 +185,7 @@ StackScopedClone(JSContext *cx, StackScopedCloneOptions &options,
|
||||
// (unless it's a primitive)
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (val.isObject()) {
|
||||
ac.construct(cx, &val.toObject());
|
||||
ac.emplace(cx, &val.toObject());
|
||||
} else if (val.isString() && !JS_WrapValue(cx, val)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3191,7 +3191,7 @@ nsXPCComponents_Utils::Dispatch(HandleValue runnableArg, HandleValue scope,
|
||||
JSObject *scopeObj = js::UncheckedUnwrap(&scope.toObject());
|
||||
if (!scopeObj)
|
||||
return NS_ERROR_FAILURE;
|
||||
ac.construct(cx, scopeObj);
|
||||
ac.emplace(cx, scopeObj);
|
||||
if (!JS_WrapValue(cx, &runnable))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1187,7 +1187,7 @@ class WatchdogManager : public nsIObserver
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
Maybe<AutoLockWatchdog> lock;
|
||||
if (mWatchdog)
|
||||
lock.construct(mWatchdog);
|
||||
lock.emplace(mWatchdog);
|
||||
|
||||
// Write state.
|
||||
mTimestamps[TimestampRuntimeStateChange] = PR_Now();
|
||||
@ -1211,7 +1211,7 @@ class WatchdogManager : public nsIObserver
|
||||
// The watchdog thread always holds the lock when it runs.
|
||||
Maybe<AutoLockWatchdog> maybeLock;
|
||||
if (NS_IsMainThread() && mWatchdog)
|
||||
maybeLock.construct(mWatchdog);
|
||||
maybeLock.emplace(mWatchdog);
|
||||
mTimestamps[aCategory] = PR_Now();
|
||||
}
|
||||
PRTime GetTimestamp(WatchdogTimestampCategory aCategory)
|
||||
@ -1219,7 +1219,7 @@ class WatchdogManager : public nsIObserver
|
||||
// The watchdog thread always holds the lock when it runs.
|
||||
Maybe<AutoLockWatchdog> maybeLock;
|
||||
if (NS_IsMainThread() && mWatchdog)
|
||||
maybeLock.construct(mWatchdog);
|
||||
maybeLock.emplace(mWatchdog);
|
||||
return mTimestamps[aCategory];
|
||||
}
|
||||
|
||||
|
@ -648,8 +648,8 @@ static Maybe<PersistentRootedValue> sScriptedInterruptCallback;
|
||||
static bool
|
||||
XPCShellInterruptCallback(JSContext *cx)
|
||||
{
|
||||
MOZ_ASSERT(!sScriptedInterruptCallback.empty());
|
||||
RootedValue callback(cx, sScriptedInterruptCallback.ref());
|
||||
MOZ_ASSERT(sScriptedInterruptCallback);
|
||||
RootedValue callback(cx, *sScriptedInterruptCallback);
|
||||
|
||||
// If no interrupt callback was set by script, no-op.
|
||||
if (callback.isUndefined())
|
||||
@ -671,7 +671,7 @@ XPCShellInterruptCallback(JSContext *cx)
|
||||
static bool
|
||||
SetInterruptCallback(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
MOZ_ASSERT(!sScriptedInterruptCallback.empty());
|
||||
MOZ_ASSERT(sScriptedInterruptCallback);
|
||||
|
||||
// Sanity-check args.
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
@ -682,7 +682,7 @@ SetInterruptCallback(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
// Allow callers to remove the interrupt callback by passing undefined.
|
||||
if (args[0].isUndefined()) {
|
||||
sScriptedInterruptCallback.ref() = UndefinedValue();
|
||||
*sScriptedInterruptCallback = UndefinedValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -692,7 +692,7 @@ SetInterruptCallback(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
sScriptedInterruptCallback.ref() = args[0];
|
||||
*sScriptedInterruptCallback = args[0];
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1459,7 +1459,7 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
|
||||
// Override the default XPConnect interrupt callback. We could store the
|
||||
// old one and restore it before shutting down, but there's not really a
|
||||
// reason to bother.
|
||||
sScriptedInterruptCallback.construct(rt, UndefinedValue());
|
||||
sScriptedInterruptCallback.emplace(rt, UndefinedValue());
|
||||
JS_SetInterruptCallback(rt, XPCShellInterruptCallback);
|
||||
|
||||
dom::AutoJSAPI jsapi;
|
||||
@ -1590,7 +1590,7 @@ XRE_XPCShellMain(int argc, char **argv, char **envp)
|
||||
rv = NS_ShutdownXPCOM( nullptr );
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
||||
|
||||
sScriptedInterruptCallback.destroyIfConstructed();
|
||||
sScriptedInterruptCallback.reset();
|
||||
|
||||
#ifdef TEST_CALL_ON_WRAPPED_JS_AFTER_SHUTDOWN
|
||||
// test of late call and release (see above)
|
||||
|
@ -46,7 +46,7 @@ bool AutoScriptEvaluate::StartEvaluating(HandleObject scope, JSErrorReporter err
|
||||
}
|
||||
|
||||
JS_BeginRequest(mJSContext);
|
||||
mAutoCompartment.construct(mJSContext, scope);
|
||||
mAutoCompartment.emplace(mJSContext, scope);
|
||||
|
||||
// Saving the exception state keeps us from interfering with another script
|
||||
// that may also be running on this context. This occurred first with the
|
||||
@ -54,7 +54,7 @@ bool AutoScriptEvaluate::StartEvaluating(HandleObject scope, JSErrorReporter err
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=88130 but presumably could
|
||||
// show up in any situation where a script calls into a wrapped js component
|
||||
// on the same context, while the context has a nonzero exception state.
|
||||
mState.construct(mJSContext);
|
||||
mState.emplace(mJSContext);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -63,7 +63,7 @@ AutoScriptEvaluate::~AutoScriptEvaluate()
|
||||
{
|
||||
if (!mJSContext || !mEvaluated)
|
||||
return;
|
||||
mState.ref().restore();
|
||||
mState->restore();
|
||||
|
||||
JS_EndRequest(mJSContext);
|
||||
|
||||
|
@ -366,7 +366,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
|
||||
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(parent),
|
||||
"Xray wrapper being used to parent XPCWrappedNative?");
|
||||
|
||||
ac.construct(static_cast<JSContext*>(cx), parent);
|
||||
ac.emplace(static_cast<JSContext*>(cx), parent);
|
||||
|
||||
if (parent != plannedParent) {
|
||||
XPCWrappedNativeScope* betterScope = ObjectScope(parent);
|
||||
@ -397,7 +397,7 @@ XPCWrappedNative::GetNewOrUsed(xpcObjectHelper& helper,
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
ac.construct(static_cast<JSContext*>(cx), parent);
|
||||
ac.emplace(static_cast<JSContext*>(cx), parent);
|
||||
}
|
||||
|
||||
AutoMarkingWrappedNativeProtoPtr proto(cx);
|
||||
|
@ -39,21 +39,21 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull)
|
||||
// Enter a request and a compartment for the duration that the cx is on the
|
||||
// stack if non-null.
|
||||
if (cx) {
|
||||
mAutoRequest.construct(cx);
|
||||
mAutoRequest.emplace(cx);
|
||||
|
||||
// DOM JSContexts don't store their default compartment object on the cx.
|
||||
JSObject *compartmentObject = mScx ? mScx->GetWindowProxy()
|
||||
: js::DefaultObjectForContextOrNull(cx);
|
||||
if (compartmentObject)
|
||||
mAutoCompartment.construct(cx, compartmentObject);
|
||||
mAutoCompartment.emplace(cx, compartmentObject);
|
||||
}
|
||||
}
|
||||
|
||||
AutoCxPusher::~AutoCxPusher()
|
||||
{
|
||||
// Leave the compartment and request before popping.
|
||||
mAutoCompartment.destroyIfConstructed();
|
||||
mAutoRequest.destroyIfConstructed();
|
||||
mAutoCompartment.reset();
|
||||
mAutoRequest.reset();
|
||||
|
||||
// When we push a context, we may save the frame chain and pretend like we
|
||||
// haven't entered any compartment. This gets restored on Pop(), but we can
|
||||
@ -103,7 +103,7 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
|
||||
if (!mCx) {
|
||||
mCx = xpc->GetSafeJSContext();
|
||||
mPusher.construct(mCx);
|
||||
mPusher.emplace(mCx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,10 +118,10 @@ ThreadsafeAutoJSContext::ThreadsafeAutoJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
mCx = nullptr;
|
||||
mAutoJSContext.construct();
|
||||
mAutoJSContext.emplace();
|
||||
} else {
|
||||
mCx = mozilla::dom::workers::GetCurrentThreadJSContext();
|
||||
mRequest.construct(mCx);
|
||||
mRequest.emplace(mCx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ ThreadsafeAutoJSContext::operator JSContext*() const
|
||||
if (mCx) {
|
||||
return mCx;
|
||||
} else {
|
||||
return mAutoJSContext.ref();
|
||||
return *mAutoJSContext;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,10 +146,10 @@ ThreadsafeAutoSafeJSContext::ThreadsafeAutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFI
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
mCx = nullptr;
|
||||
mAutoSafeJSContext.construct();
|
||||
mAutoSafeJSContext.emplace();
|
||||
} else {
|
||||
mCx = mozilla::dom::workers::GetCurrentThreadJSContext();
|
||||
mRequest.construct(mCx);
|
||||
mRequest.emplace(mCx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ ThreadsafeAutoSafeJSContext::operator JSContext*() const
|
||||
if (mCx) {
|
||||
return mCx;
|
||||
} else {
|
||||
return mAutoSafeJSContext.ref();
|
||||
return *mAutoSafeJSContext;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,9 +396,9 @@ public:
|
||||
StringType* Create()
|
||||
{
|
||||
for (uint32_t i = 0; i < ArrayLength(mStrings); ++i) {
|
||||
if (mStrings[i].empty()) {
|
||||
mStrings[i].construct();
|
||||
return mStrings[i].addr();
|
||||
if (!mStrings[i]) {
|
||||
mStrings[i].emplace();
|
||||
return mStrings[i].ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,11 +409,10 @@ public:
|
||||
void Destroy(StringType *string)
|
||||
{
|
||||
for (uint32_t i = 0; i < ArrayLength(mStrings); ++i) {
|
||||
if (!mStrings[i].empty() &&
|
||||
mStrings[i].addr() == string) {
|
||||
if (mStrings[i] && mStrings[i].ptr() == string) {
|
||||
// One of our internal strings is no longer in use, mark
|
||||
// it as such and free its data.
|
||||
mStrings[i].destroy();
|
||||
mStrings[i].reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -427,7 +426,7 @@ public:
|
||||
{
|
||||
#ifdef DEBUG
|
||||
for (uint32_t i = 0; i < ArrayLength(mStrings); ++i) {
|
||||
MOZ_ASSERT(mStrings[i].empty(), "Short lived string still in use");
|
||||
MOZ_ASSERT(!mStrings[i], "Short lived string still in use");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2282,7 +2282,7 @@ HasNativeProperty(JSContext *cx, HandleObject wrapper, HandleId id, bool *hasPro
|
||||
// Try resolveOwnProperty.
|
||||
Maybe<ResolvingId> resolvingId;
|
||||
if (traits == &XPCWrappedNativeXrayTraits::singleton)
|
||||
resolvingId.construct(cx, wrapper, id);
|
||||
resolvingId.emplace(cx, wrapper, id);
|
||||
if (!traits->resolveOwnProperty(cx, *handler, wrapper, holder, id, &desc))
|
||||
return false;
|
||||
if (desc.object()) {
|
||||
|
Loading…
Reference in New Issue
Block a user