vm: enhance cached data handling for empty functions and add validation tests#56442
vm: enhance cached data handling for empty functions and add validation tests#56442gurgunday wants to merge 4 commits intonodejs:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56442 +/- ##
==========================================
- Coverage 88.54% 88.54% -0.01%
==========================================
Files 657 657
Lines 190742 190744 +2
Branches 36606 36617 +11
==========================================
- Hits 168901 168893 -8
- Misses 15027 15029 +2
- Partials 6814 6822 +8
|
legendecas
left a comment
There was a problem hiding this comment.
The issue is that the code cache of vm.Script and vm.compileFunction can not be interchanged. I think this is rather a V8 issue that it didn't reject the incorrect code cache.
| if (produce_cached_data) { | ||
| new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fn)); | ||
| if (produce_cached_data && !fn.IsEmpty()) { | ||
| TryCatchScope try_cache(env); |
There was a problem hiding this comment.
There is no JavaScript execution in this scope and this TryCacheScope is redundant.
| new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fn)); | ||
| if (produce_cached_data && !fn.IsEmpty()) { | ||
| TryCatchScope try_cache(env); | ||
| if (options != ScriptCompiler::kConsumeCodeCache) { |
There was a problem hiding this comment.
I don't think this guard is the correct solution. When produceCachedData is true, a new cached data should always be returned regardless of whether the old one is consumed or not.
| std::unique_ptr<ScriptCompiler::CachedData> new_cached_data; | ||
| if (produce_cached_data) { | ||
| new_cached_data.reset(ScriptCompiler::CreateCodeCacheForFunction(fn)); | ||
| if (produce_cached_data && !fn.IsEmpty()) { |
There was a problem hiding this comment.
The fn here is always not empty.
I see, so you say it's better to signal this to the V8 team and wait? This also fixes it |
|
v8/v8@96ee9bb should fix the issue. |
Fixes #56366