author | Ted Campbell <tcampbell@mozilla.com> |
Mon, 16 Mar 2020 19:49:55 +0000 | |
changeset 519046 | ac02488efbcc76d07b10411b117150ddcc63b7ef |
parent 519045 | 3119be3dcf975bf0698363766930789d2e339c24 |
child 519047 | 36d00c1d1a1f080395aa8823e6fbe30f67cfa9ed |
push id | 110273 |
push user | tcampbell@mozilla.com |
push date | Mon, 16 Mar 2020 20:09:27 +0000 |
treeherder | autoland@cc99b4449f14 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mgaudet |
bugs | 1620495 |
milestone | 76.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/public/CompileOptions.h +++ b/js/public/CompileOptions.h @@ -94,18 +94,18 @@ class JS_PUBLIC_API TransitiveCompileOpt * sanitized ("muted") when the script is not same-origin with the global * for which it is loaded. Callers should set this flag for cross-origin * scripts, and it will be propagated appropriately to child scripts and * passed back in JSErrorReports. */ bool mutedErrors_ = false; // Either the Realm configuration or specialized VM operating modes may - // disallow syntax-parse (and the LazyScript data type) altogether. These - // conditions are checked in the CompileOptions constructor. + // disallow syntax-parse altogether. These conditions are checked in the + // CompileOptions constructor. bool forceFullParse_ = false; // Either the Realm configuration or the compile request may force // strict-mode. bool forceStrictMode_ = false; const char* filename_ = nullptr; const char* introducerFilename_ = nullptr; @@ -182,24 +182,24 @@ class JS_PUBLIC_API ReadOnlyCompileOptio public: // POD options. unsigned lineno = 1; unsigned column = 0; // The offset within the ScriptSource's full uncompressed text of the first // character we're presenting for compilation with this CompileOptions. // - // When we compile a LazyScript, we pass the compiler only the substring of - // the source the lazy function occupies. With chunked decompression, we - // may not even have the complete uncompressed source present in memory. But - // parse node positions are offsets within the ScriptSource's full text, - // and LazyScripts indicate their substring of the full source by its - // starting and ending offsets within the full text. This - // scriptSourceOffset field lets the frontend convert between these - // offsets and offsets within the substring presented for compilation. + // When we compile a lazy script, we pass the compiler only the substring of + // the source the lazy function occupies. With chunked decompression, we may + // not even have the complete uncompressed source present in memory. But parse + // node positions are offsets within the ScriptSource's full text, and + // BaseScript indicate their substring of the full source by its starting and + // ending offsets within the full text. This scriptSourceOffset field lets the + // frontend convert between these offsets and offsets within the substring + // presented for compilation. unsigned scriptSourceOffset = 0; // isRunOnce only applies to non-function scripts. bool isRunOnce = false; bool nonSyntacticScope = false; bool noScriptRval = false;
--- a/js/src/debugger/Debugger.h +++ b/js/src/debugger/Debugger.h @@ -435,21 +435,17 @@ class MOZ_RAII EvalOptions { * of lexical scopes). This is currently just JSObject, and is implemented by * CallObject, LexicalEnvironmentObject, and WithEnvironmentObject, among * others--but environments and objects are really two different concepts. */ using Env = JSObject; // The referent of a Debugger.Script. // -// - For most scripts, we point at their LazyScript, because that address -// doesn't change as the script is lazified/delazified. -// -// - For scripts that cannot be lazified, and thus have no LazyScript, we point -// directly to their JSScript. +// - For most scripts, we point at their BaseScript. // // - For Web Assembly instances for which we are presenting a script-like // interface, we point at their WasmInstanceObject. // // The DebuggerScript object itself simply stores a Cell* in its private // pointer, but when we're working with that pointer in C++ code, we'd rather // not pass around a Cell* and be constantly asserting that, yes, this really // does point to something okay. Instead, we immediately build an instance of
--- a/js/src/frontend/BinASTParserPerTokenizer.cpp +++ b/js/src/frontend/BinASTParserPerTokenizer.cpp @@ -301,17 +301,17 @@ JS::Result<FunctionBox*> BinASTParserPer } return funbox; } template <typename Tok> JS::Result<FunctionNode*> BinASTParserPerTokenizer<Tok>::makeEmptyFunctionNode( const size_t start, const FunctionSyntaxKind syntaxKind, FunctionBox* funbox) { - // LazyScript compilation requires basically none of the fields filled out. + // Lazy script compilation requires basically none of the fields filled out. TokenPos pos = tokenizer_->pos(start); BINJS_TRY_DECL(result, handler_.newFunction(syntaxKind, pos)); funbox->setStart(start, 0, pos.begin); funbox->setEnd(pos.end); handler_.setFunctionBox(result, funbox);
--- a/js/src/frontend/BinASTTokenReaderContext.h +++ b/js/src/frontend/BinASTTokenReaderContext.h @@ -1626,17 +1626,17 @@ class MOZ_STACK_CLASS BinASTTokenReaderC * This does *not* attempt to parse the subtree itself. Rather, the * returned `SkippableSubTree` contains the necessary information * to parse/tokenize the subtree at a later stage */ MOZ_MUST_USE JS::Result<SkippableSubTree> readSkippableSubTree( const FieldContext&); /** - * Register LazyScript for later modification. + * Register lazy script for later modification. */ MOZ_MUST_USE JS::Result<Ok> registerLazyScript(BaseScript* lazy); // --- Composite values. // // The underlying format does NOT allows for a `null` composite value. // // Reading will return an error either in case of I/O error or in case of @@ -1765,17 +1765,17 @@ class MOZ_STACK_CLASS BinASTTokenReaderC private: enum class MetadataOwnership { Owned, Unowned }; MetadataOwnership metadataOwned_ = MetadataOwnership::Owned; BinASTSourceMetadataContext* metadata_; const uint8_t* posBeforeTree_; - // LazyScript created while reading the tree. + // Lazy script created while reading the tree. // After reading tree, the start/end offset are set to correct value. Rooted<GCVector<BaseScript*>> lazyScripts_; public: BinASTTokenReaderContext(const BinASTTokenReaderContext&) = delete; BinASTTokenReaderContext(BinASTTokenReaderContext&&) = delete; BinASTTokenReaderContext& operator=(BinASTTokenReaderContext&) = delete;
--- a/js/src/frontend/BinASTTokenReaderMultipart.h +++ b/js/src/frontend/BinASTTokenReaderMultipart.h @@ -141,17 +141,17 @@ class MOZ_STACK_CLASS BinASTTokenReaderM * This does *not* attempt to parse the subtree itself. Rather, the * returned `SkippableSubTree` contains the necessary information * to parse/tokenize the subtree at a later stage */ MOZ_MUST_USE JS::Result<SkippableSubTree> readSkippableSubTree( const FieldContext&); /** - * Register LazyScript for later modification. + * Register lazy script for later modification. * Not used in multipart format. */ MOZ_MUST_USE JS::Result<Ok> registerLazyScript(BaseScript* lazy) { return Ok(); } // --- Composite values. //
--- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -2159,19 +2159,19 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::e return false; } return true; } bool BytecodeEmitter::isRunOnceLambda() { if (lazyScript) { - // NOTE: The TreatAsRunOnce flag on LazyScript was computed without a - // complete 'funbox' so we must compute the shouldSuppressRunOnce - // conditions now that we have the full parse info. + // NOTE: The TreatAsRunOnce flag on lazy BaseScript was computed without a + // complete 'funbox' so we must compute the shouldSuppressRunOnce conditions + // now that we have the full parse info. return lazyScript->treatAsRunOnce() && !sc->asFunctionBox()->shouldSuppressRunOnce(); } return parent && parent->emittingRunOnceLambda && !sc->asFunctionBox()->shouldSuppressRunOnce(); }
--- a/js/src/frontend/FullParseHandler.h +++ b/js/src/frontend/FullParseHandler.h @@ -104,21 +104,21 @@ class FullParseHandler { FullParseHandler(JSContext* cx, LifoAlloc& alloc, BaseScript* lazyOuterFunction, SourceKind kind = SourceKind::Text) : allocator(cx, alloc), lazyOuterFunction_(cx, lazyOuterFunction), lazyInnerFunctionIndex(0), lazyClosedOverBindingIndex(0), sourceKind_(kind) { - // The LazyScript::gcthings() array contains the inner function list + // The BaseScript::gcthings() array contains the inner function list // followed by the closed-over bindings data. Advance the index for // closed-over bindings to the end of the inner functions. The // nextLazyInnerFunction / nextLazyClosedOverBinding accessors confirm we - // have the expected types. See also: LazyScript::Create. + // have the expected types. See also: BaseScript::CreateLazy. if (lazyOuterFunction) { for (JS::GCCellPtr gcThing : lazyOuterFunction->gcthings()) { if (gcThing.is<JSObject>()) { lazyClosedOverBindingIndex++; } else { break; } }
--- a/js/src/frontend/NameAnalysisTypes.h +++ b/js/src/frontend/NameAnalysisTypes.h @@ -322,17 +322,17 @@ class NameLocation { bool isConst() const { return bindingKind() == BindingKind::Const; } bool hasKnownSlot() const { return kind_ == Kind::ArgumentSlot || kind_ == Kind::FrameSlot || kind_ == Kind::EnvironmentCoordinate; } }; -// These types are declared here for LazyScript::Create. +// These types are declared here for BaseScript::CreateLazy. using AtomVector = Vector<JSAtom*, 24, SystemAllocPolicy>; class FunctionBox; // FunctionBoxes stored in this type are required to be rooted // by the parser using FunctionBoxVector = Vector<const FunctionBox*, 8>; } // namespace frontend
--- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -802,17 +802,17 @@ bool PerHandlerParser<ParseHandler>:: propagateFreeNamesAndMarkClosedOverBindings(ParseContext::Scope& scope) { // Now that we have all the declared names in the scope, check which // functions should exhibit Annex B semantics. if (!scope.propagateAndMarkAnnexBFunctionBoxes(pc_)) { return false; } if (handler_.canSkipLazyClosedOverBindings()) { - // Scopes are nullptr-delimited in the LazyScript closed over bindings + // Scopes are nullptr-delimited in the BaseScript closed over bindings // array. while (JSAtom* name = handler_.nextLazyClosedOverBinding()) { scope.lookupDeclaredName(name)->value()->setClosedOver(); } return true; } bool isSyntaxParser = @@ -1647,17 +1647,17 @@ bool PerHandlerParser<FullParseHandler>: return true; } template <> bool PerHandlerParser<SyntaxParseHandler>::finishFunction( bool isStandaloneFunction /* = false */, IsFieldInitializer isFieldInitializer /* = IsFieldInitializer::Yes */) { - // The LazyScript for a lazily parsed function needs to know its set of + // The BaseScript for a lazily parsed function needs to know its set of // free variables and inner functions so that when it is fully parsed, we // can skip over any already syntax parsed inner functions and still // retain correct scope information. if (!finishFunctionScopes(isStandaloneFunction)) { return false; } @@ -2691,19 +2691,19 @@ GeneralParser<ParseHandler, Unit>::funct bool tryAnnexB /* = false */) { MOZ_ASSERT_IF(kind == FunctionSyntaxKind::Statement, funName); // If we see any inner function, note it on our current context. The bytecode // emitter may eliminate the function later, but we use a conservative // definition for consistency between lazy and full parsing. pc_->sc()->setHasInnerFunctions(); - // When fully parsing a LazyScript, we do not fully reparse its inner - // functions, which are also lazy. Instead, their free variables and - // source extents are recorded and may be skipped. + // When fully parsing a lazy script, we do not fully reparse its inner + // functions, which are also lazy. Instead, their free variables and source + // extents are recorded and may be skipped. if (handler_.canSkipLazyInnerFunctions()) { if (!skipLazyInnerFunction(funNode, toStringStart, kind, tryAnnexB)) { return null(); } return funNode; }
--- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -510,19 +510,18 @@ class MOZ_STACK_CLASS PerHandlerParser : NameNodeType stringLiteral(); const char* nameIsArgumentsOrEval(Node node); bool noteDestructuredPositionalFormalParameter(FunctionNodeType funNode, Node destruct); bool noteUsedName(HandlePropertyName name) { - // If the we are delazifying, the LazyScript already has all the - // closed-over info for bindings and there's no need to track used - // names. + // If the we are delazifying, the BaseScript already has all the closed-over + // info for bindings and there's no need to track used names. if (handler_.canSkipLazyClosedOverBindings()) { return true; } return ParserBase::noteUsedNameInternal(name); } // Required on Scope exit.
--- a/js/src/frontend/SharedContext.cpp +++ b/js/src/frontend/SharedContext.cpp @@ -279,17 +279,17 @@ void FunctionBox::initWithEnclosingScope enclosingScope_ = AbstractScopePtr(enclosingScope); } void FunctionBox::setEnclosingScopeForInnerLazyFunction( const AbstractScopePtr& enclosingScope) { // For lazy functions inside a function which is being compiled, we cache // the incomplete scope object while compiling, and store it to the - // LazyScript once the enclosing script successfully finishes compilation + // BaseScript once the enclosing script successfully finishes compilation // in FunctionBox::finish. MOZ_ASSERT(!enclosingScope_); enclosingScope_ = enclosingScope; } void FunctionBox::finish() { if (!emitBytecode) { // Lazy inner functions need to record their enclosing scope for when they
--- a/js/src/frontend/SharedContext.h +++ b/js/src/frontend/SharedContext.h @@ -302,19 +302,19 @@ class FunctionBox : public SharedContext FunctionBox* emitLink_; // This field is used for two purposes: // * If this FunctionBox refers to the function being compiled, this field // holds its enclosing scope, used for compilation. // * If this FunctionBox refers to a lazy child of the function being // compiled, this field holds the child's immediately enclosing scope. // Once compilation succeeds, we will store it in the child's - // LazyScript. (Debugger may become confused if LazyScripts refer to + // BaseScript. (Debugger may become confused if lazy scripts refer to // partially initialized enclosing scopes, so we must avoid storing the - // scope in the LazyScript until compilation has completed + // scope in the BaseScript until compilation has completed // successfully.) AbstractScopePtr enclosingScope_; // Names from the named lambda scope, if a named lambda. LexicalScope::Data* namedLambdaBindings_; // Names from the function scope. FunctionScope::Data* functionScopeBindings_;
--- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -2409,17 +2409,17 @@ void GCRuntime::updateCellPointers(Zone* // // 1) shapes // 2) typed object type descriptor objects // 3) all other objects // // Also, there can be data races calling IsForwarded() on the new location of a // cell that is being updated in parallel on another thread. This can be avoided // by updating some kinds of cells in different phases. This is done for -// JSScripts and LazyScripts, and JSScripts and Scopes. +// BaseScripts and Scopes. // // Since we want to minimize the number of phases, arrange kinds into three // arbitrary phases. static constexpr AllocKinds UpdatePhaseOne{ AllocKind::SCRIPT, AllocKind::BASE_SHAPE, AllocKind::SHAPE, AllocKind::ACCESSOR_SHAPE, AllocKind::OBJECT_GROUP, AllocKind::STRING, AllocKind::JITCODE}; @@ -7584,19 +7584,19 @@ void GCRuntime::mergeRealms(Realm* sourc // Cleanup tables and other state in the source realm/zone that will be // meaningless after merging into the target realm/zone. source->clearTables(); source->zone()->clearTables(); source->unsetIsDebuggee(); - // The delazification flag indicates the presence of LazyScripts in a - // realm for the Debugger API, so if the source realm created LazyScripts, - // the flag must be propagated to the target realm. + // The delazification flag indicates the presence of lazy scripts in a realm + // for the Debugger API, so if the source realm created lazy scripts, the flag + // must be propagated to the target realm. if (source->needsDelazificationForDebugger()) { target->scheduleDelazificationForDebugger(); } // Release any relocated arenas which we may be holding on to as they might // be in the source zone releaseHeldRelocatedArenas();
--- a/js/src/gc/PublicIterators.cpp +++ b/js/src/gc/PublicIterators.cpp @@ -110,17 +110,17 @@ static void TraverseInnerLazyScriptsForL } } static inline void DoScriptCallback(JSContext* cx, void* data, BaseScript* script, IterateScriptCallback callback, const JS::AutoRequireNoGC& nogc) { if (script->isLazyScript()) { - // We call the callback only for the LazyScript that: + // We call the callback only for the lazy script that: // (a) its enclosing script has ever been fully compiled and // itself is delazifyable (handled in this function) // (b) it is contained in the (a)'s inner function tree // (handled in TraverseInnerLazyScriptsForLazyScript) if (!script->enclosingScriptHasEverBeenCompiled()) { return; } } else {
--- a/js/src/gc/Tracer.h +++ b/js/src/gc/Tracer.h @@ -109,19 +109,17 @@ inline void AssertRootMarkingPhase(JSTra // Trace through a strong edge in the live object graph on behalf of // tracing. The effect of tracing the edge depends on the JSTracer being // used. For pointer types, |*thingp| must not be null. // // Note that weak edges are handled separately. GC things with weak edges must // not trace those edges during marking tracing (which would keep the referent // alive) but instead arrange for the edge to be swept by calling -// js::gc::IsAboutToBeFinalized or TraceWeakEdge during sweeping. For example, -// see the treatment of the script_ edge in LazyScript::traceChildren and -// GCRuntime::sweepLazyScripts. +// js::gc::IsAboutToBeFinalized or TraceWeakEdge during sweeping. // // GC things that are weakly held in containers can use WeakMap or a container // wrapped in the WeakCache<> template to perform the appropriate sweeping. template <typename T> inline void TraceEdge(JSTracer* trc, const WriteBarriered<T>* thingp, const char* name) { gc::TraceEdgeInternal(
--- a/js/src/jit-test/tests/xdr/debug-lazy.js +++ b/js/src/jit-test/tests/xdr/debug-lazy.js @@ -1,15 +1,15 @@ load(libdir + 'bytecode-cache.js'); // Ensure that if a function is encoded when non-lazy but relazifiable, then -// decoded, the resulting LazyScript is marked as being non-lazy so that when -// the debugger tries to delazify things it doesn't get all confused. We just -// use findScripts() to trigger debugger delazification; we don't really care -// about the scripts themselves. +// decoded, the resulting script is marked as being non-lazy so that when the +// debugger tries to delazify things it doesn't get all confused. We just use +// findScripts() to trigger debugger delazification; we don't really care about +// the scripts themselves. function checkAfter(ctx) { var dbg = new Debugger(ctx.global); var allScripts = dbg.findScripts(); assertEq(allScripts.length == 0, false); } test = ` function f() { return true; };
--- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -5211,23 +5211,18 @@ void CodeGenerator::visitCallKnown(LCall if (call->mir()->maybeCrossRealm()) { masm.switchToObjectRealm(calleereg, objreg); } if (call->mir()->needsArgCheck()) { masm.loadJitCodeRaw(calleereg, objreg); } else { - // In order to use the jitCodeNoArgCheck entry point, we must ensure the - // JSFunction is pointing to the canonical JSScript. Due to lambda cloning, - // we may still be referencing the original LazyScript. - // // NOTE: We checked that canonical function script had a valid JitScript. // This will not be tossed without all Ion code being tossed first. - masm.loadJitCodeMaybeNoArgCheck(calleereg, objreg); } // Nestle the StackPointer up to the argument vector. masm.freeStack(unusedStack); // Construct the IonFramePrefix. uint32_t descriptor = MakeFrameDescriptor(
--- a/js/src/vm/JSFunction.h +++ b/js/src/vm/JSFunction.h @@ -677,22 +677,19 @@ class JSFunction : public js::NativeObje static bool delazifyLazilyInterpretedFunction(JSContext* cx, js::HandleFunction fun); static bool delazifySelfHostedLazyFunction(JSContext* cx, js::HandleFunction fun); void maybeRelazify(JSRuntime* rt); // Function Scripts // - // Interpreted functions may either have an explicit JSScript (hasScript()) - // or be lazy with sufficient information to construct the JSScript if - // necessary (isInterpretedLazy()). - // - // A lazy function will have a LazyScript if the function came from parsed - // source, or nullptr if the function is a clone of a self hosted function. + // Interpreted functions have either a BaseScript or a SelfHostedLazyScript. A + // BaseScript may either be lazy or non-lazy (hasBytecode()). Methods may + // return a JSScript* if underlying BaseScript is known to have bytecode. // // There are several methods to get the script of an interpreted function: // // - For all interpreted functions, getOrCreateScript() will get the // JSScript, delazifying the function if necessary. This is the safest to // use, but has extra checks, requires a cx and may trigger a GC. // // - For functions known to have a JSScript, nonLazyScript() will get it.
--- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -235,17 +235,17 @@ XDRResult js::XDRScriptConst(XDRState<mo } template XDRResult js::XDRScriptConst(XDRState<XDR_ENCODE>*, MutableHandleValue); template XDRResult js::XDRScriptConst(XDRState<XDR_DECODE>*, MutableHandleValue); -// Code LazyScript's closed over bindings. +// Code lazy scripts's closed over bindings. template <XDRMode mode> /* static */ XDRResult BaseScript::XDRLazyScriptData(XDRState<mode>* xdr, HandleScriptSourceObject sourceObject, Handle<BaseScript*> lazy, bool hasFieldInitializers) { JSContext* cx = xdr->cx(); @@ -1120,19 +1120,17 @@ XDRResult js::XDRScript(XDRState<mode>* !realm->behaviors().getSingletonsAsTemplates()) { return xdr->fail(JS::TranscodeResult_Failure_RunOnceNotSupported); } } if (!sourceObjectArg) { xdrFlags |= OwnSource; } - // If script allows relazifying back to a LazyScript we must save that lazy - // script. If the lazy script only existed for the Debugger, we do not - // preserve it. + // Preserve the MutableFlags::AllowRelazify flag. if (script->allowRelazify()) { xdrFlags |= HasLazyScript; } } MOZ_TRY(xdr->codeUint8(&xdrFlags)); if (mode == XDR_ENCODE) { @@ -1331,17 +1329,17 @@ XDRResult js::XDRLazyScript(XDRState<mod if (!lazy) { return xdr->fail(JS::TranscodeResult_Throw); } lazy->setImmutableFlags(immutableFlags); // Set the enclosing scope of the lazy function. This value should only be // set if we have a non-lazy enclosing script at this point. - // LazyScript::enclosingScriptHasEverBeenCompiled relies on the enclosing + // BaseScript::enclosingScriptHasEverBeenCompiled relies on the enclosing // scope being non-null if we have ever been nested inside non-lazy // function. if (enclosingScope) { lazy->setEnclosingScope(enclosingScope); } fun->initLazyScript(lazy); } @@ -5469,17 +5467,17 @@ BaseScript* BaseScript::CreateRawLazy(JS uint8_t* stubEntry = nullptr; #endif BaseScript* lazy = new (res) BaseScript(stubEntry, fun, sourceObject, extent); if (!lazy) { return nullptr; } - // Flag this script as a LazyScript + // Flag this script as a lazy BaseScript. lazy->setIsLazyScript(); // Allocate a PrivateScriptData if it will not be empty. Lazy class // constructors also need PrivateScriptData for field lists. if (ngcthings || fun->isClassConstructor()) { UniquePtr<PrivateScriptData> data(PrivateScriptData::new_(cx, ngcthings)); if (!data) { return nullptr;
--- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -2140,21 +2140,20 @@ class BaseScript : public gc::TenuredCel SourceExtent extent() const { return extent_; } MOZ_MUST_USE bool appendSourceDataForToString(JSContext* cx, js::StringBuffer& buf); #if defined(JS_BUILD_BINAST) // Set the position of the function in the source code. // - // BinAST file format can put lazy functions after the entire tree, - // and in that case LazyScript::Create will be called with - // dummy values for those positions, and then once it reaches to the lazy - // function part, this function is called to set those positions to - // correct value. + // BinAST file format can put lazy functions after the entire tree, and in + // that case BaseScript::CreateLazy will be called with dummy values for those + // positions, and then once it reaches to the lazy function part, this + // function is called to set those positions to correct value. void setPositions(uint32_t sourceStart, uint32_t sourceEnd, uint32_t toStringStart, uint32_t toStringEnd) { MOZ_ASSERT(toStringStart <= sourceStart); MOZ_ASSERT(sourceStart <= sourceEnd); MOZ_ASSERT(sourceEnd <= toStringEnd); extent_.sourceStart = sourceStart; extent_.sourceEnd = sourceEnd; @@ -3158,18 +3157,16 @@ JSScript* CloneScriptIntoFunction(JSCont HandleFunction fun, HandleScript src, Handle<ScriptSourceObject*> sourceObject); JSScript* CloneGlobalScript(JSContext* cx, ScopeKind scopeKind, HandleScript src); } /* namespace js */ -// JS::ubi::Nodes can point to js::LazyScripts; they're js::gc::Cell instances -// with no associated compartment. namespace JS { namespace ubi { template <> class Concrete<JSScript> : public Concrete<js::BaseScript> {}; } // namespace ubi } // namespace JS
--- a/js/src/vm/Realm.cpp +++ b/js/src/vm/Realm.cpp @@ -560,20 +560,16 @@ static bool AddInnerLazyFunctionsFromScr static bool AddLazyFunctionsForRealm(JSContext* cx, MutableHandleObjectVector lazyFunctions, gc::AllocKind kind) { // Find all live root lazy functions in the realm: those which have a // non-lazy enclosing script, and which do not have an uncompiled enclosing // script. The last condition is so that we don't compile lazy scripts // whose enclosing scripts failed to compile, indicating that the lazy // script did not escape the script. - // - // Some LazyScripts have a non-null |JSScript* script| pointer. We still - // want to delazify in that case: this pointer is weak so the JSScript - // could be destroyed at the next GC. for (auto i = cx->zone()->cellIter<JSObject>(kind); !i.done(); i.next()) { JSFunction* fun = &i->as<JSFunction>(); // When iterating over the GC-heap, we may encounter function objects that // are incomplete (missing a BaseScript when we expect one). We must check // for this case before we can call JSFunction::hasBytecode(). if (fun->isIncomplete()) {
--- a/js/src/vm/Realm.h +++ b/js/src/vm/Realm.h @@ -764,17 +764,17 @@ class JS::Realm : public JS::shadow::Rea bool collectCoverage() const; bool collectCoverageForDebug() const; bool collectCoverageForPGO() const; bool needsDelazificationForDebugger() const { return debugModeBits_ & DebuggerNeedsDelazification; } - // Schedule the realm to be delazified. Called from LazyScript::Create. + // Schedule the realm to be delazified. Called from BaseScript::CreateLazy. void scheduleDelazificationForDebugger() { debugModeBits_ |= DebuggerNeedsDelazification; } // If we scheduled delazification for turning on debug mode, delazify all // scripts. bool ensureDelazifyScriptsForDebugger(JSContext* cx);
--- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -211,26 +211,24 @@ inline bool CanUseExtraThreads() { } void DisableExtraThreads(); using ScriptAndCountsVector = GCVector<ScriptAndCounts, 0, SystemAllocPolicy>; class AutoLockScriptData; -// Self-hosted lazy functions do not maintain a LazyScript as we can compile -// from the copy in the self-hosting zone. To allow these functions to be -// called by the JITs, we need a minimal script object. There is one instance -// per runtime. +// Self-hosted lazy functions do not maintain a BaseScript as we can clone from +// the copy in the self-hosting zone. To allow these functions to be called by +// the JITs, we need a minimal script object. There is one instance per runtime. struct SelfHostedLazyScript { SelfHostedLazyScript() = default; - // Pointer to interpreter trampoline. This field is stored at same location - // as in JSScript, allowing the JIT to directly call LazyScripts in the same - // way as JSScripts. + // Pointer to interpreter trampoline. This field is stored at same location as + // in BaseScript::jitCodeRaw_. uint8_t* jitCodeRaw_ = nullptr; static constexpr size_t offsetOfJitCodeRaw() { return offsetof(SelfHostedLazyScript, jitCodeRaw_); } }; } // namespace js @@ -390,19 +388,19 @@ struct JSRuntime { js::MainThreadData<const JSSecurityCallbacks*> securityCallbacks; js::MainThreadData<const js::DOMCallbacks*> DOMcallbacks; js::MainThreadData<JSDestroyPrincipalsOp> destroyPrincipals; js::MainThreadData<JSReadPrincipalsOp> readPrincipals; /* Optional warning reporter. */ js::MainThreadData<JS::WarningReporter> warningReporter; - // Lazy self-hosted functions use a shared SelfHostedLazyScript instead - // instead of a LazyScript. This contains the minimal trampolines for the - // scripts to perform direct calls. + // Lazy self-hosted functions use a shared SelfHostedLazyScript instance + // instead instead of a BaseScript. This contains the minimal pointers to + // trampolines for the scripts to support direct jitCodeRaw calls. js::UnprotectedData<js::SelfHostedLazyScript> selfHostedLazyScript; private: /* Gecko profiling metadata */ js::UnprotectedData<js::GeckoProfilerRuntime> geckoProfiler_; public: js::GeckoProfilerRuntime& geckoProfiler() { return geckoProfiler_.ref(); }
--- a/js/src/vm/SharedStencil.h +++ b/js/src/vm/SharedStencil.h @@ -197,18 +197,19 @@ enum class MutableScriptFlagsEnum : uint HasBeenCloned = 1 << 10, // Script has an entry in Realm::scriptCountsMap. HasScriptCounts = 1 << 12, // Script has an entry in Realm::debugScriptMap. HasDebugScript = 1 << 13, - // Script has an associated LazyScript that may be used for relazification. - // This flag may be used to prevent relazification from happening. + // Script supports relazification where it releases bytecode and gcthings to + // save memory. This process is opt-in since various complexities may disallow + // this for some scripts. // NOTE: Must check for isRelazifiable() before setting this flag. AllowRelazify = 1 << 14, // IonMonkey compilation hints. // Script has had hoisted bounds checks fail. FailedBoundsCheck = 1 << 15, @@ -239,17 +240,17 @@ enum class MutableScriptFlagsEnum : uint NeedsArgsObj = 1 << 25, // Set if the debugger's onNewScript hook has not yet been called. HideScriptFromDebugger = 1 << 26, // Set if the script has opted into spew SpewEnabled = 1 << 27, - // Set if this is a LazyScript. + // Set if this is a lazy script. IsLazyScript = 1 << 28, }; class MutableScriptFlags : public ScriptFlagBase<MutableScriptFlagsEnum> { public: MutableScriptFlags() = default; void static_asserts() {
--- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -120,18 +120,18 @@ class XDRBuffer<XDR_DECODE> : public XDR class XDRCoderBase; class XDRIncrementalEncoder; // An AutoXDRTree is used to identify section encoded by an // XDRIncrementalEncoder. // // Its primary goal is to identify functions, such that we can first encode them -// as LazyScript, and later replaced by them by their corresponding bytecode -// once delazified. +// as a lazy BaseScript, and later replaced by them by their corresponding +// bytecode once delazified. // // As a convenience, this is also used to identify the top-level of the content // encoded by an XDRIncrementalEncoder. // // Sections can be encoded any number of times in an XDRIncrementalEncoder, and // the latest encoded version would replace all the previous one. class MOZ_RAII AutoXDRTree { public: