-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm: enhance cached data handling for empty functions and add validation tests #56442
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -1564,9 +1564,13 @@ Local<Object> ContextifyContext::CompileFunctionAndCacheResult( | |||
return Object::New(env->isolate()); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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