[m-dev.] 4 tag bits
    Michael Day 
    mikeday at yeslogic.com
       
    Fri Jul  8 17:30:41 AEST 2016
    
    
  
Hi Zoltan,
> The real question is: would this buy us anything worthwhile? How frequent
> are types that have more than 16 functors in which two or more functors
> would get 5+ bit alignment? In my experience, almost all types with
> that many functors are enums.
Indeed. It's an interesting thought experiment, but it's applicability 
to actual programs seems limited.
Some JavaScript implementations have used NaN-boxing to distinguish 
between 64-bit pointers and 64-bit doubles:
https://wingolog.org/archives/2011/05/18/value-representation-in-javascript-implementations
In Prince we have a type like this:
:- type js_value
     --->    undefined
     ;       null
     ;       bool(bool)
     ;       number(number)
     ;       string(js_string)
     ;       object(js_object).
:- type number
     --->    int(int)
     ;       float(float).
Technically the int values are not really necessary, as JavaScript 
doesn't have a primitive int type. So we could simplify it:
:- type js_value
     --->    undefined
     ;       null
     ;       bool(bool)
     ;       number(float)
     ;       string(js_string)
     ;       object(js_object).
Some hypothetical compiler cleverness could notice that this type is 
either a float, a tagged pointer, or an enum, and pack it in a NaN if 
necessary. But it would have complications and overhead that would 
probably make it a bad idea to apply too liberally.
Michael
-- 
Prince: Print with CSS!
http://www.princexml.com
    
    
More information about the developers
mailing list