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

Erikcorry/multi sandbox #3102

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Erikcorry/multi sandbox #3102

wants to merge 3 commits into from

Conversation

erikcorry
Copy link
Contributor

No description provided.

@erikcorry erikcorry requested review from a team as code owners November 13, 2024 15:57
@erikcorry erikcorry marked this pull request as draft November 13, 2024 15:57
} else {
auto result = BackingStore(v8::ArrayBuffer::NewBackingStore(js.v8Isolate, size), size, 0,
getBufferSourceElementSize<T>(), construct<T>, checkIsIntegerType<T>());
memcpy(result.asArrayPtr().begin(), data.begin(), size);
Copy link
Member

Choose a reason for hiding this comment

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

Use result.AsArrayPtr().copyFrom(...) here instead?

Copy link
Member

Choose a reason for hiding this comment

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

Also, using jsg::BackingStore::alloc<T>(js, N) would be easier here?

// Creates a new BackingStore that takes over ownership of the given kj::Array.
// The bytes may be moved if they are not inside the sandbox already.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// The bytes may be moved if they are not inside the sandbox already.
// The bytes may be copied if they are not inside the sandbox already.

size_t size = value.size();
if (size == 0) {
// BackingStore doesn't call custom deleter if begin is null, which it often is for empty
// arrays.
return v8::ArrayBuffer::New(isolate, 0);
}
byte* begin = value.begin();
if (isolate->GetGroup().SandboxContains(begin)) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this could be extracted into a separate utility since there are two places doing this same check and operation?

@erikcorry erikcorry force-pushed the erikcorry/multi-sandbox branch from 1ca82ac to 7a1716d Compare November 20, 2024 14:29
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