Prev | Current Page 86 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The reason for this is to increase
the speed at which values are accessed.
Normally, a type within a scripting language is stored within the virtual machine using a structure, like
this:
struct value {
int value_type;
void *value_data;
};
Here, the value_type is used to determine the type of the value, so an integer might be 1 , a float is 2 ,
and a string is 3 . The actual data of the value is then stored in the value_data pointer. When the virtual
machine needs to apply processes to the value_data , it has only to check the value of value_type to
determine the content of value_data . While this works really well, the problem with this approach is
that creating such a structure slows things down, as the garbage collector has to deal with a more
complex data type. As Int s are more often used than any other type, it seemed fitting to make use of a
trick to maintain the maximum possible speed. When a value structure is used by Neko, it is referenced
using a pointer that occupies 32 bits. The most significant bit of this pointer is always 0.


Pages:
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98