Mercurial > hg > truffle
comparison src/share/vm/oops/arrayOop.hpp @ 481:7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
Reviewed-by: apetrusenko, ysr
author | jcoomes |
---|---|
date | Thu, 11 Dec 2008 12:05:08 -0800 |
parents | d1605aabd0a1 |
children | 0fbdb4381b99 |
comparison
equal
deleted
inserted
replaced
480:d249b360e026 | 481:7d7a7c599c17 |
---|---|
94 return (int)(Universe::element_type_should_be_aligned(type) | 94 return (int)(Universe::element_type_should_be_aligned(type) |
95 ? align_object_size(typesize_in_bytes/HeapWordSize) | 95 ? align_object_size(typesize_in_bytes/HeapWordSize) |
96 : typesize_in_bytes/HeapWordSize); | 96 : typesize_in_bytes/HeapWordSize); |
97 } | 97 } |
98 | 98 |
99 // This method returns the maximum length that can passed into | 99 // Return the maximum length of an array of BasicType. The length can passed |
100 // typeArrayOop::object_size(scale, length, header_size) without causing an | 100 // to typeArrayOop::object_size(scale, length, header_size) without causing an |
101 // overflow. We substract an extra 2*wordSize to guard against double word | 101 // overflow. |
102 // alignments. It gets the scale from the type2aelembytes array. | |
103 static int32_t max_array_length(BasicType type) { | 102 static int32_t max_array_length(BasicType type) { |
104 assert(type >= 0 && type < T_CONFLICT, "wrong type"); | 103 assert(type >= 0 && type < T_CONFLICT, "wrong type"); |
105 assert(type2aelembytes(type) != 0, "wrong type"); | 104 assert(type2aelembytes(type) != 0, "wrong type"); |
106 // We use max_jint, since object_size is internally represented by an 'int' | 105 const int bytes_per_element = type2aelembytes(type); |
107 // This gives us an upper bound of max_jint words for the size of the oop. | 106 if (bytes_per_element < HeapWordSize) { |
108 int32_t max_words = (max_jint - header_size(type) - 2); | 107 return max_jint; |
109 int elembytes = type2aelembytes(type); | 108 } |
110 jlong len = ((jlong)max_words * HeapWordSize) / elembytes; | 109 |
111 return (len > max_jint) ? max_jint : (int32_t)len; | 110 const int32_t max_words = align_size_down(max_jint, MinObjAlignment); |
111 const int32_t max_element_words = max_words - header_size(type); | |
112 const int32_t words_per_element = bytes_per_element >> LogHeapWordSize; | |
113 return max_element_words / words_per_element; | |
112 } | 114 } |
113 | |
114 }; | 115 }; |