Skip to content

wasm64 + EM_JS requires special handling for pointer types (and long and size_t) #16975

@sbc100

Description

@sbc100

Under wasm64 pointer types (and long and size_t) get passed as BigInt.

This means that EM_JS functions that take or return pointers will most likely need modifications (since BigInt and Number in JS are not generally compatible).

Should we try to find a way to avoid this type of thing:

EM_JS(char*, return_ptr, (void), {   
#if __wasm64__                                                                   
    return BigInt(addressAsNumber);                                             
#else                                                                            
    return addressAsNumber;                                                                                                   
#endif                                                                              
});    

For JS library functions have use the __sig metadata to encode certain arguments and return values are being "pointers" which means that get cooerced to Number/int53 in the JS glue code.

Should we do that same for EM_JS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions