Make the HostHooks shareable between app and context#4141
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4141 +/- ##
==========================================
+ Coverage 47.24% 53.55% +6.31%
==========================================
Files 476 487 +11
Lines 46892 48874 +1982
==========================================
+ Hits 22154 26176 +4022
+ Misses 24738 22698 -2040 ☔ View full report in Codecov by Sentry. |
|
IIRC we had I think it's fine to make it possible to add special data to the hooks, but I'm slightly worried that some subtle bugs could be triggered because the hooks are used at realm creation time. |
jedel1043
left a comment
There was a problem hiding this comment.
Preemptively approving since this is immediately useful, but it would be good to make a survey on how the host hooks are defined on other engines to be sure that we're not introducing bugs by doing this.
Then we would prevent hooks from ever be mocked, which is in general not a great idea.
I'll have a look at the public API of quickjs, SpiderMonkey and V8, but since they're all in C I'll venture it's all pointers with the undertext that "you need to make sure this outlives the engine", which doesn't work that well in Rust. |
I was more talking about other Rust based engines: rhai, RustPython, Piccolo. Even wrappers such as rusty_v8 or rquickjs. See what they offer that is similar to "HostHooks" and how they offer them. |
|
Well that's going to be kind of boring :P
So I'll go check more C++ code :) |
Previously it was very difficult to keep a stateful
HostHooks, since it needed to be a static reference. Now it can be shared. This is particularly useful for mocking hooks for testing.This also follows the pattern for the job executor and the module loader.
I did not see any impact on performance.