forked from mirrors/gecko-dev
Bug 1857536 - Remove unneeded struct CompilationStorage r=arai
Differential Revision: https://phabricator.services.mozilla.com/D203632
This commit is contained in:
parent
8e891db9c2
commit
73e160f12c
13 changed files with 63 additions and 179 deletions
|
|
@ -207,9 +207,8 @@ JSValidatorChild::ValidatorResult JSValidatorChild::ShouldAllowJS(
|
|||
prefableOptions.setAsmJSOption(JS::AsmJSOption::DisabledByAsmJSPref);
|
||||
|
||||
JS::CompileOptions options(prefableOptions);
|
||||
JS::CompilationStorage storage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf, storage);
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
|
||||
if (!stencil) {
|
||||
JS::ClearFrontendErrors(fc);
|
||||
|
|
|
|||
|
|
@ -1891,14 +1891,13 @@ class ScriptOrModuleCompileTask final : public CompileOrDecodeTask {
|
|||
JS::SetNativeStackQuota(mFrontendContext,
|
||||
JS::ThreadStackQuotaForSize(stackSize));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
auto compile = [&](auto& source) {
|
||||
if constexpr (target == CompilationTarget::Script) {
|
||||
return JS::CompileGlobalScriptToStencil(mFrontendContext, mOptions,
|
||||
source, compileStorage);
|
||||
source);
|
||||
}
|
||||
return JS::CompileModuleScriptToStencil(mFrontendContext, mOptions,
|
||||
source, compileStorage);
|
||||
source);
|
||||
};
|
||||
return mMaybeSource.mapNonEmpty(compile);
|
||||
}
|
||||
|
|
@ -1962,7 +1961,6 @@ class ScriptDecodeTask final : public CompileOrDecodeTask {
|
|||
already_AddRefed<JS::Stencil> Decode() {
|
||||
// NOTE: JS::DecodeStencil doesn't need the stack quota.
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
mResult = JS::DecodeStencil(mFrontendContext, mDecodeOptions, mRange,
|
||||
getter_AddRefs(stencil));
|
||||
|
|
|
|||
|
|
@ -1839,9 +1839,8 @@ class ScriptCompileTask final : public Task {
|
|||
return;
|
||||
}
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
mStencil = JS::CompileGlobalScriptToStencil(mFrontendContext, mOptions,
|
||||
srcBuf, compileStorage);
|
||||
mStencil =
|
||||
JS::CompileGlobalScriptToStencil(mFrontendContext, mOptions, srcBuf);
|
||||
#ifdef DEBUG
|
||||
// Chrome-privileged code shouldn't have any compilation error.
|
||||
CheckErrorsAndWarnings(mFrontendContext, mOptions);
|
||||
|
|
|
|||
|
|
@ -105,71 +105,21 @@ JS_PUBLIC_API const JSErrorReport* GetFrontendWarningAt(
|
|||
JS::FrontendContext* fc, size_t index,
|
||||
const JS::ReadOnlyCompileOptions& options);
|
||||
|
||||
// Temporary storage used during compiling and preparing to instantiate a
|
||||
// Stencil.
|
||||
//
|
||||
// Off-thread consumers can allocate this instance off main thread, and pass it
|
||||
// back to the main thread, in order to reduce the main thread allocation.
|
||||
struct JS_PUBLIC_API CompilationStorage {
|
||||
private:
|
||||
// Owned CompilationInput.
|
||||
//
|
||||
// This uses raw pointer instead of UniquePtr because CompilationInput
|
||||
// is opaque.
|
||||
JS_HAZ_NON_GC_POINTER js::frontend::CompilationInput* input_ = nullptr;
|
||||
bool isBorrowed_ = false;
|
||||
|
||||
public:
|
||||
CompilationStorage() = default;
|
||||
explicit CompilationStorage(js::frontend::CompilationInput* input)
|
||||
: input_(input), isBorrowed_(true) {}
|
||||
CompilationStorage(CompilationStorage&& other)
|
||||
: input_(other.input_), isBorrowed_(other.isBorrowed_) {
|
||||
other.input_ = nullptr;
|
||||
}
|
||||
|
||||
~CompilationStorage();
|
||||
|
||||
private:
|
||||
CompilationStorage(const CompilationStorage& other) = delete;
|
||||
void operator=(const CompilationStorage& aOther) = delete;
|
||||
|
||||
public:
|
||||
bool hasInput() { return !!input_; }
|
||||
|
||||
// Internal function that initializes the CompilationInput. It should only be
|
||||
// called once.
|
||||
bool allocateInput(FrontendContext* fc,
|
||||
const JS::ReadOnlyCompileOptions& options);
|
||||
|
||||
js::frontend::CompilationInput& getInput() {
|
||||
MOZ_ASSERT(hasInput());
|
||||
return *input_;
|
||||
}
|
||||
|
||||
// Size of dynamic data. Note that GC data is counted by GC and not here.
|
||||
size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
|
||||
|
||||
void trace(JSTracer* trc);
|
||||
};
|
||||
extern JS_PUBLIC_API already_AddRefed<JS::Stencil> CompileGlobalScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<JS::Stencil> CompileGlobalScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::CompilationStorage& compileStorage);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<JS::Stencil> CompileGlobalScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf, JS::CompilationStorage& compileStorage);
|
||||
JS::SourceText<char16_t>& srcBuf);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<JS::Stencil> CompileModuleScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::CompilationStorage& compileStorage);
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf);
|
||||
|
||||
extern JS_PUBLIC_API already_AddRefed<JS::Stencil> CompileModuleScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf, JS::CompilationStorage& compileStorage);
|
||||
JS::SourceText<char16_t>& srcBuf);
|
||||
|
||||
extern JS_PUBLIC_API bool PrepareForInstantiate(
|
||||
JS::FrontendContext* fc, JS::Stencil& stencil,
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ struct PreallocatedCompilationGCOutput;
|
|||
|
||||
namespace JS {
|
||||
|
||||
struct JS_PUBLIC_API CompilationStorage;
|
||||
|
||||
using Stencil = js::frontend::CompilationStencil;
|
||||
using FrontendContext = js::FrontendContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -7240,13 +7240,10 @@ static bool CompileToStencil(JSContext* cx, uint32_t argc, Value* vp) {
|
|||
|
||||
AutoReportFrontendContext fc(cx);
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
JS::CompilationStorage compileStorage;
|
||||
if (isModule) {
|
||||
stencil =
|
||||
JS::CompileModuleScriptToStencil(&fc, options, srcBuf, compileStorage);
|
||||
stencil = JS::CompileModuleScriptToStencil(&fc, options, srcBuf);
|
||||
} else {
|
||||
stencil =
|
||||
JS::CompileGlobalScriptToStencil(&fc, options, srcBuf, compileStorage);
|
||||
stencil = JS::CompileGlobalScriptToStencil(&fc, options, srcBuf);
|
||||
}
|
||||
if (!stencil) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -87,73 +87,46 @@ JS_PUBLIC_API const JSErrorReport* JS::GetFrontendWarningAt(
|
|||
return &fc->warnings()[index];
|
||||
}
|
||||
|
||||
JS::CompilationStorage::~CompilationStorage() {
|
||||
if (input_ && !isBorrowed_) {
|
||||
js_delete(input_);
|
||||
input_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
size_t JS::CompilationStorage::sizeOfIncludingThis(
|
||||
mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
size_t sizeOfCompilationInput =
|
||||
input_ ? input_->sizeOfExcludingThis(mallocSizeOf) : 0;
|
||||
return mallocSizeOf(this) + sizeOfCompilationInput;
|
||||
}
|
||||
|
||||
bool JS::CompilationStorage::allocateInput(
|
||||
FrontendContext* fc, const JS::ReadOnlyCompileOptions& options) {
|
||||
MOZ_ASSERT(!input_);
|
||||
input_ = fc->getAllocator()->new_<frontend::CompilationInput>(options);
|
||||
return !!input_;
|
||||
}
|
||||
|
||||
void JS::CompilationStorage::trace(JSTracer* trc) {
|
||||
if (input_) {
|
||||
input_->trace(trc);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
static already_AddRefed<JS::Stencil> CompileGlobalScriptToStencilImpl(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<CharT>& srcBuf, JS::CompilationStorage& compilationStorage) {
|
||||
JS::SourceText<CharT>& srcBuf) {
|
||||
ScopeKind scopeKind =
|
||||
options.nonSyntacticScope ? ScopeKind::NonSyntactic : ScopeKind::Global;
|
||||
|
||||
JS::SourceText<CharT> data(std::move(srcBuf));
|
||||
|
||||
compilationStorage.allocateInput(fc, options);
|
||||
if (!compilationStorage.hasInput()) {
|
||||
return nullptr;
|
||||
}
|
||||
frontend::CompilationInput compilationInput(options);
|
||||
|
||||
frontend::NoScopeBindingCache scopeCache;
|
||||
LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
RefPtr<frontend::CompilationStencil> stencil_ =
|
||||
frontend::CompileGlobalScriptToStencil(nullptr, fc, tempLifoAlloc,
|
||||
compilationStorage.getInput(),
|
||||
&scopeCache, data, scopeKind);
|
||||
RefPtr<JS::Stencil> stencil_ = frontend::CompileGlobalScriptToStencil(
|
||||
nullptr, fc, tempLifoAlloc, compilationInput, &scopeCache, data,
|
||||
scopeKind);
|
||||
// CompilationInput initialized with CompileGlobalScriptToStencil only
|
||||
// references information from the JS::Stencil context and the
|
||||
// ref-counted ScriptSource, which are both GC-free.
|
||||
JS_HAZ_VALUE_IS_GC_SAFE(compilationInput);
|
||||
return stencil_.forget();
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
static already_AddRefed<JS::Stencil> CompileModuleScriptToStencilImpl(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& optionsInput,
|
||||
JS::SourceText<CharT>& srcBuf, JS::CompilationStorage& compilationStorage) {
|
||||
JS::SourceText<CharT>& srcBuf) {
|
||||
JS::CompileOptions options(nullptr, optionsInput);
|
||||
options.setModule();
|
||||
|
||||
compilationStorage.allocateInput(fc, options);
|
||||
if (!compilationStorage.hasInput()) {
|
||||
return nullptr;
|
||||
}
|
||||
frontend::CompilationInput compilationInput(options);
|
||||
|
||||
NoScopeBindingCache scopeCache;
|
||||
js::LifoAlloc tempLifoAlloc(JSContext::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE);
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
ParseModuleToStencil(nullptr, fc, tempLifoAlloc,
|
||||
compilationStorage.getInput(), &scopeCache, srcBuf);
|
||||
RefPtr<JS::Stencil> stencil = ParseModuleToStencil(
|
||||
nullptr, fc, tempLifoAlloc, compilationInput, &scopeCache, srcBuf);
|
||||
// CompilationInput initialized with ParseModuleToStencil only
|
||||
// references information from the JS::Stencil context and the
|
||||
// ref-counted ScriptSource, which are both GC-free.
|
||||
JS_HAZ_VALUE_IS_GC_SAFE(compilationInput);
|
||||
if (!stencil) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -164,42 +137,38 @@ static already_AddRefed<JS::Stencil> CompileModuleScriptToStencilImpl(
|
|||
|
||||
already_AddRefed<JS::Stencil> JS::CompileGlobalScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::CompilationStorage& compileStorage) {
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf) {
|
||||
#ifdef DEBUG
|
||||
fc->assertNativeStackLimitThread();
|
||||
#endif
|
||||
return CompileGlobalScriptToStencilImpl(fc, options, srcBuf, compileStorage);
|
||||
return CompileGlobalScriptToStencilImpl(fc, options, srcBuf);
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> JS::CompileGlobalScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf, JS::CompilationStorage& compileStorage) {
|
||||
JS::SourceText<char16_t>& srcBuf) {
|
||||
#ifdef DEBUG
|
||||
fc->assertNativeStackLimitThread();
|
||||
#endif
|
||||
return CompileGlobalScriptToStencilImpl(fc, options, srcBuf, compileStorage);
|
||||
return CompileGlobalScriptToStencilImpl(fc, options, srcBuf);
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> JS::CompileModuleScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& optionsInput,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::CompilationStorage& compileStorage) {
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf) {
|
||||
#ifdef DEBUG
|
||||
fc->assertNativeStackLimitThread();
|
||||
#endif
|
||||
return CompileModuleScriptToStencilImpl(fc, optionsInput, srcBuf,
|
||||
compileStorage);
|
||||
return CompileModuleScriptToStencilImpl(fc, optionsInput, srcBuf);
|
||||
}
|
||||
|
||||
already_AddRefed<JS::Stencil> JS::CompileModuleScriptToStencil(
|
||||
JS::FrontendContext* fc, const JS::ReadOnlyCompileOptions& optionsInput,
|
||||
JS::SourceText<char16_t>& srcBuf, JS::CompilationStorage& compileStorage) {
|
||||
JS::SourceText<char16_t>& srcBuf) {
|
||||
#ifdef DEBUG
|
||||
fc->assertNativeStackLimitThread();
|
||||
#endif
|
||||
return CompileModuleScriptToStencilImpl(fc, optionsInput, srcBuf,
|
||||
compileStorage);
|
||||
return CompileModuleScriptToStencilImpl(fc, optionsInput, srcBuf);
|
||||
}
|
||||
|
||||
bool JS::PrepareForInstantiate(JS::FrontendContext* fc, JS::Stencil& stencil,
|
||||
|
|
|
|||
|
|
@ -53,9 +53,8 @@ bool testCompile() {
|
|||
CHECK(buf16.init(cx, src_16.data(), src_16.length(),
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileGlobalScriptToStencil(fc, options, buf16, compileStorage);
|
||||
CompileGlobalScriptToStencil(fc, options, buf16);
|
||||
CHECK(stencil);
|
||||
CHECK(stencil->scriptExtra.size() == 1);
|
||||
CHECK(stencil->scriptExtra[0].extent.sourceStart == 0);
|
||||
|
|
@ -63,7 +62,6 @@ bool testCompile() {
|
|||
CHECK(stencil->scriptData.size() == 1);
|
||||
CHECK(stencil->scriptData[0].hasSharedData()); // has generated bytecode
|
||||
CHECK(stencil->scriptData[0].gcThingsLength == 1);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
{ // 8-bit characters
|
||||
|
|
@ -71,9 +69,8 @@ bool testCompile() {
|
|||
CHECK(
|
||||
buf8.init(cx, src.data(), src.length(), JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileGlobalScriptToStencil(fc, options, buf8, compileStorage);
|
||||
CompileGlobalScriptToStencil(fc, options, buf8);
|
||||
CHECK(stencil);
|
||||
CHECK(stencil->scriptExtra.size() == 1);
|
||||
CHECK(stencil->scriptExtra[0].extent.sourceStart == 0);
|
||||
|
|
@ -81,7 +78,6 @@ bool testCompile() {
|
|||
CHECK(stencil->scriptData.size() == 1);
|
||||
CHECK(stencil->scriptData[0].hasSharedData()); // has generated bytecode
|
||||
CHECK(stencil->scriptData[0].gcThingsLength == 1);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
{ // propagates failures
|
||||
|
|
@ -90,9 +86,8 @@ bool testCompile() {
|
|||
CHECK(srcBuf.init(cx, badSrc.data(), badSrc.length(),
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(!stencil);
|
||||
CHECK(fc->maybeError().isSome());
|
||||
const js::CompileError& error = fc->maybeError().ref();
|
||||
|
|
@ -120,9 +115,8 @@ bool testNonsyntacticCompile() {
|
|||
auto destroyFc =
|
||||
mozilla::MakeScopeExit([fc] { JS::DestroyFrontendContext(fc); });
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(stencil);
|
||||
|
||||
JS::InstantiateOptions instantiateOptions(options);
|
||||
|
|
@ -153,9 +147,8 @@ bool testCompileModule() {
|
|||
CHECK(buf16.init(cx, src_16.data(), src_16.length(),
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileModuleScriptToStencil(fc, options, buf16, compileStorage);
|
||||
CompileModuleScriptToStencil(fc, options, buf16);
|
||||
CHECK(stencil);
|
||||
CHECK(stencil->isModule());
|
||||
CHECK(stencil->scriptExtra.size() == 1);
|
||||
|
|
@ -164,7 +157,6 @@ bool testCompileModule() {
|
|||
CHECK(stencil->scriptData.size() == 1);
|
||||
CHECK(stencil->scriptData[0].hasSharedData()); // has generated bytecode
|
||||
CHECK(stencil->scriptData[0].gcThingsLength == 1);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
{ // 8-bit characters
|
||||
|
|
@ -172,9 +164,8 @@ bool testCompileModule() {
|
|||
CHECK(
|
||||
buf8.init(cx, src.data(), src.length(), JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileModuleScriptToStencil(fc, options, buf8, compileStorage);
|
||||
CompileModuleScriptToStencil(fc, options, buf8);
|
||||
CHECK(stencil);
|
||||
CHECK(stencil->scriptExtra.size() == 1);
|
||||
CHECK(stencil->scriptExtra[0].extent.sourceStart == 0);
|
||||
|
|
@ -182,7 +173,6 @@ bool testCompileModule() {
|
|||
CHECK(stencil->scriptData.size() == 1);
|
||||
CHECK(stencil->scriptData[0].hasSharedData()); // has generated bytecode
|
||||
CHECK(stencil->scriptData[0].gcThingsLength == 1);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
{ // propagates failures
|
||||
|
|
@ -191,9 +181,8 @@ bool testCompileModule() {
|
|||
CHECK(srcBuf.init(cx, badSrc.data(), badSrc.length(),
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileModuleScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
CompileModuleScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(!stencil);
|
||||
CHECK(fc->maybeError().isSome());
|
||||
const js::CompileError& error = fc->maybeError().ref();
|
||||
|
|
@ -220,15 +209,12 @@ bool testPrepareForInstantiate() {
|
|||
auto destroyFc =
|
||||
mozilla::MakeScopeExit([fc] { JS::DestroyFrontendContext(fc); });
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
CompileGlobalScriptToStencil(fc, options, buf16, compileStorage);
|
||||
CompileGlobalScriptToStencil(fc, options, buf16);
|
||||
CHECK(stencil);
|
||||
CHECK(stencil->scriptData.size() == 2);
|
||||
CHECK(stencil->scopeData.size() == 1); // function f
|
||||
CHECK(stencil->parserAtomData.size() == 1); // 'field'
|
||||
CHECK(compileStorage.hasInput());
|
||||
CHECK(compileStorage.getInput().atomCache.empty());
|
||||
|
||||
JS::InstantiationStorage storage;
|
||||
CHECK(JS::PrepareForInstantiate(fc, *stencil, storage));
|
||||
|
|
|
|||
|
|
@ -41,11 +41,9 @@ BEGIN_FRONTEND_TEST(testFrontendContextCompileGlobalScriptToStencil) {
|
|||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(
|
||||
srcBuf.init(fc, source, strlen(source), JS::SourceOwnership::Borrowed));
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(stencil);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -54,11 +52,9 @@ BEGIN_FRONTEND_TEST(testFrontendContextCompileGlobalScriptToStencil) {
|
|||
JS::SourceText<char16_t> srcBuf;
|
||||
CHECK(srcBuf.init(fc, source, std::char_traits<char16_t>::length(source),
|
||||
JS::SourceOwnership::Borrowed));
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(stencil);
|
||||
CHECK(compileStorage.hasInput());
|
||||
}
|
||||
|
||||
JS::DestroyFrontendContext(fc);
|
||||
|
|
|
|||
|
|
@ -51,9 +51,8 @@ BEGIN_TEST(testFrontendErrors_error) {
|
|||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(
|
||||
srcBuf.init(fc, source, strlen(source), JS::SourceOwnership::Borrowed));
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(!stencil);
|
||||
}
|
||||
|
||||
|
|
@ -133,9 +132,8 @@ BEGIN_TEST(testFrontendErrors_warning) {
|
|||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(
|
||||
srcBuf.init(fc, source, strlen(source), JS::SourceOwnership::Borrowed));
|
||||
JS::CompilationStorage compileStorage;
|
||||
RefPtr<JS::Stencil> stencil =
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf, compileStorage);
|
||||
JS::CompileGlobalScriptToStencil(fc, options, srcBuf);
|
||||
CHECK(stencil);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
#include "js/ErrorReport.h" // JS::PrintError
|
||||
#include "js/Exception.h" // JS::StealPendingExceptionStack
|
||||
#include "js/experimental/CodeCoverage.h" // js::EnableCodeCoverage
|
||||
#include "js/experimental/CompileScript.h" // JS::NewFrontendContext, JS::DestroyFrontendContext, JS::HadFrontendErrors, JS::ConvertFrontendErrorsToRuntimeErrors, JS::CompileGlobalScriptToStencil, JS::CompileModuleScriptToStencil, JS::CompilationStorage
|
||||
#include "js/experimental/CompileScript.h" // JS::NewFrontendContext, JS::DestroyFrontendContext, JS::HadFrontendErrors, JS::ConvertFrontendErrorsToRuntimeErrors, JS::CompileGlobalScriptToStencil, JS::CompileModuleScriptToStencil
|
||||
#include "js/experimental/CTypes.h" // JS::InitCTypesClass
|
||||
#include "js/experimental/Intl.h" // JS::AddMoz{DateTimeFormat,DisplayNames}Constructor
|
||||
#include "js/experimental/JitInfo.h" // JSJit{Getter,Setter,Method}CallArgs, JSJitGetterInfo, JSJit{Getter,Setter}Op, JSJitInfo
|
||||
|
|
@ -637,15 +637,11 @@ void OffThreadJob::run() {
|
|||
|
||||
switch (kind_) {
|
||||
case Kind::CompileScript: {
|
||||
JS::CompilationStorage compileStorage;
|
||||
stencil_ = JS::CompileGlobalScriptToStencil(fc_, options_, srcBuf_,
|
||||
compileStorage);
|
||||
stencil_ = JS::CompileGlobalScriptToStencil(fc_, options_, srcBuf_);
|
||||
break;
|
||||
}
|
||||
case Kind::CompileModule: {
|
||||
JS::CompilationStorage compileStorage;
|
||||
stencil_ = JS::CompileModuleScriptToStencil(fc_, options_, srcBuf_,
|
||||
compileStorage);
|
||||
stencil_ = JS::CompileModuleScriptToStencil(fc_, options_, srcBuf_);
|
||||
break;
|
||||
}
|
||||
case Kind::Decode: {
|
||||
|
|
|
|||
|
|
@ -26,13 +26,12 @@
|
|||
#include <stdint.h> // uint32_t, uint64_t
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "ds/Fifo.h" // Fifo
|
||||
#include "frontend/CompilationStencil.h" // frontend::CompilationStencil
|
||||
#include "gc/GCRuntime.h" // gc::GCRuntime
|
||||
#include "js/AllocPolicy.h" // SystemAllocPolicy
|
||||
#include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions
|
||||
#include "js/experimental/CompileScript.h" // JS::CompilationStorage
|
||||
#include "js/experimental/JSStencil.h" // JS::InstantiationStorage
|
||||
#include "ds/Fifo.h" // Fifo
|
||||
#include "frontend/CompilationStencil.h" // frontend::CompilationStencil
|
||||
#include "gc/GCRuntime.h" // gc::GCRuntime
|
||||
#include "js/AllocPolicy.h" // SystemAllocPolicy
|
||||
#include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions
|
||||
#include "js/experimental/JSStencil.h" // JS::InstantiationStorage
|
||||
#include "js/HelperThreadAPI.h" // JS::HelperThreadTaskCallback, JS::DispatchReason
|
||||
#include "js/MemoryMetrics.h" // JS::GlobalStats
|
||||
#include "js/ProfilingStack.h" // JS::RegisterThreadCallback, JS::UnregisterThreadCallback
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
#include "js/CompileOptions.h" // JS::CompileOptions, JS::OwningCompileOptions
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/experimental/CompileScript.h" // JS::CompileGlobalScriptToStencil, JS::NewFrontendContext, JS::DestroyFrontendContext, JS::SetNativeStackQuota, JS::ThreadStackQuotaForSize, JS::HadFrontendErrors, JS::ConvertFrontendErrorsToRuntimeErrors
|
||||
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::CompileGlobalScriptToStencil, JS::InstantiateGlobalStencil, JS::CompilationStorage
|
||||
#include "js/SourceText.h" // JS::SourceText
|
||||
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::CompileGlobalScriptToStencil, JS::InstantiateGlobalStencil
|
||||
#include "js/SourceText.h" // JS::SourceText
|
||||
#include "js/Utility.h"
|
||||
|
||||
#include "mozilla/AlreadyAddRefed.h" // already_AddRefed
|
||||
|
|
@ -119,9 +119,8 @@ class AsyncScriptCompileTask final : public Task {
|
|||
JS::SetNativeStackQuota(mFrontendContext,
|
||||
JS::ThreadStackQuotaForSize(stackSize));
|
||||
|
||||
JS::CompilationStorage compileStorage;
|
||||
mStencil = JS::CompileGlobalScriptToStencil(mFrontendContext, mOptions,
|
||||
mSrcBuf, compileStorage);
|
||||
mStencil =
|
||||
JS::CompileGlobalScriptToStencil(mFrontendContext, mOptions, mSrcBuf);
|
||||
}
|
||||
|
||||
// Cancel the task.
|
||||
|
|
|
|||
Loading…
Reference in a new issue