зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 17 changesets (bug 1744178, bug 1734098) for causing leaks. CLOSED TREE
Backed out changeset 08070838c7d2 (bug 1734098) Backed out changeset cfdf7ed9a5a2 (bug 1734098) Backed out changeset 02d7ca7fc45c (bug 1734098) Backed out changeset 7b7c59fc644b (bug 1734098) Backed out changeset 630055366dac (bug 1734098) Backed out changeset da83b4571cf2 (bug 1734098) Backed out changeset 323af9d3e0e1 (bug 1734098) Backed out changeset cf458ad5345a (bug 1734098) Backed out changeset a85846f79eb5 (bug 1734098) Backed out changeset 0d07931e6bc8 (bug 1734098) Backed out changeset ffd72fa3fc59 (bug 1734098) Backed out changeset 3174f1ecfd03 (bug 1734098) Backed out changeset cfb19671fd4e (bug 1734098) Backed out changeset c3b9c8221059 (bug 1734098) Backed out changeset 532328aedaaa (bug 1734098) Backed out changeset 48aa5ca15135 (bug 1734098) Backed out changeset 6ca5bceb693c (bug 1744178)
This commit is contained in:
Родитель
120bd0a098
Коммит
777ce42897
|
@ -95,35 +95,18 @@ nsresult JSExecutionContext::JoinCompile(JS::OffThreadToken** aOffThreadToken) {
|
|||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
MOZ_ASSERT(!mScript);
|
||||
|
||||
JS::InstantiateOptions instantiateOptions(mCompileOptions);
|
||||
JS::Rooted<JS::InstantiationStorage> storage(mCx);
|
||||
RefPtr<JS::Stencil> stencil = JS::FinishCompileToStencilOffThread(
|
||||
mCx, *aOffThreadToken, storage.address());
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!stencil) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
JS::Rooted<JSScript*> script(
|
||||
mCx, JS::InstantiateGlobalStencil(mCx, instantiateOptions, stencil,
|
||||
storage.address()));
|
||||
if (!script) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
if (mEncodeBytecode) {
|
||||
if (!JS::StartIncrementalEncoding(mCx, std::move(stencil))) {
|
||||
mScript.set(JS::FinishOffThreadScriptAndStartIncrementalEncoding(
|
||||
mCx, *aOffThreadToken));
|
||||
} else {
|
||||
mScript.set(JS::FinishOffThreadScript(mCx, *aOffThreadToken));
|
||||
}
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
}
|
||||
|
||||
mScript.set(script);
|
||||
|
||||
if (!UpdateDebugMetadata()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -248,19 +231,8 @@ nsresult JSExecutionContext::JoinDecode(JS::OffThreadToken** aOffThreadToken) {
|
|||
}
|
||||
|
||||
MOZ_ASSERT(!mWantsReturnValue);
|
||||
JS::Rooted<JS::InstantiationStorage> storage(mCx);
|
||||
RefPtr<JS::Stencil> stencil = JS::FinishDecodeStencilOffThread(
|
||||
mCx, *aOffThreadToken, storage.address());
|
||||
mScript.set(JS::FinishOffThreadScriptDecoder(mCx, *aOffThreadToken));
|
||||
*aOffThreadToken = nullptr; // Mark the token as having been finished.
|
||||
if (!stencil) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
return mRv;
|
||||
}
|
||||
|
||||
JS::InstantiateOptions instantiateOptions(mCompileOptions);
|
||||
mScript.set(JS::InstantiateGlobalStencil(mCx, instantiateOptions, stencil,
|
||||
storage.address()));
|
||||
if (!mScript) {
|
||||
mSkip = true;
|
||||
mRv = EvaluationExceptionToNSResult(mCx);
|
||||
|
|
|
@ -250,16 +250,7 @@ nsresult ModuleLoader::CreateModuleScript(ModuleLoadRequest* aRequest) {
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (aRequest->mWasCompiledOMT) {
|
||||
JS::Rooted<JS::InstantiationStorage> storage(cx);
|
||||
|
||||
RefPtr<JS::Stencil> stencil = JS::FinishCompileModuleToStencilOffThread(
|
||||
cx, aRequest->mOffThreadToken, storage.address());
|
||||
if (stencil) {
|
||||
JS::InstantiateOptions instantiateOptions(options);
|
||||
module = JS::InstantiateModuleStencil(cx, instantiateOptions, stencil,
|
||||
storage.address());
|
||||
}
|
||||
|
||||
module = JS::FinishOffThreadModule(cx, aRequest->mOffThreadToken);
|
||||
aRequest->mOffThreadToken = nullptr;
|
||||
rv = module ? NS_OK : NS_ERROR_FAILURE;
|
||||
} else {
|
||||
|
|
|
@ -171,12 +171,12 @@ void ScriptLoadRequest::MaybeCancelOffThreadScript() {
|
|||
JSContext* cx = danger::GetJSContext();
|
||||
// Follow the same conditions as ScriptLoader::AttemptAsyncScriptCompile
|
||||
if (IsModuleRequest()) {
|
||||
JS::CancelCompileModuleToStencilOffThread(cx, mOffThreadToken);
|
||||
JS::CancelOffThreadModule(cx, mOffThreadToken);
|
||||
} else if (IsSource()) {
|
||||
JS::CancelCompileToStencilOffThread(cx, mOffThreadToken);
|
||||
JS::CancelOffThreadScript(cx, mOffThreadToken);
|
||||
} else {
|
||||
MOZ_ASSERT(IsBytecode());
|
||||
JS::CancelDecodeStencilOffThread(cx, mOffThreadToken);
|
||||
JS::CancelOffThreadScriptDecoder(cx, mOffThreadToken);
|
||||
}
|
||||
|
||||
// Cancellation request above should guarantee removal of the parse task, so
|
||||
|
|
|
@ -1840,8 +1840,7 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
|
|||
|
||||
size_t length =
|
||||
aRequest->mScriptBytecode.length() - aRequest->mBytecodeOffset;
|
||||
JS::DecodeOptions decodeOptions(options);
|
||||
if (!JS::CanDecodeOffThread(cx, decodeOptions, length)) {
|
||||
if (!JS::CanDecodeOffThread(cx, options, length)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -1868,19 +1867,18 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
|
|||
|
||||
aRequest->mOffThreadToken =
|
||||
maybeSource.constructed<SourceText<char16_t>>()
|
||||
? JS::CompileModuleToStencilOffThread(
|
||||
? JS::CompileOffThreadModule(
|
||||
cx, options, maybeSource.ref<SourceText<char16_t>>(),
|
||||
OffThreadScriptLoaderCallback, static_cast<void*>(runnable))
|
||||
: JS::CompileModuleToStencilOffThread(
|
||||
: JS::CompileOffThreadModule(
|
||||
cx, options, maybeSource.ref<SourceText<Utf8Unit>>(),
|
||||
OffThreadScriptLoaderCallback, static_cast<void*>(runnable));
|
||||
if (!aRequest->mOffThreadToken) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else if (aRequest->IsBytecode()) {
|
||||
JS::DecodeOptions decodeOptions(options);
|
||||
aRequest->mOffThreadToken = JS::DecodeStencilOffThread(
|
||||
cx, decodeOptions, aRequest->mScriptBytecode, aRequest->mBytecodeOffset,
|
||||
aRequest->mOffThreadToken = JS::DecodeOffThreadScript(
|
||||
cx, options, aRequest->mScriptBytecode, aRequest->mBytecodeOffset,
|
||||
OffThreadScriptLoaderCallback, static_cast<void*>(runnable));
|
||||
if (!aRequest->mOffThreadToken) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -1908,10 +1906,10 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
|
|||
|
||||
aRequest->mOffThreadToken =
|
||||
maybeSource.constructed<SourceText<char16_t>>()
|
||||
? JS::CompileToStencilOffThread(
|
||||
? JS::CompileOffThread(
|
||||
cx, options, maybeSource.ref<SourceText<char16_t>>(),
|
||||
OffThreadScriptLoaderCallback, static_cast<void*>(runnable))
|
||||
: JS::CompileToStencilOffThread(
|
||||
: JS::CompileOffThread(
|
||||
cx, options, maybeSource.ref<SourceText<Utf8Unit>>(),
|
||||
OffThreadScriptLoaderCallback, static_cast<void*>(runnable));
|
||||
if (!aRequest->mOffThreadToken) {
|
||||
|
@ -2182,8 +2180,6 @@ nsresult ScriptLoader::FillCompileOptionsForRequest(
|
|||
|
||||
aOptions->borrowBuffer = true;
|
||||
|
||||
aOptions->allocateInstantiationStorage = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1855,7 +1855,7 @@ NotifyOffThreadScriptCompletedRunnable::Run() {
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
stencil = JS::FinishCompileToStencilOffThread(cx, mToken);
|
||||
stencil = JS::FinishOffThreadCompileToStencil(cx, mToken);
|
||||
}
|
||||
|
||||
if (!sReceivers) {
|
||||
|
|
|
@ -179,11 +179,6 @@ class JS_PUBLIC_API TransitiveCompileOptions {
|
|||
// called. There is currently no mechanism to release the data sooner.
|
||||
bool usePinnedBytecode = false;
|
||||
|
||||
// When performing off-thread task that generates JS::Stencil as output,
|
||||
// allocate JS::InstantiationStorage off main thread to reduce the
|
||||
// main thread allocation.
|
||||
bool allocateInstantiationStorage = false;
|
||||
|
||||
/**
|
||||
* |introductionType| is a statically allocated C string: one of "eval",
|
||||
* "Function", or "GeneratorFunction".
|
||||
|
@ -503,8 +498,6 @@ class JS_PUBLIC_API DecodeOptions {
|
|||
public:
|
||||
bool borrowBuffer = false;
|
||||
bool usePinnedBytecode = false;
|
||||
bool allocateInstantiationStorage = false;
|
||||
bool forceAsync = false;
|
||||
|
||||
const char* introducerFilename = nullptr;
|
||||
|
||||
|
@ -519,8 +512,6 @@ class JS_PUBLIC_API DecodeOptions {
|
|||
explicit DecodeOptions(const ReadOnlyCompileOptions& options)
|
||||
: borrowBuffer(options.borrowBuffer),
|
||||
usePinnedBytecode(options.usePinnedBytecode),
|
||||
allocateInstantiationStorage(options.allocateInstantiationStorage),
|
||||
forceAsync(options.forceAsync),
|
||||
introducerFilename(options.introducerFilename()),
|
||||
introductionType(options.introductionType),
|
||||
introductionLineno(options.introductionLineno),
|
||||
|
@ -529,8 +520,6 @@ class JS_PUBLIC_API DecodeOptions {
|
|||
void copyTo(CompileOptions& options) const {
|
||||
options.borrowBuffer = borrowBuffer;
|
||||
options.usePinnedBytecode = usePinnedBytecode;
|
||||
options.allocateInstantiationStorage = allocateInstantiationStorage;
|
||||
options.forceAsync = forceAsync;
|
||||
options.introducerFilename_ = introducerFilename;
|
||||
options.introductionType = introductionType;
|
||||
options.introductionLineno = introductionLineno;
|
||||
|
|
|
@ -11,13 +11,30 @@
|
|||
#ifndef js_OffThreadScriptCompilation_h
|
||||
#define js_OffThreadScriptCompilation_h
|
||||
|
||||
#include "mozilla/Range.h" // mozilla::Range
|
||||
#include "mozilla/Vector.h" // mozilla::Vector
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
#include "jstypes.h" // JS_PUBLIC_API
|
||||
|
||||
#include "js/CompileOptions.h" // JS::DecodeOptions, JS::ReadOnlyCompileOptions
|
||||
#include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions
|
||||
#include "js/GCVector.h" // JS::GCVector
|
||||
#include "js/Transcoding.h" // JS::TranscodeSource
|
||||
|
||||
struct JS_PUBLIC_API JSContext;
|
||||
class JS_PUBLIC_API JSScript;
|
||||
|
||||
namespace JS {
|
||||
|
||||
template <typename UnitT>
|
||||
class SourceText;
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
union Utf8Unit;
|
||||
}
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -29,29 +46,113 @@ using OffThreadCompileCallback = void (*)(OffThreadToken* token,
|
|||
/*
|
||||
* Off thread compilation control flow.
|
||||
*
|
||||
* (See also js/public/experimental/JSStencil.h)
|
||||
*
|
||||
* After successfully triggering an off thread compile of a script, the
|
||||
* callback will eventually be invoked with the specified data and a token
|
||||
* for the compilation. The callback will be invoked while off thread,
|
||||
* so must ensure that its operations are thread safe. Afterwards, one of the
|
||||
* following functions must be invoked on the runtime's main thread:
|
||||
*
|
||||
* - FinishCompileToStencilOffThread, to get the result stencil (or nullptr on
|
||||
* failure).
|
||||
* - CancelCompileToStencilOffThread, to free the resources without creating a
|
||||
* stencil.
|
||||
* - FinishOffThreadScript, to get the result script (or nullptr on failure).
|
||||
* - CancelOffThreadScript, to free the resources without creating a script.
|
||||
*
|
||||
* The characters passed in to CompileToStencilOffThread must remain live until
|
||||
* the callback is invoked.
|
||||
* The characters passed in to CompileOffThread must remain live until the
|
||||
* callback is invoked, and the resulting script will be rooted until the call
|
||||
* to FinishOffThreadScript.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API bool CanCompileOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options, size_t length);
|
||||
|
||||
extern JS_PUBLIC_API bool CanDecodeOffThread(JSContext* cx,
|
||||
const DecodeOptions& options,
|
||||
size_t length);
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// NOTE: Unlike for the normal sync compilation functions, this function NEVER
|
||||
// INFLATES TO UTF-16. Therefore, it is ALWAYS invoking experimental
|
||||
// UTF-8 support. Inflate to UTF-16 yourself and use the other overload
|
||||
// if you're unable to take a risk using unstable functionality.
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// Finish the off-thread parse/decode task and return the script. Return the
|
||||
// script on success, or return null on failure (usually with an error reported)
|
||||
extern JS_PUBLIC_API JSScript* FinishOffThreadScript(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
// Finish the off-thread parse/decode task and return the script, and register
|
||||
// an encoder on its script source, such that all functions can be encoded as
|
||||
// they are parsed. This strategy is used to avoid blocking the main thread in
|
||||
// a non-interruptible way.
|
||||
//
|
||||
// See also JS::FinishIncrementalEncoding.
|
||||
//
|
||||
// Return the script on success, or return null on failure (usually with an
|
||||
// error reported)
|
||||
extern JS_PUBLIC_API JSScript* FinishOffThreadScriptAndStartIncrementalEncoding(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelOffThreadScript(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelOffThreadCompileToStencil(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileOffThreadModule(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// NOTE: Unlike for the normal sync compilation functions, this function NEVER
|
||||
// INFLATES TO UTF-16. Therefore, it is ALWAYS invoking experimental
|
||||
// UTF-8 support. Inflate to UTF-16 yourself and use the other overload
|
||||
// if you're unable to take a risk using unstable functionality.
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileOffThreadModule(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API JSObject* FinishOffThreadModule(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelOffThreadModule(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API bool CanDecodeOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options, size_t length);
|
||||
|
||||
// Decode stencil from the buffer and instantiate JSScript from it.
|
||||
//
|
||||
// The start of `buffer` and `cursor` should meet
|
||||
// IsTranscodingBytecodeAligned and IsTranscodingBytecodeOffsetAligned.
|
||||
// (This should be handled while encoding).
|
||||
//
|
||||
// `buffer` should be alive until the end of `FinishOffThreadScriptDecoder`.
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeOffThreadScript(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
mozilla::Vector<uint8_t>& buffer /* TranscodeBuffer& */, size_t cursor,
|
||||
OffThreadCompileCallback callback, void* callbackData);
|
||||
|
||||
// The start of `range` should be meet IsTranscodingBytecodeAligned and
|
||||
// AlignTranscodingBytecodeOffset.
|
||||
// (This should be handled while encoding).
|
||||
//
|
||||
// `range` should be alive until the end of `FinishOffThreadScriptDecoder`.
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeOffThreadScript(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
const mozilla::Range<uint8_t>& range /* TranscodeRange& */,
|
||||
OffThreadCompileCallback callback, void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API JSScript* FinishOffThreadScriptDecoder(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelOffThreadScriptDecoder(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelMultiOffThreadScriptsDecoder(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
|||
//
|
||||
// JS::DecodeScript* and JS::DecodeOffThreadScript internally check this.
|
||||
//
|
||||
// JS::DecodeMultiStencilsOffThread checks some options shared across multiple
|
||||
// JS::DecodeMultiOffThreadStencils checks some options shared across multiple
|
||||
// scripts. Caller is responsible for checking each script with this API when
|
||||
// using the decoded script instead of compiling a new script wiht the given
|
||||
// options.
|
||||
|
|
|
@ -26,20 +26,14 @@
|
|||
#include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions, JS::InstantiateOptions, JS::DecodeOptions
|
||||
#include "js/OffThreadScriptCompilation.h" // JS::OffThreadCompileCallback
|
||||
#include "js/SourceText.h" // JS::SourceText
|
||||
#include "js/Transcoding.h" // JS::TranscodeSources, JS::TranscodeBuffer, JS::TranscodeRange
|
||||
#include "js/UniquePtr.h" // js::UniquePtr
|
||||
#include "js/Transcoding.h" // JS::TranscodeSource
|
||||
|
||||
struct JS_PUBLIC_API JSContext;
|
||||
class JS_PUBLIC_API JSTracer;
|
||||
|
||||
// Underlying opaque type.
|
||||
namespace js {
|
||||
struct ParseTask;
|
||||
namespace frontend {
|
||||
namespace js::frontend {
|
||||
struct CompilationStencil;
|
||||
struct CompilationGCOutput;
|
||||
} // namespace frontend
|
||||
} // namespace js
|
||||
};
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -47,47 +41,6 @@ class OffThreadToken;
|
|||
|
||||
using Stencil = js::frontend::CompilationStencil;
|
||||
|
||||
// Temporary storage used during instantiating Stencil.
|
||||
//
|
||||
// Off-thread APIs can allocate this instance off main thread, and pass it back
|
||||
// to the main thread, in order to reduce the main thread allocation.
|
||||
struct InstantiationStorage {
|
||||
private:
|
||||
// Owned CompilationGCOutput.
|
||||
//
|
||||
// This uses raw pointer instead of UniquePtr because CompilationGCOutput
|
||||
// is opaque.
|
||||
js::frontend::CompilationGCOutput* gcOutput_ = nullptr;
|
||||
|
||||
friend JS_PUBLIC_API JSScript* InstantiateGlobalStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil,
|
||||
InstantiationStorage* storage);
|
||||
|
||||
friend JS_PUBLIC_API JSObject* InstantiateModuleStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil,
|
||||
InstantiationStorage* storage);
|
||||
|
||||
friend struct js::ParseTask;
|
||||
|
||||
public:
|
||||
InstantiationStorage() = default;
|
||||
InstantiationStorage(InstantiationStorage&& other)
|
||||
: gcOutput_(other.gcOutput_) {
|
||||
other.gcOutput_ = nullptr;
|
||||
}
|
||||
|
||||
~InstantiationStorage();
|
||||
|
||||
private:
|
||||
InstantiationStorage(const InstantiationStorage& other) = delete;
|
||||
void operator=(const InstantiationStorage& aOther) = delete;
|
||||
|
||||
public:
|
||||
bool isValid() const { return !!gcOutput_; }
|
||||
|
||||
void trace(JSTracer* trc);
|
||||
};
|
||||
|
||||
// These non-member functions let us manipulate the ref counts of the opaque
|
||||
// Stencil type. The RefPtrTraits below calls these for use when using the
|
||||
// RefPtr type.
|
||||
|
@ -118,12 +71,15 @@ extern JS_PUBLIC_API already_AddRefed<Stencil> CompileModuleScriptToStencil(
|
|||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<char16_t>& srcBuf);
|
||||
|
||||
// Off-thread compilation uses the normal off-thread APIs but uses a special
|
||||
// finish method to avoid automatic instantiation. This is used for both global
|
||||
// and modules compiles.
|
||||
extern JS_PUBLIC_API already_AddRefed<Stencil> FinishOffThreadStencil(
|
||||
JSContext* cx, JS::OffThreadToken* token);
|
||||
|
||||
// Instantiate the Stencil into current Realm and return the JSScript.
|
||||
extern JS_PUBLIC_API JSScript* InstantiateGlobalStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil);
|
||||
extern JS_PUBLIC_API JSScript* InstantiateGlobalStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil,
|
||||
InstantiationStorage* storage);
|
||||
|
||||
// Return true if the stencil relies on external data as a result of XDR
|
||||
// decoding.
|
||||
|
@ -136,9 +92,6 @@ extern JS_PUBLIC_API bool StencilCanLazilyParse(Stencil* stencil);
|
|||
// engine this is a js::ModuleObject.
|
||||
extern JS_PUBLIC_API JSObject* InstantiateModuleStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil);
|
||||
extern JS_PUBLIC_API JSObject* InstantiateModuleStencil(
|
||||
JSContext* cx, const InstantiateOptions& options, Stencil* stencil,
|
||||
InstantiationStorage* storage);
|
||||
|
||||
// Serialize the Stencil into the transcode buffer.
|
||||
extern JS_PUBLIC_API TranscodeResult EncodeStencil(JSContext* cx,
|
||||
|
@ -154,8 +107,6 @@ extern JS_PUBLIC_API TranscodeResult DecodeStencil(JSContext* cx,
|
|||
extern JS_PUBLIC_API size_t SizeOfStencil(Stencil* stencil,
|
||||
mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
// Start an off-thread task to compile the source text into a JS::Stencil,
|
||||
// using the provided options.
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileToStencilOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
|
@ -166,82 +117,18 @@ extern JS_PUBLIC_API OffThreadToken* CompileToStencilOffThread(
|
|||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// Start an off-thread task to compile the module source text into a
|
||||
// JS::Stencil, using the provided options.
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileModuleToStencilOffThread(
|
||||
extern JS_PUBLIC_API already_AddRefed<Stencil> FinishOffThreadCompileToStencil(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeMultiOffThreadStencils(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API OffThreadToken* CompileModuleToStencilOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// Start an off-thread task to decode stencil.
|
||||
//
|
||||
// The start of `buffer` and `cursor` should meet
|
||||
// IsTranscodingBytecodeAligned and IsTranscodingBytecodeOffsetAligned.
|
||||
// (This should be handled while encoding).
|
||||
//
|
||||
// `buffer` should be alive until the end of `FinishOffThreadScriptDecoder`.
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeStencilOffThread(
|
||||
JSContext* cx, const DecodeOptions& options, const TranscodeBuffer& buffer,
|
||||
size_t cursor, OffThreadCompileCallback callback, void* callbackData);
|
||||
|
||||
// The start of `range` should be meet IsTranscodingBytecodeAligned and
|
||||
// AlignTranscodingBytecodeOffset.
|
||||
// (This should be handled while encoding).
|
||||
//
|
||||
// `range` should be alive until the end of `FinishOffThreadScriptDecoder`.
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeStencilOffThread(
|
||||
JSContext* cx, const DecodeOptions& options, const TranscodeRange& range,
|
||||
mozilla::Vector<TranscodeSource>& sources,
|
||||
OffThreadCompileCallback callback, void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API OffThreadToken* DecodeMultiStencilsOffThread(
|
||||
JSContext* cx, const DecodeOptions& options, TranscodeSources& sources,
|
||||
OffThreadCompileCallback callback, void* callbackData);
|
||||
|
||||
// Finish the off-thread task to compile the source text into a JS::Stencil,
|
||||
// started by JS::CompileToStencilOffThread, and return the result JS::Stencil.
|
||||
//
|
||||
// If `options.allocateInstantiationStorage` was true in
|
||||
// JS::CompileToStencilOffThread, pre-allocated JS::InstantiationStorage
|
||||
// is returned as `storage` out parameter.
|
||||
extern JS_PUBLIC_API already_AddRefed<Stencil> FinishCompileToStencilOffThread(
|
||||
JSContext* cx, OffThreadToken* token,
|
||||
InstantiationStorage* storage = nullptr);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<Stencil>
|
||||
FinishCompileModuleToStencilOffThread(JSContext* cx, OffThreadToken* token,
|
||||
InstantiationStorage* storage = nullptr);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<Stencil> FinishDecodeStencilOffThread(
|
||||
JSContext* cx, OffThreadToken* token,
|
||||
InstantiationStorage* storage = nullptr);
|
||||
|
||||
extern JS_PUBLIC_API bool FinishDecodeMultiStencilsOffThread(
|
||||
extern JS_PUBLIC_API bool FinishMultiOffThreadStencilDecoder(
|
||||
JSContext* cx, OffThreadToken* token,
|
||||
mozilla::Vector<RefPtr<Stencil>>* stencils);
|
||||
|
||||
extern JS_PUBLIC_API void CancelCompileToStencilOffThread(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelCompileModuleToStencilOffThread(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelDecodeStencilOffThread(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
extern JS_PUBLIC_API void CancelDecodeMultiStencilsOffThread(
|
||||
JSContext* cx, OffThreadToken* token);
|
||||
|
||||
// Register an encoder on its script source, such that all functions can be
|
||||
// encoded as they are parsed, in the same way as
|
||||
// JS::CompileAndStartIncrementalEncoding
|
||||
extern JS_PUBLIC_API bool StartIncrementalEncoding(JSContext* cx,
|
||||
RefPtr<Stencil>&& stencil);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -819,4 +819,7 @@ MSG_DEF(JSMSG_BAD_WEAKREF_TARGET, 0, JSEXN_TYPEERR, "cann
|
|||
// Iterator Helpers
|
||||
MSG_DEF(JSMSG_NEGATIVE_LIMIT, 0, JSEXN_RANGEERR, "Iterator limits cannot be negative")
|
||||
|
||||
// Stencil
|
||||
MSG_DEF(JSMSG_STENCIL_OPTIONS_MISMATCH, 0, JSEXN_ERR, "CompileOptions mismatch between input and Stencil")
|
||||
|
||||
//clang-format on
|
||||
|
|
|
@ -52,7 +52,9 @@
|
|||
#include "builtin/Promise.h"
|
||||
#include "builtin/SelfHostingDefines.h"
|
||||
#include "builtin/TestingUtility.h" // js::ParseCompileOptions, js::ParseDebugMetadata
|
||||
#include "frontend/BytecodeCompilation.h" // frontend::CompileGlobalScriptToExtensibleStencil, frontend::DelazifyCanonicalScriptedFunction
|
||||
#include "frontend/BytecodeCompilation.h" // frontend::CanLazilyParse,
|
||||
// frontend::CompileGlobalScriptToExtensibleStencil,
|
||||
// frontend::DelazifyCanonicalScriptedFunction
|
||||
#include "frontend/BytecodeCompiler.h" // frontend::ParseModuleToExtensibleStencil
|
||||
#include "frontend/CompilationStencil.h" // frontend::CompilationStencil
|
||||
#include "gc/Allocator.h"
|
||||
|
@ -6277,6 +6279,13 @@ static bool EvalStencil(JSContext* cx, uint32_t argc, Value* vp) {
|
|||
}
|
||||
}
|
||||
|
||||
if (stencilObj->stencil()->canLazilyParse !=
|
||||
frontend::CanLazilyParse(options)) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
|
||||
JSMSG_STENCIL_OPTIONS_MISMATCH);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool useDebugMetadata = !privateValue.isUndefined() || elementAttributeName;
|
||||
|
||||
JS::InstantiateOptions instantiateOptions(options);
|
||||
|
|
|
@ -13,7 +13,7 @@ basic/bug677957-2.js
|
|||
basic/bug753283.js
|
||||
basic/bug867946.js
|
||||
basic/destructuring-iterator.js
|
||||
basic/offThreadCompileToStencil-01.js
|
||||
basic/offThreadCompileScript-01.js
|
||||
basic/testAtomize.js
|
||||
basic/testBug614653.js
|
||||
basic/testBug686274.js
|
||||
|
|
|
@ -1168,18 +1168,6 @@ struct CompilationStencil {
|
|||
|
||||
bool isModule() const;
|
||||
|
||||
bool hasMultipleReference() const { return refCount > 1; }
|
||||
|
||||
bool hasOwnedBorrow() const {
|
||||
return storageType == StorageType::OwnedExtensible;
|
||||
}
|
||||
|
||||
ExtensibleCompilationStencil* takeOwnedBorrow() {
|
||||
MOZ_ASSERT(!hasMultipleReference());
|
||||
MOZ_ASSERT(hasOwnedBorrow());
|
||||
return ownedBorrowStencil.release();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void assertNoExternalDependency() const;
|
||||
#endif
|
||||
|
@ -1238,8 +1226,6 @@ struct ExtensibleCompilationStencil {
|
|||
|
||||
RefPtr<StencilAsmJSContainer> asmJS;
|
||||
|
||||
explicit ExtensibleCompilationStencil(JSContext* cx, ScriptSource* source);
|
||||
|
||||
ExtensibleCompilationStencil(JSContext* cx, CompilationInput& input);
|
||||
|
||||
ExtensibleCompilationStencil(ExtensibleCompilationStencil&& other) noexcept
|
||||
|
|
|
@ -1144,12 +1144,6 @@ void CompilationGCOutput::trace(JSTracer* trc) {
|
|||
scopes.trace(trc);
|
||||
}
|
||||
|
||||
void JS::InstantiationStorage::trace(JSTracer* trc) {
|
||||
if (gcOutput_) {
|
||||
gcOutput_->trace(trc);
|
||||
}
|
||||
}
|
||||
|
||||
RegExpObject* RegExpStencil::createRegExp(
|
||||
JSContext* cx, const CompilationAtomCache& atomCache) const {
|
||||
RootedAtom atom(cx, atomCache.getExistingAtomAt(cx, atom_));
|
||||
|
@ -2274,12 +2268,6 @@ bool CompilationStencil::deserializeStencils(JSContext* cx,
|
|||
return true;
|
||||
}
|
||||
|
||||
ExtensibleCompilationStencil::ExtensibleCompilationStencil(JSContext* cx,
|
||||
ScriptSource* source)
|
||||
: alloc(CompilationStencil::LifoAllocChunkSize),
|
||||
source(source),
|
||||
parserAtoms(cx->runtime(), alloc) {}
|
||||
|
||||
ExtensibleCompilationStencil::ExtensibleCompilationStencil(
|
||||
JSContext* cx, CompilationInput& input)
|
||||
: canLazilyParse(CanLazilyParse(input.options)),
|
||||
|
@ -4392,8 +4380,8 @@ already_AddRefed<JS::Stencil> JS::CompileModuleScriptToStencil(
|
|||
return CompileModuleScriptToStencilImpl(cx, options, srcBuf);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSScript* JS::InstantiateGlobalStencil(
|
||||
JSContext* cx, const JS::InstantiateOptions& options,
|
||||
JSScript* JS::InstantiateGlobalStencil(JSContext* cx,
|
||||
const JS::InstantiateOptions& options,
|
||||
JS::Stencil* stencil) {
|
||||
CompileOptions compileOptions(cx);
|
||||
options.copyTo(compileOptions);
|
||||
|
@ -4406,21 +4394,6 @@ JS_PUBLIC_API JSScript* JS::InstantiateGlobalStencil(
|
|||
return gcOutput.get().script;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSScript* JS::InstantiateGlobalStencil(
|
||||
JSContext* cx, const JS::InstantiateOptions& options, JS::Stencil* stencil,
|
||||
JS::InstantiationStorage* storage) {
|
||||
MOZ_ASSERT(storage->isValid());
|
||||
|
||||
CompileOptions compileOptions(cx);
|
||||
options.copyTo(compileOptions);
|
||||
Rooted<CompilationInput> input(cx, CompilationInput(compileOptions));
|
||||
if (!InstantiateStencils(cx, input.get(), *stencil, *storage->gcOutput_)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return storage->gcOutput_->script;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::StencilIsBorrowed(Stencil* stencil) {
|
||||
return stencil->storageType == CompilationStencil::StorageType::Borrowed;
|
||||
}
|
||||
|
@ -4429,8 +4402,8 @@ JS_PUBLIC_API bool JS::StencilCanLazilyParse(Stencil* stencil) {
|
|||
return stencil->canLazilyParse;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::InstantiateModuleStencil(
|
||||
JSContext* cx, const JS::InstantiateOptions& options,
|
||||
JSObject* JS::InstantiateModuleStencil(JSContext* cx,
|
||||
const JS::InstantiateOptions& options,
|
||||
JS::Stencil* stencil) {
|
||||
CompileOptions compileOptions(cx);
|
||||
options.copyTo(compileOptions);
|
||||
|
@ -4445,23 +4418,6 @@ JS_PUBLIC_API JSObject* JS::InstantiateModuleStencil(
|
|||
return gcOutput.get().module;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::InstantiateModuleStencil(
|
||||
JSContext* cx, const JS::InstantiateOptions& options, JS::Stencil* stencil,
|
||||
JS::InstantiationStorage* storage) {
|
||||
MOZ_ASSERT(storage->isValid());
|
||||
|
||||
CompileOptions compileOptions(cx);
|
||||
options.copyTo(compileOptions);
|
||||
compileOptions.setModule();
|
||||
|
||||
Rooted<CompilationInput> input(cx, CompilationInput(compileOptions));
|
||||
if (!InstantiateStencils(cx, input.get(), *stencil, *storage->gcOutput_)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return storage->gcOutput_->module;
|
||||
}
|
||||
|
||||
JS::TranscodeResult JS::EncodeStencil(JSContext* cx, JS::Stencil* stencil,
|
||||
TranscodeBuffer& buffer) {
|
||||
XDRStencilEncoder encoder(cx, buffer);
|
||||
|
@ -4493,14 +4449,14 @@ JS::TranscodeResult JS::DecodeStencil(JSContext* cx,
|
|||
return TranscodeResult::Ok;
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> JS::FinishOffThreadStencil(
|
||||
JSContext* cx, JS::OffThreadToken* token) {
|
||||
MOZ_ASSERT(cx);
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(cx->runtime()));
|
||||
return HelperThreadState().finishStencilParseTask(cx, token);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API size_t JS::SizeOfStencil(Stencil* stencil,
|
||||
mozilla::MallocSizeOf mallocSizeOf) {
|
||||
return stencil->sizeOfIncludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
JS::InstantiationStorage::~InstantiationStorage() {
|
||||
if (gcOutput_) {
|
||||
js_free(gcOutput_);
|
||||
gcOutput_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -738,13 +738,8 @@ template <XDRMode mode>
|
|||
XDRState<mode>* xdr, CompilationStencil& stencil) {
|
||||
MOZ_ASSERT(!stencil.asmJS);
|
||||
|
||||
if constexpr (mode == XDR_DECODE) {
|
||||
const auto& options = static_cast<XDRStencilDecoder*>(xdr)->options();
|
||||
if (options.borrowBuffer) {
|
||||
if (mode == XDR_DECODE) {
|
||||
stencil.storageType = CompilationStencil::StorageType::Borrowed;
|
||||
} else {
|
||||
stencil.storageType = CompilationStencil::StorageType::Owned;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_TRY(CodeMarker(xdr, SectionMarker::ParserAtomData));
|
||||
|
|
|
@ -81,12 +81,12 @@ function sanitizeGlobal(g) {
|
|||
setModuleDynamicImportHook: function() {},
|
||||
finishDynamicModuleImport: function() {},
|
||||
abortDynamicModuleImport: function() {},
|
||||
offThreadCompileToStencil: function() {},
|
||||
finishOffThreadCompileToStencil: function() {},
|
||||
offThreadCompileModuleToStencil: function() {},
|
||||
finishOffThreadCompileModuleToStencil: function() {},
|
||||
offThreadDecodeStencil: function() {},
|
||||
finishOffThreadDecodeStencil: function() {},
|
||||
offThreadCompileScript: function() {},
|
||||
runOffThreadScript: function() {},
|
||||
offThreadCompileModule: function() {},
|
||||
finishOffThreadModule: function() {},
|
||||
offThreadDecodeScript: function() {},
|
||||
runOffThreadDecodedScript: function() {},
|
||||
addPromiseReactions: function() {},
|
||||
ignoreUnhandledRejections: function() {},
|
||||
enableTrackAllocations: function() {},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
offThreadCompileToStencil("\
|
||||
offThreadCompileScript("\
|
||||
(function(stdlib, foreign) {\
|
||||
\"use asm\";\
|
||||
function() {};\
|
||||
|
|
|
@ -5,7 +5,7 @@ const maxSize = Math.pow(2, 29) - 1;
|
|||
// We just don't want to crash during compilation here.
|
||||
|
||||
evaluate(`
|
||||
offThreadCompileToStencil("\\
|
||||
offThreadCompileScript("\\
|
||||
g = (function(t,foreign){\\
|
||||
\\"use asm\\";\\
|
||||
var ff = foreign.ff;\\
|
||||
|
@ -17,7 +17,7 @@ evaluate(`
|
|||
`);
|
||||
|
||||
evaluate(`
|
||||
offThreadCompileToStencil("\\
|
||||
offThreadCompileScript("\\
|
||||
g = (function(t,foreign){\\
|
||||
\\"use asm\\";\\
|
||||
var ff = foreign.ff;\\
|
||||
|
|
|
@ -12,10 +12,9 @@ module += "return f0";
|
|||
var script = "(function() {\n" + module + "})";
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
offThreadCompileToStencil(script);
|
||||
offThreadCompileScript(script);
|
||||
var f = new Function(module);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
var g = evalStencil(stencil);
|
||||
var g = runOffThreadScript();
|
||||
assertEq(isAsmJSModule(f), true);
|
||||
assertEq(isAsmJSModule(g), true);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| exitstatus: 6; skip-if: helperThreadCount() == 0
|
||||
|
||||
var job = offThreadCompileToStencil(`
|
||||
runOffThreadScript(offThreadCompileScript(`
|
||||
function asmModule() {
|
||||
"use asm";
|
||||
function f() {
|
||||
|
@ -9,9 +9,7 @@ var job = offThreadCompileToStencil(`
|
|||
}
|
||||
return f;
|
||||
}
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil(job);
|
||||
evalStencil(stencil);
|
||||
`));
|
||||
timeout(1);
|
||||
asmModule()();
|
||||
assertEq(true, false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this)
|
||||
|
||||
oomTest(function() {
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
});
|
||||
"".match();
|
||||
|
|
|
@ -10,7 +10,7 @@ for (lfLocal in this) {
|
|||
lfGlobal[lfLocal] = this[lfLocal];
|
||||
}
|
||||
}
|
||||
lfGlobal.offThreadCompileToStencil(`
|
||||
lfGlobal.offThreadCompileScript(`
|
||||
if (!("oomAtAllocation" in this && "resetOOMFailure" in this))
|
||||
gczeal(0);
|
||||
function oomTest(f) {
|
||||
|
@ -30,8 +30,7 @@ var g = newGlobal();
|
|||
oomTest(function() { new revocable(); });
|
||||
`);
|
||||
try {
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.runOffThreadScript();
|
||||
} catch(e) {
|
||||
// This can happen if we OOM while bailing out in Ion.
|
||||
assertEq(e, "out of memory");
|
||||
|
|
|
@ -6,6 +6,5 @@ lfGlobal = newGlobal()
|
|||
for (lfLocal in this)
|
||||
if (!(lfLocal in lfGlobal))
|
||||
lfGlobal[lfLocal] = this[lfLocal]
|
||||
offThreadCompileToStencil(lfVarx);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
offThreadCompileScript(lfVarx)
|
||||
lfGlobal.runOffThreadScript()
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this)
|
||||
|
||||
function parseModule(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
return instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
return finishOffThreadModule();
|
||||
}
|
||||
function loadFile(lfVarx) {
|
||||
oomTest(function() {
|
||||
|
|
|
@ -2,17 +2,15 @@
|
|||
// 1236476
|
||||
|
||||
if (typeof oomTest !== 'function' ||
|
||||
typeof offThreadCompileToStencil !== 'function' ||
|
||||
typeof finishOffThreadCompileToStencil !== 'function' ||
|
||||
typeof evalStencil !== 'function')
|
||||
typeof offThreadCompileScript !== 'function' ||
|
||||
typeof runOffThreadScript !== 'function')
|
||||
quit();
|
||||
|
||||
oomTest(() => {
|
||||
offThreadCompileToStencil(`
|
||||
offThreadCompileScript(`
|
||||
"use asm";
|
||||
return assertEq;
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil();
|
||||
runOffThreadScript();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
offThreadCompileToStencil(``);
|
||||
evalInWorker(`
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
`);
|
||||
offThreadCompileScript(``);
|
||||
evalInWorker(`runOffThreadScript()`);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
function eval(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
offThreadCompileModule(source);
|
||||
}
|
||||
var N = 10000;
|
||||
var left = repeat_str('(1&', N);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
// Test off-thread parsing.
|
||||
|
||||
load(libdir + 'asserts.js');
|
||||
|
||||
offThreadCompileScript('Math.sin(Math.PI/2)');
|
||||
assertEq(runOffThreadScript(), 1);
|
||||
|
||||
offThreadCompileScript('a string which cannot be reduced to the start symbol');
|
||||
assertThrowsInstanceOf(runOffThreadScript, SyntaxError);
|
||||
|
||||
offThreadCompileScript('smerg;');
|
||||
assertThrowsInstanceOf(runOffThreadScript, ReferenceError);
|
||||
|
||||
offThreadCompileScript('throw "blerg";');
|
||||
assertThrowsValue(runOffThreadScript, 'blerg');
|
|
@ -0,0 +1,21 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
// Test offThreadCompileScript option handling.
|
||||
|
||||
offThreadCompileScript("Error()");
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@<string>:1:1\n/), true);
|
||||
|
||||
offThreadCompileScript("Error()", { fileName: "candelabra", lineNumber: 6502 });
|
||||
assertEq(!!runOffThreadScript().stack.match(/^@candelabra:6502:1\n/), true);
|
||||
|
||||
var element = {};
|
||||
var job = offThreadCompileScript("Error()"); // shouldn't crash
|
||||
runOffThreadScript(job, { element });
|
||||
|
||||
var elementAttributeName = "molybdenum";
|
||||
elementAttributeName +=
|
||||
elementAttributeName + elementAttributeName + elementAttributeName;
|
||||
job = offThreadCompileScript("Error()"); // shouldn't crash
|
||||
runOffThreadScript(job, {
|
||||
elementAttributeName,
|
||||
});
|
|
@ -1,38 +1,34 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
// Test offThreadCompileToStencil for different function types.
|
||||
// Test offThreadCompileScript for different function types.
|
||||
|
||||
load(libdir + 'asserts.js');
|
||||
|
||||
var id, stencil;
|
||||
var id;
|
||||
|
||||
id = offThreadCompileToStencil(`
|
||||
id = offThreadCompileScript(`
|
||||
function f() { return "pass"; }
|
||||
f();
|
||||
`);
|
||||
stencil = finishOffThreadCompileToStencil(id);
|
||||
assertEq(evalStencil(stencil), "pass");
|
||||
assertEq(runOffThreadScript(id), "pass");
|
||||
|
||||
id = offThreadCompileToStencil(`
|
||||
id = offThreadCompileScript(`
|
||||
function* f() { return "pass"; }
|
||||
f().next();
|
||||
`);
|
||||
stencil = finishOffThreadCompileToStencil(id);
|
||||
assertDeepEq(evalStencil(stencil), {value: "pass", done: true});
|
||||
assertDeepEq(runOffThreadScript(id), {value: "pass", done: true});
|
||||
|
||||
id = offThreadCompileToStencil(`
|
||||
id = offThreadCompileScript(`
|
||||
async function f() { return "pass"; }
|
||||
f();
|
||||
`);
|
||||
stencil = finishOffThreadCompileToStencil(id);
|
||||
assertEventuallyEq(evalStencil(stencil), "pass");
|
||||
assertEventuallyEq(runOffThreadScript(id), "pass");
|
||||
|
||||
id = offThreadCompileToStencil(`
|
||||
id = offThreadCompileScript(`
|
||||
async function* f() { return "pass"; }
|
||||
f().next();
|
||||
`);
|
||||
stencil = finishOffThreadCompileToStencil(id);
|
||||
assertEventuallyDeepEq(evalStencil(stencil), {value: "pass", done: true});
|
||||
assertEventuallyDeepEq(runOffThreadScript(id), {value: "pass", done: true});
|
||||
|
||||
// Copied from js/src/tests/shell.js
|
||||
function getPromiseResult(promise) {
|
|
@ -1,30 +0,0 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
|
||||
// Test off-thread parsing.
|
||||
|
||||
load(libdir + 'asserts.js');
|
||||
|
||||
offThreadCompileToStencil('Math.sin(Math.PI/2)');
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
assertEq(evalStencil(stencil), 1);
|
||||
|
||||
offThreadCompileToStencil('a string which cannot be reduced to the start symbol');
|
||||
assertThrowsInstanceOf(() => {
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
}, SyntaxError);
|
||||
|
||||
offThreadCompileToStencil('smerg;');
|
||||
assertThrowsInstanceOf(() => {
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
}, ReferenceError);
|
||||
|
||||
offThreadCompileToStencil('throw "blerg";');
|
||||
assertThrowsValue(() => {
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
}, 'blerg');
|
|
@ -1,25 +0,0 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
// Test offThreadCompileToStencil/evalStencil option handling.
|
||||
|
||||
offThreadCompileToStencil("Error()");
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
assertEq(!!evalStencil(stencil).stack.match(/^@<string>:1:1\n/), true);
|
||||
|
||||
offThreadCompileToStencil("Error()", { fileName: "candelabra", lineNumber: 6502 });
|
||||
stencil = finishOffThreadCompileToStencil();
|
||||
assertEq(!!evalStencil(stencil).stack.match(/^@candelabra:6502:1\n/), true);
|
||||
|
||||
var element = {};
|
||||
offThreadCompileToStencil("Error()"); // shouldn't crash
|
||||
stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil, { element });
|
||||
|
||||
var elementAttributeName = "molybdenum";
|
||||
elementAttributeName +=
|
||||
elementAttributeName + elementAttributeName + elementAttributeName;
|
||||
offThreadCompileToStencil("Error()"); // shouldn't crash
|
||||
stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil, {
|
||||
elementAttributeName,
|
||||
});
|
|
@ -34,9 +34,8 @@ assertEq(ex.toString(), "InternalError: unsafe filename: file://foo.js");
|
|||
|
||||
// Off-thread parse throws too, when finishing.
|
||||
if (helperThreadCount() > 0) {
|
||||
offThreadCompileToStencil('throw 1');
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
assertThrowsInstanceOf(() => evalStencil(stencil), InternalError);
|
||||
offThreadCompileScript('throw 1');
|
||||
assertThrowsInstanceOf(() => runOffThreadScript(), InternalError);
|
||||
}
|
||||
|
||||
// Unsafe filename is accepted if we opt-out.
|
||||
|
|
|
@ -24,9 +24,8 @@ csoLoop();
|
|||
|
||||
// Tests off thread compilation
|
||||
if (helperThreadCount() !== 0) {
|
||||
offThreadCompileToStencil("(x=>x)`abc`");
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
a = evalStencil(stencil);
|
||||
offThreadCompileScript("(x=>x)`abc`");
|
||||
a = runOffThreadScript();
|
||||
check(a, ["abc"]);
|
||||
check(a.raw, ["abc"]);
|
||||
assertEq(a === a.raw, false);
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
var lfGlobal = newGlobal();
|
||||
lfGlobal.offThreadCompileToStencil(`{ let x; throw 42; }`);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.offThreadCompileScript(`{ let x; throw 42; }`);
|
||||
try {
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.runOffThreadScript();
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
lfGlobal.offThreadCompileToStencil(`function f() { { let x = 42; return x; } }`);
|
||||
stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.offThreadCompileScript(`function f() { { let x = 42; return x; } }`);
|
||||
try {
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.runOffThreadScript();
|
||||
} catch (e) {
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
|
||||
evalInWorker(`
|
||||
var lfGlobal = newGlobal();
|
||||
lfGlobal.offThreadCompileToStencil(\`{ let x; throw 42; }\`);
|
||||
lfGlobal.offThreadCompileScript(\`{ let x; throw 42; }\`);
|
||||
`);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
assertEq(isLcovEnabled(), true);
|
||||
|
||||
offThreadCompileToStencil(`
|
||||
offThreadCompileScript(`
|
||||
let hitCount = 0;
|
||||
function offThreadFun() {
|
||||
hitCount += 1;
|
||||
|
@ -13,8 +13,7 @@ offThreadCompileToStencil(`
|
|||
offThreadFun();
|
||||
offThreadFun();
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
assertEq(hitCount, 4);
|
||||
|
||||
let report = getLcovInfo();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
assertEq(isLcovEnabled(), true);
|
||||
|
||||
offThreadCompileModuleToStencil(`
|
||||
offThreadCompileModule(`
|
||||
globalThis.hitCount = 0;
|
||||
function offThreadFun() {
|
||||
globalThis.hitCount += 1;
|
||||
|
@ -13,8 +13,7 @@ offThreadCompileModuleToStencil(`
|
|||
offThreadFun();
|
||||
offThreadFun();
|
||||
`);
|
||||
let stencil = finishOffThreadCompileModuleToStencil();
|
||||
let mod = instantiateModuleStencil(stencil);
|
||||
let mod = finishOffThreadModule();
|
||||
mod.declarationInstantiation();
|
||||
mod.evaluation();
|
||||
assertEq(hitCount, 4);
|
||||
|
|
|
@ -14,9 +14,8 @@ assertEq(g.dbg.allowUnobservedAsmJS, false);
|
|||
enableLastWarning();
|
||||
|
||||
var asmFunStr = USE_ASM + 'function f() {} return f';
|
||||
offThreadCompileToStencil("(function() {" + asmFunStr + "})");
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
offThreadCompileScript("(function() {" + asmFunStr + "})");
|
||||
runOffThreadScript();
|
||||
|
||||
var msg = getLastWarning().message;
|
||||
assertEq(msg === "asm.js type error: Asm.js optimizer disabled by debugger" ||
|
||||
|
|
|
@ -9,7 +9,7 @@ root.eval("this.dbg = new Debugger()");
|
|||
root.dbg.addDebuggee(this);
|
||||
root.dbg.memory.trackingAllocationSites = true;
|
||||
|
||||
offThreadCompileToStencil(
|
||||
offThreadCompileScript(
|
||||
"function foo() {\n" +
|
||||
" print('hello world');\n" +
|
||||
"}"
|
||||
|
|
|
@ -18,10 +18,9 @@ dbg.onDebuggerStatement = function (frame) {
|
|||
assertEq(source.elementAttributeName, 'mass');
|
||||
};
|
||||
|
||||
var job = g.offThreadCompileToStencil('debugger;');
|
||||
var stencil = g.finishOffThreadCompileToStencil(job);
|
||||
var job = g.offThreadCompileScript('debugger;');
|
||||
log += 'o';
|
||||
g.evalStencil(stencil,
|
||||
g.runOffThreadScript(job,
|
||||
{
|
||||
element: elt,
|
||||
elementAttributeName: 'mass'
|
||||
|
|
|
@ -61,16 +61,14 @@ log = '';
|
|||
g.run(scriptdir + 'Source-introductionType-data');
|
||||
assertEq(log, 'd');
|
||||
|
||||
// Shell 'offThreadCompileToStencil' function.
|
||||
// Shell 'offThreadCompileScript' function.
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
log += 'd';
|
||||
assertEq(frame.script.source.introductionType,
|
||||
"js shell offThreadCompileToStencil");
|
||||
assertEq(frame.script.source.introductionType, "js shell offThreadCompileScript");
|
||||
};
|
||||
log = '';
|
||||
g.offThreadCompileToStencil('debugger;');
|
||||
var stencil = g.finishOffThreadCompileToStencil();
|
||||
g.evalStencil(stencil);
|
||||
g.offThreadCompileScript('debugger;');
|
||||
g.runOffThreadScript();
|
||||
assertEq(log, 'd');
|
||||
|
||||
// Debugger.Frame.prototype.eval
|
||||
|
|
|
@ -16,7 +16,6 @@ function loadFile(lfVarx) {
|
|||
for (lfLocal in this)
|
||||
if (!(lfLocal in lfGlobal))
|
||||
lfGlobal[lfLocal] = this[lfLocal]
|
||||
offThreadCompileToStencil(lfVarx);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
offThreadCompileScript(lfVarx)
|
||||
lfGlobal.runOffThreadScript()
|
||||
}
|
||||
|
|
|
@ -8,6 +8,5 @@ for (var i = 0; i < 70000; i++)
|
|||
evaluate(s);
|
||||
var g = newGlobal({newCompartment: true});
|
||||
(new Debugger).addDebuggee(g);
|
||||
g.offThreadCompileToStencil('debugger;',{});
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
g.evalStencil(stencil);
|
||||
g.offThreadCompileScript('debugger;',{});
|
||||
g.runOffThreadScript();
|
||||
|
|
|
@ -16,14 +16,13 @@ for (lfLocal in this) {
|
|||
lfGlobal[lfLocal] = this[lfLocal];
|
||||
}
|
||||
}
|
||||
lfGlobal.offThreadCompileToStencil(`
|
||||
lfGlobal.offThreadCompileScript(`
|
||||
var dbg = new Debugger(g);
|
||||
dbg.onEnterFrame = function (frame) {
|
||||
var frameThis = frame.this;
|
||||
}
|
||||
`);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.runOffThreadScript();
|
||||
assertThrowsInstanceOf(test, ReferenceError);
|
||||
function test() {
|
||||
function check(fun, msg, todo) {
|
||||
|
|
|
@ -12,7 +12,6 @@ dbg.onNewScript = function (s) {
|
|||
}
|
||||
|
||||
log = '';
|
||||
g.offThreadCompileToStencil('"t" + "wine"');
|
||||
var stencil = g.finishOffThreadCompileToStencil();
|
||||
assertEq(g.evalStencil(stencil), 'twine');
|
||||
g.offThreadCompileScript('"t" + "wine"');
|
||||
assertEq(g.runOffThreadScript(), 'twine');
|
||||
assertEq(log, 's');
|
||||
|
|
|
@ -8,6 +8,5 @@ dbg.onNewScript = function (s) {
|
|||
assertEq(s.getChildScripts().length, 1);
|
||||
};
|
||||
|
||||
global.eval('offThreadCompileToStencil("function inner() { \\\"use asm\\\"; function xxx() {} return xxx; }");');
|
||||
global.eval('var stencil = finishOffThreadCompileToStencil();');
|
||||
global.eval('evalStencil(stencil);');
|
||||
global.eval('offThreadCompileScript("function inner() { \\\"use asm\\\"; function xxx() {} return xxx; }");');
|
||||
global.eval('runOffThreadScript();');
|
||||
|
|
|
@ -6,6 +6,5 @@ gc();
|
|||
schedulezone(this);
|
||||
startgc(0, "shrinking");
|
||||
var g = newGlobal();
|
||||
g.offThreadCompileToStencil('debugger;', {});
|
||||
var stencil = g.finishOffThreadCompileToStencil();
|
||||
g.evalStencil(stencil);
|
||||
g.offThreadCompileScript('debugger;', {});
|
||||
g.runOffThreadScript();
|
||||
|
|
|
@ -7,6 +7,5 @@ for (lfLocal in this) {
|
|||
}
|
||||
}
|
||||
const script = 'oomTest(() => getBacktrace({args: true, locals: "123795", thisprops: true}));';
|
||||
lfGlobal.offThreadCompileToStencil(script);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.offThreadCompileScript(script);
|
||||
lfGlobal.runOffThreadScript();
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
enableGeckoProfiling();
|
||||
var s = newGlobal();
|
||||
s.offThreadCompileToStencil('oomTest(() => {});');
|
||||
var stencil = s.finishOffThreadCompileToStencil();
|
||||
s.evalStencil(stencil);
|
||||
s.offThreadCompileScript('oomTest(() => {});');
|
||||
s.runOffThreadScript();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this)
|
||||
|
||||
oomTest(() => {
|
||||
offThreadCompileToStencil(`try {} catch (NaN) {}`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
offThreadCompileScript(`try {} catch (NaN) {}`);
|
||||
runOffThreadScript();
|
||||
});
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0 || !('oomTest' in this)
|
||||
|
||||
offThreadCompileToStencil(`
|
||||
offThreadCompileScript(`
|
||||
oomTest(() => "".search(/d/));
|
||||
fullcompartmentchecks(3);
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
|
|
|
@ -22,9 +22,8 @@ function loadFile(lfVarx) {
|
|||
case 5:
|
||||
var lfGlobal = newGlobal();
|
||||
for (lfLocal in this) {}
|
||||
lfGlobal.offThreadCompileToStencil(lfVarx);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.offThreadCompileScript(lfVarx);
|
||||
lfGlobal.runOffThreadScript();
|
||||
}
|
||||
} else if (!isNaN(lfVarx)) {
|
||||
lfRunTypeId = parseInt(lfVarx);
|
||||
|
|
|
@ -11,9 +11,8 @@ oomTest(() => {
|
|||
} catch (x) {}
|
||||
gczeal(0);
|
||||
`;
|
||||
lfGlobal.offThreadCompileToStencil(lfVarx);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.offThreadCompileScript(lfVarx);
|
||||
lfGlobal.runOffThreadScript();
|
||||
runCount++;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
// This will fail with --no-threads.
|
||||
verifyprebarriers();
|
||||
var lfGlobal = newGlobal();
|
||||
lfGlobal.offThreadCompileToStencil(`
|
||||
lfGlobal.offThreadCompileScript(`
|
||||
version(185);
|
||||
`);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var lfGlobal = newGlobal();
|
||||
gczeal(4);
|
||||
for (lfLocal in this) {}
|
||||
lfGlobal.offThreadCompileToStencil(`
|
||||
lfGlobal.offThreadCompileScript(`
|
||||
var desc = {
|
||||
value: 'bar',
|
||||
value: false,
|
||||
|
|
|
@ -7,7 +7,6 @@ gczeal(9);
|
|||
function rejectionTracker(state) {}
|
||||
setPromiseRejectionTrackerCallback(rejectionTracker)
|
||||
lfGlobal = newGlobal();
|
||||
offThreadCompileToStencil(`new Promise(()=>rej)`);
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
offThreadCompileScript(`new Promise(()=>rej)`);
|
||||
lfGlobal.runOffThreadScript();
|
||||
for (lfLocal in this);
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
/x/;
|
||||
oomTest(function(){
|
||||
offThreadCompileToStencil('');
|
||||
offThreadCompileScript('');
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
gczeal(0);
|
||||
startgc(1, 'shrinking');
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
// Adapted from randomly chosen test: js/src/jit-test/tests/parser/bug-1263355-13.js
|
||||
gczeal(9);
|
||||
newGlobal();
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
m = 'x';
|
||||
for (var i = 0; i < 10; i++)
|
||||
m += m;
|
||||
offThreadCompileToStencil("", ({elementAttributeName: m}));
|
||||
offThreadCompileScript("", ({elementAttributeName: m}));
|
||||
var n = newGlobal();
|
||||
gczeal(2,1);
|
||||
var stencil = n.finishOffThreadCompileToStencil();
|
||||
n.evalStencil(stencil);
|
||||
n.runOffThreadScript();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
gczeal(0);
|
||||
print = function(s) {}
|
||||
startgc(1);
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
gczeal(10, 3);
|
||||
for (var count = 0; count < 20; count++) {
|
||||
print(count);
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
gczeal(0);
|
||||
startgc(8301);
|
||||
offThreadCompileToStencil("(({a,b,c}))");
|
||||
offThreadCompileScript("(({a,b,c}))");
|
||||
gcparam("maxBytes", gcparam("gcBytes"));
|
||||
|
|
|
@ -5,7 +5,7 @@ if (helperThreadCount() === 0)
|
|||
|
||||
var lfOffThreadGlobal = newGlobal();
|
||||
enableShellAllocationMetadataBuilder()
|
||||
lfOffThreadGlobal.offThreadCompileToStencil(`
|
||||
lfOffThreadGlobal.offThreadCompileScript(`
|
||||
if ("gczeal" in this)
|
||||
gczeal(8, 1)
|
||||
function recurse(x) {
|
||||
|
@ -13,5 +13,4 @@ lfOffThreadGlobal.offThreadCompileToStencil(`
|
|||
};
|
||||
recurse(0);
|
||||
`);
|
||||
var stencil = lfOffThreadGlobal.finishOffThreadCompileToStencil();
|
||||
lfOffThreadGlobal.evalStencil(stencil);
|
||||
lfOffThreadGlobal.runOffThreadScript();
|
||||
|
|
|
@ -19,4 +19,4 @@ if (typeof oomTest == "function") {
|
|||
}
|
||||
deterministicgc(true);
|
||||
startgc(9469, "shrinking");
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
gczeal(0);
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
startgc(0);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
|
|
|
@ -12,7 +12,7 @@ gcparam('allocationThreshold', 1);
|
|||
gc();
|
||||
|
||||
// Start an off-thread parse.
|
||||
offThreadCompileToStencil("print('Finished')");
|
||||
offThreadCompileScript("print('Finished')");
|
||||
|
||||
// Allocate lots of atoms, parsing occasionally.
|
||||
for (let i = 0; i < 10; i++) {
|
||||
|
@ -23,5 +23,4 @@ for (let i = 0; i < 10; i++) {
|
|||
}
|
||||
|
||||
// Finish the off-thread parse.
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
var fe = "vv";
|
||||
for (i = 0; i < 24; i++) fe += fe;
|
||||
offThreadCompileToStencil(fe, {});
|
||||
offThreadCompileScript(fe, {});
|
||||
|
|
|
@ -4,7 +4,7 @@ setGCCallback({
|
|||
action: "majorGC"
|
||||
});
|
||||
gcparam("allocationThreshold", 1);
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
for (let i = 0; i < 40000; i++)
|
||||
Symbol.for(i);
|
||||
eval(0);
|
||||
|
|
|
@ -6,5 +6,5 @@ setGCCallback({
|
|||
});
|
||||
gcslice(3);
|
||||
var lfGlobal = newGlobal();
|
||||
lfGlobal.offThreadCompileToStencil("");
|
||||
lfGlobal.offThreadCompileScript("");
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0 || !('oomTest' in this)
|
||||
|
||||
oomTest(new Function(`function execOffThread(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
return instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
return finishOffThreadModule();
|
||||
}
|
||||
b = execOffThread("[1, 2, 3]")
|
||||
`));
|
||||
|
|
|
@ -4,13 +4,12 @@ gcparam('allocationThreshold', 1);
|
|||
setGCCallback({
|
||||
action: "majorGC",
|
||||
});
|
||||
offThreadCompileToStencil(('Boolean.prototype.toString.call(new String())'));
|
||||
offThreadCompileScript(('Boolean.prototype.toString.call(new String())'));
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let j = 0; j < 10000; j++) Symbol.for(i + 10 * j);
|
||||
}
|
||||
try {
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
} catch (e) {
|
||||
assertEq(e.constructor, TypeError);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// |jit-test| allow-overrecursed; skip-if: helperThreadCount() === 0
|
||||
function eval(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
offThreadCompileModule(source);
|
||||
let get = (eval("function w(){}") ++);
|
||||
};
|
||||
gczeal(21, 10);
|
||||
|
|
|
@ -20,12 +20,11 @@ evaluate(`
|
|||
var g = newGlobal({newCompartment: true});
|
||||
var gw = dbg.addDebuggee(g);
|
||||
`);
|
||||
lfOffThreadGlobal.offThreadCompileToStencil(`
|
||||
lfOffThreadGlobal.offThreadCompileScript(`
|
||||
gcparam("markStackLimit", 1);
|
||||
grayRoot()[0] = "foo";
|
||||
`);
|
||||
var stencil = lfOffThreadGlobal.finishOffThreadCompileToStencil();
|
||||
lfOffThreadGlobal.evalStencil(stencil);
|
||||
lfOffThreadGlobal.runOffThreadScript();
|
||||
eval(`
|
||||
var lfOffThreadGlobal = newGlobal({newCompartment: true});
|
||||
try { evaluate(\`
|
||||
|
|
|
@ -4,7 +4,7 @@ try {
|
|||
oomTest(function() {
|
||||
eval(`
|
||||
function eval(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
offThreadCompileModule(source);
|
||||
minorgc();
|
||||
}
|
||||
eval("");
|
||||
|
|
|
@ -4,11 +4,10 @@ var g = newGlobal({ newCompartment: true });
|
|||
var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
lfOffThreadGlobal = g;
|
||||
lfOffThreadGlobal.offThreadCompileToStencil(`
|
||||
lfOffThreadGlobal.offThreadCompileScript(`
|
||||
grayRoot()[0] = "foo";
|
||||
`);
|
||||
var stencil = lfOffThreadGlobal.finishOffThreadCompileToStencil();
|
||||
lfOffThreadGlobal.evalStencil(stencil);
|
||||
lfOffThreadGlobal.runOffThreadScript();
|
||||
var g = newGlobal({newCompartment: true});
|
||||
var gw = dbg.addDebuggee(g);
|
||||
lfOffThreadGlobal = null;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this)
|
||||
|
||||
function parseModule(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
return instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
return finishOffThreadModule();
|
||||
}
|
||||
function loadFile(lfVarx) {
|
||||
oomTest(function() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
verifyprebarriers();
|
||||
offThreadCompileToStencil('');
|
||||
offThreadCompileScript('');
|
||||
var dbg = new Debugger();
|
||||
var objects = dbg.findObjects();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var g = newGlobal();
|
||||
gczeal(9, 1);
|
||||
gczeal(11, 2);
|
||||
g.offThreadCompileToStencil("");
|
||||
g.offThreadCompileScript("")
|
||||
setJitCompilerOption("offthread-compilation.enable", 1);
|
||||
|
||||
for (let i = 0 ; i < 3000; i++) {
|
||||
|
|
|
@ -9,4 +9,4 @@ function a(b) {
|
|||
});
|
||||
return c;
|
||||
}
|
||||
offThreadDecodeStencil(a(""));
|
||||
offThreadDecodeScript(a(""));
|
||||
|
|
|
@ -5,6 +5,5 @@ setGCCallback({
|
|||
schedulezone(this)
|
||||
gcslice(3)
|
||||
var lfGlobal = newGlobal();
|
||||
lfGlobal.offThreadCompileToStencil("");
|
||||
var stencil = lfGlobal.finishOffThreadCompileToStencil();
|
||||
lfGlobal.evalStencil(stencil);
|
||||
lfGlobal.offThreadCompileScript("");
|
||||
lfGlobal.runOffThreadScript();
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
gczeal(0);
|
||||
startgc(45);
|
||||
offThreadCompileToStencil("print(1)");
|
||||
offThreadCompileScript("print(1)");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
gczeal(10);
|
||||
newGlobal();
|
||||
offThreadCompileToStencil("let x = 1;");
|
||||
offThreadCompileScript("let x = 1;");
|
||||
abortgc();
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
gczeal(4);
|
||||
offThreadCompileToStencil("let x = 1;");
|
||||
offThreadCompileScript("let x = 1;");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
schedulezone("");
|
||||
offThreadCompileToStencil("");
|
||||
offThreadCompileScript("");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this)
|
||||
oomTest(function () {
|
||||
offThreadCompileModuleToStencil('');
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule('');
|
||||
finishOffThreadModule();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this) || helperThreadCount() === 0
|
||||
|
||||
oomTest(() => {
|
||||
offThreadCompileToStencil(
|
||||
offThreadCompileScript(
|
||||
`
|
||||
function f(x) {
|
||||
if (x == 0)
|
||||
|
@ -10,6 +10,5 @@ oomTest(() => {
|
|||
}
|
||||
f(5);
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this) || helperThreadCount() === 0
|
||||
|
||||
oomTest(() => {
|
||||
offThreadCompileToStencil("function a(x) {");
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
offThreadCompileScript("function a(x) {");
|
||||
runOffThreadScript();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// |jit-test| skip-if: !('oomTest' in this) || helperThreadCount() === 0
|
||||
|
||||
oomTest(() => {
|
||||
offThreadCompileToStencil(`
|
||||
offThreadCompileScript(`
|
||||
function f(x) {
|
||||
class of extends ("ABCDEFGHIJK") {
|
||||
test() { return true; };
|
||||
|
@ -12,6 +12,5 @@ oomTest(() => {
|
|||
}
|
||||
return g("try{}catch(e){}", n);
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Unhandlable OOM in AlternativeGeneration::AlternativeGeneration.
|
||||
|
||||
if (typeof oomAfterAllocations == "function" && helperThreadCount() > 0) {
|
||||
offThreadCompileToStencil(`
|
||||
offThreadCompileScript(`
|
||||
[null, "", ""].forEach(function(locales) {
|
||||
try {
|
||||
Intl.NumberFormat(locales)
|
||||
|
@ -11,6 +11,5 @@ Intl.NumberFormat(locales)
|
|||
oomAfterAllocations(100);
|
||||
})
|
||||
`);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
runOffThreadScript();
|
||||
}
|
||||
|
|
|
@ -2,17 +2,12 @@
|
|||
|
||||
// (1) Poison an element in the ionLazyLinkList with a builder whose
|
||||
// script is in a different compartment.
|
||||
evaluate(`
|
||||
offThreadCompileToStencil("var x = -1");
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
`,
|
||||
evaluate('offThreadCompileScript("var x = -1"); runOffThreadScript()',
|
||||
{ global: newGlobal() });
|
||||
|
||||
// (2) Spam the ionLazyLinkList with pending builders until it pops off the one
|
||||
// for the other compartment's script.
|
||||
for (var i = 0; i < 1000; ++i) {
|
||||
offThreadCompileToStencil('var x = ' + i);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
evalStencil(stencil);
|
||||
offThreadCompileScript('var x = ' + i);
|
||||
runOffThreadScript();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// |jit-test| error: Error
|
||||
offThreadCompileToStencil("");
|
||||
finishOffThreadCompileModuleToStencil();
|
||||
offThreadCompileScript("");
|
||||
finishOffThreadModule();
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
// Overwrite built-in parseModule with off-thread module parser.
|
||||
function parseModule(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
return instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
return finishOffThreadModule();
|
||||
}
|
||||
|
||||
// Test case derived from: js/src/jit-test/tests/modules/many-imports.js
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
offThreadCompileToStencil('import("")', {});
|
||||
offThreadCompileScript('import("")', {});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
offThreadCompileModuleToStencil("");
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule("");
|
||||
finishOffThreadModule();
|
||||
|
|
|
@ -19,9 +19,8 @@ if (helperThreadCount() == 0)
|
|||
quit();
|
||||
|
||||
function offThreadEvalModuleAndCheck(source, expected) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
let stencil = finishOffThreadCompileModuleToStencil();
|
||||
let m = instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
let m = finishOffThreadModule();
|
||||
print("compiled");
|
||||
m.declarationInstantiation();
|
||||
m.evaluation();
|
||||
|
|
|
@ -3,8 +3,5 @@
|
|||
load(libdir + "asserts.js")
|
||||
|
||||
// Don't assert.
|
||||
offThreadCompileModuleToStencil("export { x };");
|
||||
assertThrowsInstanceOf(() => {
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
instantiateModuleStencil(stencil);
|
||||
}, SyntaxError);
|
||||
offThreadCompileModule("export { x };");
|
||||
assertThrowsInstanceOf(() => finishOffThreadModule(), SyntaxError);
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
load(libdir + "asserts.js");
|
||||
|
||||
function offThreadParseAndEvaluate(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
let stencil = finishOffThreadCompileModuleToStencil();
|
||||
let m = instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
let m = finishOffThreadModule();
|
||||
m.declarationInstantiation();
|
||||
return m.evaluation();
|
||||
}
|
||||
|
|
|
@ -212,9 +212,8 @@ testMethod(q, "declarationInstantiation");
|
|||
testMethod(q, "evaluation");
|
||||
|
||||
if (helperThreadCount() > 0) {
|
||||
offThreadCompileModuleToStencil(``);
|
||||
let stencil = finishOffThreadCompileModuleToStencil();
|
||||
let r = instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(``);
|
||||
let r = finishOffThreadModule();
|
||||
r.declarationInstantiation();
|
||||
r.evaluation();
|
||||
testMethod(r, "declarationInstantiation");
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// |jit-test| skip-if: helperThreadCount() === 0
|
||||
|
||||
function eval(source) {
|
||||
offThreadCompileModuleToStencil(source);
|
||||
let stencil = finishOffThreadCompileModuleToStencil();
|
||||
let m = instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
let m = finishOffThreadModule();
|
||||
m.declarationInstantiation();
|
||||
return m.evaluation();
|
||||
}
|
||||
|
|
|
@ -5,16 +5,14 @@
|
|||
|
||||
function execOffThread(source)
|
||||
{
|
||||
offThreadCompileToStencil(source);
|
||||
var stencil = finishOffThreadCompileToStencil();
|
||||
return evalStencil(stencil);
|
||||
offThreadCompileScript(source);
|
||||
return runOffThreadScript();
|
||||
}
|
||||
|
||||
function parseModuleOffThread(source)
|
||||
{
|
||||
offThreadCompileModuleToStencil(source);
|
||||
var stencil = finishOffThreadCompileModuleToStencil();
|
||||
return instantiateModuleStencil(stencil);
|
||||
offThreadCompileModule(source);
|
||||
return finishOffThreadModule();
|
||||
}
|
||||
|
||||
let a = { x: 1 };
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче