31 32 // A typeArrayOop is an array containing basic types (non oop elements). 33 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs} 34 #include <limits.h> 35 36 class typeArrayOopDesc : public arrayOopDesc { 37 protected: 38 jchar* char_base() const { return (jchar*) base(T_CHAR); } 39 jboolean* bool_base() const { return (jboolean*)base(T_BOOLEAN); } 40 jbyte* byte_base() const { return (jbyte*) base(T_BYTE); } 41 jint* int_base() const { return (jint*) base(T_INT); } 42 jlong* long_base() const { return (jlong*) base(T_LONG); } 43 jshort* short_base() const { return (jshort*) base(T_SHORT); } 44 jfloat* float_base() const { return (jfloat*) base(T_FLOAT); } 45 jdouble* double_base() const { return (jdouble*) base(T_DOUBLE); } 46 47 friend class TypeArrayKlass; 48 49 public: 50 jbyte* byte_at_addr(int which) const { 51 assert(is_within_bounds(which), "index out of bounds"); 52 return &byte_base()[which]; 53 } 54 55 jboolean* bool_at_addr(int which) const { 56 assert(is_within_bounds(which), "index out of bounds"); 57 return &bool_base()[which]; 58 } 59 60 jchar* char_at_addr(int which) const { 61 assert(is_within_bounds(which), "index out of bounds"); 62 return &char_base()[which]; 63 } 64 65 jint* int_at_addr(int which) const { 66 assert(is_within_bounds(which), "index out of bounds"); 67 return &int_base()[which]; 68 } 69 70 jshort* short_at_addr(int which) const { 71 assert(is_within_bounds(which), "index out of bounds"); 72 return &short_base()[which]; 73 } 74 75 jushort* ushort_at_addr(int which) const { // for field descriptor arrays 76 assert(is_within_bounds(which), "index out of bounds"); 77 return (jushort*) &short_base()[which]; 78 } 79 80 jlong* long_at_addr(int which) const { 81 assert(is_within_bounds(which), "index out of bounds"); 82 return &long_base()[which]; 83 } 84 85 jfloat* float_at_addr(int which) const { 86 assert(is_within_bounds(which), "index out of bounds"); 87 return &float_base()[which]; 88 } 89 90 jdouble* double_at_addr(int which) const { 91 assert(is_within_bounds(which), "index out of bounds"); 92 return &double_base()[which]; 93 } 94 95 jbyte byte_at(int which) const { return *byte_at_addr(which); } 96 void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; } 97 98 jboolean bool_at(int which) const { return *bool_at_addr(which); } 99 void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = contents; } 100 101 jchar char_at(int which) const { return *char_at_addr(which); } 102 void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; } 103 104 jint int_at(int which) const { return *int_at_addr(which); } 105 void int_at_put(int which, jint contents) { *int_at_addr(which) = contents; } 106 107 jshort short_at(int which) const { return *short_at_addr(which); } 108 void short_at_put(int which, jshort contents) { *short_at_addr(which) = contents; } 109 110 jushort ushort_at(int which) const { return *ushort_at_addr(which); } 111 void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; } | 31 32 // A typeArrayOop is an array containing basic types (non oop elements). 33 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs} 34 #include <limits.h> 35 36 class typeArrayOopDesc : public arrayOopDesc { 37 protected: 38 jchar* char_base() const { return (jchar*) base(T_CHAR); } 39 jboolean* bool_base() const { return (jboolean*)base(T_BOOLEAN); } 40 jbyte* byte_base() const { return (jbyte*) base(T_BYTE); } 41 jint* int_base() const { return (jint*) base(T_INT); } 42 jlong* long_base() const { return (jlong*) base(T_LONG); } 43 jshort* short_base() const { return (jshort*) base(T_SHORT); } 44 jfloat* float_base() const { return (jfloat*) base(T_FLOAT); } 45 jdouble* double_base() const { return (jdouble*) base(T_DOUBLE); } 46 47 friend class TypeArrayKlass; 48 49 public: 50 jbyte* byte_at_addr(int which) const { 51 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 52 return &byte_base()[which]; 53 } 54 55 jboolean* bool_at_addr(int which) const { 56 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 57 return &bool_base()[which]; 58 } 59 60 jchar* char_at_addr(int which) const { 61 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 62 return &char_base()[which]; 63 } 64 65 jint* int_at_addr(int which) const { 66 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 67 return &int_base()[which]; 68 } 69 70 jshort* short_at_addr(int which) const { 71 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 72 return &short_base()[which]; 73 } 74 75 jushort* ushort_at_addr(int which) const { // for field descriptor arrays 76 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 77 return (jushort*) &short_base()[which]; 78 } 79 80 jlong* long_at_addr(int which) const { 81 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 82 return &long_base()[which]; 83 } 84 85 jfloat* float_at_addr(int which) const { 86 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 87 return &float_base()[which]; 88 } 89 90 jdouble* double_at_addr(int which) const { 91 assert(is_within_bounds(which), "index %d out of bounds %d", which, length()); 92 return &double_base()[which]; 93 } 94 95 jbyte byte_at(int which) const { return *byte_at_addr(which); } 96 void byte_at_put(int which, jbyte contents) { *byte_at_addr(which) = contents; } 97 98 jboolean bool_at(int which) const { return *bool_at_addr(which); } 99 void bool_at_put(int which, jboolean contents) { *bool_at_addr(which) = contents; } 100 101 jchar char_at(int which) const { return *char_at_addr(which); } 102 void char_at_put(int which, jchar contents) { *char_at_addr(which) = contents; } 103 104 jint int_at(int which) const { return *int_at_addr(which); } 105 void int_at_put(int which, jint contents) { *int_at_addr(which) = contents; } 106 107 jshort short_at(int which) const { return *short_at_addr(which); } 108 void short_at_put(int which, jshort contents) { *short_at_addr(which) = contents; } 109 110 jushort ushort_at(int which) const { return *ushort_at_addr(which); } 111 void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; } |