Mercurial > hg > truffle
comparison src/share/vm/oops/arrayOop.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | 6fd81579526f |
children | 3c648b9ad052 |
comparison
equal
deleted
inserted
replaced
3737:9dc19b7d89a3 | 4137:04b9a2566eec |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 | |
27 /////////////// Unit tests /////////////// | |
28 | |
29 #ifndef PRODUCT | |
30 | |
26 #include "oops/arrayOop.hpp" | 31 #include "oops/arrayOop.hpp" |
27 #include "oops/objArrayOop.hpp" | 32 #include "utilities/globalDefinitions.hpp" |
28 #include "oops/oop.inline.hpp" | |
29 #include "oops/symbol.hpp" | |
30 | 33 |
31 // <<this page is intentionally left blank>> | 34 bool arrayOopDesc::check_max_length_overflow(BasicType type) { |
35 julong length = max_array_length(type); | |
36 julong bytes_per_element = type2aelembytes(type); | |
37 julong bytes = length * bytes_per_element + header_size_in_bytes(); | |
38 return (julong)(size_t)bytes == bytes; | |
39 } | |
40 | |
41 bool arrayOopDesc::test_max_array_length() { | |
42 tty->print_cr("test_max_array_length"); | |
43 | |
44 assert(check_max_length_overflow(T_BOOLEAN), "size_t overflow for boolean array"); | |
45 assert(check_max_length_overflow(T_CHAR), "size_t overflow for char array"); | |
46 assert(check_max_length_overflow(T_FLOAT), "size_t overflow for float array"); | |
47 assert(check_max_length_overflow(T_DOUBLE), "size_t overflow for double array"); | |
48 assert(check_max_length_overflow(T_BYTE), "size_t overflow for byte array"); | |
49 assert(check_max_length_overflow(T_SHORT), "size_t overflow for short array"); | |
50 assert(check_max_length_overflow(T_INT), "size_t overflow for int array"); | |
51 assert(check_max_length_overflow(T_LONG), "size_t overflow for long array"); | |
52 assert(check_max_length_overflow(T_OBJECT), "size_t overflow for object array"); | |
53 assert(check_max_length_overflow(T_ARRAY), "size_t overflow for array array"); | |
54 assert(check_max_length_overflow(T_NARROWOOP), "size_t overflow for narrowOop array"); | |
55 | |
56 // T_VOID and T_ADDRESS are not supported by max_array_length() | |
57 | |
58 return true; | |
59 } | |
60 | |
61 | |
62 #endif //PRODUCT |