| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 236dc4d commit 0ea079b
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,14 @@ const { Worker } = require('worker_threads'); | |||
| 8 | 8 | // Verify that Workers don't care about --stack-size, as they have their own | |
| 9 | 9 | // fixed and known stack sizes. | |
| 10 | 10 | ||
| 11 | + // The depth of the stack depends not only on the stack size, but also on the size of each | ||
| 12 | + // stack frame, which in turn depends on which tier the recursive function happens to be | ||
| 13 | + // running at when the overflow occurs. Under load the background tier-up can land at a | ||
| 14 | + // non-deterministic point in the recursion and flake the test. Keep the recursive | ||
| 15 | + // function in the interpreter with %NeverOptimizeFunction() so the frame size - | ||
| 16 | + // and thus the depth - is deterministic. | ||
| 17 | + v8.setFlagsFromString('--allow-natives-syntax'); | ||
| 18 | + | ||
| 11 | 19 | async function runWorker(options = {}) { | |
| 12 | 20 | const empiricalStackDepth = new Uint32Array(new SharedArrayBuffer(4)); | |
| 13 | 21 | const worker = new Worker(` | |
@@ -16,6 +24,7 @@ async function runWorker(options = {}) { | |||
| 16 | 24 | empiricalStackDepth[0]++; | |
| 17 | 25 | f(); | |
| 18 | 26 | } | |
| 27 | + %NeverOptimizeFunction(f); | ||
| 19 | 28 | f();`, { | |
| 20 | 29 | eval: true, | |
| 21 | 30 | workerData: { empiricalStackDepth }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments