mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1575298 - Use field initializers for js::ScriptSource. r=jandem
Also reorder the fields for better organization. Differential Revision: https://phabricator.services.mozilla.com/D42685 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
95bbcd5be9
commit
00cbe5361f
@ -586,10 +586,18 @@ class ScriptSource {
|
||||
|
||||
mozilla::Atomic<uint32_t, mozilla::ReleaseAcquire,
|
||||
mozilla::recordreplay::Behavior::DontPreserve>
|
||||
refs;
|
||||
refs = {};
|
||||
|
||||
// An id for this source that is unique across the process. This can be used
|
||||
// to refer to this source from places that don't want to hold a strong
|
||||
// reference on the source itself.
|
||||
//
|
||||
// This is a 32 bit ID and could overflow, in which case the ID will not be
|
||||
// unique anymore.
|
||||
uint32_t id_ = 0;
|
||||
|
||||
// Source data (as a mozilla::Variant).
|
||||
SourceType data;
|
||||
SourceType data = SourceType(Missing());
|
||||
|
||||
// If the GC calls triggerConvertToCompressedSource with PinnedUnits present,
|
||||
// the first PinnedUnits (that is, bottom of the stack) will install the
|
||||
@ -597,27 +605,13 @@ class ScriptSource {
|
||||
//
|
||||
// Retrievability isn't part of the type here because uncompressed->compressed
|
||||
// transitions must preserve existing retrievability.
|
||||
PinnedUnitsBase* pinnedUnitsStack_;
|
||||
PinnedUnitsBase* pinnedUnitsStack_ = nullptr;
|
||||
mozilla::MaybeOneOf<CompressedData<mozilla::Utf8Unit>,
|
||||
CompressedData<char16_t>>
|
||||
pendingCompressed_;
|
||||
|
||||
// The filename of this script.
|
||||
UniqueChars filename_;
|
||||
|
||||
UniqueTwoByteChars displayURL_;
|
||||
UniqueTwoByteChars sourceMapURL_;
|
||||
bool mutedErrors_;
|
||||
|
||||
// bytecode offset in caller script that generated this code.
|
||||
// This is present for eval-ed code, as well as "new Function(...)"-introduced
|
||||
// scripts.
|
||||
uint32_t introductionOffset_;
|
||||
|
||||
// If this source is for Function constructor, the position of ")" after
|
||||
// parameter list in the source. This is used to get function body.
|
||||
// 0 for other cases.
|
||||
uint32_t parameterListEnd_;
|
||||
UniqueChars filename_ = nullptr;
|
||||
|
||||
// If this ScriptSource was generated by a code-introduction mechanism such
|
||||
// as |eval| or |new Function|, the debugger needs access to the "raw"
|
||||
@ -629,27 +623,15 @@ class ScriptSource {
|
||||
//
|
||||
// In the case described above, this field will be non-null and will be the
|
||||
// original raw filename from above. Otherwise this field will be null.
|
||||
UniqueChars introducerFilename_;
|
||||
UniqueChars introducerFilename_ = nullptr;
|
||||
|
||||
// A string indicating how this source code was introduced into the system.
|
||||
// This accessor returns one of the following values:
|
||||
// "eval" for code passed to |eval|.
|
||||
// "Function" for code passed to the |Function| constructor.
|
||||
// "Worker" for code loaded by calling the Web worker
|
||||
// constructor—the worker's main script. "importScripts" for code
|
||||
// by calling |importScripts| in a web worker. "handler" for code
|
||||
// assigned to DOM elements' event handler IDL attributes.
|
||||
// "scriptElement" for code belonging to <script> elements.
|
||||
// undefined if the implementation doesn't know how the code was
|
||||
// introduced.
|
||||
// This is a constant, statically allocated C string, so does not need
|
||||
// memory management.
|
||||
const char* introductionType_;
|
||||
UniqueTwoByteChars displayURL_ = nullptr;
|
||||
UniqueTwoByteChars sourceMapURL_ = nullptr;
|
||||
|
||||
// The bytecode cache encoder is used to encode only the content of function
|
||||
// which are delazified. If this value is not nullptr, then each delazified
|
||||
// function should be recorded before their first execution.
|
||||
UniquePtr<XDRIncrementalEncoder> xdrEncoder_;
|
||||
UniquePtr<XDRIncrementalEncoder> xdrEncoder_ = nullptr;
|
||||
|
||||
// Instant at which the first parse of this source ended, or null
|
||||
// if the source hasn't been parsed yet.
|
||||
@ -659,16 +641,27 @@ class ScriptSource {
|
||||
// our syntax parse vs. full parse heuristics are correct.
|
||||
mozilla::TimeStamp parseEnded_;
|
||||
|
||||
// An id for this source that is unique across the process. This can be used
|
||||
// to refer to this source from places that don't want to hold a strong
|
||||
// reference on the source itself.
|
||||
//
|
||||
// This is a 32 bit ID and could overflow, in which case the ID will not be
|
||||
// unique anymore.
|
||||
uint32_t id_;
|
||||
// A string indicating how this source code was introduced into the system.
|
||||
// This is a constant, statically allocated C string, so does not need memory
|
||||
// management.
|
||||
const char* introductionType_ = nullptr;
|
||||
|
||||
bool hasIntroductionOffset_ : 1;
|
||||
bool containsAsmJS_ : 1;
|
||||
// bytecode offset in caller script that generated this code.
|
||||
// This is present for eval-ed code, as well as "new Function(...)"-introduced
|
||||
// scripts.
|
||||
uint32_t introductionOffset_ = 0;
|
||||
|
||||
// If this source is for Function constructor, the position of ")" after
|
||||
// parameter list in the source. This is used to get function body.
|
||||
// 0 for other cases.
|
||||
uint32_t parameterListEnd_ = 0;
|
||||
|
||||
// See: CompileOptions::mutedErrors.
|
||||
bool mutedErrors_ = false;
|
||||
|
||||
// Set to true if parser saw asmjs directives.
|
||||
bool containsAsmJS_ = false;
|
||||
bool hasIntroductionOffset_ = false;
|
||||
|
||||
//
|
||||
// End of fields.
|
||||
@ -698,22 +691,7 @@ class ScriptSource {
|
||||
// to deflate to Latin1 for longer strings, because this can be slow.
|
||||
static const size_t SourceDeflateLimit = 100;
|
||||
|
||||
explicit ScriptSource()
|
||||
: refs(0),
|
||||
data(SourceType(Missing())),
|
||||
pinnedUnitsStack_(nullptr),
|
||||
filename_(nullptr),
|
||||
displayURL_(nullptr),
|
||||
sourceMapURL_(nullptr),
|
||||
mutedErrors_(false),
|
||||
introductionOffset_(0),
|
||||
parameterListEnd_(0),
|
||||
introducerFilename_(nullptr),
|
||||
introductionType_(nullptr),
|
||||
xdrEncoder_(nullptr),
|
||||
id_(++idCount_),
|
||||
hasIntroductionOffset_(false),
|
||||
containsAsmJS_(false) {}
|
||||
explicit ScriptSource() : id_(++idCount_) {}
|
||||
|
||||
~ScriptSource() { MOZ_ASSERT(refs == 0); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user