hotspot/src/share/vm/classfile/javaClasses.inline.hpp
changeset 35498 392b50de06c6
parent 34280 72bfaaffee36
child 36508 5f9eee6b383b
--- a/hotspot/src/share/vm/classfile/javaClasses.inline.hpp	Tue Jan 12 21:17:13 2016 +0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.inline.hpp	Mon Jan 04 15:41:05 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,105 @@
 #include "oops/oop.inline.hpp"
 #include "oops/oopsHierarchy.hpp"
 
+void java_lang_String::set_coder(oop string, jbyte coder) {
+  assert(initialized, "Must be initialized");
+  if (coder_offset > 0) {
+    string->byte_field_put(coder_offset, coder);
+  }
+}
+
+void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
+  assert(initialized, "Must be initialized");
+  string->obj_field_put_raw(value_offset, buffer);
+}
+void java_lang_String::set_value(oop string, typeArrayOop buffer) {
+  assert(initialized && (value_offset > 0), "Must be initialized");
+  string->obj_field_put(value_offset, (oop)buffer);
+}
+void java_lang_String::set_hash(oop string, unsigned int hash) {
+  assert(initialized && (hash_offset > 0), "Must be initialized");
+  string->int_field_put(hash_offset, hash);
+}
+
+// Accessors
+typeArrayOop java_lang_String::value(oop java_string) {
+  assert(initialized && (value_offset > 0), "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  return (typeArrayOop) java_string->obj_field(value_offset);
+}
+unsigned int java_lang_String::hash(oop java_string) {
+  assert(initialized && (hash_offset > 0), "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  return java_string->int_field(hash_offset);
+}
+bool java_lang_String::is_latin1(oop java_string) {
+  assert(initialized, "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  if (coder_offset > 0) {
+    jbyte coder = java_string->byte_field(coder_offset);
+    assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
+    return coder == CODER_LATIN1;
+  } else {
+    return false;
+  }
+}
+int java_lang_String::length(oop java_string) {
+  assert(initialized, "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  typeArrayOop value_array = ((typeArrayOop)java_string->obj_field(value_offset));
+  if (value_array == NULL) {
+    return 0;
+  }
+  int arr_length = value_array->length();
+  if (!is_latin1(java_string)) {
+    assert((arr_length & 1) == 0, "should be even for UTF16 string");
+    arr_length >>= 1; // convert number of bytes to number of elements
+  }
+  return arr_length;
+}
+
+bool java_lang_String::is_instance_inlined(oop obj) {
+  return obj != NULL && obj->klass() == SystemDictionary::String_klass();
+}
+
+// Accessors
+oop java_lang_ref_Reference::referent(oop ref) {
+  return ref->obj_field(referent_offset);
+}
+void java_lang_ref_Reference::set_referent(oop ref, oop value) {
+  ref->obj_field_put(referent_offset, value);
+}
+void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(referent_offset, value);
+}
+HeapWord* java_lang_ref_Reference::referent_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(referent_offset);
+}
+oop java_lang_ref_Reference::next(oop ref) {
+  return ref->obj_field(next_offset);
+}
+void java_lang_ref_Reference::set_next(oop ref, oop value) {
+  ref->obj_field_put(next_offset, value);
+}
+void java_lang_ref_Reference::set_next_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(next_offset, value);
+}
+HeapWord* java_lang_ref_Reference::next_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(next_offset);
+}
+oop java_lang_ref_Reference::discovered(oop ref) {
+  return ref->obj_field(discovered_offset);
+}
+void java_lang_ref_Reference::set_discovered(oop ref, oop value) {
+  ref->obj_field_put(discovered_offset, value);
+}
+void java_lang_ref_Reference::set_discovered_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(discovered_offset, value);
+}
+HeapWord* java_lang_ref_Reference::discovered_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(discovered_offset);
+}
+
 inline void java_lang_invoke_CallSite::set_target_volatile(oop site, oop target) {
   site->obj_field_put_volatile(_target_offset, target);
 }
@@ -41,10 +140,6 @@
   site->obj_field_put(_target_offset, target);
 }
 
-inline bool java_lang_String::is_instance_inlined(oop obj) {
-  return obj != NULL && obj->klass() == SystemDictionary::String_klass();
-}
-
 inline bool java_lang_invoke_CallSite::is_instance(oop obj) {
   return obj != NULL && is_subclass(obj->klass());
 }
@@ -73,6 +168,9 @@
   return obj != NULL && is_subclass(obj->klass());
 }
 
+
+
+
 inline int Backtrace::merge_bci_and_version(int bci, int version) {
   // only store u2 for version, checking for overflow.
   if (version > USHRT_MAX || version < 0) version = USHRT_MAX;