one embodiment of the present invention facilitates skewing a bi - directional object layout to provide good cache behavior . during operation , the system receives a request to access an object . this request includes an object identifier and an object offset that specifies the offset of a target field within the object , wherein the object has a bi - directional layout that locates scalar fields at positive offsets and reference fields at negative offsets , so that a reference field can be immediately identified from its object offset . next , the system determines a skew value for a cache line containing the object , wherein data within the cache line is shifted based upon the skew value , so that reference fields with small negative offsets are likely to be located in the same cache line as scalar fields with small positive offsets . next , the system uses the skew value in accessing the object .