-
Notifications
You must be signed in to change notification settings - Fork 693
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
call_import separate from call_direct? #421
Comments
I kind of see the distinction the same way relocations work. I think we can optimize things at load time, but I'm not sure we want to mandate a specific implementation. Put another way: does this distinction give us something? |
My main argument earlier was that putting normal functions and imports into the same main function table would suggest allowing imports in the indirect function table which in turn would require some extra thunking complexity for I also think the spec will get a bit more complex having main function table entries being either internal functions or imports, but that's not a strong argument. In return, we'd get re-exports (requested in #355) "for free" and you could So despite my, ahem, spirited objection earlier, I'm now mildly in favor. ¯_(ツ)_/¯ |
I don't think it would be wise to unify the two. Even if it turns out to be easy to treat imports in the same manner as internal functions in some implementations we should not assume that that is the case for all implementations and environments hosting Wasm. We might be putting a potentially significant burden on others. Given that there isn't any real benefit in combining them, erring on the conservative side seems advisable. |
An additional point: when we add dynamic linking and need to export unaliased mutable thread-local variables (viz., |
FWIW, I'm back to thinking it's cleaner and simpler to keep things as-is in the spec. In addition to simplifying the impl (at least in SM), it's become more clear that the right way to think about imports, from a C++/compiler/toolchain pov, is as syscalls (e.g., they take you out of your "user" address space). Like syscalls, imports would be called in one or two places by wasm functions defined by toolchain/library. In particular, wasm imports do not correspond to |
In that case, should we not call these imports anymore? Should we straight-up call them "syscalls"? That seems like it might be right. Then when we solve dynamic linking we introduce something tailor-made for those import/export scenarios that has the right semantics (and it would be ideal if you just used |
Some (minor) confusion worries me about calling them syscalls, since libc ports might use that name for their current syscall interface, and it might not match up to what we call imports (some libc syscalls might end up implemented in wasm, such as a virtual filesystem). |
libc itself would use I think it's worth changing |
Yeah, writing the above made me think about renaming too. I would like the name "syscall" except that it is a very monolithic-C++-app-centric view of the world. For all of the modular wasm-as-part-of-a-bigger-app use cases, then imports are aptly named. This isn't just on the web, but would show up in node.js and possibly other environments that wanted to allow wasm multiple instances for the memory-isolation benefits. Perhaps we could think of a less C++-centric name that still left "import" reserved for dynamic linking (say, |
How about splitting out the naming into a separate issue if there is no consensus now. It would be nice to have v8's binary implementation and the spec consistent if consensus can be reached now, irrespective of the naming. |
"syscall" sounds to me like calling into some kind of "system" (OS, browser, or other 'outer system'). How is it C++-centric, other than that C++ coders use the word more than others? |
Note that these calls correspond to the "import" section of a Wasm module, so we should either rename both, or keep the name. Moreover, there also is the dualism with module "exports", which we also would want to keep somehow. But FWIW, I tend to think of this mechanism as more of a foreign function interface. So how about |
If we add a call_multiple in the future to handle multiple return values, On Wed, Jan 13, 2016 at 11:45 AM, rossberg-chromium <
|
@titzer: that's one of reasons why I think you don't want call_multiple, but something more compositional. |
But I also agree that it would be odd to lose the "import"/"export" parallel. So renaming |
Are imports actually the dual of exports? @lukewagner 's suggestion was that dynamic linking between modules would probably use a different mechanism, and I think he might be right. In that case 'import' as it is right now is effectively a syscall, and 'export' is a mechanism used by the host environment to find the entry point (and in the case of wasm libraries, used by the host environment to access library APIs). |
@rossberg-chromium Maintaining One idea is to call what we have in the wasm MVP "external imports"/"external exports" and, symmetrically, call the dynamic linking feature "internal imports"/"internal exports". Then you would call an external import with |
@kg Since wasm environments (incl the web) can allow binding (to use my proposed terminology) external exports to external imports I do think there is a dualism. The discussion in the other issue is convincing me that "syscall", while effective as a metaphor for conveying the concept of "leaving the address space", incorrectly suggests that the call is into a system-fixed set of entry points, which isn't the case. |
With the new design for tables established in #682, the there is no longer a distinct |
Should we combine the import table and the function table like v8-native-prototype, which allows combining call_direct and call_import and indirect calls to imports, or have separate tables?
The text was updated successfully, but these errors were encountered: