Merge inbound to mozilla-central. a=merge

This commit is contained in:
Brindusan Cristian 2018-06-24 00:45:20 +03:00
commit d6f7c182cc
64 changed files with 342 additions and 218 deletions

View File

@ -29,6 +29,7 @@
#include "mozilla/MozPromise.h"
#include "mozilla/Mutex.h"
#include "mozilla/NotNull.h"
#include "mozilla/Scoped.h"
#include "mozilla/UniquePtr.h"
#include "MainThreadUtils.h"
#include "nsILabelableRunnable.h"

View File

@ -12,7 +12,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/Compiler.h"
#include "mozilla/Move.h"
#include "mozilla/Scoped.h"
#include "mozilla/TemplateLib.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WrappingOperations.h"
@ -606,33 +605,6 @@ js_pod_realloc(T* prior, size_t oldSize, size_t newSize)
return static_cast<T*>(js_realloc(prior, bytes));
}
namespace js {
template<typename T>
struct ScopedFreePtrTraits
{
typedef T* type;
static T* empty() { return nullptr; }
static void release(T* ptr) { js_free(ptr); }
};
SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits)
template <typename T>
struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T>
{
static void release(T* ptr) { js_delete(ptr); }
};
SCOPED_TEMPLATE(ScopedJSDeletePtr, ScopedDeletePtrTraits)
template <typename T>
struct ScopedReleasePtrTraits : public ScopedFreePtrTraits<T>
{
static void release(T* ptr) { if (ptr) ptr->release(); }
};
SCOPED_TEMPLATE(ScopedReleasePtr, ScopedReleasePtrTraits)
} /* namespace js */
namespace JS {
template<typename T>

View File

@ -3351,7 +3351,7 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
if (!src)
return false;
ScopedJSFreePtr<char> filename;
UniqueChars filename;
uint32_t lineno = 1;
bool loc = true;
RootedObject builder(cx);
@ -3390,7 +3390,7 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
if (!str)
return false;
filename = JS_EncodeString(cx, str);
filename.reset(JS_EncodeString(cx, str));
if (!filename)
return false;
}
@ -3451,7 +3451,7 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
}
/* Extract the builder methods first to report errors before parsing. */
ASTSerializer serialize(cx, loc, filename, lineno);
ASTSerializer serialize(cx, loc, filename.get(), lineno);
if (!serialize.init(builder))
return false;
@ -3464,7 +3464,7 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
return false;
CompileOptions options(cx);
options.setFileAndLine(filename, lineno);
options.setFileAndLine(filename.get(), lineno);
options.setCanLazilyParse(false);
options.allowHTMLComments = target == ParseGoal::Script;
mozilla::Range<const char16_t> chars = linearChars.twoByteRange();

View File

@ -39,6 +39,7 @@
#include "gc/Policy.h"
#include "gc/Zone.h"
#include "jit/AtomicOperations.h"
#include "js/UniquePtr.h"
#include "js/Vector.h"
#include "util/Windows.h"
#include "vm/JSContext.h"
@ -8393,7 +8394,7 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, Value* vp)
valCodeType);
}
ScopedJSFreePtr<void> cargs(malloc(sizeArg));
UniquePtr<void, JS::FreePolicy> cargs(malloc(sizeArg));
if (!ImplicitConvert(cx, valData, objArgType, cargs.get(),
ConversionType::Finalizer, &freePointer,
@ -8408,10 +8409,9 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, Value* vp)
// 4. Prepare buffer for holding return value
ScopedJSFreePtr<void> rvalue;
UniquePtr<void, JS::FreePolicy> rvalue;
if (CType::GetTypeCode(returnType) != TYPE_void_t) {
rvalue = malloc(Align(CType::GetSize(returnType),
sizeof(ffi_arg)));
rvalue.reset(malloc(Align(CType::GetSize(returnType), sizeof(ffi_arg))));
} //Otherwise, simply do not allocate
// 5. Create |objResult|
@ -8465,18 +8465,18 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, Value* vp)
}
// 7. Store C information as private
ScopedJSFreePtr<CDataFinalizer::Private>
UniquePtr<CDataFinalizer::Private, JS::FreePolicy>
p((CDataFinalizer::Private*)malloc(sizeof(CDataFinalizer::Private)));
memmove(&p->CIF, &funInfoFinalizer->mCIF, sizeof(ffi_cif));
p->cargs = cargs.forget();
p->rvalue = rvalue.forget();
p->cargs = cargs.release();
p->rvalue = rvalue.release();
p->cargs_size = sizeArg;
p->code = code;
JS_SetPrivate(objResult, p.forget());
JS_SetPrivate(objResult, p.release());
args.rval().setObject(*objResult);
return true;
}

View File

@ -102,6 +102,9 @@ class OrderedHashTable
: hashTable(nullptr),
data(nullptr),
dataLength(0),
dataCapacity(0),
liveCount(0),
hashShift(0),
ranges(nullptr),
nurseryRanges(nullptr),
alloc(ap),

View File

@ -108,6 +108,7 @@ class BinASTParser : public BinASTParserBase, public ErrorReporter, public BCEPa
BinASTParser(JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames, const JS::ReadOnlyCompileOptions& options)
: BinASTParserBase(cx, alloc, usedNames)
, options_(options)
, variableDeclarationKind_(VariableDeclarationKind::Var)
{
}
~BinASTParser()

View File

@ -75,6 +75,7 @@ class MOZ_STACK_CLASS BinTokenReaderBase
protected:
BinTokenReaderBase(JSContext* cx, const uint8_t* start, const size_t length)
: cx_(cx)
, poisoned_(false)
, start_(start)
, current_(start)
, stop_(start + length)

View File

@ -344,7 +344,8 @@ BinTokenReaderMultipart::AutoBase::init()
}
BinTokenReaderMultipart::AutoBase::AutoBase(BinTokenReaderMultipart& reader)
: reader_(reader)
: initialized_(false)
, reader_(reader)
{ }
BinTokenReaderMultipart::AutoBase::~AutoBase()

View File

@ -355,7 +355,8 @@ BinTokenReaderTester::AutoBase::init()
}
BinTokenReaderTester::AutoBase::AutoBase(BinTokenReaderTester& reader)
: reader_(reader)
: initialized_(false)
, reader_(reader)
{ }
BinTokenReaderTester::AutoBase::~AutoBase()

View File

@ -1696,7 +1696,8 @@ class MOZ_STACK_CLASS TryEmitter
controlKind_(controlKind),
depth_(0),
noteIndex_(0),
tryStart_(0)
tryStart_(0),
tryEnd_{}
#ifdef DEBUG
, state_(State::Start)
#endif
@ -2511,6 +2512,7 @@ BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent,
prologue(cx, lineNum),
main(cx, lineNum),
current(&main),
parser(nullptr),
atomIndices(cx->frontendCollectionPool()),
firstLine(lineNum),
maxFixedSlots(0),

View File

@ -113,7 +113,9 @@ struct RecyclableAtomMapValueWrapper
"Can only recycle atom maps with values smaller than uint64");
}
RecyclableAtomMapValueWrapper() {
RecyclableAtomMapValueWrapper()
: dummy(0)
{
assertInvariant();
}

View File

@ -196,7 +196,10 @@ struct TokenPos {
uint32_t begin; // Offset of the token's first char.
uint32_t end; // Offset of 1 past the token's last char.
TokenPos() {}
TokenPos()
: begin(0),
end(0)
{}
TokenPos(uint32_t begin, uint32_t end) : begin(begin), end(end) {}
// Return a TokenPos that covers left, right, and anything in between.

View File

@ -433,16 +433,12 @@ class Nursery
ProfileDurations profileDurations_;
ProfileDurations totalDurations_;
/*
* This data is initialised only if the nursery is enabled and after at
* least one call to Nursery::collect()
*/
struct {
JS::gcreason::Reason reason;
size_t nurseryCapacity;
size_t nurseryLazyCapacity;
size_t nurseryUsedBytes;
size_t tenuredBytes;
JS::gcreason::Reason reason = JS::gcreason::NO_REASON;
size_t nurseryCapacity = 0;
size_t nurseryLazyCapacity = 0;
size_t nurseryUsedBytes = 0;
size_t tenuredBytes = 0;
} previousGC;
/*

View File

@ -134,7 +134,9 @@ class FakeMutableHandle : public js::MutableHandleBase<T, FakeMutableHandle<T>>
DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(*ptr);
private:
FakeMutableHandle() {}
FakeMutableHandle()
: ptr(nullptr)
{}
DELETE_ASSIGNMENT_OPS(FakeMutableHandle, T);
T* ptr;

View File

@ -744,6 +744,9 @@ Statistics::Statistics(JSRuntime* rt)
thresholdTriggered(false),
triggerAmount(0.0),
triggerThreshold(0.0),
startingMinorGCNumber(0),
startingMajorGCNumber(0),
startingSliceNumber(0),
maxPauseInInterval(0),
sliceCallback(nullptr),
nurseryCollectionCallback(nullptr),

View File

@ -221,7 +221,8 @@ struct Statistics
finalState(gc::State::NotActive),
resetReason(gc::AbortReason::None),
start(start),
startFaults(startFaults)
startFaults(startFaults),
endFaults(0)
{}
SliceBudget budget;

View File

@ -1652,6 +1652,7 @@ RegExpCompiler::RegExpCompiler(JSContext* cx, LifoAlloc* alloc, int capture_coun
bool ignore_case, bool latin1, bool match_only, bool unicode)
: next_register_(2 * (capture_count + 1)),
recursion_depth_(0),
macro_assembler_(nullptr),
ignore_case_(ignore_case),
latin1_(latin1),
match_only_(match_only),

View File

@ -686,6 +686,7 @@ class ActionNode : public SeqRegExpNode
ActionNode(ActionType action_type, RegExpNode* on_success)
: SeqRegExpNode(on_success),
data_{},
action_type_(action_type)
{}

View File

@ -9,6 +9,7 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/Unused.h"
#include "gc/FreeOp.h"
#include "gc/Marking.h"
@ -46,6 +47,7 @@
#include "jit/ValueNumbering.h"
#include "jit/WasmBCE.h"
#include "js/Printf.h"
#include "js/UniquePtr.h"
#include "util/Windows.h"
#include "vm/Debugger.h"
#include "vm/HelperThreads.h"
@ -2045,13 +2047,11 @@ IonCompile(JSContext* cx, JSScript* script,
TrackPropertiesForSingletonScopes(cx, script, baselineFrame);
LifoAlloc* alloc = cx->new_<LifoAlloc>(TempAllocator::PreferredLifoChunkSize);
auto alloc = cx->make_unique<LifoAlloc>(TempAllocator::PreferredLifoChunkSize);
if (!alloc)
return AbortReason::Alloc;
ScopedJSDeletePtr<LifoAlloc> autoDelete(alloc);
TempAllocator* temp = alloc->new_<TempAllocator>(alloc);
TempAllocator* temp = alloc->new_<TempAllocator>(alloc.get());
if (!temp)
return AbortReason::Alloc;
@ -2184,16 +2184,15 @@ IonCompile(JSContext* cx, JSScript* script,
// The allocator and associated data will be destroyed after being
// processed in the finishedOffThreadCompilations list.
autoDelete.forget();
mozilla::Unused << alloc.release();
return AbortReason::NoAbort;
}
bool succeeded = false;
{
ScopedJSDeletePtr<CodeGenerator> codegen;
AutoEnterAnalysis enter(cx);
codegen = CompileBackEnd(builder);
UniquePtr<CodeGenerator> codegen(CompileBackEnd(builder));
if (!codegen) {
JitSpew(JitSpew_IonAbort, "Failed during back-end compilation.");
if (cx->isExceptionPending())
@ -2201,7 +2200,7 @@ IonCompile(JSContext* cx, JSScript* script,
return AbortReason::Disable;
}
succeeded = LinkCodeGen(cx, builder, codegen);
succeeded = LinkCodeGen(cx, builder, codegen.get());
}
if (succeeded)

View File

@ -24,6 +24,8 @@ class TestTracer : public JS::CallbackTracer
explicit TestTracer(JSContext* cx)
: JS::CallbackTracer(cx),
expectedCell(nullptr),
expectedKind(static_cast<JS::TraceKind>(0)),
found(false)
{ }
};

View File

@ -479,7 +479,11 @@ class AutoLeaveZeal
uint32_t frequency_;
public:
explicit AutoLeaveZeal(JSContext* cx) : cx_(cx) {
explicit AutoLeaveZeal(JSContext* cx)
: cx_(cx),
zealBits_(0),
frequency_(0)
{
uint32_t dummy;
JS_GetGCZealBits(cx_, &zealBits_, &frequency_, &dummy);
JS_SetGCZeal(cx_, 0, 0);

View File

@ -6630,7 +6630,7 @@ JS_NewRegExpObject(JSContext* cx, const char* bytes, size_t length, unsigned fla
AssertHeapIsIdle();
CHECK_REQUEST(cx);
ScopedJSFreePtr<char16_t> chars(InflateString(cx, bytes, length));
UniqueTwoByteChars chars(InflateString(cx, bytes, length));
if (!chars)
return nullptr;
@ -6869,7 +6869,10 @@ JS::AutoSaveExceptionState::~AutoSaveExceptionState()
}
struct JSExceptionState {
explicit JSExceptionState(JSContext* cx) : exception(cx) {}
explicit JSExceptionState(JSContext* cx)
: throwing(false),
exception(cx)
{}
bool throwing;
PersistentRootedValue exception;
};

View File

@ -1424,7 +1424,7 @@ class MOZ_STACK_CLASS JS_FRIEND_API(AutoStableStringChars)
/* Ensure the string is kept alive while we're using its chars. */
JS::RootedString s_;
union {
MOZ_INIT_OUTSIDE_CTOR union {
const char16_t* twoByteChars_;
const JS::Latin1Char* latin1Chars_;
};

View File

@ -86,7 +86,7 @@ ComputeAccurateDecimalInteger(JSContext* cx, const CharT* start, const CharT* en
double* dp)
{
size_t length = end - start;
ScopedJSFreePtr<char> cstr(cx->pod_malloc<char>(length + 1));
UniqueChars cstr(cx->pod_malloc<char>(length + 1));
if (!cstr)
return false;
@ -101,7 +101,7 @@ ComputeAccurateDecimalInteger(JSContext* cx, const CharT* start, const CharT* en
return false;
char* estr;
*dp = js_strtod_harder(cx->dtoaState, cstr, &estr);
*dp = js_strtod_harder(cx->dtoaState, cstr.get(), &estr);
return true;
}

View File

@ -884,7 +884,7 @@ InitModuleLoader(JSContext* cx)
// the module loader for the current compartment.
uint32_t srcLen = moduleloader::GetRawScriptsSize();
ScopedJSFreePtr<char> src(cx->pod_malloc<char>(srcLen));
UniqueChars src(cx->pod_malloc<char>(srcLen));
if (!src || !DecompressString(moduleloader::compressedSources, moduleloader::GetCompressedSize(),
reinterpret_cast<unsigned char*>(src.get()), srcLen))
{
@ -900,7 +900,7 @@ InitModuleLoader(JSContext* cx)
options.strictOption = true;
RootedValue rv(cx);
return Evaluate(cx, options, src, srcLen, &rv);
return Evaluate(cx, options, src.get(), srcLen, &rv);
}
static bool

View File

@ -7,6 +7,7 @@
#include "util/StringBuffer.h"
#include "mozilla/Range.h"
#include "mozilla/Unused.h"
#include "vm/JSObject-inl.h"
#include "vm/StringType-inl.h"
@ -79,7 +80,7 @@ FinishStringFlat(JSContext* cx, StringBuffer& sb, Buffer& cb)
if (!sb.append('\0'))
return nullptr;
ScopedJSFreePtr<CharT> buf(ExtractWellSized<CharT>(cx, cb));
UniquePtr<CharT[], JS::FreePolicy> buf(ExtractWellSized<CharT>(cx, cb));
if (!buf)
return nullptr;
@ -93,7 +94,7 @@ FinishStringFlat(JSContext* cx, StringBuffer& sb, Buffer& cb)
*/
cx->updateMallocCounter(sizeof(CharT) * len);
buf.forget();
mozilla::Unused << buf.release();
return str;
}

View File

@ -473,7 +473,7 @@ class SrcNoteLineScanner
public:
SrcNoteLineScanner(jssrcnote* sn, uint32_t lineno)
: offset(0), sn(sn), lineno(lineno)
: offset(0), sn(sn), lineno(lineno), lineHeader(false)
{
}

View File

@ -83,7 +83,7 @@ struct EvalCacheLookup
explicit EvalCacheLookup(JSContext* cx) : str(cx), callerScript(cx) {}
RootedLinearString str;
RootedScript callerScript;
jsbytecode* pc;
MOZ_INIT_OUTSIDE_CTOR jsbytecode* pc;
};
struct EvalCacheHashPolicy

View File

@ -127,22 +127,22 @@ CopyStringPure(JSContext* cx, JSString* str)
}
if (str->hasLatin1Chars()) {
ScopedJSFreePtr<Latin1Char> copiedChars;
if (!str->asRope().copyLatin1CharsZ(cx, copiedChars))
UniquePtr<Latin1Char[], JS::FreePolicy> copiedChars = str->asRope().copyLatin1CharsZ(cx);
if (!copiedChars)
return nullptr;
auto* rawCopiedChars = copiedChars.forget();
auto* rawCopiedChars = copiedChars.release();
auto* result = NewString<CanGC>(cx, rawCopiedChars, len);
if (!result)
js_free(rawCopiedChars);
return result;
}
ScopedJSFreePtr<char16_t> copiedChars;
if (!str->asRope().copyTwoByteCharsZ(cx, copiedChars))
UniqueTwoByteChars copiedChars = str->asRope().copyTwoByteCharsZ(cx);
if (!copiedChars)
return nullptr;
auto* rawCopiedChars = copiedChars.forget();
auto* rawCopiedChars = copiedChars.release();
auto* result = NewStringDontDeflate<CanGC>(cx, rawCopiedChars, len);
if (!result)
js_free(rawCopiedChars);

View File

@ -45,6 +45,13 @@ Compressor::Compressor(const unsigned char* inp, size_t inplen)
zs.avail_out = 0;
zs.zalloc = zlib_alloc;
zs.zfree = zlib_free;
zs.total_in = 0;
zs.total_out = 0;
zs.msg = nullptr;
zs.state = nullptr;
zs.data_type = 0;
zs.adler = 0;
zs.reserved = 0;
// Reserve space for the CompressedDataHeader.
outbytes = sizeof(CompressedDataHeader);

View File

@ -4230,9 +4230,13 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
displayURLString(cx),
hasSource(false),
source(cx, AsVariant(static_cast<ScriptSourceObject*>(nullptr))),
hasLine(false),
line(0),
innermost(false),
innermostForRealm(cx->zone()),
vector(cx, ScriptVector(cx)),
wasmInstanceVector(cx, WasmInstanceObjectVector(cx))
wasmInstanceVector(cx, WasmInstanceObjectVector(cx)),
oom(false)
{}
/*
@ -5463,7 +5467,10 @@ struct DebuggerScriptGetLineCountMatcher
JSContext* cx_;
double totalLines;
explicit DebuggerScriptGetLineCountMatcher(JSContext* cx) : cx_(cx) {}
explicit DebuggerScriptGetLineCountMatcher(JSContext* cx)
: cx_(cx),
totalLines(0.0)
{}
using ReturnType = bool;
ReturnType match(HandleScript script) {
@ -6687,7 +6694,11 @@ class DebuggerScriptIsInCatchScopeMatcher
bool isInCatch_;
public:
explicit DebuggerScriptIsInCatchScopeMatcher(JSContext* cx, size_t offset) : cx_(cx), offset_(offset) { }
explicit DebuggerScriptIsInCatchScopeMatcher(JSContext* cx, size_t offset)
: cx_(cx),
offset_(offset),
isInCatch_(false)
{ }
using ReturnType = bool;
inline bool isInCatch() const { return isInCatch_; }

View File

@ -14,6 +14,7 @@
#include "frontend/BytecodeCompiler.h"
#include "gc/GCInternals.h"
#include "jit/IonBuilder.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"
#include "threading/CpuCount.h"
#include "util/NativeStack.h"
@ -826,12 +827,11 @@ js::StartOffThreadParseScript(JSContext* cx, const ReadOnlyCompileOptions& optio
const char16_t* chars, size_t length,
JS::OffThreadCompileCallback callback, void* callbackData)
{
ScopedJSDeletePtr<ParseTask> task;
task = cx->new_<ScriptParseTask>(cx, chars, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task, options))
auto task = cx->make_unique<ScriptParseTask>(cx, chars, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task.get(), options))
return false;
task.forget();
Unused << task.release();
return true;
}
@ -840,12 +840,11 @@ js::StartOffThreadParseModule(JSContext* cx, const ReadOnlyCompileOptions& optio
const char16_t* chars, size_t length,
JS::OffThreadCompileCallback callback, void* callbackData)
{
ScopedJSDeletePtr<ParseTask> task;
task = cx->new_<ModuleParseTask>(cx, chars, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task, options))
auto task = cx->make_unique<ModuleParseTask>(cx, chars, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task.get(), options))
return false;
task.forget();
Unused << task.release();
return true;
}
@ -854,12 +853,11 @@ js::StartOffThreadDecodeScript(JSContext* cx, const ReadOnlyCompileOptions& opti
const JS::TranscodeRange& range,
JS::OffThreadCompileCallback callback, void* callbackData)
{
ScopedJSDeletePtr<ParseTask> task;
task = cx->new_<ScriptDecodeTask>(cx, range, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task, options))
auto task = cx->make_unique<ScriptDecodeTask>(cx, range, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task.get(), options))
return false;
task.forget();
Unused << task.release();
return true;
}
@ -868,12 +866,11 @@ js::StartOffThreadDecodeMultiScripts(JSContext* cx, const ReadOnlyCompileOptions
JS::TranscodeSources& sources,
JS::OffThreadCompileCallback callback, void* callbackData)
{
ScopedJSDeletePtr<ParseTask> task;
task = cx->new_<MultiScriptsDecodeTask>(cx, sources, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task, options))
auto task = cx->make_unique<MultiScriptsDecodeTask>(cx, sources, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task.get(), options))
return false;
task.forget();
Unused << task.release();
return true;
}
@ -884,12 +881,11 @@ js::StartOffThreadDecodeBinAST(JSContext* cx, const ReadOnlyCompileOptions& opti
const uint8_t* buf, size_t length,
JS::OffThreadCompileCallback callback, void *callbackData)
{
ScopedJSDeletePtr<ParseTask> task;
task = cx->new_<BinASTDecodeTask>(cx, buf, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task, options))
auto task = cx->make_unique<BinASTDecodeTask>(cx, buf, length, callback, callbackData);
if (!task || !StartOffThreadParseTask(cx, task.get(), options))
return false;
task.forget();
Unused << task.release();
return true;
}
@ -1665,18 +1661,18 @@ GlobalHelperThreadState::finishParseTask(JSContext* cx, ParseTaskKind kind,
{
MOZ_ASSERT(cx->realm());
ScopedJSDeletePtr<ParseTask> parseTask(removeFinishedParseTask(kind, token));
Rooted<UniquePtr<ParseTask>> parseTask(cx, removeFinishedParseTask(kind, token));
// Make sure we have all the constructors we need for the prototype
// remapping below, since we can't GC while that's happening.
if (!EnsureParserCreatedClasses(cx, kind)) {
LeaveParseTaskZone(cx->runtime(), parseTask);
LeaveParseTaskZone(cx->runtime(), parseTask.get().get());
return false;
}
mergeParseTaskRealm(cx, parseTask, cx->realm());
mergeParseTaskRealm(cx, parseTask.get().get(), cx->realm());
bool ok = finishCallback(parseTask);
bool ok = finishCallback(parseTask.get().get());
for (auto& script : parseTask->scripts)
releaseAssertSameCompartment(cx, script);
@ -1690,8 +1686,7 @@ GlobalHelperThreadState::finishParseTask(JSContext* cx, ParseTaskKind kind,
return false;
}
// Report any error or warnings generated during the parse, and inform the
// debugger about the compiled scripts.
// Report any error or warnings generated during the parse.
for (size_t i = 0; i < parseTask->errors.length(); i++)
parseTask->errors[i]->throwError(cx);
if (parseTask->overRecursed)

View File

@ -37,6 +37,7 @@
#include "jit/IonCode.h"
#include "js/MemoryMetrics.h"
#include "js/Printf.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"
#include "js/Wrapper.h"
#include "util/StringBuffer.h"
@ -1617,7 +1618,9 @@ ScriptSource::chunkChars(JSContext* cx, UncompressedSourceCache::AutoHoldEntry&
ScriptSource::PinnedChars::PinnedChars(JSContext* cx, ScriptSource* source,
UncompressedSourceCache::AutoHoldEntry& holder,
size_t begin, size_t len)
: source_(source)
: stack_(nullptr),
prev_(nullptr),
source_(source)
{
chars_ = source->chars(cx, holder, begin, len);
if (chars_) {
@ -3451,7 +3454,7 @@ js::detail::CopyScript(JSContext* cx, HandleScript src, HandleScript dst,
/* Script data */
size_t size = src->dataSize();
ScopedJSFreePtr<uint8_t> data(AllocScriptData(cx->zone(), size));
UniquePtr<uint8_t, JS::FreePolicy> data(AllocScriptData(cx->zone(), size));
if (size && !data) {
ReportOutOfMemory(cx);
return false;
@ -3519,7 +3522,7 @@ js::detail::CopyScript(JSContext* cx, HandleScript src, HandleScript dst,
}
/* This assignment must occur before all the Rebase calls. */
dst->data = data.forget();
dst->data = data.release();
dst->dataSize_ = size;
MOZ_ASSERT(bool(dst->data) == bool(src->data));
if (dst->data)
@ -4255,10 +4258,13 @@ LazyScript::CreateRaw(JSContext* cx, HandleFunction fun,
size_t bytes = (p.numClosedOverBindings * sizeof(JSAtom*))
+ (p.numInnerFunctions * sizeof(GCPtrFunction));
ScopedJSFreePtr<uint8_t> table(bytes ? fun->zone()->pod_malloc<uint8_t>(bytes) : nullptr);
if (bytes && !table) {
ReportOutOfMemory(cx);
return nullptr;
UniquePtr<uint8_t, JS::FreePolicy> table;
if (bytes) {
table.reset(fun->zone()->pod_malloc<uint8_t>(bytes));
if (!table) {
ReportOutOfMemory(cx);
return nullptr;
}
}
LazyScript* res = Allocate<LazyScript>(cx);
@ -4267,8 +4273,8 @@ LazyScript::CreateRaw(JSContext* cx, HandleFunction fun,
cx->realm()->scheduleDelazificationForDebugger();
return new (res) LazyScript(fun, *sourceObject, table.forget(), packed, sourceStart, sourceEnd,
toStringStart, lineno, column);
return new (res) LazyScript(fun, *sourceObject, table.release(), packed, sourceStart,
sourceEnd, toStringStart, lineno, column);
}
/* static */ LazyScript*

View File

@ -2099,6 +2099,7 @@ class JSScript : public js::gc::TenuredCell
explicit AutoDelazify(JSContext* cx, JS::HandleFunction fun = nullptr)
: script_(cx)
, cx_(cx)
, oldDoNotRelazify_(false)
{
holdScript(fun);
}

View File

@ -81,24 +81,26 @@ EqualStringsPure(JSString* s1, JSString* s2)
return false;
const Char1* c1;
ScopedJSFreePtr<Char1> ownedChars1;
UniquePtr<Char1[], JS::FreePolicy> ownedChars1;
JS::AutoCheckCannotGC nogc;
if (s1->isLinear()) {
c1 = s1->asLinear().chars<Char1>(nogc);
} else {
if (!s1->asRope().copyChars<Char1>(/* tcx */ nullptr, ownedChars1))
ownedChars1 = s1->asRope().copyChars<Char1>(/* tcx */ nullptr);
if (!ownedChars1)
MOZ_CRASH("oom");
c1 = ownedChars1;
c1 = ownedChars1.get();
}
const Char2* c2;
ScopedJSFreePtr<Char2> ownedChars2;
UniquePtr<Char2[], JS::FreePolicy> ownedChars2;
if (s2->isLinear()) {
c2 = s2->asLinear().chars<Char2>(nogc);
} else {
if (!s2->asRope().copyChars<Char2>(/* tcx */ nullptr, ownedChars2))
ownedChars2 = s2->asRope().copyChars<Char2>(/* tcx */ nullptr);
if (!ownedChars2)
MOZ_CRASH("oom");
c2 = ownedChars2;
c2 = ownedChars2.get();
}
return EqualChars(c1, c2, s1->length());
@ -148,14 +150,15 @@ static void
StoreStringChars(char* buffer, size_t bufferSize, JSString* str)
{
const CharT* chars;
ScopedJSFreePtr<CharT> ownedChars;
UniquePtr<CharT[], JS::FreePolicy> ownedChars;
JS::AutoCheckCannotGC nogc;
if (str->isLinear()) {
chars = str->asLinear().chars<CharT>(nogc);
} else {
if (!str->asRope().copyChars<CharT>(/* tcx */ nullptr, ownedChars))
ownedChars = str->asRope().copyChars<CharT>(/* tcx */ nullptr);
if (!ownedChars)
MOZ_CRASH("oom");
chars = ownedChars;
chars = ownedChars.get();
}
// We might truncate |str| even if it's much shorter than 1024 chars, if

View File

@ -7,6 +7,7 @@
#include "vm/ObjectGroup.h"
#include "mozilla/Maybe.h"
#include "mozilla/Unused.h"
#include "jsexn.h"
@ -17,6 +18,7 @@
#include "gc/StoreBuffer.h"
#include "gc/Zone.h"
#include "js/CharacterEncoding.h"
#include "js/UniquePtr.h"
#include "vm/ArrayObject.h"
#include "vm/JSObject.h"
#include "vm/RegExpObject.h"
@ -1230,13 +1232,13 @@ ObjectGroup::newPlainObject(JSContext* cx, IdValuePair* properties, size_t nprop
group->setPreliminaryObjects(preliminaryObjects);
preliminaryObjects->registerNewObject(obj);
ScopedJSFreePtr<jsid> ids(group->zone()->pod_calloc<jsid>(nproperties));
UniquePtr<jsid[], JS::FreePolicy> ids(group->zone()->pod_calloc<jsid>(nproperties));
if (!ids) {
ReportOutOfMemory(cx);
return nullptr;
}
ScopedJSFreePtr<TypeSet::Type> types(
UniquePtr<TypeSet::Type[], JS::FreePolicy> types(
group->zone()->pod_calloc<TypeSet::Type>(nproperties));
if (!types) {
ReportOutOfMemory(cx);
@ -1250,14 +1252,14 @@ ObjectGroup::newPlainObject(JSContext* cx, IdValuePair* properties, size_t nprop
}
ObjectGroupRealm::PlainObjectKey key;
key.properties = ids;
key.properties = ids.get();
key.nproperties = nproperties;
MOZ_ASSERT(ObjectGroupRealm::PlainObjectKey::match(key, lookup));
ObjectGroupRealm::PlainObjectEntry entry;
entry.group.set(group);
entry.shape.set(obj->lastProperty());
entry.types = types;
entry.types = types.get();
ObjectGroupRealm::PlainObjectTable::AddPtr np = table->lookupForAdd(lookup);
if (!table->add(np, key, entry)) {
@ -1265,8 +1267,8 @@ ObjectGroup::newPlainObject(JSContext* cx, IdValuePair* properties, size_t nprop
return nullptr;
}
ids.forget();
types.forget();
mozilla::Unused << ids.release();
mozilla::Unused << types.release();
return obj;
}

View File

@ -628,7 +628,11 @@ class ObjectGroupRealm
JSObject* associated_;
public:
DefaultNewGroupCache() { purge(); }
DefaultNewGroupCache()
: associated_(nullptr)
{
purge();
}
void purge() {
group_ = nullptr;

View File

@ -234,7 +234,9 @@ class RegExpZone
JSAtom* atom;
uint16_t flag;
Key() {}
Key()
: atom(nullptr), flag(0)
{ }
Key(JSAtom* atom, RegExpFlag flag)
: atom(atom), flag(flag)
{ }

View File

@ -2955,14 +2955,14 @@ JSRuntime::initSelfHosting(JSContext* cx)
const unsigned char* compressed = compressedSources;
uint32_t compressedLen = GetCompressedSize();
ScopedJSFreePtr<char> src(selfHostingGlobal_->zone()->pod_malloc<char>(srcLen));
UniqueChars src(selfHostingGlobal_->zone()->pod_malloc<char>(srcLen));
if (!src || !DecompressString(compressed, compressedLen,
reinterpret_cast<unsigned char*>(src.get()), srcLen))
{
return false;
}
if (!Evaluate(cx, options, src, srcLen, &rv))
if (!Evaluate(cx, options, src.get(), srcLen, &rv))
return false;
if (!VerifyGlobalNames(cx, shg))

View File

@ -1524,7 +1524,8 @@ Shape::Shape(const StackShape& other, uint32_t nfixed)
immutableFlags(other.immutableFlags),
attrs(other.attrs),
mutableFlags(other.mutableFlags),
parent(nullptr)
parent(nullptr),
listp(nullptr)
{
setNumFixedSlots(nfixed);
@ -1558,7 +1559,8 @@ Shape::Shape(UnownedBaseShape* base, uint32_t nfixed)
immutableFlags(SHAPE_INVALID_SLOT | (nfixed << FIXED_SLOTS_SHIFT)),
attrs(0),
mutableFlags(0),
parent(nullptr)
parent(nullptr),
listp(nullptr)
{
MOZ_ASSERT(base);
kids.setNull();

View File

@ -1671,7 +1671,7 @@ class JitActivation : public Activation
protected:
// Used to verify that live registers don't change between a VM call and
// the OsiPoint that follows it. Protected to silence Clang warning.
uint32_t checkRegs_;
uint32_t checkRegs_ = 0;
RegisterDump regs_;
#endif

View File

@ -279,55 +279,56 @@ AllocChars(JSString* str, size_t length, CharT** chars, size_t* capacity)
return *chars != nullptr;
}
bool
JSRope::copyLatin1CharsZ(JSContext* cx, ScopedJSFreePtr<Latin1Char>& out) const
UniquePtr<Latin1Char[], JS::FreePolicy>
JSRope::copyLatin1CharsZ(JSContext* cx) const
{
return copyCharsInternal<Latin1Char>(cx, out, true);
return copyCharsInternal<Latin1Char>(cx, true);
}
bool
JSRope::copyTwoByteCharsZ(JSContext* cx, ScopedJSFreePtr<char16_t>& out) const
UniqueTwoByteChars
JSRope::copyTwoByteCharsZ(JSContext* cx) const
{
return copyCharsInternal<char16_t>(cx, out, true);
return copyCharsInternal<char16_t>(cx, true);
}
bool
JSRope::copyLatin1Chars(JSContext* cx, ScopedJSFreePtr<Latin1Char>& out) const
UniquePtr<Latin1Char[], JS::FreePolicy>
JSRope::copyLatin1Chars(JSContext* cx) const
{
return copyCharsInternal<Latin1Char>(cx, out, false);
return copyCharsInternal<Latin1Char>(cx, false);
}
bool
JSRope::copyTwoByteChars(JSContext* cx, ScopedJSFreePtr<char16_t>& out) const
UniqueTwoByteChars
JSRope::copyTwoByteChars(JSContext* cx) const
{
return copyCharsInternal<char16_t>(cx, out, false);
return copyCharsInternal<char16_t>(cx, false);
}
template <typename CharT>
bool
JSRope::copyCharsInternal(JSContext* cx, ScopedJSFreePtr<CharT>& out,
bool nullTerminate) const
UniquePtr<CharT[], JS::FreePolicy>
JSRope::copyCharsInternal(JSContext* cx, bool nullTerminate) const
{
// Left-leaning ropes are far more common than right-leaning ropes, so
// perform a non-destructive traversal of the rope, right node first,
// splatting each node's characters into a contiguous buffer.
size_t n = length();
UniquePtr<CharT[], JS::FreePolicy> out;
if (cx)
out.reset(cx->pod_malloc<CharT>(n + 1));
else
out.reset(js_pod_malloc<CharT>(n + 1));
if (!out)
return false;
return nullptr;
Vector<const JSString*, 8, SystemAllocPolicy> nodeStack;
const JSString* str = this;
CharT* end = out + str->length();
CharT* end = out.get() + str->length();
while (true) {
if (str->isRope()) {
if (!nodeStack.append(str->asRope().leftChild()))
return false;
return nullptr;
str = str->asRope().rightChild();
} else {
end -= str->length();
@ -338,12 +339,12 @@ JSRope::copyCharsInternal(JSContext* cx, ScopedJSFreePtr<CharT>& out,
}
}
MOZ_ASSERT(end == out);
MOZ_ASSERT(end == out.get());
if (nullTerminate)
out[n] = 0;
return true;
return out;
}
template <typename CharT>
@ -1502,13 +1503,13 @@ NewStringDeflated(JSContext* cx, const char16_t* s, size_t n)
if (JSInlineString::lengthFits<Latin1Char>(n))
return NewInlineStringDeflated<allowGC>(cx, mozilla::Range<const char16_t>(s, n));
ScopedJSFreePtr<Latin1Char> news(cx->pod_malloc<Latin1Char>(n + 1));
UniquePtr<Latin1Char[], JS::FreePolicy> news(cx->pod_malloc<Latin1Char>(n + 1));
if (!news)
return nullptr;
for (size_t i = 0; i < n; i++) {
MOZ_ASSERT(s[i] <= JSString::MAX_LATIN1_CHAR);
news.get()[i] = Latin1Char(s[i]);
news[i] = Latin1Char(s[i]);
}
news[n] = '\0';
@ -1516,7 +1517,7 @@ NewStringDeflated(JSContext* cx, const char16_t* s, size_t n)
if (!str)
return nullptr;
news.forget();
mozilla::Unused << news.release();
return str;
}
@ -1604,7 +1605,7 @@ NewStringCopyNDontDeflate(JSContext* cx, const CharT* s, size_t n)
if (JSInlineString::lengthFits<CharT>(n))
return NewInlineString<allowGC>(cx, mozilla::Range<const CharT>(s, n));
ScopedJSFreePtr<CharT> news(cx->pod_malloc<CharT>(n + 1));
UniquePtr<CharT[], JS::FreePolicy> news(cx->pod_malloc<CharT>(n + 1));
if (!news) {
if (!allowGC)
cx->recoverFromOutOfMemory();
@ -1618,7 +1619,7 @@ NewStringCopyNDontDeflate(JSContext* cx, const CharT* s, size_t n)
if (!str)
return nullptr;
news.forget();
mozilla::Unused << news.release();
return str;
}

View File

@ -22,6 +22,7 @@
#include "gc/Rooting.h"
#include "js/CharacterEncoding.h"
#include "js/RootingAPI.h"
#include "js/UniquePtr.h"
#include "util/Text.h"
#include "vm/Printer.h"
@ -666,8 +667,8 @@ class JSString : public js::gc::Cell
class JSRope : public JSString
{
template <typename CharT>
bool copyCharsInternal(JSContext* cx, js::ScopedJSFreePtr<CharT>& out,
bool nullTerminate) const;
js::UniquePtr<CharT[], JS::FreePolicy> copyCharsInternal(JSContext* cx,
bool nullTerminate) const;
enum UsingBarrier { WithIncrementalBarrier, NoBarrier };
@ -689,16 +690,14 @@ class JSRope : public JSString
typename js::MaybeRooted<JSString*, allowGC>::HandleType right,
size_t length, js::gc::InitialHeap = js::gc::DefaultHeap);
bool copyLatin1Chars(JSContext* cx,
js::ScopedJSFreePtr<JS::Latin1Char>& out) const;
bool copyTwoByteChars(JSContext* cx, js::ScopedJSFreePtr<char16_t>& out) const;
js::UniquePtr<JS::Latin1Char[], JS::FreePolicy> copyLatin1Chars(JSContext* cx) const;
JS::UniqueTwoByteChars copyTwoByteChars(JSContext* cx) const;
bool copyLatin1CharsZ(JSContext* cx,
js::ScopedJSFreePtr<JS::Latin1Char>& out) const;
bool copyTwoByteCharsZ(JSContext* cx, js::ScopedJSFreePtr<char16_t>& out) const;
js::UniquePtr<JS::Latin1Char[], JS::FreePolicy> copyLatin1CharsZ(JSContext* cx) const;
JS::UniqueTwoByteChars copyTwoByteCharsZ(JSContext* cx) const;
template <typename CharT>
bool copyChars(JSContext* cx, js::ScopedJSFreePtr<CharT>& out) const;
js::UniquePtr<CharT[], JS::FreePolicy> copyChars(JSContext* cx) const;
// Hash function specific for ropes that avoids allocating a temporary
// string. There are still allocations internally so it's technically
@ -1734,18 +1733,17 @@ JSLinearString::chars(const JS::AutoRequireNoGC& nogc) const
}
template <>
MOZ_ALWAYS_INLINE bool
JSRope::copyChars<JS::Latin1Char>(JSContext* cx,
js::ScopedJSFreePtr<JS::Latin1Char>& out) const
MOZ_ALWAYS_INLINE js::UniquePtr<JS::Latin1Char[], JS::FreePolicy>
JSRope::copyChars<JS::Latin1Char>(JSContext* cx) const
{
return copyLatin1Chars(cx, out);
return copyLatin1Chars(cx);
}
template <>
MOZ_ALWAYS_INLINE bool
JSRope::copyChars<char16_t>(JSContext* cx, js::ScopedJSFreePtr<char16_t>& out) const
MOZ_ALWAYS_INLINE JS::UniqueTwoByteChars
JSRope::copyChars<char16_t>(JSContext* cx) const
{
return copyTwoByteChars(cx, out);
return copyTwoByteChars(cx);
}
template<>

View File

@ -575,7 +575,8 @@ class MOZ_RAII AutoTraceLog
const TraceLoggerEvent& event MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: logger(logger),
isEvent(true),
executed(false)
executed(false),
prev(nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
payload.event = &event;
@ -590,7 +591,8 @@ class MOZ_RAII AutoTraceLog
AutoTraceLog(TraceLoggerThread* logger, TraceLoggerTextId id MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: logger(logger),
isEvent(false),
executed(false)
executed(false),
prev(nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
payload.id = id;

View File

@ -130,6 +130,10 @@ class TraceLoggerGraph
nextId_ = nextId;
}
TreeEntry()
: start_(0),
stop_(0),
u{},
nextId_(0)
{ }
uint64_t start() {
return start_;

View File

@ -162,7 +162,9 @@ class ContinuousSpace {
public:
ContinuousSpace ()
: data_(nullptr)
: data_(nullptr),
size_(0),
capacity_(0)
{ }
bool init() {

View File

@ -26,6 +26,7 @@
#include "jit/JitRealm.h"
#include "jit/OptimizationTracking.h"
#include "js/MemoryMetrics.h"
#include "js/UniquePtr.h"
#include "vm/HelperThreads.h"
#include "vm/JSContext.h"
#include "vm/JSObject.h"
@ -3641,7 +3642,7 @@ PreliminaryObjectArrayWithTemplate::maybeAnalyze(JSContext* cx, ObjectGroup* gro
AutoEnterAnalysis enter(cx);
ScopedJSDeletePtr<PreliminaryObjectArrayWithTemplate> preliminaryObjects(this);
UniquePtr<PreliminaryObjectArrayWithTemplate> preliminaryObjects(this);
group->detachPreliminaryObjects();
MOZ_ASSERT(shape());
@ -3663,7 +3664,7 @@ PreliminaryObjectArrayWithTemplate::maybeAnalyze(JSContext* cx, ObjectGroup* gro
return;
}
TryConvertToUnboxedLayout(cx, enter, shape(), group, preliminaryObjects);
TryConvertToUnboxedLayout(cx, enter, shape(), group, preliminaryObjects.get());
AutoSweepObjectGroup sweep(group);
if (group->maybeUnboxedLayout(sweep))
return;
@ -3692,7 +3693,7 @@ TypeNewScript::make(JSContext* cx, ObjectGroup* group, JSFunction* fun)
if (group->unknownProperties(sweep))
return true;
ScopedJSDeletePtr<TypeNewScript> newScript(cx->new_<TypeNewScript>());
auto newScript = cx->make_unique<TypeNewScript>();
if (!newScript)
return false;
@ -3702,7 +3703,7 @@ TypeNewScript::make(JSContext* cx, ObjectGroup* group, JSFunction* fun)
if (!newScript->preliminaryObjects)
return true;
group->setNewScript(newScript.forget());
group->setNewScript(newScript.release());
gc::gcTracer.traceTypeNewScript(group);
return true;
@ -3716,7 +3717,7 @@ TypeNewScript::makeNativeVersion(JSContext* cx, TypeNewScript* newScript,
{
MOZ_RELEASE_ASSERT(cx->zone()->types.activeAnalysis);
ScopedJSDeletePtr<TypeNewScript> nativeNewScript(cx->new_<TypeNewScript>());
auto nativeNewScript = cx->make_unique<TypeNewScript>();
if (!nativeNewScript)
return nullptr;
@ -3734,7 +3735,7 @@ TypeNewScript::makeNativeVersion(JSContext* cx, TypeNewScript* newScript,
}
PodCopy(nativeNewScript->initializerList, newScript->initializerList, initializerLength);
return nativeNewScript.forget();
return nativeNewScript.release();
}
size_t

View File

@ -30,6 +30,7 @@
#include "gc/Marking.h"
#include "jit/InlinableNatives.h"
#include "js/Conversions.h"
#include "js/UniquePtr.h"
#include "js/Wrapper.h"
#include "util/Windows.h"
#include "vm/ArrayBufferObject.h"
@ -652,15 +653,13 @@ class TypedArrayObjectTemplate : public TypedArrayObject
NewObjectKind newKind = TenuredObject;
ScopedJSFreePtr<void> buf;
UniquePtr<void, JS::FreePolicy> buf;
if (!fitsInline && len > 0) {
buf = cx->zone()->pod_malloc<uint8_t>(nbytes);
buf.reset(cx->zone()->pod_calloc<uint8_t>(nbytes));
if (!buf) {
ReportOutOfMemory(cx);
return nullptr;
}
memset(buf, 0, nbytes);
}
TypedArrayObject* obj = NewObjectWithGroup<TypedArrayObject>(cx, group, allocKind, newKind);
@ -668,7 +667,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject
return nullptr;
initTypedArraySlots(obj, len);
initTypedArrayData(cx, obj, len, buf.forget(), allocKind);
initTypedArrayData(cx, obj, len, buf.release(), allocKind);
return obj;
}

View File

@ -338,6 +338,7 @@ struct js::AsmJSMetadata : Metadata, AsmJSMetadataCacheablePod
AsmJSMetadata()
: Metadata(ModuleKind::AsmJS),
cacheResult(CacheResult::Miss),
toStringStart(0),
srcStart(0),
strict(false)
{}
@ -1524,7 +1525,7 @@ class MOZ_STACK_CLASS JS_HAZ_ROOTED ModuleValidator
// non-trivial constructor and therefore MUST be placement-new'd
// into existence.
MOZ_PUSH_DISABLE_NONTRIVIAL_UNION_WARNINGS
U() {}
U() : funcDefIndex_(0) {}
MOZ_POP_DISABLE_NONTRIVIAL_UNION_WARNINGS
} u;
@ -1615,7 +1616,7 @@ class MOZ_STACK_CLASS JS_HAZ_ROOTED ModuleValidator
AsmJSMathBuiltinFunction func;
} u;
MathBuiltin() : kind(Kind(-1)) {}
MathBuiltin() : kind(Kind(-1)), u{} {}
explicit MathBuiltin(double cst) : kind(Constant) {
u.cst = cst;
}

View File

@ -1010,6 +1010,8 @@ BaseLocalIter::BaseLocalIter(const ValTypeVector& locals, size_t argsLength, boo
index_(0),
localSize_(debugEnabled ? DebugFrame::offsetOfFrame() : 0),
reservedSize_(localSize_),
frameOffset_(0),
mirType_(MIRType::Undefined),
done_(false)
{
MOZ_ASSERT(argsLength <= locals.length());

View File

@ -40,7 +40,8 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
lineOrBytecode_(0),
fp_(fp ? fp : activation->wasmExitFP()),
unwoundIonCallerFP_(nullptr),
unwind_(Unwind::False)
unwind_(Unwind::False),
unwoundAddressOfReturnAddress_(nullptr)
{
MOZ_ASSERT(fp_);

View File

@ -99,10 +99,6 @@ enum class SymbolicAddress;
// function that is used for better display in the profiler.
class ExitReason
{
uint32_t payload_;
ExitReason() {}
public:
enum class Fixed : uint32_t
{
@ -115,6 +111,13 @@ class ExitReason
DebugTrap // call to debug trap handler
};
private:
uint32_t payload_;
ExitReason() : ExitReason(Fixed::None) {}
public:
MOZ_IMPLICIT ExitReason(Fixed exitReason)
: payload_(0x0 | (uint32_t(exitReason) << 1))
{

View File

@ -2892,6 +2892,7 @@ class CompileStreamTask : public PromiseHelperTask, public JS::StreamConsumer
instantiate_(instantiate),
importObj_(cx, importObj),
streamState_(mutexid::WasmStreamStatus, Env),
codeSection_{},
codeStreamEnd_(nullptr),
exclusiveCodeStreamEnd_(mutexid::WasmCodeStreamEnd, nullptr),
exclusiveTailBytes_(mutexid::WasmTailBytesPtr, nullptr),

View File

@ -238,6 +238,8 @@ struct LinearMemoryAddress
uint32_t align;
LinearMemoryAddress()
: offset(0),
align(0)
{}
LinearMemoryAddress(Value base, uint32_t offset, uint32_t align)
: base(base), offset(offset), align(align)

View File

@ -169,7 +169,8 @@ class WasmToken
WasmToken(Kind kind, const char16_t* begin, const char16_t* end)
: kind_(kind),
begin_(begin),
end_(end)
end_(end),
u{}
{
MOZ_ASSERT(kind_ != Error);
MOZ_ASSERT(kind_ != Invalid);
@ -252,7 +253,8 @@ class WasmToken
explicit WasmToken(const char16_t* begin)
: kind_(Error),
begin_(begin),
end_(begin)
end_(begin),
u{}
{}
Kind kind() const {
MOZ_ASSERT(kind_ != Kind::Invalid);

View File

@ -797,7 +797,7 @@ class InitExpr
uint32_t index_;
ValType type_;
} global;
U() {}
U() : global{} {}
} u;
public:
@ -920,7 +920,7 @@ class GlobalDesc
ValType type_;
uint32_t index_;
} import;
U() {}
U() : import{} {}
} val;
unsigned offset_;
bool isMutable_;
@ -1600,7 +1600,10 @@ class CallSiteDesc
LeaveFrame, // call to a leave frame handler
Breakpoint // call to instruction breakpoint
};
CallSiteDesc() {}
CallSiteDesc()
: lineOrBytecode_(0),
kind_(0)
{}
explicit CallSiteDesc(Kind kind)
: lineOrBytecode_(0), kind_(kind)
{
@ -1621,7 +1624,7 @@ class CallSite : public CallSiteDesc
uint32_t returnAddressOffset_;
public:
CallSite() {}
CallSite() : returnAddressOffset_(0) {}
CallSite(CallSiteDesc desc, uint32_t returnAddressOffset)
: CallSiteDesc(desc),
@ -1999,7 +2002,7 @@ class CalleeDesc
// which_ shall be initialized in the static constructors
MOZ_INIT_OUTSIDE_CTOR Which which_;
union U {
U() {}
U() : funcIndex_(0) {}
uint32_t funcIndex_;
struct {
uint32_t globalDataOffset_;

View File

@ -36,8 +36,12 @@ interface nsITimedChannel : nsISupports {
attribute uint8_t redirectCount;
attribute uint8_t internalRedirectCount;
[noscript] readonly attribute TimeStamp channelCreation;
[noscript] readonly attribute TimeStamp asyncOpen;
// These properties should only be written externally when they must be
// propagated across an internal redirect. For example, when a service
// worker interception falls back to network we need to copy the original
// timing values to the new nsHttpChannel.
[noscript] attribute TimeStamp channelCreation;
[noscript] attribute TimeStamp asyncOpen;
// The following are only set when the request is intercepted by a service
// worker no matter the response is synthesized.

View File

@ -201,6 +201,7 @@ HttpBaseChannel::HttpBaseChannel()
, mRedirectCount(0)
, mInternalRedirectCount(0)
, mChannelCreationTime(0)
, mAsyncOpenTimeOverriden(false)
, mForcePending(false)
, mCorsIncludeCredentials(false)
, mCorsMode(nsIHttpChannelInternal::CORS_MODE_NO_CORS)
@ -3784,14 +3785,28 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
newTimedChannel->SetInternalRedirectCount(mInternalRedirectCount);
}
TimeStamp oldAsyncOpenTime;
oldTimedChannel->GetAsyncOpen(&oldAsyncOpenTime);
if (redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) {
TimeStamp oldChannelCreationTimestamp;
oldTimedChannel->GetChannelCreation(&oldChannelCreationTimestamp);
if (!oldChannelCreationTimestamp.IsNull()) {
newTimedChannel->SetChannelCreation(oldChannelCreationTimestamp);
}
if (!oldAsyncOpenTime.IsNull()) {
newTimedChannel->SetAsyncOpen(oldAsyncOpenTime);
}
}
// If the RedirectStart is null, we will use the AsyncOpen value of the
// previous channel (this is the first redirect in the redirects chain).
if (mRedirectStartTimeStamp.IsNull()) {
// Only do this for real redirects. Internal redirects should be hidden.
if (!(redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL)) {
TimeStamp asyncOpen;
oldTimedChannel->GetAsyncOpen(&asyncOpen);
newTimedChannel->SetRedirectStart(asyncOpen);
newTimedChannel->SetRedirectStart(oldAsyncOpenTime);
}
} else {
newTimedChannel->SetRedirectStart(mRedirectStartTimeStamp);
@ -3928,12 +3943,29 @@ HttpBaseChannel::GetChannelCreation(TimeStamp* _retval) {
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::SetChannelCreation(TimeStamp aValue) {
MOZ_DIAGNOSTIC_ASSERT(!aValue.IsNull());
TimeDuration adjust = aValue - mChannelCreationTimestamp;
mChannelCreationTimestamp = aValue;
mChannelCreationTime += (PRTime)adjust.ToMicroseconds();
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetAsyncOpen(TimeStamp* _retval) {
*_retval = mAsyncOpenTime;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::SetAsyncOpen(TimeStamp aValue) {
MOZ_DIAGNOSTIC_ASSERT(!aValue.IsNull());
mAsyncOpenTime = aValue;
mAsyncOpenTimeOverriden = true;
return NS_OK;
}
/**
* @return the number of redirects. There is no check for cross-domain
* redirects. This check must be done by the consumers.

View File

@ -676,6 +676,7 @@ protected:
// so that the timing can still be queried from OnStopRequest
TimingStruct mTransactionTimings;
bool mAsyncOpenTimeOverriden;
bool mForcePending;
bool mCorsIncludeCredentials;

View File

@ -2502,7 +2502,10 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
return NS_OK;
}
mAsyncOpenTime = TimeStamp::Now();
if (!mAsyncOpenTimeOverriden) {
mAsyncOpenTime = TimeStamp::Now();
}
#ifdef MOZ_TASK_TRACER
if (tasktracer::IsStartLogging()) {
nsCOMPtr<nsIURI> uri;

View File

@ -685,6 +685,16 @@ InterceptedHttpChannel::ResetInterception(void)
rv = SetupReplacementChannel(mURI, newChannel, true, flags);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITimedChannel> newTimedChannel = do_QueryInterface(newChannel);
if (newTimedChannel) {
if (!mAsyncOpenTime.IsNull()) {
newTimedChannel->SetAsyncOpen(mAsyncOpenTime);
}
if (!mChannelCreationTimestamp.IsNull()) {
newTimedChannel->SetChannelCreation(mChannelCreationTimestamp);
}
}
if (mRedirectMode != nsIHttpChannelInternal::REDIRECT_MODE_MANUAL) {
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
rv = newChannel->GetLoadFlags(&loadFlags);

View File

@ -610,6 +610,15 @@ NullHttpChannel::GetChannelCreation(mozilla::TimeStamp *aChannelCreation)
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::SetChannelCreation(TimeStamp aValue) {
MOZ_DIAGNOSTIC_ASSERT(!aValue.IsNull());
TimeDuration adjust = aValue - mChannelCreationTimestamp;
mChannelCreationTimestamp = aValue;
mChannelCreationTime += (PRTime)adjust.ToMicroseconds();
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::GetAsyncOpen(mozilla::TimeStamp *aAsyncOpen)
{
@ -617,6 +626,13 @@ NullHttpChannel::GetAsyncOpen(mozilla::TimeStamp *aAsyncOpen)
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::SetAsyncOpen(TimeStamp aValue) {
MOZ_DIAGNOSTIC_ASSERT(!aValue.IsNull());
mAsyncOpenTime = aValue;
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::GetLaunchServiceWorkerStart(mozilla::TimeStamp *_retval)
{

View File

@ -6050,7 +6050,9 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
// don't want it after OnModifyRequest() weighs in. But waiting for
// that to complete would mean we don't include proxy resolution in the
// timing.
mAsyncOpenTime = TimeStamp::Now();
if (!mAsyncOpenTimeOverriden) {
mAsyncOpenTime = TimeStamp::Now();
}
// Remember we have Authorization header set here. We need to check on it
// just once and early, AsyncOpen is the best place.

View File

@ -18,6 +18,7 @@
#include "nsProxyRelease.h"
#include "nsTArray.h"
#include "mozilla/Logging.h"
#include "mozilla/Scoped.h"
namespace mozilla {