United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6516018 : simplify object layout calculations to enable faster reflection

Details
Type:
Bug
Submit Date:
2007-01-22
Status:
Resolved
Updated Date:
2010-05-20
Project Name:
JDK
Resolved Date:
2007-02-17
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs10 (b08)

Related Reports
Backport:
Backport:
Duplicate:
Relates:

Sub Tasks

Description
We want to intrinsify (open-code) certain reflective operations, notably metadata queries and heap allocation routines in java.lang.reflect.Array and java.lang.Class.  They are used in many components of modern Java-based systems.  In order to do this, some small cleanups and extensions are needed in src/share/vm/oops/.

We will remove these fields, used for ad hoc optimizations:
 Klass::size_helper
 Klass::is_objArray
 arrayKlass::array_header_in_bytes
 

We will add these fields, which subsume and extend the previous fields with no loss of performance:
 Klass::layout_helper
 arrayKlass::component_mirror
 java_lang_Class::array_klass

The component_mirror and array_klass fields are a bi-directional link between each array klass and the java.lang.Class mirror for the array component type.  They enable optimizable open-coding for the native method java.lang.Class.getComponentType and java.lang.reflect.Array.newInstance.  They work like the pre-existing pair of fields, Klass::java_mirror and java_lang_Class::klass, which are also a bi-directional link.

Relevant comments from klass.hpp:
// The "layout helper" is a combined descriptor of object layout.
// For klasses which are neither instance nor array, the value is zero.
//
// For instances, layout helper is a positive number, the instance size.
// This size is already passed through align_object_size and scaled to bytes.
// The low order bit is set if instances of this class cannot be
// allocated using the fastpath.
//
// For arrays, layout helper is a negative number, containing four
// distinct bytes, as follows:
//    MSB:[tag, ebt, hsz, log2(esz)]:LSB
// where:
//    tag is 0x80 if the elements are non-oops, 0xC0 if oops
//    ebt is the BasicType of the elements
//    esz is the element size in bytes
//    hsz is array header size in bytes (i.e., offset of first element)
// This packed word is arranged so as to be quickly unpacked by the
// various fast paths that use the various subfields.

                                    

Comments
SUGGESTED FIX

http://prt-web.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2007/20070202000636.jrose.dolphin-reflection/workspace/webrevs/webrev-2007.02.02/index.html
                                     
2007-02-15
EVALUATION

yes, done
                                     
2007-02-15



Hardware and Software, Engineered to Work Together