Java_Magazine_NovemberDecember_2018

(singke) #1

59


//java future/


y = b;
c = z;
}

// Additional methods, for example, getters, toString(), and so on
}

In the Java Hotspot VM, an array of these point objects is laid out in memory as shown in
Figure 3.

When processing this array, each element is accessed via an additional pointer indirection
to get the object that holds the coordinates of each point. This could cause a cache miss for each
point in the array, which in turn might cause a performance issue.
For programmers who care a lot about performance, the ability to define types that can be
laid out in memory more effectively would be very useful.
In this particular example, object identity is not likely to be important to the programmer,
because the code uses neither mutability nor polymorphism, and clients are unlikely to make
use of identity-sensitive features such as locking.

Figure 3. Array of point objects


Point3D[] M K 3


M K 1.2 3.10.7


M K 1.6 -2 2.8


M K 2.10.4 -1

Free download pdf