Repository navigation
Some tests assume that a single compilation is not cached #6258
Description
Activity
- addedtestIssues and PRs related to Node.js core tests and test infrastructure.Issues and PRs related to Node.js core tests and test infrastructure.
on Apr 18, 2016 I wonder if the
v8.setFlagsFromStringAPI even makes sense in Node.js. Here's the current documentation:Set additional V8 command line flags. Use with care; changing settings after the VM has started may result in unpredictable behavior, including crashes and data loss. Or it may simply do nothing.
@ChALkeR do you know if this gets much use by user-space modules on npm?
/cc @indutny for
test-vm-cache-data.We use it quite a bit within StrongLoop (and yes, we're well aware of the gotchas - I wrote the code and the docs.)
parallel/test-v8-flags assumes that running the same script twice will result in the script being compiled twice, specifically, it flips the --allow-natives-syntax between the two compilations. This could be fixed by using eval() also when testing execution in a different context.
I'm not 100% sure how to parse that sentence. The test executes
eval('%_IsSmi(42)')andvm.runInThisContext('%_IsSmi(42)')twice. Is the idea to have a cache keyed on the source string so that the second invocation produces the exact same (identity-wise)v8::Script?eval and runInThisContext hit different caches. The cache currently works like this: the first time we compile something, we put a marker in the cache, but not the actual script. On the second compilation, we replace the marker with the actual script, so the third and future attempts to compile will just get the entry from the cache.
This was introduced for eval() on the assumption that it's unlikely that you'll eval the same string twice, so in order to safe memory, we wait until you actually compile it twice before caching.
For scripts this makes less sense, as you might run in several times in different contexts (or iframes in a browser). Anyways,
so if you changed the test to call eval() twice before flipping the flag, it would also fail.
- added 2 commits that reference this issue
on Apr 25, 2016 - added 2 commits that reference this issue
on Apr 26, 2016 - added a commit that references this issue
on Jul 27, 2026
I'd like to cache scripts immediately instead of recompiling the same script twice before caching it. This breaks two tests:
parallel/test-v8-flags assumes that running the same script twice will result in the script being compiled twice, specifically, it flips the --allow-natives-syntax between the two compilations. This could be fixed by using eval() also when testing execution in a different context.
Note that in general, V8 makes no guarantees about flags being changeable after the first isolate was created
The other test is test-vm-cached-data.js which creates a cache for a valid script, and then corrupts the cache and compiles the script again. But since the script is now already in the memory cache, the passed in cache is ignored. Not sure what to do about this one. It looks like this also relies on a pretty borderline case. If you corrupted the cache between the second and third compilation, it would already get ignored now.
Sample output here: https://build.chromium.org/p/client.v8.fyi/builders/V8%20-%20node.js%20integration%20-%20lkgr/builds/243/steps/build%20and%20test%20node.js/logs/stdio
/cc @nodejs/v8