Skip to content
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

Scopes refactor #406

Merged
merged 5 commits into from
Jun 26, 2020
Merged

Scopes refactor #406

merged 5 commits into from
Jun 26, 2020

Conversation

piscisaureus
Copy link
Member

No description provided.

piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 14, 2020
This makes it possible to add a run-time check that verifies that the
specified closure is actually the one that contains the local handle.
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 14, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 14, 2020
tests/test_api.rs Outdated Show resolved Hide resolved
tests/test_api.rs Show resolved Hide resolved
src/scope.rs Show resolved Hide resolved
src/scope.rs Outdated Show resolved Hide resolved
tests/test_ui.rs Show resolved Hide resolved
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 15, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 15, 2020
src/scope.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that this matters, but FYI the number of "unsafe" usages increased from 462 in master to 474 in this patch. We really need valgrind or ASAN/LSAN.

src/lib.rs Outdated Show resolved Hide resolved
src/scope.rs Show resolved Hide resolved
src/scope.rs Outdated Show resolved Hide resolved
src/scope.rs Show resolved Hide resolved
src/isolate.rs Outdated Show resolved Hide resolved
ry
ry previously approved these changes Jun 15, 2020
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I can't say I understand very well what's happening here. It's very complex - but I have zero doubt that it's justified, given how much energy you've poured into this.

I just request some documentation, somewhere, about how this is all organized. This is going to take many days for another engineer to get up to speed on what's happening, and why. A couple of sentences of docs probably would go a long way.

tests/test_api.rs Show resolved Hide resolved
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 17, 2020
This makes it possible to add a run-time check that verifies that the
specified closure is actually the one that contains the local handle.
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 17, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 17, 2020
This makes it possible to add a run-time check that verifies that the
specified closure is actually the one that contains the local handle.
@piscisaureus
Copy link
Member Author

current Deno delta: denoland/deno@master...piscisaureus:scopes_refactor_update

@ry
Copy link
Member

ry commented Jun 20, 2020

@piscisaureus Very nice to see the deno delta - thanks. One thing that sticks out is that there are several new instances of unsafe.
Example:

-  let mut cbs = v8::CallbackScope::new_escapable(context);
-  let mut hs = v8::EscapableHandleScope::new(cbs.enter());
-  let scope = hs.enter();
+  let scope = &mut unsafe { v8::CallbackScope::new(context) };

It would be nice to have some sort of utility function in rusty_v8 to do that safely (maybe impl From?)

@piscisaureus
Copy link
Member Author

piscisaureus commented Jun 20, 2020

It would be nice to have some sort of utility function in rusty_v8 to do that safely (maybe impl From?)

I think might be hard to get right -- everytime we're entering the vm we'd have to set some flag that says "callbacks possible - CallbackScope ok!", and then we have to clear that flag as we exit the VM. But who knows which callback could be triggered when...

I think the long term solution is what we are already doing for FunctionCallbackInfo/PropertyCallbackInfo, that is, rusty_v8 takes care of creating a scope and passes a safe one to the user callback. here for instance - there's no unsafe and not even a CallbackScope.

piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 20, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 20, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 20, 2020
piscisaureus added a commit to piscisaureus/safe_v8 that referenced this pull request Jun 20, 2020
@@ -61,6 +61,10 @@ fn build_v8() {
vec!["is_debug=false".to_string()]
};

if !cargo_gn::is_debug() {
gn_args.push("v8_enable_handle_zapping=false".to_string());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here? What's this for?

src/scope.rs Outdated Show resolved Hide resolved
@piscisaureus piscisaureus force-pushed the scope branch 5 times, most recently from 7e9a8eb to 464602e Compare June 25, 2020 23:04
Local handles never need to be mutable. This patch also rounds up the
last few places where we were still asking the user to pass an `&mut T`
to an API method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants