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

chore: update rusty_v8 to 0.56.0 #16814

Merged
merged 6 commits into from
Nov 26, 2022

Conversation

bartlomieju
Copy link
Member

No description provided.

ops/lib.rs Outdated
Comment on lines 455 to 457
let data = b.data();
assert!(data.is_some());
let store = data.unwrap().cast::<u8>().as_ptr();
Copy link
Member Author

Choose a reason for hiding this comment

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

Changes in this file are related to denoland/rusty_v8#1131

CC @andreubotella @littledivy

Copy link
Contributor

Choose a reason for hiding this comment

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

This is related to #16161. IIUC ArrayBuffer::data will return None for all empty buffers, in which case most APIs would expect &[] or &mut [].

For FFI APIs, however, this might break things, and it might need the #[op] macro to also support Option<&[u8]>.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the heads up, I'm gonna merge the PR if it goes green and let Divy handle that in a follow up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Welp, it seems I hit that problem already in test_ffi/tests/test.js in

const emptyBuffer = new BigUint64Array(0);
console.log(Boolean(dylib.symbols.is_null_ptr(Deno.UnsafePointer.of(emptyBuffer))));

It prints false while it should print true

Copy link
Member Author

Choose a reason for hiding this comment

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

@andreubotella so you're saying that all buffers should be mapped to Option<& [u8]>? In which case empty buffers would be None?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really. Only the ptr_of op is probably interested in the real pointer behind the slice instead of being interested in the slice itself.

There's just no good way to (currently at least) explain this to serde_v8 since while a plain pointer would be accurate to what the op needs, it doesn't really explain the JS param type.

Copy link
Contributor

Choose a reason for hiding this comment

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

My idea was to that op parameters could be either &[u8] or Option<&[u8]>, so that only ops that care about the pointer possibly being null have to deal with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for comments. it's a bit unclear what to do here, I'll wait for Divy's opinion

Copy link
Member

@littledivy littledivy Nov 26, 2022

Choose a reason for hiding this comment

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

Option<&[u8]> interferes with undefined and null values in serde_v8. I opened a PR adding support for raw ptr in ops macro: #16826

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM

ops/lib.rs Outdated Show resolved Hide resolved
littledivy added a commit that referenced this pull request Nov 26, 2022
See #16814 (comment).
Allows nullable buffers in low-level ops like FFI:

```rust
fn op_ffi_ptr_of<FP>(
  state: &mut OpState,
  buf: *const u8,
  out: &mut [u32],
) 
where
  FP: FfiPermissions + 'static {
  // ..
}
```
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM. Nit: Use std::ptr::null() as _ instead of 0 as _

@bartlomieju bartlomieju merged commit 55da1a2 into denoland:main Nov 26, 2022
@bartlomieju bartlomieju deleted the upgrade_rusty_v8 branch November 26, 2022 15:35
@bartlomieju
Copy link
Member Author

LGTM. Nit: Use std::ptr::null() as _ instead of 0 as _

Yeah, clippy screamed and me and I fixed that.

kt3k pushed a commit that referenced this pull request Dec 1, 2022
See #16814 (comment).
Allows nullable buffers in low-level ops like FFI:

```rust
fn op_ffi_ptr_of<FP>(
  state: &mut OpState,
  buf: *const u8,
  out: &mut [u32],
) 
where
  FP: FfiPermissions + 'static {
  // ..
}
```
kt3k pushed a commit that referenced this pull request Dec 1, 2022
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.

5 participants