Skip to content

Commit

Permalink
Bug 1754443 - Do not schedule DelazifyTask if there is no inner funct…
Browse files Browse the repository at this point in the history
…ion to delazify. r=arai

Differential Revision: https://phabricator.services.mozilla.com/D138292
  • Loading branch information
nbp committed Feb 9, 2022
1 parent f1035ae commit 4fabbcf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions js/src/jit-test/tests/parser/stencil-eager-delazify-empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// |jit-test| skip-if: helperThreadCount() === 0 || isLcovEnabled()

// Extra GCs can empty the StencilCache to reclaim memory. This lines
// re-configure the gc-zeal setting to prevent this from happening in this test
// case which waits for the cache to contain some entry.
if ('gczeal' in this)
gczeal(0);

// Generate a source code with no inner functions.
function justVariables(n) {
let text = "";
for (let i = 0; i < n; i++) {
text += `let v${i} = ${i};`;
}
return text;
};

// Create an extra task to test the case where there is nothing to delazify.
let job = offThreadCompileToStencil(justVariables(10000), options);

const stencil = finishOffThreadCompileToStencil(job);
evalStencil(stencil, options);
6 changes: 4 additions & 2 deletions js/src/vm/HelperThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,10 @@ void ParseTask::scheduleDelazifyTask(AutoLockHelperThreadState& lock) {
task->errors_ = std::move(errors);
}

// Schedule delazification task.
HelperThreadState().submitTask(task.release(), lock);
// Schedule delazification task if there is any function to delazify.
if (!task->strategy->done()) {
HelperThreadState().submitTask(task.release(), lock);
}
}

template <typename Unit>
Expand Down

0 comments on commit 4fabbcf

Please sign in to comment.