Bug 1853480 - Part 1: Use TaskController thread stack size as JS stack quota in ScriptLoader off-thread compilation. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D188556
This commit is contained in:
Tooru Fujisawa
2023-09-19 11:12:52 +00:00
parent f369e7062b
commit 9003f6d2cb
2 changed files with 9 additions and 3 deletions

View File

@@ -1827,8 +1827,16 @@ class ScriptOrModuleCompileTask final : public CompileOrDecodeTask {
}
private:
static size_t ThreadStackQuotaForSize(size_t size) {
// Set the stack quota to 10% less that the actual size.
// NOTE: This follows what JS helper thread does.
return size_t(double(size) * 0.9);
}
already_AddRefed<JS::Stencil> Compile() {
JS::SetNativeStackQuota(mFrontendContext, kDefaultStackQuota);
size_t stackSize = TaskController::GetThreadStackSize();
JS::SetNativeStackQuota(mFrontendContext,
ThreadStackQuotaForSize(stackSize));
JS::CompilationStorage compileStorage;
auto compile = [&](auto& source) {