src/share/vm/classfile/javaClasses.hpp

Print this page
rev 2 : [mq]: wkk.patch


  28 // If the layout of any of the classes above changes the offsets must be adjusted.
  29 //
  30 // For most classes we hardwire the offsets for performance reasons. In certain
  31 // cases (e.g. java.security.AccessControlContext) we compute the offsets at
  32 // startup since the layout here differs between JDK1.2 and JDK1.3.
  33 //
  34 // Note that fields (static and non-static) are arranged with oops before non-oops
  35 // on a per class basis. The offsets below have to reflect this ordering.
  36 //
  37 // When editing the layouts please update the check_offset verification code
  38 // correspondingly. The names in the enums must be identical to the actual field
  39 // names in order for the verification code to work.
  40 
  41 
  42 // Interface to java.lang.String objects
  43 
  44 class java_lang_String : AllStatic {
  45  private:
  46   enum {
  47     hc_value_offset  = 0,
  48     hc_offset_offset = 1,
  49     hc_count_offset  = 2,
  50     hc_hash_offset   = 3
  51   };
  52 
  53   static int value_offset;
  54   static int offset_offset;
  55   static int count_offset;
  56   static int hash_offset;
  57 
  58   static Handle basic_create(int length, bool tenured, TRAPS);
  59   static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
  60 
  61   static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset,  (oop)buffer); }
  62   static void set_offset(oop string, int offset)          { string->int_field_put(offset_offset, offset); }
  63   static void set_count( oop string, int count)           { string->int_field_put(count_offset,  count);  }
  64 
  65  public:
  66   // Instance creation
  67   static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
  68   static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS);
  69   static oop    create_oop_from_unicode(jchar* unicode, int len, TRAPS);
  70   static Handle create_from_str(const char* utf8_str, TRAPS);


 131     hc_resolved_constructor_offset = 2,
 132     hc_number_of_fake_oop_fields   = 3
 133   };
 134 
 135   static int klass_offset;
 136   static int resolved_constructor_offset;
 137   static int array_klass_offset;
 138   static int number_of_fake_oop_fields;
 139 
 140   static void compute_offsets();
 141   static bool offsets_computed;
 142   static int classRedefinedCount_offset;
 143 
 144  public:
 145   // Instance creation
 146   static oop  create_mirror(KlassHandle k, TRAPS);
 147   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 148   // Conversion
 149   static klassOop as_klassOop(oop java_class);
 150   // Testing



 151   static bool is_primitive(oop java_class);
 152   static BasicType primitive_type(oop java_class);
 153   static oop primitive_mirror(BasicType t);
 154   // JVM_NewInstance support
 155   static methodOop resolved_constructor(oop java_class);
 156   static void set_resolved_constructor(oop java_class, methodOop constructor);
 157   // JVM_NewArray support
 158   static klassOop array_klass(oop java_class);
 159   static void set_array_klass(oop java_class, klassOop klass);
 160   // compiler support for class operations
 161   static int klass_offset_in_bytes() { return klass_offset; }
 162   static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
 163   static int array_klass_offset_in_bytes() { return array_klass_offset; }
 164   // Support for classRedefinedCount field
 165   static int classRedefinedCount(oop the_class_mirror);
 166   static void set_classRedefinedCount(oop the_class_mirror, int value);
 167   // Debugging
 168   friend class JavaClasses;
 169   friend class instanceKlass;   // verification code accesses offsets
 170   friend class ClassFileParser; // access to number_of_fake_fields


 633 
 634 // Interface to java.lang primitive type boxing objects:
 635 //  - java.lang.Boolean
 636 //  - java.lang.Character
 637 //  - java.lang.Float
 638 //  - java.lang.Double
 639 //  - java.lang.Byte
 640 //  - java.lang.Short
 641 //  - java.lang.Integer
 642 //  - java.lang.Long
 643 
 644 // This could be separated out into 8 individual classes.
 645 
 646 class java_lang_boxing_object: AllStatic {
 647  private:
 648   enum {
 649    hc_value_offset = 0
 650   };
 651   static int value_offset;
 652 
 653   static oop initialize_and_allocate(klassOop klass, TRAPS);
 654  public:
 655   // Allocation. Returns a boxed value, or NULL for invalid type.
 656   static oop create(BasicType type, jvalue* value, TRAPS);
 657   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
 658   static BasicType get_value(oop box, jvalue* value);
 659   static BasicType set_value(oop box, jvalue* value);



 660 
 661   static int value_offset_in_bytes() { return value_offset; }
 662 
 663   // Debugging
 664   friend class JavaClasses;
 665 };
 666 
 667 
 668 
 669 // Interface to java.lang.ref.Reference objects
 670 
 671 class java_lang_ref_Reference: AllStatic {
 672  public:
 673   enum {
 674    hc_referent_offset   = 0,
 675    hc_queue_offset      = 1,
 676    hc_next_offset       = 2,
 677    hc_discovered_offset = 3  // Is not last, see SoftRefs.
 678   };
 679   enum {


 880 
 881  public:
 882   static int  value_offset();
 883   static void compute_offsets();
 884 };
 885 
 886 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
 887  private:
 888   static int  _owner_offset;
 889  public:
 890   static void initialize(TRAPS);
 891   static oop  get_owner_threadObj(oop obj);
 892 };
 893 
 894 // Interface to hard-coded offset checking
 895 
 896 class JavaClasses : AllStatic {
 897  private:
 898   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
 899   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;

 900  public:
 901   static void compute_hard_coded_offsets();
 902   static void compute_offsets();
 903   static void check_offsets() PRODUCT_RETURN;
 904 };


  28 // If the layout of any of the classes above changes the offsets must be adjusted.
  29 //
  30 // For most classes we hardwire the offsets for performance reasons. In certain
  31 // cases (e.g. java.security.AccessControlContext) we compute the offsets at
  32 // startup since the layout here differs between JDK1.2 and JDK1.3.
  33 //
  34 // Note that fields (static and non-static) are arranged with oops before non-oops
  35 // on a per class basis. The offsets below have to reflect this ordering.
  36 //
  37 // When editing the layouts please update the check_offset verification code
  38 // correspondingly. The names in the enums must be identical to the actual field
  39 // names in order for the verification code to work.
  40 
  41 
  42 // Interface to java.lang.String objects
  43 
  44 class java_lang_String : AllStatic {
  45  private:
  46   enum {
  47     hc_value_offset  = 0,
  48     hc_offset_offset = 1
  49     //hc_count_offset = 2  -- not a word-scaled offset
  50     //hc_hash_offset  = 3  -- not a word-scaled offset
  51   };
  52 
  53   static int value_offset;
  54   static int offset_offset;
  55   static int count_offset;
  56   static int hash_offset;
  57 
  58   static Handle basic_create(int length, bool tenured, TRAPS);
  59   static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
  60 
  61   static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset,  (oop)buffer); }
  62   static void set_offset(oop string, int offset)          { string->int_field_put(offset_offset, offset); }
  63   static void set_count( oop string, int count)           { string->int_field_put(count_offset,  count);  }
  64 
  65  public:
  66   // Instance creation
  67   static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
  68   static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS);
  69   static oop    create_oop_from_unicode(jchar* unicode, int len, TRAPS);
  70   static Handle create_from_str(const char* utf8_str, TRAPS);


 131     hc_resolved_constructor_offset = 2,
 132     hc_number_of_fake_oop_fields   = 3
 133   };
 134 
 135   static int klass_offset;
 136   static int resolved_constructor_offset;
 137   static int array_klass_offset;
 138   static int number_of_fake_oop_fields;
 139 
 140   static void compute_offsets();
 141   static bool offsets_computed;
 142   static int classRedefinedCount_offset;
 143 
 144  public:
 145   // Instance creation
 146   static oop  create_mirror(KlassHandle k, TRAPS);
 147   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 148   // Conversion
 149   static klassOop as_klassOop(oop java_class);
 150   // Testing
 151   static bool is_instance(oop obj) {
 152     return obj != NULL && obj->klass() == SystemDictionary::class_klass();
 153   }
 154   static bool is_primitive(oop java_class);
 155   static BasicType primitive_type(oop java_class);
 156   static oop primitive_mirror(BasicType t);
 157   // JVM_NewInstance support
 158   static methodOop resolved_constructor(oop java_class);
 159   static void set_resolved_constructor(oop java_class, methodOop constructor);
 160   // JVM_NewArray support
 161   static klassOop array_klass(oop java_class);
 162   static void set_array_klass(oop java_class, klassOop klass);
 163   // compiler support for class operations
 164   static int klass_offset_in_bytes() { return klass_offset; }
 165   static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
 166   static int array_klass_offset_in_bytes() { return array_klass_offset; }
 167   // Support for classRedefinedCount field
 168   static int classRedefinedCount(oop the_class_mirror);
 169   static void set_classRedefinedCount(oop the_class_mirror, int value);
 170   // Debugging
 171   friend class JavaClasses;
 172   friend class instanceKlass;   // verification code accesses offsets
 173   friend class ClassFileParser; // access to number_of_fake_fields


 636 
 637 // Interface to java.lang primitive type boxing objects:
 638 //  - java.lang.Boolean
 639 //  - java.lang.Character
 640 //  - java.lang.Float
 641 //  - java.lang.Double
 642 //  - java.lang.Byte
 643 //  - java.lang.Short
 644 //  - java.lang.Integer
 645 //  - java.lang.Long
 646 
 647 // This could be separated out into 8 individual classes.
 648 
 649 class java_lang_boxing_object: AllStatic {
 650  private:
 651   enum {
 652    hc_value_offset = 0
 653   };
 654   static int value_offset;
 655 
 656   static oop initialize_and_allocate(BasicType type, TRAPS);
 657  public:
 658   // Allocation. Returns a boxed value, or NULL for invalid type.
 659   static oop create(BasicType type, jvalue* value, TRAPS);
 660   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
 661   static BasicType get_value(oop box, jvalue* value);
 662   static BasicType set_value(oop box, jvalue* value);
 663   static BasicType basic_type(oop box);
 664   static bool is_instance(oop box)                 { return basic_type(box) != T_ILLEGAL; }
 665   static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
 666 
 667   static int value_offset_in_bytes() { return value_offset; }
 668 
 669   // Debugging
 670   friend class JavaClasses;
 671 };
 672 
 673 
 674 
 675 // Interface to java.lang.ref.Reference objects
 676 
 677 class java_lang_ref_Reference: AllStatic {
 678  public:
 679   enum {
 680    hc_referent_offset   = 0,
 681    hc_queue_offset      = 1,
 682    hc_next_offset       = 2,
 683    hc_discovered_offset = 3  // Is not last, see SoftRefs.
 684   };
 685   enum {


 886 
 887  public:
 888   static int  value_offset();
 889   static void compute_offsets();
 890 };
 891 
 892 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
 893  private:
 894   static int  _owner_offset;
 895  public:
 896   static void initialize(TRAPS);
 897   static oop  get_owner_threadObj(oop obj);
 898 };
 899 
 900 // Interface to hard-coded offset checking
 901 
 902 class JavaClasses : AllStatic {
 903  private:
 904   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
 905   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
 906   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
 907  public:
 908   static void compute_hard_coded_offsets();
 909   static void compute_offsets();
 910   static void check_offsets() PRODUCT_RETURN;
 911 };