-
Notifications
You must be signed in to change notification settings - Fork 74
Should there be an "escape hatch" for vtable structural subtyping? #29
Comments
There is a wealth of options for enriching the type system in a principled manner to avoid casts in certain situations. They all tend to conflict with simplicity, of course. We will need implementation experience to see what is bearable and what isn't -- such casts can be much cheaper than you'd expect and may already be dominated by the cost of a call. That said, a special type system hack for the benefit of Java-like languages -- and language bias in general -- is something we'd rather want to avoid. |
I think we should make virtual calls in Kotlin-like languages efficient at runtime and in terms if code size. We would get a lot of value having a simple type-check rule and an instruction Proposed shortcut can be completely ignored without any cost by languages that don't need this feature. My main concern with current proposal is the size of generated code, a quality we absolutely want to have when targeting web clients. Inside a function that overrides virtual method we would need 4 extra instructions and extra
If we would like to keep zero-overhead direct calls we'd put this cast into a bridge method. It would require an extra Virtual methods become bloated, but call sites look even worse.
in some cases we would need 5 extra instructions and a temp
compared to proposed
|
…able.copy`. (#29) This would make it simpler to extend those instructions to support multiple memories/tables, and copying between different memories/tables. The current encoding has a single placeholder zero byte for those instructions, which allows extension to multiple memories/tables, but would require a more complicated encoding to add two immediate indices.
We have discussed improved method dispatch as a potential high-priority post-MVP feature, but we won't be adding it to the MVP, so closing this. |
The "median" target for this proposal appears to be Java-like languages (though others can certainly be represented) which will heavily make use of vtable calls. In that light, it seems odd that we're willing to put up with adding code like:
to most methods, which is both a speed and code bloat issue.
I'm probably missing something, but maybe someone can clarify why we shouldn't special-case this super common use case.
I'd imagine we can have an escape hatch to structural subtyping that goes something like this:
The text was updated successfully, but these errors were encountered: