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_OOPS_VALUEARRAYOOP_INLINE_HPP 26 #define SHARE_VM_OOPS_VALUEARRAYOOP_INLINE_HPP 27 28 #include "oops/access.inline.hpp" 29 #include "oops/arrayOop.inline.hpp" 30 #include "oops/valueArrayOop.hpp" 31 #include "oops/oop.inline.hpp" 32 #include "runtime/globals.hpp" 33 34 inline void* valueArrayOopDesc::base() const { return arrayOopDesc::base(T_VALUETYPE); } 35 36 inline void* valueArrayOopDesc::value_at_addr(int index, jint lh) const { 37 assert(is_within_bounds(index), "index out of bounds"); 38 39 address addr = (address) base(); 40 addr += (index << Klass::layout_helper_log2_element_size(lh)); 41 return (void*) addr; 42 } 43 44 inline int valueArrayOopDesc::object_size() const { 45 return object_size(klass()->layout_helper(), length()); 46 } 47 48 49 50 #endif // SHARE_VM_OOPS_VALUEARRAYOOP_INLINE_HPP | 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_OOPS_VALUEARRAYOOP_INLINE_HPP 26 #define SHARE_VM_OOPS_VALUEARRAYOOP_INLINE_HPP 27 28 #include "oops/access.inline.hpp" 29 #include "oops/arrayOop.inline.hpp" 30 #include "oops/valueArrayOop.hpp" 31 #include "oops/valueKlass.inline.hpp" 32 #include "oops/oop.inline.hpp" 33 #include "runtime/globals.hpp" 34 35 inline void* valueArrayOopDesc::base() const { return arrayOopDesc::base(T_VALUETYPE); } 36 37 inline void* valueArrayOopDesc::value_at_addr(int index, jint lh) const { 38 assert(is_within_bounds(index), "index out of bounds"); 39 40 address addr = (address) base(); 41 addr += (index << Klass::layout_helper_log2_element_size(lh)); 42 return (void*) addr; 43 } 44 45 inline int valueArrayOopDesc::object_size() const { 46 return object_size(klass()->layout_helper(), length()); 47 } 48 49 inline oop valueArrayOopDesc::value_copy_from_index(valueArrayHandle vah, int index, TRAPS) { 50 ValueArrayKlass* vaklass = ValueArrayKlass::cast(vah->klass()); 51 ValueKlass* vklass = vaklass->element_klass(); 52 if (vklass->is_empty_value()) { 53 return vklass->default_value(); 54 } else { 55 oop buf = vklass->allocate_instance(CHECK_NULL); 56 vklass->value_copy_payload_to_new_oop(vah->value_at_addr(index, vaklass->layout_helper()) ,buf); 57 return buf; 58 } 59 } 60 61 inline void valueArrayOopDesc::value_copy_from_index(int index, oop dst) const { 62 ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass()); 63 ValueKlass* vklass = vaklass->element_klass(); 64 if (vklass->is_empty_value()) { 65 return; // Assumes dst was a new and clean buffer (OptoRuntime::load_unknown_value()) 66 } else { 67 void* src = value_at_addr(index, vaklass->layout_helper()); 68 return vklass->value_copy_payload_to_new_oop(src ,dst); 69 } 70 } 71 72 inline void valueArrayOopDesc::value_copy_to_index(oop src, int index) const { 73 ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass()); 74 ValueKlass* vklass = vaklass->element_klass(); 75 if (vklass->is_empty_value()) { 76 return; 77 } 78 void* dst = value_at_addr(index, vaklass->layout_helper()); 79 vklass->value_copy_oop_to_payload(src, dst); 80 } 81 82 83 84 #endif // SHARE_VM_OOPS_VALUEARRAYOOP_INLINE_HPP |