author | Ted Campbell <tcampbell@mozilla.com> |
Mon, 16 Mar 2020 19:26:55 +0000 | |
changeset 519041 | c1233643f6affa98444a3b75186cc42952421344 |
parent 519040 | 4478047b72deb3382c609d235cb77b48cfc5e602 |
child 519042 | 17f0784ab346b5a6cda72984d0b72c804b1fac7f |
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
|
js/src/vm/JSScript.cpp | file | annotate | diff | comparison | revisions | |
js/src/vm/JSScript.h | file | annotate | diff | comparison | revisions |
--- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -1298,60 +1298,55 @@ XDRResult js::XDRLazyScript(XDRState<mod HandleScriptSourceObject sourceObject, HandleFunction fun, MutableHandle<LazyScript*> lazy) { MOZ_ASSERT_IF(mode == XDR_DECODE, sourceObject); JSContext* cx = xdr->cx(); { - uint32_t sourceStart; - uint32_t sourceEnd; - uint32_t toStringStart; - uint32_t toStringEnd; - uint32_t lineno; - uint32_t column; + SourceExtent extent; uint32_t immutableFlags; uint32_t ngcthings; if (mode == XDR_ENCODE) { - // Note: it's possible the LazyScript has a non-null script_ pointer - // to a JSScript. We don't encode it: we can just delazify the - // lazy script. - MOZ_ASSERT(fun == lazy->function()); - sourceStart = lazy->sourceStart(); - sourceEnd = lazy->sourceEnd(); - toStringStart = lazy->toStringStart(); - toStringEnd = lazy->toStringEnd(); - lineno = lazy->lineno(); - column = lazy->column(); + extent = lazy->extent(); immutableFlags = lazy->immutableFlags(); ngcthings = lazy->gcthings().size(); } - MOZ_TRY(xdr->codeUint32(&sourceStart)); - MOZ_TRY(xdr->codeUint32(&sourceEnd)); - MOZ_TRY(xdr->codeUint32(&toStringStart)); - MOZ_TRY(xdr->codeUint32(&toStringEnd)); - MOZ_TRY(xdr->codeUint32(&lineno)); - MOZ_TRY(xdr->codeUint32(&column)); + MOZ_TRY(xdr->codeUint32(&extent.sourceStart)); + MOZ_TRY(xdr->codeUint32(&extent.sourceEnd)); + MOZ_TRY(xdr->codeUint32(&extent.toStringStart)); + MOZ_TRY(xdr->codeUint32(&extent.toStringEnd)); + MOZ_TRY(xdr->codeUint32(&extent.lineno)); + MOZ_TRY(xdr->codeUint32(&extent.column)); + MOZ_TRY(xdr->codeUint32(&immutableFlags)); MOZ_TRY(xdr->codeUint32(&ngcthings)); if (mode == XDR_DECODE) { - lazy.set(LazyScript::CreateForXDR( - cx, ngcthings, fun, nullptr, enclosingScope, sourceObject, - immutableFlags, sourceStart, sourceEnd, toStringStart, toStringEnd, - lineno, column)); + lazy.set(LazyScript::CreateRaw(cx, ngcthings, fun, sourceObject, extent)); 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 + // scope being non-null if we have ever been nested inside non-lazy + // function. + if (enclosingScope) { + lazy->setEnclosingScope(enclosingScope); + } + fun->initLazyScript(lazy); } } bool hasFieldInitializers = fun->isClassConstructor(); MOZ_TRY( LazyScript::XDRScriptData(xdr, sourceObject, lazy, hasFieldInitializers)); @@ -5538,45 +5533,16 @@ LazyScript* LazyScript::Create( } } MOZ_ASSERT(iter == gcThings.end()); return lazy; } -/* static */ -LazyScript* LazyScript::CreateForXDR( - JSContext* cx, uint32_t ngcthings, HandleFunction fun, HandleScript script, - HandleScope enclosingScope, HandleScriptSourceObject sourceObject, - uint32_t immutableFlags, uint32_t sourceStart, uint32_t sourceEnd, - uint32_t toStringStart, uint32_t toStringEnd, uint32_t lineno, - uint32_t column) { - SourceExtent extent{sourceStart, sourceEnd, toStringStart, - toStringEnd, lineno, column}; - LazyScript* lazy = - LazyScript::CreateRaw(cx, ngcthings, fun, sourceObject, extent); - if (!lazy) { - return nullptr; - } - - 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 - // scope being non-null if we have ever been nested inside non-lazy - // function. - if (enclosingScope) { - lazy->setEnclosingScope(enclosingScope); - } - - return lazy; -} - void JSScript::updateJitCodeRaw(JSRuntime* rt) { MOZ_ASSERT(rt); uint8_t* jitCodeSkipArgCheck; if (hasBaselineScript() && baselineScript()->hasPendingIonCompileTask()) { MOZ_ASSERT(!isIonCompilingOffThread()); jitCodeRaw_ = rt->jitRuntime()->lazyLinkStub().value; jitCodeSkipArgCheck = jitCodeRaw_; } else if (hasIonScript()) {
--- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -1989,16 +1989,18 @@ using RuntimeScriptDataTable = // ^ ^ ^ ^ // | | | `---------` // | sourceStart sourceEnd | // | | // toStringStart toStringEnd // // NOTE: These are counted in Code Units from the start of the script source. struct SourceExtent { + SourceExtent() = default; + SourceExtent(uint32_t sourceStart, uint32_t sourceEnd, uint32_t toStringStart, uint32_t toStringEnd, uint32_t lineno, uint32_t column) : sourceStart(sourceStart), sourceEnd(sourceEnd), toStringStart(toStringStart), toStringEnd(toStringEnd), lineno(lineno), column(column) {} @@ -3144,52 +3146,34 @@ class LazyScript : public BaseScript { // | (setEnclosingScope) | and enclosing script is not lazy // v | (CreateForXDR with enclosingScope) // +-----------------+ | // | enclosing Scope |<-------------+ // +-----------------+ using BaseScript::BaseScript; + public: // Create a LazyScript without initializing the closedOverBindings and the // innerFunctions. To be GC-safe, the caller must initialize both vectors // with valid atoms and functions. static LazyScript* CreateRaw(JSContext* cx, uint32_t ngcthings, HandleFunction fun, HandleScriptSourceObject sourceObject, const SourceExtent& extent); - public: // Create a LazyScript and initialize closedOverBindings and innerFunctions // with the provided vectors. static LazyScript* Create( JSContext* cx, const frontend::CompilationInfo& compilationInfo, HandleFunction fun, HandleScriptSourceObject sourceObject, const frontend::AtomVector& closedOverBindings, const Vector<frontend::FunctionIndex>& innerFunctionIndexes, const SourceExtent& extent); - // Create a LazyScript and initialize the closedOverBindings and the - // innerFunctions with dummy values to be replaced in a later initialization - // phase. - // - // The "script" argument to this function can be null. If it's non-null, - // then this LazyScript should be associated with the given JSScript. - // - // The sourceObject and enclosingScope arguments may be null if the - // enclosing function is also lazy. - static LazyScript* CreateForXDR(JSContext* cx, uint32_t ngcthings, - HandleFunction fun, HandleScript script, - HandleScope enclosingScope, - HandleScriptSourceObject sourceObject, - uint32_t immutableFlags, uint32_t sourceStart, - uint32_t sourceEnd, uint32_t toStringStart, - uint32_t toStringEnd, uint32_t lineno, - uint32_t column); - template <XDRMode mode> static XDRResult XDRScriptData(XDRState<mode>* xdr, HandleScriptSourceObject sourceObject, Handle<LazyScript*> lazy, bool hasFieldInitializer); }; struct ScriptAndCounts {