-
Notifications
You must be signed in to change notification settings - Fork 285
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
limit allocation to innermost Scope #2
Comments
You could hack it with macros. Rather than: pub extern fn make_an_array(call: &mut Call) {
let result = Scope::run(|scope| {
let mut array = scope.array(3);
array.set(0, scope.integer(17));
array.set(1, scope.integer(42));
array.set(2, scope.integer(1999));
call.set_return(array);
});
} you could have something like: pub extern fn make_an_array(call: &mut Call) {
let result = scope_run!({
let mut array = v8_array!(3);
array.set(0, v8_integer!(17));
array.set(1, v8_integer!(42));
array.set(2, v8_integer!(1999));
call.set_return(array);
});
} I feel dirty just thinking about it. |
I had another hacky idea but I think it's too painful to use: if we could exploit the borrowing rules that prevent multiple simultaneous borrows when one is mutable, maybe we could somehow force the client into a mutable borrow when nesting so that no other borrowing is legal for that duration. I'm not sure if this would work, but the problem is it means you have to declare all |
Fixed in 3c596a0 |
# This is the 1st commit message: get_uv # This is the commit message neon-bindings#2: added AsyncContext and cx.spawn_async # This is the commit message neon-bindings#3: added async function registration # This is the commit message neon-bindings#4: tidy # This is the commit message neon-bindings#5: comments # This is the commit message neon-bindings#6: using futures # This is the commit message neon-bindings#7: using futures # This is the commit message neon-bindings#8: vendored libuv # This is the commit message neon-bindings#9: Incorrect settings
Since V8 actually allocates handles using the current isolate's innermost HandleScope, but the Rust types do not statically prevent attempting to allocate a handle connected to an outer Scope, dynamically track the linked list of Scopes and disallow allocation to a Scope that is not the current innermost one.
This seems unfortunate for performance, but I'm not sure if there's a faster way. Ideally we'd prevent it statically.
The text was updated successfully, but these errors were encountered: