Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/typeArrayKlass.cpp @ 1334:b5d78a3b8843
6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
Summary: Use size_t type cast to widen int values in typeArrayKlass::copy_array().
Reviewed-by: never, jcoomes
author | kvn |
---|---|
date | Thu, 03 Dec 2009 14:20:22 -0800 |
parents | 1413494da700 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1053:455105fc81d9 | 1334:b5d78a3b8843 |
---|---|
121 // Check if the ranges are valid | 121 // Check if the ranges are valid |
122 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) | 122 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) |
123 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { | 123 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { |
124 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); | 124 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); |
125 } | 125 } |
126 // Check zero copy | |
127 if (length == 0) | |
128 return; | |
126 | 129 |
127 // This is an attempt to make the copy_array fast. | 130 // This is an attempt to make the copy_array fast. |
128 // NB: memmove takes care of overlapping memory segments. | |
129 // Potential problem: memmove is not guaranteed to be word atomic | |
130 // Revisit in Merlin | |
131 int l2es = log2_element_size(); | 131 int l2es = log2_element_size(); |
132 int ihs = array_header_in_bytes() / wordSize; | 132 int ihs = array_header_in_bytes() / wordSize; |
133 char* src = (char*) ((oop*)s + ihs) + (src_pos << l2es); | 133 char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es); |
134 char* dst = (char*) ((oop*)d + ihs) + (dst_pos << l2es); | 134 char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es); |
135 memmove(dst, src, length << l2es); | 135 Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es); |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 // create a klass of array holding typeArrays | 139 // create a klass of array holding typeArrays |
140 klassOop typeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { | 140 klassOop typeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { |