annotate src/share/vm/oops/arrayOop.cpp @ 2984:3c648b9ad052

7121373: Clean up CollectedHeap::is_in Summary: Fixed G1CollectedHeap::is_in, added tests, cleaned up comments and made Space::is_in pure virtual. Reviewed-by: brutisso, tonyp, jcoomes
author stefank
date Wed, 14 Dec 2011 12:15:26 +0100
parents 6fd81579526f
children 0382d2b469b2
rev   line source
duke@0 1 /*
trims@2273 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #include "precompiled.hpp"
brutisso@2908 26
brutisso@2908 27 /////////////// Unit tests ///////////////
brutisso@2908 28
brutisso@2908 29 #ifndef PRODUCT
brutisso@2908 30
stefank@1879 31 #include "oops/arrayOop.hpp"
brutisso@2908 32 #include "utilities/globalDefinitions.hpp"
duke@0 33
brutisso@2908 34 bool arrayOopDesc::check_max_length_overflow(BasicType type) {
brutisso@2908 35 julong length = max_array_length(type);
brutisso@2908 36 julong bytes_per_element = type2aelembytes(type);
brutisso@2908 37 julong bytes = length * bytes_per_element + header_size_in_bytes();
brutisso@2908 38 return (julong)(size_t)bytes == bytes;
brutisso@2908 39 }
brutisso@2908 40
stefank@2984 41 void arrayOopDesc::test_max_array_length() {
brutisso@2908 42 assert(check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array");
brutisso@2908 43 assert(check_max_length_overflow(T_CHAR), "size_t overflow for char array");
brutisso@2908 44 assert(check_max_length_overflow(T_FLOAT), "size_t overflow for float array");
brutisso@2908 45 assert(check_max_length_overflow(T_DOUBLE), "size_t overflow for double array");
brutisso@2908 46 assert(check_max_length_overflow(T_BYTE), "size_t overflow for byte array");
brutisso@2908 47 assert(check_max_length_overflow(T_SHORT), "size_t overflow for short array");
brutisso@2908 48 assert(check_max_length_overflow(T_INT), "size_t overflow for int array");
brutisso@2908 49 assert(check_max_length_overflow(T_LONG), "size_t overflow for long array");
brutisso@2908 50 assert(check_max_length_overflow(T_OBJECT), "size_t overflow for object array");
brutisso@2908 51 assert(check_max_length_overflow(T_ARRAY), "size_t overflow for array array");
brutisso@2908 52 assert(check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array");
brutisso@2908 53
brutisso@2908 54 // T_VOID and T_ADDRESS are not supported by max_array_length()
brutisso@2908 55 }
brutisso@2908 56
brutisso@2908 57
brutisso@2908 58 #endif //PRODUCT