Replies: 1 comment 4 replies
-
I feel substructural types would help, though they wouldn't need to be specified explicitly. Specifically, here's how I could envision this being encoded at a high level:
There are already some implications here:
As for how the types would work out:
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Type checking, in general, is a technique for allowing limited correctness proofs for programs. For high-level languages this typically revolves around the allowed values a variable may be assigned to and the allowed uses of variables.
For a virtual machine like WebAssembly, the goal has a different focus: we need to ensure that the machine cannot enter an invalid state. One important feature of this viewpoint compared to that of high-level languages is that the machine cannot trust the output of a compiler. Or, perhaps more accurately, the machine has to be able to verify that its integrity will not be compromised.
For stack switching, this may seem straightforward: there must be sufficient metadata available to ensure that a stack switch cannot violate integrity constraints of the engine. Furthermore, if this could be proved when compiling the module this must be better than if the machine has to keep re-proving the safety. However, in many applications of stack switching, even if the types involved in a stack switch could be proved statically, it is also often necessary to use cast instructions to allow the program to 'prepare' for a stack switch -- i.e., loading the target to switch to can also involve executing a cast instruction.
Beta Was this translation helpful? Give feedback.
All reactions