< prev index next >

src/hotspot/share/classfile/javaClasses.inline.hpp

Print this page
rev 48017 : [mq]: Access_strings


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
  26 #define SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
  27 
  28 #include "classfile/javaClasses.hpp"

  29 #include "oops/oop.inline.hpp"
  30 #include "oops/oopsHierarchy.hpp"
  31 
  32 void java_lang_String::set_coder(oop string, jbyte coder) {
  33   assert(initialized && (coder_offset > 0), "Must be initialized");
  34   string->byte_field_put(coder_offset, coder);
  35 }
  36 
  37 void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
  38   assert(initialized, "Must be initialized");
  39   string->obj_field_put_raw(value_offset, buffer);
  40 }
  41 void java_lang_String::set_value(oop string, typeArrayOop buffer) {
  42   assert(initialized && (value_offset > 0), "Must be initialized");
  43   string->obj_field_put(value_offset, (oop)buffer);
  44 }
  45 void java_lang_String::set_hash(oop string, unsigned int hash) {
  46   assert(initialized && (hash_offset > 0), "Must be initialized");
  47   string->int_field_put(hash_offset, hash);
  48 }
  49 
  50 // Accessors
  51 typeArrayOop java_lang_String::value(oop java_string) {
  52   assert(initialized && (value_offset > 0), "Must be initialized");
  53   assert(is_instance(java_string), "must be java_string");
  54   return (typeArrayOop) java_string->obj_field(value_offset);
  55 }






  56 unsigned int java_lang_String::hash(oop java_string) {
  57   assert(initialized && (hash_offset > 0), "Must be initialized");
  58   assert(is_instance(java_string), "must be java_string");
  59   return java_string->int_field(hash_offset);
  60 }
  61 bool java_lang_String::is_latin1(oop java_string) {
  62   assert(initialized && (coder_offset > 0), "Must be initialized");
  63   assert(is_instance(java_string), "must be java_string");
  64   jbyte coder = java_string->byte_field(coder_offset);
  65   assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
  66   return coder == CODER_LATIN1;
  67 }
  68 int java_lang_String::length(oop java_string) {

  69   assert(initialized, "Must be initialized");
  70   assert(is_instance(java_string), "must be java_string");
  71   typeArrayOop value_array = ((typeArrayOop)java_string->obj_field(value_offset));
  72   if (value_array == NULL) {
  73     return 0;
  74   }
  75   int arr_length = value_array->length();
  76   if (!is_latin1(java_string)) {
  77     assert((arr_length & 1) == 0, "should be even for UTF16 string");
  78     arr_length >>= 1; // convert number of bytes to number of elements
  79   }
  80   return arr_length;
  81 }
  82 
  83 bool java_lang_String::is_instance_inlined(oop obj) {
  84   return obj != NULL && obj->klass() == SystemDictionary::String_klass();
  85 }
  86 
  87 // Accessors
  88 oop java_lang_ref_Reference::referent(oop ref) {
  89   return ref->obj_field(referent_offset);
  90 }
  91 void java_lang_ref_Reference::set_referent(oop ref, oop value) {
  92   ref->obj_field_put(referent_offset, value);
  93 }
  94 void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
  95   ref->obj_field_put_raw(referent_offset, value);




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
  26 #define SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "oops/access.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "oops/oopsHierarchy.hpp"
  32 
  33 void java_lang_String::set_coder(oop string, jbyte coder) {
  34   assert(initialized && (coder_offset > 0), "Must be initialized");
  35   string->byte_field_put(coder_offset, coder);
  36 }
  37 
  38 void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
  39   assert(initialized, "Must be initialized");
  40   string->obj_field_put_raw(value_offset, buffer);
  41 }
  42 void java_lang_String::set_value(oop string, typeArrayOop buffer) {
  43   assert(initialized && (value_offset > 0), "Must be initialized");
  44   string->obj_field_put(value_offset, (oop)buffer);
  45 }
  46 void java_lang_String::set_hash(oop string, unsigned int hash) {
  47   assert(initialized && (hash_offset > 0), "Must be initialized");
  48   string->int_field_put(hash_offset, hash);
  49 }
  50 
  51 // Accessors
  52 typeArrayOop java_lang_String::value(oop java_string) {
  53   assert(initialized && (value_offset > 0), "Must be initialized");
  54   assert(is_instance(java_string), "must be java_string");
  55   return (typeArrayOop) java_string->obj_field(value_offset);
  56 }
  57 typeArrayOop java_lang_String::value_no_keepalive(oop java_string) {
  58   assert(initialized && (value_offset > 0), "Must be initialized");
  59   assert(is_instance(java_string), "must be java_string");
  60   oop value = HeapAccess<AS_NO_KEEPALIVE>::oop_load_at(java_string, value_offset);
  61   return (typeArrayOop)value;
  62 }
  63 unsigned int java_lang_String::hash(oop java_string) {
  64   assert(initialized && (hash_offset > 0), "Must be initialized");
  65   assert(is_instance(java_string), "must be java_string");
  66   return java_string->int_field(hash_offset);
  67 }
  68 bool java_lang_String::is_latin1(oop java_string) {
  69   assert(initialized && (coder_offset > 0), "Must be initialized");
  70   assert(is_instance(java_string), "must be java_string");
  71   jbyte coder = java_string->byte_field(coder_offset);
  72   assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
  73   return coder == CODER_LATIN1;
  74 }
  75 int java_lang_String::length(oop java_string) {
  76   typeArrayOop value = java_lang_String::value_no_keepalive(java_string);
  77   assert(initialized, "Must be initialized");
  78   assert(is_instance(java_string), "must be java_string");
  79   if (value == NULL) {

  80     return 0;
  81   }
  82   int arr_length = value->length();
  83   if (!is_latin1(java_string)) {
  84     assert((arr_length & 1) == 0, "should be even for UTF16 string");
  85     arr_length >>= 1; // convert number of bytes to number of elements
  86   }
  87   return arr_length;
  88 }
  89 
  90 bool java_lang_String::is_instance_inlined(oop obj) {
  91   return obj != NULL && obj->klass() == SystemDictionary::String_klass();
  92 }
  93 
  94 // Accessors
  95 oop java_lang_ref_Reference::referent(oop ref) {
  96   return ref->obj_field(referent_offset);
  97 }
  98 void java_lang_ref_Reference::set_referent(oop ref, oop value) {
  99   ref->obj_field_put(referent_offset, value);
 100 }
 101 void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
 102   ref->obj_field_put_raw(referent_offset, value);


< prev index next >