Skip to content

Commit

Permalink
Bug 1853480 - Part 2: Use TaskController thread stack size as JS stac…
Browse files Browse the repository at this point in the history
…k quota in nsXULPrototypeScript off-thread compilation. r=nbp

Depends on D188556

Differential Revision: https://phabricator.services.mozilla.com/D188557
  • Loading branch information
arai-a committed Sep 19, 2023
1 parent eaf4a57 commit b8915fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dom/xul/nsXULElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,10 +1856,17 @@ class ScriptCompileTask final : public Task {
}

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);
}

void Compile() {
// NOTE: The stack limit must be set from the same thread that compiles.
const size_t kDefaultStackQuota = 128 * sizeof(size_t) * 1024;
JS::SetNativeStackQuota(mFrontendContext, kDefaultStackQuota);
size_t stackSize = TaskController::GetThreadStackSize();
JS::SetNativeStackQuota(mFrontendContext,
ThreadStackQuotaForSize(stackSize));

JS::SourceText<Utf8Unit> srcBuf;
if (NS_WARN_IF(!srcBuf.init(mFrontendContext, mText.get(), mTextLength,
Expand Down

0 comments on commit b8915fe

Please sign in to comment.