Tue, 06 Apr 2010 22:06:57 -0700
Merge
src/share/vm/opto/type.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/ci/ciEnv.cpp Fri Apr 02 15:55:04 2010 -0700 1.2 +++ b/src/share/vm/ci/ciEnv.cpp Tue Apr 06 22:06:57 2010 -0700 1.3 @@ -385,11 +385,6 @@ 1.4 KILL_COMPILE_ON_FATAL_(fail_type)); 1.5 } 1.6 1.7 - if (found_klass != NULL) { 1.8 - // Found it. Build a CI handle. 1.9 - return get_object(found_klass)->as_klass(); 1.10 - } 1.11 - 1.12 // If we fail to find an array klass, look again for its element type. 1.13 // The element type may be available either locally or via constraints. 1.14 // In either case, if we can find the element type in the system dictionary, 1.15 @@ -414,6 +409,11 @@ 1.16 } 1.17 } 1.18 1.19 + if (found_klass != NULL) { 1.20 + // Found it. Build a CI handle. 1.21 + return get_object(found_klass)->as_klass(); 1.22 + } 1.23 + 1.24 if (require_local) return NULL; 1.25 // Not yet loaded into the VM, or not governed by loader constraints. 1.26 // Make a CI representative for it.
2.1 --- a/src/share/vm/classfile/loaderConstraints.cpp Fri Apr 02 15:55:04 2010 -0700 2.2 +++ b/src/share/vm/classfile/loaderConstraints.cpp Tue Apr 06 22:06:57 2010 -0700 2.3 @@ -334,33 +334,6 @@ 2.4 return NULL; 2.5 } 2.6 2.7 - 2.8 -klassOop LoaderConstraintTable::find_constrained_elem_klass(symbolHandle name, 2.9 - symbolHandle elem_name, 2.10 - Handle loader, 2.11 - TRAPS) { 2.12 - LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); 2.13 - if (p != NULL) { 2.14 - assert(p->klass() == NULL, "Expecting null array klass"); 2.15 - 2.16 - // The array name has a constraint, but it will not have a class. Check 2.17 - // each loader for an associated elem 2.18 - for (int i = 0; i < p->num_loaders(); i++) { 2.19 - Handle no_protection_domain; 2.20 - 2.21 - klassOop k = SystemDictionary::find(elem_name, p->loader(i), no_protection_domain, THREAD); 2.22 - if (k != NULL) { 2.23 - // Return the first elem klass found. 2.24 - return k; 2.25 - } 2.26 - } 2.27 - } 2.28 - 2.29 - // No constraints, or else no klass loaded yet. 2.30 - return NULL; 2.31 -} 2.32 - 2.33 - 2.34 void LoaderConstraintTable::ensure_loader_constraint_capacity( 2.35 LoaderConstraintEntry *p, 2.36 int nfree) {
3.1 --- a/src/share/vm/classfile/loaderConstraints.hpp Fri Apr 02 15:55:04 2010 -0700 3.2 +++ b/src/share/vm/classfile/loaderConstraints.hpp Tue Apr 06 22:06:57 2010 -0700 3.3 @@ -66,9 +66,6 @@ 3.4 // bool is_method, TRAPS) 3.5 3.6 klassOop find_constrained_klass(symbolHandle name, Handle loader); 3.7 - klassOop find_constrained_elem_klass(symbolHandle name, symbolHandle elem_name, 3.8 - Handle loader, TRAPS); 3.9 - 3.10 3.11 // Class loader constraints 3.12
4.1 --- a/src/share/vm/classfile/systemDictionary.cpp Fri Apr 02 15:55:04 2010 -0700 4.2 +++ b/src/share/vm/classfile/systemDictionary.cpp Tue Apr 06 22:06:57 2010 -0700 4.3 @@ -2178,9 +2178,8 @@ 4.4 // a loader constraint that would require this loader to return the 4.5 // klass that is already loaded. 4.6 if (FieldType::is_array(class_name())) { 4.7 - // Array classes are hard because their klassOops are not kept in the 4.8 - // constraint table. The array klass may be constrained, but the elem class 4.9 - // may not be. 4.10 + // For array classes, their klassOops are not kept in the 4.11 + // constraint table. The element klassOops are. 4.12 jint dimension; 4.13 symbolOop object_key; 4.14 BasicType t = FieldType::get_array_info(class_name(), &dimension, 4.15 @@ -2190,8 +2189,9 @@ 4.16 } else { 4.17 symbolHandle elem_name(THREAD, object_key); 4.18 MutexLocker mu(SystemDictionary_lock, THREAD); 4.19 - klass = constraints()->find_constrained_elem_klass(class_name, elem_name, class_loader, THREAD); 4.20 + klass = constraints()->find_constrained_klass(elem_name, class_loader); 4.21 } 4.22 + // If element class already loaded, allocate array klass 4.23 if (klass != NULL) { 4.24 klass = Klass::cast(klass)->array_klass_or_null(dimension); 4.25 } 4.26 @@ -2209,22 +2209,38 @@ 4.27 Handle class_loader1, 4.28 Handle class_loader2, 4.29 Thread* THREAD) { 4.30 - unsigned int d_hash1 = dictionary()->compute_hash(class_name, class_loader1); 4.31 + symbolHandle constraint_name; 4.32 + if (!FieldType::is_array(class_name())) { 4.33 + constraint_name = class_name; 4.34 + } else { 4.35 + // For array classes, their klassOops are not kept in the 4.36 + // constraint table. The element classes are. 4.37 + jint dimension; 4.38 + symbolOop object_key; 4.39 + BasicType t = FieldType::get_array_info(class_name(), &dimension, 4.40 + &object_key, CHECK_(false)); 4.41 + // primitive types always pass 4.42 + if (t != T_OBJECT) { 4.43 + return true; 4.44 + } else { 4.45 + constraint_name = symbolHandle(THREAD, object_key); 4.46 + } 4.47 + } 4.48 + unsigned int d_hash1 = dictionary()->compute_hash(constraint_name, class_loader1); 4.49 int d_index1 = dictionary()->hash_to_index(d_hash1); 4.50 4.51 - unsigned int d_hash2 = dictionary()->compute_hash(class_name, class_loader2); 4.52 + unsigned int d_hash2 = dictionary()->compute_hash(constraint_name, class_loader2); 4.53 int d_index2 = dictionary()->hash_to_index(d_hash2); 4.54 + { 4.55 + MutexLocker mu_s(SystemDictionary_lock, THREAD); 4.56 4.57 - { 4.58 - MutexLocker mu_s(SystemDictionary_lock, THREAD); 4.59 + // Better never do a GC while we're holding these oops 4.60 + No_Safepoint_Verifier nosafepoint; 4.61 4.62 - // Better never do a GC while we're holding these oops 4.63 - No_Safepoint_Verifier nosafepoint; 4.64 - 4.65 - klassOop klass1 = find_class(d_index1, d_hash1, class_name, class_loader1); 4.66 - klassOop klass2 = find_class(d_index2, d_hash2, class_name, class_loader2); 4.67 - return constraints()->add_entry(class_name, klass1, class_loader1, 4.68 - klass2, class_loader2); 4.69 + klassOop klass1 = find_class(d_index1, d_hash1, constraint_name, class_loader1); 4.70 + klassOop klass2 = find_class(d_index2, d_hash2, constraint_name, class_loader2); 4.71 + return constraints()->add_entry(constraint_name, klass1, class_loader1, 4.72 + klass2, class_loader2); 4.73 } 4.74 } 4.75 4.76 @@ -2301,6 +2317,7 @@ 4.77 // Returns the name of the type that failed a loader constraint check, or 4.78 // NULL if no constraint failed. The returned C string needs cleaning up 4.79 // with a ResourceMark in the caller. No exception except OOME is thrown. 4.80 +// Arrays are not added to the loader constraint table, their elements are. 4.81 char* SystemDictionary::check_signature_loaders(symbolHandle signature, 4.82 Handle loader1, Handle loader2, 4.83 bool is_method, TRAPS) {
5.1 --- a/src/share/vm/oops/typeArrayKlass.cpp Fri Apr 02 15:55:04 2010 -0700 5.2 +++ b/src/share/vm/oops/typeArrayKlass.cpp Tue Apr 06 22:06:57 2010 -0700 5.3 @@ -123,16 +123,16 @@ 5.4 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { 5.5 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); 5.6 } 5.7 + // Check zero copy 5.8 + if (length == 0) 5.9 + return; 5.10 5.11 // This is an attempt to make the copy_array fast. 5.12 - // NB: memmove takes care of overlapping memory segments. 5.13 - // Potential problem: memmove is not guaranteed to be word atomic 5.14 - // Revisit in Merlin 5.15 int l2es = log2_element_size(); 5.16 int ihs = array_header_in_bytes() / wordSize; 5.17 - char* src = (char*) ((oop*)s + ihs) + (src_pos << l2es); 5.18 - char* dst = (char*) ((oop*)d + ihs) + (dst_pos << l2es); 5.19 - memmove(dst, src, length << l2es); 5.20 + char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es); 5.21 + char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es); 5.22 + Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es); 5.23 } 5.24 5.25
6.1 --- a/src/share/vm/opto/cfgnode.cpp Fri Apr 02 15:55:04 2010 -0700 6.2 +++ b/src/share/vm/opto/cfgnode.cpp Tue Apr 06 22:06:57 2010 -0700 6.3 @@ -956,6 +956,7 @@ 6.4 } 6.5 if( jtkp && ttkp ) { 6.6 if( jtkp->is_loaded() && jtkp->klass()->is_interface() && 6.7 + !jtkp->klass_is_exact() && // Keep exact interface klass (6894807) 6.8 ttkp->is_loaded() && !ttkp->klass()->is_interface() ) { 6.9 assert(ft == ttkp->cast_to_ptr_type(jtkp->ptr()) || 6.10 ft->isa_narrowoop() && ft->make_ptr() == ttkp->cast_to_ptr_type(jtkp->ptr()), "");
7.1 --- a/src/share/vm/opto/type.cpp Fri Apr 02 15:55:04 2010 -0700 7.2 +++ b/src/share/vm/opto/type.cpp Tue Apr 06 22:06:57 2010 -0700 7.3 @@ -2545,12 +2545,15 @@ 7.4 ftip->is_loaded() && ftip->klass()->is_interface() && 7.5 ktip->is_loaded() && !ktip->klass()->is_interface()) { 7.6 // Happens in a CTW of rt.jar, 320-341, no extra flags 7.7 + assert(!ftip->klass_is_exact(), "interface could not be exact"); 7.8 return ktip->cast_to_ptr_type(ftip->ptr()); 7.9 } 7.10 + // Interface klass type could be exact in opposite to interface type, 7.11 + // return it here instead of incorrect Constant ptr J/L/Object (6894807). 7.12 if (ftkp != NULL && ktkp != NULL && 7.13 ftkp->is_loaded() && ftkp->klass()->is_interface() && 7.14 + !ftkp->klass_is_exact() && // Keep exact interface klass 7.15 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { 7.16 - // Happens in a CTW of rt.jar, 320-341, no extra flags 7.17 return ktkp->cast_to_ptr_type(ftkp->ptr()); 7.18 } 7.19
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/compiler/6892265/Test.java Tue Apr 06 22:06:57 2010 -0700 8.3 @@ -0,0 +1,65 @@ 8.4 +/* 8.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 8.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 8.24 + * have any questions. 8.25 + * 8.26 + */ 8.27 + 8.28 +/** 8.29 + * @test 8.30 + * @bug 6892265 8.31 + * @summary System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes 8.32 + * 8.33 + * @run main/othervm Test 8.34 + */ 8.35 + 8.36 +public class Test { 8.37 + static final int NCOPY = 1; 8.38 + static final int OVERFLOW = 1; 8.39 + static int[] src2 = new int[NCOPY]; 8.40 + static int[] dst2; 8.41 + 8.42 + static void test() { 8.43 + int N; 8.44 + int SIZE; 8.45 + 8.46 + N = Integer.MAX_VALUE/4 + OVERFLOW; 8.47 + System.arraycopy(src2, 0, dst2, N, NCOPY); 8.48 + System.arraycopy(dst2, N, src2, 0, NCOPY); 8.49 + } 8.50 + 8.51 + public static void main(String[] args) { 8.52 + try { 8.53 + dst2 = new int[NCOPY + Integer.MAX_VALUE/4 + OVERFLOW]; 8.54 + } catch (OutOfMemoryError e) { 8.55 + System.exit(95); // Not enough memory 8.56 + } 8.57 + System.out.println("warmup"); 8.58 + for (int i=0; i <11000; i++) { 8.59 + test(); 8.60 + } 8.61 + System.out.println("start"); 8.62 + for (int i=0; i <1000; i++) { 8.63 + test(); 8.64 + } 8.65 + System.out.println("finish"); 8.66 + } 8.67 + 8.68 +}