JDK-6516018 : simplify object layout calculations to enable faster reflection
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: hotspot
  • Sub-Component: compiler
  • Priority: P3
  • Affected Version: 7
  • OS: generic
  • CPU: generic
  • Submit Date: 2007-01-22
  • Updated Date: 2013-11-01
  • Resolved Date: 2007-02-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u4Resolved 7Fixed
Related Reports
Duplicate :  
Relates :  
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