[MLton] Compressed pointers

Daniel C. Wang danwang at CS.Princeton.EDU
Fri May 18 18:26:17 PDT 2007


What about the following design, by default MLton is free to represent 
any object however it likes. Introduce a new type constructor   'a 
native, for the few cases where you want  the "native" representation 
of  objects/values.
All heap pointers in heap objects that aren't "native" can be 
represented as compressed pointers. Stack and registers only ever hold 
uncompressed addresses. This means the GC only every sees native 
uncompressed pointers in its root set. Every other object reachable from 
the root can contain compressed pointers except for the few that are 
marked as native.
This scheme just requires you to keep extra bits around in the object 
headers of heap objects with native types.

For the char** case, the ml_type would be something like

((char array) native) array native

In then end you'll probably expose something like the following:
signature NATIVE = sig
    type 'a native
    val toNative: 'a -> 'a native
    val fromNative: 'a native-> 'a
end

Making the "interop" issues explicit at the user level gives the 
compiler more freedom and the end-user some more guarantees.




More information about the MLton mailing list