Skip to content

Erikcorry/multi sandbox#3102

Draft
erikcorry wants to merge 3 commits into
mainfrom
erikcorry/multi-sandbox
Draft

Erikcorry/multi sandbox#3102
erikcorry wants to merge 3 commits into
mainfrom
erikcorry/multi-sandbox

Conversation

@erikcorry

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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?

static BackingStore from(kj::Array<kj::byte> data) {
static BackingStore from(Lock& js, kj::Array<kj::byte> data) {
// 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
Copy Markdown
Collaborator

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.

Comment thread src/workerd/jsg/value.h
return v8::ArrayBuffer::New(isolate, 0);
}
byte* begin = value.begin();
if (isolate->GetGroup().SandboxContains(begin)) {

Copy link
Copy Markdown
Collaborator

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