< prev index next >

src/share/vm/oops/typeArrayOop.hpp

Print this page
rev 9803 : 8146401: Clean up oop.hpp: add inline directives and fix header files
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


 143 
 144   // Returns the number of words necessary to hold an array of "len"
 145   // elements each of the given "byte_size".
 146  private:
 147   static int object_size(int lh, int length) {
 148     int instance_header_size = Klass::layout_helper_header_size(lh);
 149     int element_shift = Klass::layout_helper_log2_element_size(lh);
 150     DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
 151     assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
 152 
 153     julong size_in_bytes = (juint)length;
 154     size_in_bytes <<= element_shift;
 155     size_in_bytes += instance_header_size;
 156     julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);
 157     assert(size_in_words <= (julong)max_jint, "no overflow");
 158 
 159     return align_object_size((intptr_t)size_in_words);
 160   }
 161 
 162  public:
 163   int object_size() {
 164     TypeArrayKlass* tk = TypeArrayKlass::cast(klass());
 165     return object_size(tk->layout_helper(), length());
 166   }
 167 };
 168 
 169 #endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


 143 
 144   // Returns the number of words necessary to hold an array of "len"
 145   // elements each of the given "byte_size".
 146  private:
 147   static int object_size(int lh, int length) {
 148     int instance_header_size = Klass::layout_helper_header_size(lh);
 149     int element_shift = Klass::layout_helper_log2_element_size(lh);
 150     DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
 151     assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
 152 
 153     julong size_in_bytes = (juint)length;
 154     size_in_bytes <<= element_shift;
 155     size_in_bytes += instance_header_size;
 156     julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);
 157     assert(size_in_words <= (julong)max_jint, "no overflow");
 158 
 159     return align_object_size((intptr_t)size_in_words);
 160   }
 161 
 162  public:
 163   int object_size();



 164 };
 165 
 166 #endif // SHARE_VM_OOPS_TYPEARRAYOOP_HPP
< prev index next >