Skip to content

[Wasm64] Initial work for get parts of embind working #17239

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

Merged
merged 1 commit into from
Jun 17, 2022
Merged

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jun 16, 2022

No description provided.

@sbc100 sbc100 requested review from kripken and dschuff June 16, 2022 23:25
@dschuff dschuff requested a review from brendandahl June 17, 2022 16:39
@@ -439,6 +439,7 @@ var LibraryEmbind = {

_embind_register_bool__deps: [
'$getShiftFromSize', '$readLatin1String', '$registerType'],
_embind_register_bool__sig: 'vpppii',
Copy link
Member

Choose a reason for hiding this comment

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

Here's where I start asking dumb basic questions about JS libs.
what happens when there's no signature on a JS lib function? What does adding them here accomplish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are a couple of different uses for these signatures.

In this case we need the signature so that we can generate automatic BigInt<->Number conversion wrapper at the boundary. The p here means pointer and is used for pointer/size_t things that we know assume won't exceed 53-bits..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without these the JS code recieves BitInt values when running with MEMORY64.. which most of our JS code is not setup to receive.

@@ -372,18 +379,18 @@ var LibraryEmVal = {
return Emval.toHandle(rv);
},

_emval_lookupTypes__deps: ['$requireRegisteredType'],
_emval_lookupTypes: function(argCount, argTypes) {
$emval_lookupTypes__deps: ['$requireRegisteredType'],
Copy link
Member

Choose a reason for hiding this comment

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

what's the difference between the $-prefixed and the _-prefixed function names?

Copy link
Collaborator Author

@sbc100 sbc100 Jun 17, 2022

Choose a reason for hiding this comment

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

$-prefixed functions are JS-only, and not visible to the native code/linker. When we have a function like this that take a JS object, my policy is always to $-prefix it.

#endif
// Use uint32_t for pointer values. This limits us, for now, to 32-bit
// address ranges even on wasm64. This is enforced by assertions below.
// TODO(sbc): Allow full 64-bit address range here under wasm64, most
Copy link
Member

Choose a reason for hiding this comment

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

I assume if we updated this to 64-bit, we'd still want to use 53-bit ranges on the JS side though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think they are separate concerns.

abort();
#endif
uintptr_t short_ptr = reinterpret_cast<uintptr_t>(wt);
assert(short_ptr <= UINT32_MAX);
Copy link
Member

Choose a reason for hiding this comment

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

is this assert going to get compiled out in release builds? Should we maybe make it a "real" error, or is there some other code that will help the user if they happen to end up with a pointer outside this range?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its only going to fire for users of MEMORY64 + embind... which is hyper experiential config anyway, so I'm not too worried.

@sbc100 sbc100 enabled auto-merge (squash) June 17, 2022 17:39
@kripken
Copy link
Member

kripken commented Jun 17, 2022

Great work btw!

@sbc100 sbc100 requested a review from kripken June 17, 2022 18:12
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.

3 participants