While a compliant implementation is required to accept and run any program this verification algorithm states is verifiable, there may be programs that are accepted as verifiable by a given implementation but which this verification algorithm will fail to consider verifiable. Such programs will run in the given implementation but need not be considered verifiable by other implementations. |
Some uses of returning a managed pointer are perfectly verifiable (eg, returning a reference to a field in an object); but some not (eg, returning a pointer to a local variable of the called method). Tracking this in the general case is a burden, and therefore not included in this standard. |
These two excerpts from the specification allow to provide implementation specific verification rules and particulary rules for verification of managed pointer as return type.
I have developed liberal and simple JIT-time rules for a such verification process. For each managed poiner in stack JIT tracks it's source origin. JIT realizes following origins:
At the start of process of compilation of method JIT designates:
Note: origin of managed pointer that is stored in local variable or argument is changeable. It should be considered rather as value of variable at JIT time then property or type of variable itself.
During compilation JIT tracks origins of all managed pointers in local variables, arguments and stack guiding by the following rules:
Origin adjustment. This process allows to change origin of managed pointer as result of method call to more liberal. Considering all arguments to a method. Note that "this" value is considered also. The following rules are used:
Merge stacks. This process adjust origins of managed pointers in the stack when stack merge is performed. Result of merge is a managed pointer with less liberal origin. Following table shows how origin is adjusted as result of merge operation:
source\with | ByRefToHeap | ByRefToCaller | ByRefToLocal |
---|---|---|---|
ByRefToHeap | ByRefToHeap | ByRefToCaller (rejit required) | ByRefToLocal (rejit required) |
ByRefToCaller | ByRefToCaller | ByRefToCaller | ByRefToLocal (rejit required) |
ByRefToLocal | ByRefToLocal | ByRefToLocal | ByRefToLocal |
Virification rule:
Conclusion: this set of rules allows more complete usage of managed
pointer type with addition of simple set of rules at JIT only.