Fri, 31 May 2013 09:55:35 +0200
Merge
1.1 --- a/.hgtags Mon May 27 12:58:42 2013 +0200 1.2 +++ b/.hgtags Fri May 31 09:55:35 2013 +0200 1.3 @@ -343,3 +343,5 @@ 1.4 69494caf57908ba2c8efa9eaaa472b4d1875588a hs25-b32 1.5 1ae0472ff3a0117b5b019d380ad59fface2fde14 jdk8-b90 1.6 b19517cecc2e91636d7c16ba2f35e3d3dc628099 hs25-b33 1.7 +7cbdf0e3725c0c56a2ff7540fc70b6d4b5890d04 jdk8-b91 1.8 +38da9f4f67096745f851318d792d6468aa1f6cf8 hs25-b34
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java Mon May 27 12:58:42 2013 +0200 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java Fri May 31 09:55:35 2013 +0200 2.3 @@ -96,9 +96,10 @@ 2.4 2.5 public boolean containsProtectionDomain(Oop protectionDomain) { 2.6 InstanceKlass ik = (InstanceKlass) klass(); 2.7 - if (protectionDomain.equals(ik.getProtectionDomain())) { 2.8 - return true; // Succeeds trivially 2.9 - } 2.10 + // Currently unimplemented and not used. 2.11 + // if (protectionDomain.equals(ik.getJavaMirror().getProtectionDomain())) { 2.12 + // return true; // Succeeds trivially 2.13 + // } 2.14 for (ProtectionDomainEntry current = pdSet(); current != null; 2.15 current = current.next()) { 2.16 if (protectionDomain.equals(current.protectionDomain())) {
3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Mon May 27 12:58:42 2013 +0200 3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri May 31 09:55:35 2013 +0200 3.3 @@ -75,8 +75,6 @@ 3.4 javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0); 3.5 constants = new MetadataField(type.getAddressField("_constants"), 0); 3.6 classLoaderData = type.getAddressField("_class_loader_data"); 3.7 - protectionDomain = new OopField(type.getOopField("_protection_domain"), 0); 3.8 - signers = new OopField(type.getOopField("_signers"), 0); 3.9 sourceFileName = type.getAddressField("_source_file_name"); 3.10 sourceDebugExtension = type.getAddressField("_source_debug_extension"); 3.11 innerClasses = type.getAddressField("_inner_classes"); 3.12 @@ -136,8 +134,6 @@ 3.13 private static CIntField javaFieldsCount; 3.14 private static MetadataField constants; 3.15 private static AddressField classLoaderData; 3.16 - private static OopField protectionDomain; 3.17 - private static OopField signers; 3.18 private static AddressField sourceFileName; 3.19 private static AddressField sourceDebugExtension; 3.20 private static AddressField innerClasses; 3.21 @@ -350,8 +346,6 @@ 3.22 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } 3.23 public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); } 3.24 public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); } 3.25 - public Oop getProtectionDomain() { return protectionDomain.getValue(this); } 3.26 - public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } 3.27 public Symbol getSourceFileName() { return getSymbol(sourceFileName); } 3.28 public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); } 3.29 public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } 3.30 @@ -541,8 +535,6 @@ 3.31 // visitor.doOop(methods, true); 3.32 // visitor.doOop(localInterfaces, true); 3.33 // visitor.doOop(transitiveInterfaces, true); 3.34 - visitor.doOop(protectionDomain, true); 3.35 - visitor.doOop(signers, true); 3.36 visitor.doCInt(nonstaticFieldSize, true); 3.37 visitor.doCInt(staticFieldSize, true); 3.38 visitor.doCInt(staticOopFieldCount, true);
4.1 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java Mon May 27 12:58:42 2013 +0200 4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java Fri May 31 09:55:35 2013 +0200 4.3 @@ -204,13 +204,13 @@ 4.4 Oop loader = ik.getClassLoader(); 4.5 writeEdge(instance, loader, "loaded-by"); 4.6 4.7 - // write signers 4.8 - Oop signers = ik.getSigners(); 4.9 - writeEdge(instance, signers, "signed-by"); 4.10 + // write signers NYI 4.11 + // Oop signers = ik.getJavaMirror().getSigners(); 4.12 + writeEdge(instance, null, "signed-by"); 4.13 4.14 - // write protection domain 4.15 - Oop protectionDomain = ik.getProtectionDomain(); 4.16 - writeEdge(instance, protectionDomain, "protection-domain"); 4.17 + // write protection domain NYI 4.18 + // Oop protectionDomain = ik.getJavaMirror().getProtectionDomain(); 4.19 + writeEdge(instance, null, "protection-domain"); 4.20 4.21 // write edges for static reference fields from this class 4.22 for (Iterator itr = refFields.iterator(); itr.hasNext();) {
5.1 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Mon May 27 12:58:42 2013 +0200 5.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Fri May 31 09:55:35 2013 +0200 5.3 @@ -477,8 +477,8 @@ 5.4 if (k instanceof InstanceKlass) { 5.5 InstanceKlass ik = (InstanceKlass) k; 5.6 writeObjectID(ik.getClassLoader()); 5.7 - writeObjectID(ik.getSigners()); 5.8 - writeObjectID(ik.getProtectionDomain()); 5.9 + writeObjectID(null); // ik.getJavaMirror().getSigners()); 5.10 + writeObjectID(null); // ik.getJavaMirror().getProtectionDomain()); 5.11 // two reserved id fields 5.12 writeObjectID(null); 5.13 writeObjectID(null); 5.14 @@ -516,8 +516,8 @@ 5.15 if (bottomKlass instanceof InstanceKlass) { 5.16 InstanceKlass ik = (InstanceKlass) bottomKlass; 5.17 writeObjectID(ik.getClassLoader()); 5.18 - writeObjectID(ik.getSigners()); 5.19 - writeObjectID(ik.getProtectionDomain()); 5.20 + writeObjectID(null); // ik.getJavaMirror().getSigners()); 5.21 + writeObjectID(null); // ik.getJavaMirror().getProtectionDomain()); 5.22 } else { 5.23 writeObjectID(null); 5.24 writeObjectID(null);
6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java Mon May 27 12:58:42 2013 +0200 6.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java Fri May 31 09:55:35 2013 +0200 6.3 @@ -47,8 +47,6 @@ 6.4 private static final int FIELD_IS_SYNTHETIC = 13; 6.5 private static final int FIELD_IS_INTERFACE = 14; 6.6 private static final int FIELD_CLASS_LOADER = 15; 6.7 - private static final int FIELD_PROTECTION_DOMAIN = 16; 6.8 - private static final int FIELD_SIGNERS = 17; 6.9 private static final int FIELD_STATICS = 18; 6.10 private static final int FIELD_UNDEFINED = -1; 6.11 6.12 @@ -100,10 +98,6 @@ 6.13 return Boolean.valueOf(ik.isInterface()); 6.14 case FIELD_CLASS_LOADER: 6.15 return factory.newJSJavaObject(ik.getClassLoader()); 6.16 - case FIELD_PROTECTION_DOMAIN: 6.17 - return factory.newJSJavaObject(ik.getProtectionDomain()); 6.18 - case FIELD_SIGNERS: 6.19 - return factory.newJSJavaObject(ik.getSigners()); 6.20 case FIELD_STATICS: 6.21 return getStatics(); 6.22 case FIELD_UNDEFINED: 6.23 @@ -246,8 +240,6 @@ 6.24 addField("isSynthetic", FIELD_IS_SYNTHETIC); 6.25 addField("isInterface", FIELD_IS_INTERFACE); 6.26 addField("classLoader", FIELD_CLASS_LOADER); 6.27 - addField("protectionDomain", FIELD_PROTECTION_DOMAIN); 6.28 - addField("signers", FIELD_SIGNERS); 6.29 addField("statics", FIELD_STATICS); 6.30 } 6.31
7.1 --- a/make/excludeSrc.make Mon May 27 12:58:42 2013 +0200 7.2 +++ b/make/excludeSrc.make Fri May 31 09:55:35 2013 +0200 7.3 @@ -25,7 +25,7 @@ 7.4 CXXFLAGS += -DINCLUDE_JVMTI=0 7.5 CFLAGS += -DINCLUDE_JVMTI=0 7.6 7.7 - Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp forte.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ 7.8 + Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ 7.9 jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \ 7.10 jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \ 7.11 jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \
8.1 --- a/make/hotspot_version Mon May 27 12:58:42 2013 +0200 8.2 +++ b/make/hotspot_version Fri May 31 09:55:35 2013 +0200 8.3 @@ -35,7 +35,7 @@ 8.4 8.5 HS_MAJOR_VER=25 8.6 HS_MINOR_VER=0 8.7 -HS_BUILD_NUMBER=34 8.8 +HS_BUILD_NUMBER=35 8.9 8.10 JDK_MAJOR_VER=1 8.11 JDK_MINOR_VER=8
9.1 --- a/src/os/windows/vm/os_windows.cpp Mon May 27 12:58:42 2013 +0200 9.2 +++ b/src/os/windows/vm/os_windows.cpp Fri May 31 09:55:35 2013 +0200 9.3 @@ -944,6 +944,8 @@ 9.4 MINIDUMP_TYPE dumpType; 9.5 static const char* cwd; 9.6 9.7 +// Default is to always create dump for debug builds, on product builds only dump on server versions of Windows. 9.8 +#ifndef ASSERT 9.9 // If running on a client version of Windows and user has not explicitly enabled dumping 9.10 if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) { 9.11 VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false); 9.12 @@ -953,6 +955,12 @@ 9.13 VMError::report_coredump_status("Minidump has been disabled from the command line", false); 9.14 return; 9.15 } 9.16 +#else 9.17 + if (!FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) { 9.18 + VMError::report_coredump_status("Minidump has been disabled from the command line", false); 9.19 + return; 9.20 + } 9.21 +#endif 9.22 9.23 dbghelp = os::win32::load_Windows_dll("DBGHELP.DLL", NULL, 0); 9.24 9.25 @@ -1004,7 +1012,21 @@ 9.26 // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. 9.27 if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == false && 9.28 _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == false) { 9.29 - VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false); 9.30 + DWORD error = GetLastError(); 9.31 + LPTSTR msgbuf = NULL; 9.32 + 9.33 + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 9.34 + FORMAT_MESSAGE_FROM_SYSTEM | 9.35 + FORMAT_MESSAGE_IGNORE_INSERTS, 9.36 + NULL, error, 0, (LPTSTR)&msgbuf, 0, NULL) != 0) { 9.37 + 9.38 + jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x: %s)", error, msgbuf); 9.39 + LocalFree(msgbuf); 9.40 + } else { 9.41 + // Call to FormatMessage failed, just include the result from GetLastError 9.42 + jio_snprintf(buffer, bufferSize, "Call to MiniDumpWriteDump() failed (Error 0x%x)", error); 9.43 + } 9.44 + VMError::report_coredump_status(buffer, false); 9.45 } else { 9.46 VMError::report_coredump_status(buffer, true); 9.47 }
10.1 --- a/src/share/vm/classfile/classFileParser.cpp Mon May 27 12:58:42 2013 +0200 10.2 +++ b/src/share/vm/classfile/classFileParser.cpp Fri May 31 09:55:35 2013 +0200 10.3 @@ -444,8 +444,8 @@ 10.4 break; 10.5 case JVM_REF_invokeStatic: 10.6 case JVM_REF_invokeSpecial: 10.7 - check_property( 10.8 - tag.is_method() || tag.is_interface_method(), 10.9 + check_property(tag.is_method() || 10.10 + ((_major_version >= JAVA_8_VERSION) && tag.is_interface_method()), 10.11 "Invalid constant pool index %u in class file %s (not a method)", 10.12 ref_index, CHECK_(nullHandle)); 10.13 break; 10.14 @@ -3152,7 +3152,6 @@ 10.15 } 10.16 } 10.17 } 10.18 - int contended_count = nonstatic_contended_count; 10.19 10.20 10.21 // Calculate the starting byte offsets 10.22 @@ -3177,35 +3176,52 @@ 10.23 10.24 next_nonstatic_field_offset = nonstatic_fields_start; 10.25 10.26 + bool is_contended_class = parsed_annotations->is_contended(); 10.27 + 10.28 // Class is contended, pad before all the fields 10.29 - if (parsed_annotations->is_contended()) { 10.30 + if (is_contended_class) { 10.31 next_nonstatic_field_offset += ContendedPaddingWidth; 10.32 } 10.33 10.34 - // Compute the non-contended fields count 10.35 + // Compute the non-contended fields count. 10.36 + // The packing code below relies on these counts to determine if some field 10.37 + // can be squeezed into the alignment gap. Contended fields are obviously 10.38 + // exempt from that. 10.39 unsigned int nonstatic_double_count = fac->count[NONSTATIC_DOUBLE] - fac_contended.count[NONSTATIC_DOUBLE]; 10.40 unsigned int nonstatic_word_count = fac->count[NONSTATIC_WORD] - fac_contended.count[NONSTATIC_WORD]; 10.41 unsigned int nonstatic_short_count = fac->count[NONSTATIC_SHORT] - fac_contended.count[NONSTATIC_SHORT]; 10.42 unsigned int nonstatic_byte_count = fac->count[NONSTATIC_BYTE] - fac_contended.count[NONSTATIC_BYTE]; 10.43 unsigned int nonstatic_oop_count = fac->count[NONSTATIC_OOP] - fac_contended.count[NONSTATIC_OOP]; 10.44 10.45 + // Total non-static fields count, including every contended field 10.46 + unsigned int nonstatic_fields_count = fac->count[NONSTATIC_DOUBLE] + fac->count[NONSTATIC_WORD] + 10.47 + fac->count[NONSTATIC_SHORT] + fac->count[NONSTATIC_BYTE] + 10.48 + fac->count[NONSTATIC_OOP]; 10.49 + 10.50 bool super_has_nonstatic_fields = 10.51 (_super_klass() != NULL && _super_klass->has_nonstatic_fields()); 10.52 - bool has_nonstatic_fields = super_has_nonstatic_fields || 10.53 - ((nonstatic_double_count + nonstatic_word_count + 10.54 - nonstatic_short_count + nonstatic_byte_count + 10.55 - nonstatic_oop_count) != 0); 10.56 + bool has_nonstatic_fields = super_has_nonstatic_fields || (nonstatic_fields_count != 0); 10.57 10.58 10.59 // Prepare list of oops for oop map generation. 10.60 + // 10.61 + // "offset" and "count" lists are describing the set of contiguous oop 10.62 + // regions. offset[i] is the start of the i-th region, which then has 10.63 + // count[i] oops following. Before we know how many regions are required, 10.64 + // we pessimistically allocate the maps to fit all the oops into the 10.65 + // distinct regions. 10.66 + // 10.67 + // TODO: We add +1 to always allocate non-zero resource arrays; we need 10.68 + // to figure out if we still need to do this. 10.69 int* nonstatic_oop_offsets; 10.70 unsigned int* nonstatic_oop_counts; 10.71 unsigned int nonstatic_oop_map_count = 0; 10.72 + unsigned int max_nonstatic_oop_maps = fac->count[NONSTATIC_OOP] + 1; 10.73 10.74 nonstatic_oop_offsets = NEW_RESOURCE_ARRAY_IN_THREAD( 10.75 - THREAD, int, nonstatic_oop_count + 1); 10.76 + THREAD, int, max_nonstatic_oop_maps); 10.77 nonstatic_oop_counts = NEW_RESOURCE_ARRAY_IN_THREAD( 10.78 - THREAD, unsigned int, nonstatic_oop_count + 1); 10.79 + THREAD, unsigned int, max_nonstatic_oop_maps); 10.80 10.81 first_nonstatic_oop_offset = 0; // will be set for first oop field 10.82 10.83 @@ -3392,9 +3408,11 @@ 10.84 int(nonstatic_oop_counts[nonstatic_oop_map_count - 1]) * 10.85 heapOopSize ) { 10.86 // Extend current oop map 10.87 + assert(nonstatic_oop_map_count - 1 < max_nonstatic_oop_maps, "range check"); 10.88 nonstatic_oop_counts[nonstatic_oop_map_count - 1] += 1; 10.89 } else { 10.90 // Create new oop map 10.91 + assert(nonstatic_oop_map_count < max_nonstatic_oop_maps, "range check"); 10.92 nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset; 10.93 nonstatic_oop_counts [nonstatic_oop_map_count] = 1; 10.94 nonstatic_oop_map_count += 1; 10.95 @@ -3452,12 +3470,10 @@ 10.96 // 10.97 // Additionally, this should not break alignment for the fields, so we round the alignment up 10.98 // for each field. 10.99 - if (contended_count > 0) { 10.100 + if (nonstatic_contended_count > 0) { 10.101 10.102 // if there is at least one contended field, we need to have pre-padding for them 10.103 - if (nonstatic_contended_count > 0) { 10.104 - next_nonstatic_padded_offset += ContendedPaddingWidth; 10.105 - } 10.106 + next_nonstatic_padded_offset += ContendedPaddingWidth; 10.107 10.108 // collect all contended groups 10.109 BitMap bm(_cp->size()); 10.110 @@ -3518,6 +3534,7 @@ 10.111 next_nonstatic_padded_offset += heapOopSize; 10.112 10.113 // Create new oop map 10.114 + assert(nonstatic_oop_map_count < max_nonstatic_oop_maps, "range check"); 10.115 nonstatic_oop_offsets[nonstatic_oop_map_count] = real_offset; 10.116 nonstatic_oop_counts [nonstatic_oop_map_count] = 1; 10.117 nonstatic_oop_map_count += 1; 10.118 @@ -3554,18 +3571,17 @@ 10.119 // handle static fields 10.120 } 10.121 10.122 - // Size of instances 10.123 - int notaligned_offset = next_nonstatic_padded_offset; 10.124 - 10.125 // Entire class is contended, pad in the back. 10.126 // This helps to alleviate memory contention effects for subclass fields 10.127 // and/or adjacent object. 10.128 - if (parsed_annotations->is_contended()) { 10.129 - notaligned_offset += ContendedPaddingWidth; 10.130 + if (is_contended_class) { 10.131 + next_nonstatic_padded_offset += ContendedPaddingWidth; 10.132 } 10.133 10.134 - int nonstatic_fields_end = align_size_up(notaligned_offset, heapOopSize); 10.135 - int instance_end = align_size_up(notaligned_offset, wordSize); 10.136 + int notaligned_nonstatic_fields_end = next_nonstatic_padded_offset; 10.137 + 10.138 + int nonstatic_fields_end = align_size_up(notaligned_nonstatic_fields_end, heapOopSize); 10.139 + int instance_end = align_size_up(notaligned_nonstatic_fields_end, wordSize); 10.140 int static_fields_end = align_size_up(next_static_byte_offset, wordSize); 10.141 10.142 int static_field_size = (static_fields_end - 10.143 @@ -3579,6 +3595,14 @@ 10.144 (instanceOopDesc::base_offset_in_bytes() + nonstatic_field_size*heapOopSize), 10.145 wordSize) / wordSize), "consistent layout helper value"); 10.146 10.147 + // Invariant: nonstatic_field end/start should only change if there are 10.148 + // nonstatic fields in the class, or if the class is contended. We compare 10.149 + // against the non-aligned value, so that end alignment will not fail the 10.150 + // assert without actually having the fields. 10.151 + assert((notaligned_nonstatic_fields_end == nonstatic_fields_start) || 10.152 + is_contended_class || 10.153 + (nonstatic_fields_count > 0), "double-check nonstatic start/end"); 10.154 + 10.155 // Number of non-static oop map blocks allocated at end of klass. 10.156 const unsigned int total_oop_map_count = 10.157 compute_oop_map_count(_super_klass, nonstatic_oop_map_count, 10.158 @@ -4040,6 +4064,9 @@ 10.159 } 10.160 } 10.161 10.162 + // Allocate mirror and initialize static fields 10.163 + java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle)); 10.164 + 10.165 10.166 #ifdef ASSERT 10.167 if (ParseAllGenericSignatures) { 10.168 @@ -4055,17 +4082,6 @@ 10.169 this_klass(), &all_mirandas, CHECK_(nullHandle)); 10.170 } 10.171 10.172 - // Allocate mirror and initialize static fields 10.173 - java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle)); 10.174 - 10.175 - // Allocate a simple java object for locking during class initialization. 10.176 - // This needs to be a java object because it can be held across a java call. 10.177 - typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL); 10.178 - this_klass->set_init_lock(r); 10.179 - 10.180 - // TODO: Move these oops to the mirror 10.181 - this_klass->set_protection_domain(protection_domain()); 10.182 - 10.183 // Update the loader_data graph. 10.184 record_defined_class_dependencies(this_klass, CHECK_NULL); 10.185
11.1 --- a/src/share/vm/classfile/javaClasses.cpp Mon May 27 12:58:42 2013 +0200 11.2 +++ b/src/share/vm/classfile/javaClasses.cpp Fri May 31 09:55:35 2013 +0200 11.3 @@ -512,22 +512,22 @@ 11.4 11.5 // If the offset was read from the shared archive, it was fixed up already 11.6 if (!k->is_shared()) { 11.7 - if (k->oop_is_instance()) { 11.8 - // During bootstrap, java.lang.Class wasn't loaded so static field 11.9 - // offsets were computed without the size added it. Go back and 11.10 - // update all the static field offsets to included the size. 11.11 - for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { 11.12 - if (fs.access_flags().is_static()) { 11.13 - int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); 11.14 - fs.set_offset(real_offset); 11.15 + if (k->oop_is_instance()) { 11.16 + // During bootstrap, java.lang.Class wasn't loaded so static field 11.17 + // offsets were computed without the size added it. Go back and 11.18 + // update all the static field offsets to included the size. 11.19 + for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) { 11.20 + if (fs.access_flags().is_static()) { 11.21 + int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); 11.22 + fs.set_offset(real_offset); 11.23 + } 11.24 } 11.25 } 11.26 } 11.27 - } 11.28 - create_mirror(k, CHECK); 11.29 + create_mirror(k, Handle(NULL), CHECK); 11.30 } 11.31 11.32 -oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { 11.33 +oop java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) { 11.34 assert(k->java_mirror() == NULL, "should only assign mirror once"); 11.35 // Use this moment of initialization to cache modifier_flags also, 11.36 // to support Class.getModifiers(). Instance classes recalculate 11.37 @@ -563,6 +563,16 @@ 11.38 set_array_klass(comp_mirror(), k()); 11.39 } else { 11.40 assert(k->oop_is_instance(), "Must be"); 11.41 + 11.42 + // Allocate a simple java object for a lock. 11.43 + // This needs to be a java object because during class initialization 11.44 + // it can be held across a java call. 11.45 + typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL); 11.46 + set_init_lock(mirror(), r); 11.47 + 11.48 + // Set protection domain also 11.49 + set_protection_domain(mirror(), protection_domain()); 11.50 + 11.51 // Initialize static fields 11.52 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL); 11.53 } 11.54 @@ -597,6 +607,34 @@ 11.55 java_class->int_field_put(_static_oop_field_count_offset, size); 11.56 } 11.57 11.58 +oop java_lang_Class::protection_domain(oop java_class) { 11.59 + assert(_protection_domain_offset != 0, "must be set"); 11.60 + return java_class->obj_field(_protection_domain_offset); 11.61 +} 11.62 +void java_lang_Class::set_protection_domain(oop java_class, oop pd) { 11.63 + assert(_protection_domain_offset != 0, "must be set"); 11.64 + java_class->obj_field_put(_protection_domain_offset, pd); 11.65 +} 11.66 + 11.67 +oop java_lang_Class::init_lock(oop java_class) { 11.68 + assert(_init_lock_offset != 0, "must be set"); 11.69 + return java_class->obj_field(_init_lock_offset); 11.70 +} 11.71 +void java_lang_Class::set_init_lock(oop java_class, oop init_lock) { 11.72 + assert(_init_lock_offset != 0, "must be set"); 11.73 + java_class->obj_field_put(_init_lock_offset, init_lock); 11.74 +} 11.75 + 11.76 +objArrayOop java_lang_Class::signers(oop java_class) { 11.77 + assert(_signers_offset != 0, "must be set"); 11.78 + return (objArrayOop)java_class->obj_field(_signers_offset); 11.79 +} 11.80 +void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { 11.81 + assert(_signers_offset != 0, "must be set"); 11.82 + java_class->obj_field_put(_signers_offset, (oop)signers); 11.83 +} 11.84 + 11.85 + 11.86 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { 11.87 // This should be improved by adding a field at the Java level or by 11.88 // introducing a new VM klass (see comment in ClassFileParser) 11.89 @@ -2934,6 +2972,9 @@ 11.90 int java_lang_Class::_array_klass_offset; 11.91 int java_lang_Class::_oop_size_offset; 11.92 int java_lang_Class::_static_oop_field_count_offset; 11.93 +int java_lang_Class::_protection_domain_offset; 11.94 +int java_lang_Class::_init_lock_offset; 11.95 +int java_lang_Class::_signers_offset; 11.96 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL; 11.97 int java_lang_Throwable::backtrace_offset; 11.98 int java_lang_Throwable::detailMessage_offset;
12.1 --- a/src/share/vm/classfile/javaClasses.hpp Mon May 27 12:58:42 2013 +0200 12.2 +++ b/src/share/vm/classfile/javaClasses.hpp Fri May 31 09:55:35 2013 +0200 12.3 @@ -208,7 +208,10 @@ 12.4 macro(java_lang_Class, klass, intptr_signature, false) \ 12.5 macro(java_lang_Class, array_klass, intptr_signature, false) \ 12.6 macro(java_lang_Class, oop_size, int_signature, false) \ 12.7 - macro(java_lang_Class, static_oop_field_count, int_signature, false) 12.8 + macro(java_lang_Class, static_oop_field_count, int_signature, false) \ 12.9 + macro(java_lang_Class, protection_domain, object_signature, false) \ 12.10 + macro(java_lang_Class, init_lock, object_signature, false) \ 12.11 + macro(java_lang_Class, signers, object_signature, false) 12.12 12.13 class java_lang_Class : AllStatic { 12.14 friend class VMStructs; 12.15 @@ -222,15 +225,20 @@ 12.16 static int _oop_size_offset; 12.17 static int _static_oop_field_count_offset; 12.18 12.19 + static int _protection_domain_offset; 12.20 + static int _init_lock_offset; 12.21 + static int _signers_offset; 12.22 + 12.23 static bool offsets_computed; 12.24 static int classRedefinedCount_offset; 12.25 static GrowableArray<Klass*>* _fixup_mirror_list; 12.26 12.27 + static void set_init_lock(oop java_class, oop init_lock); 12.28 public: 12.29 static void compute_offsets(); 12.30 12.31 // Instance creation 12.32 - static oop create_mirror(KlassHandle k, TRAPS); 12.33 + static oop create_mirror(KlassHandle k, Handle protection_domain, TRAPS); 12.34 static void fixup_mirror(KlassHandle k, TRAPS); 12.35 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); 12.36 // Conversion 12.37 @@ -262,6 +270,13 @@ 12.38 static int classRedefinedCount(oop the_class_mirror); 12.39 static void set_classRedefinedCount(oop the_class_mirror, int value); 12.40 12.41 + // Support for embedded per-class oops 12.42 + static oop protection_domain(oop java_class); 12.43 + static void set_protection_domain(oop java_class, oop protection_domain); 12.44 + static oop init_lock(oop java_class); 12.45 + static objArrayOop signers(oop java_class); 12.46 + static void set_signers(oop java_class, objArrayOop signers); 12.47 + 12.48 static int oop_size(oop java_class); 12.49 static void set_oop_size(oop java_class, int size); 12.50 static int static_oop_field_count(oop java_class);
13.1 --- a/src/share/vm/classfile/vmSymbols.hpp Mon May 27 12:58:42 2013 +0200 13.2 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri May 31 09:55:35 2013 +0200 13.3 @@ -392,6 +392,9 @@ 13.4 template(array_klass_name, "array_klass") \ 13.5 template(oop_size_name, "oop_size") \ 13.6 template(static_oop_field_count_name, "static_oop_field_count") \ 13.7 + template(protection_domain_name, "protection_domain") \ 13.8 + template(init_lock_name, "init_lock") \ 13.9 + template(signers_name, "signers_name") \ 13.10 template(loader_data_name, "loader_data") \ 13.11 template(dependencies_name, "dependencies") \ 13.12 \
14.1 --- a/src/share/vm/oops/arrayKlass.cpp Mon May 27 12:58:42 2013 +0200 14.2 +++ b/src/share/vm/oops/arrayKlass.cpp Fri May 31 09:55:35 2013 +0200 14.3 @@ -94,7 +94,7 @@ 14.4 ResourceMark rm(THREAD); 14.5 k->initialize_supers(super_klass(), CHECK); 14.6 k->vtable()->initialize_vtable(false, CHECK); 14.7 - java_lang_Class::create_mirror(k, CHECK); 14.8 + java_lang_Class::create_mirror(k, Handle(NULL), CHECK); 14.9 } 14.10 14.11 GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {
15.1 --- a/src/share/vm/oops/constantPool.cpp Mon May 27 12:58:42 2013 +0200 15.2 +++ b/src/share/vm/oops/constantPool.cpp Fri May 31 09:55:35 2013 +0200 15.3 @@ -1063,9 +1063,10 @@ 15.4 int k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2); 15.5 int i1 = invoke_dynamic_bootstrap_specifier_index(index1); 15.6 int i2 = cp2->invoke_dynamic_bootstrap_specifier_index(index2); 15.7 - bool match = compare_entry_to(k1, cp2, k2, CHECK_false) && 15.8 - compare_operand_to(i1, cp2, i2, CHECK_false); 15.9 - return match; 15.10 + // separate statements and variables because CHECK_false is used 15.11 + bool match_entry = compare_entry_to(k1, cp2, k2, CHECK_false); 15.12 + bool match_operand = compare_operand_to(i1, cp2, i2, CHECK_false); 15.13 + return (match_entry && match_operand); 15.14 } break; 15.15 15.16 case JVM_CONSTANT_String:
16.1 --- a/src/share/vm/oops/instanceKlass.cpp Mon May 27 12:58:42 2013 +0200 16.2 +++ b/src/share/vm/oops/instanceKlass.cpp Fri May 31 09:55:35 2013 +0200 16.3 @@ -268,8 +268,6 @@ 16.4 set_fields(NULL, 0); 16.5 set_constants(NULL); 16.6 set_class_loader_data(NULL); 16.7 - set_protection_domain(NULL); 16.8 - set_signers(NULL); 16.9 set_source_file_name(NULL); 16.10 set_source_debug_extension(NULL, 0); 16.11 set_array_name(NULL); 16.12 @@ -279,7 +277,6 @@ 16.13 set_is_marked_dependent(false); 16.14 set_init_state(InstanceKlass::allocated); 16.15 set_init_thread(NULL); 16.16 - set_init_lock(NULL); 16.17 set_reference_type(rt); 16.18 set_oop_map_cache(NULL); 16.19 set_jni_ids(NULL); 16.20 @@ -408,12 +405,6 @@ 16.21 } 16.22 set_inner_classes(NULL); 16.23 16.24 - // Null out Java heap objects, although these won't be walked to keep 16.25 - // alive once this InstanceKlass is deallocated. 16.26 - set_protection_domain(NULL); 16.27 - set_signers(NULL); 16.28 - set_init_lock(NULL); 16.29 - 16.30 // We should deallocate the Annotations instance 16.31 MetadataFactory::free_metadata(loader_data, annotations()); 16.32 set_annotations(NULL); 16.33 @@ -451,6 +442,24 @@ 16.34 } 16.35 } 16.36 16.37 +// JVMTI spec thinks there are signers and protection domain in the 16.38 +// instanceKlass. These accessors pretend these fields are there. 16.39 +// The hprof specification also thinks these fields are in InstanceKlass. 16.40 +oop InstanceKlass::protection_domain() const { 16.41 + // return the protection_domain from the mirror 16.42 + return java_lang_Class::protection_domain(java_mirror()); 16.43 +} 16.44 + 16.45 +// To remove these from requires an incompatible change and CCC request. 16.46 +objArrayOop InstanceKlass::signers() const { 16.47 + // return the signers from the mirror 16.48 + return java_lang_Class::signers(java_mirror()); 16.49 +} 16.50 + 16.51 +volatile oop InstanceKlass::init_lock() const { 16.52 + // return the init lock from the mirror 16.53 + return java_lang_Class::init_lock(java_mirror()); 16.54 +} 16.55 16.56 void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { 16.57 EXCEPTION_MARK; 16.58 @@ -1883,16 +1892,6 @@ 16.59 16.60 // Garbage collection 16.61 16.62 -void InstanceKlass::oops_do(OopClosure* cl) { 16.63 - Klass::oops_do(cl); 16.64 - 16.65 - cl->do_oop(adr_protection_domain()); 16.66 - cl->do_oop(adr_signers()); 16.67 - cl->do_oop(adr_init_lock()); 16.68 - 16.69 - // Don't walk the arrays since they are walked from the ClassLoaderData objects. 16.70 -} 16.71 - 16.72 #ifdef ASSERT 16.73 template <class T> void assert_is_in(T *p) { 16.74 T heap_oop = oopDesc::load_heap_oop(p); 16.75 @@ -2241,9 +2240,6 @@ 16.76 m->remove_unshareable_info(); 16.77 } 16.78 16.79 - // Need to reinstate when reading back the class. 16.80 - set_init_lock(NULL); 16.81 - 16.82 // do array classes also. 16.83 array_klasses_do(remove_unshareable_in_class); 16.84 } 16.85 @@ -2275,13 +2271,6 @@ 16.86 ik->itable()->initialize_itable(false, CHECK); 16.87 } 16.88 16.89 - // Allocate a simple java object for a lock. 16.90 - // This needs to be a java object because during class initialization 16.91 - // it can be held across a java call. 16.92 - typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK); 16.93 - Handle h(THREAD, (oop)r); 16.94 - ik->set_init_lock(h()); 16.95 - 16.96 // restore constant pool resolved references 16.97 ik->constants()->restore_unshareable_info(CHECK); 16.98 16.99 @@ -2331,10 +2320,15 @@ 16.100 FreeHeap(jmeths); 16.101 } 16.102 16.103 - MemberNameTable* mnt = member_names(); 16.104 - if (mnt != NULL) { 16.105 - delete mnt; 16.106 - set_member_names(NULL); 16.107 + // Deallocate MemberNameTable 16.108 + { 16.109 + Mutex* lock_or_null = SafepointSynchronize::is_at_safepoint() ? NULL : MemberNameTable_lock; 16.110 + MutexLockerEx ml(lock_or_null, Mutex::_no_safepoint_check_flag); 16.111 + MemberNameTable* mnt = member_names(); 16.112 + if (mnt != NULL) { 16.113 + delete mnt; 16.114 + set_member_names(NULL); 16.115 + } 16.116 } 16.117 16.118 int* indices = methods_cached_itable_indices_acquire(); 16.119 @@ -2765,15 +2759,28 @@ 16.120 return NULL; 16.121 } 16.122 16.123 -void InstanceKlass::add_member_name(Handle mem_name) { 16.124 +void InstanceKlass::add_member_name(int index, Handle mem_name) { 16.125 jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); 16.126 MutexLocker ml(MemberNameTable_lock); 16.127 + assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 16.128 DEBUG_ONLY(No_Safepoint_Verifier nsv); 16.129 16.130 if (_member_names == NULL) { 16.131 - _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(); 16.132 + _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); 16.133 } 16.134 - _member_names->add_member_name(mem_name_wref); 16.135 + _member_names->add_member_name(index, mem_name_wref); 16.136 +} 16.137 + 16.138 +oop InstanceKlass::get_member_name(int index) { 16.139 + MutexLocker ml(MemberNameTable_lock); 16.140 + assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 16.141 + DEBUG_ONLY(No_Safepoint_Verifier nsv); 16.142 + 16.143 + if (_member_names == NULL) { 16.144 + return NULL; 16.145 + } 16.146 + oop mem_name =_member_names->get_member_name(index); 16.147 + return mem_name; 16.148 } 16.149 16.150 // ----------------------------------------------------------------------------------------------------- 16.151 @@ -2836,10 +2843,7 @@ 16.152 class_loader_data()->print_value_on(st); 16.153 st->cr(); 16.154 } 16.155 - st->print(BULLET"protection domain: "); ((InstanceKlass*)this)->protection_domain()->print_value_on(st); st->cr(); 16.156 st->print(BULLET"host class: "); host_klass()->print_value_on_maybe_null(st); st->cr(); 16.157 - st->print(BULLET"signers: "); signers()->print_value_on(st); st->cr(); 16.158 - st->print(BULLET"init_lock: "); ((oop)_init_lock)->print_value_on(st); st->cr(); 16.159 if (source_file_name() != NULL) { 16.160 st->print(BULLET"source file: "); 16.161 source_file_name()->print_value_on(st); 16.162 @@ -3040,7 +3044,6 @@ 16.163 n += (sz->_method_ordering_bytes = sz->count_array(method_ordering())); 16.164 n += (sz->_local_interfaces_bytes = sz->count_array(local_interfaces())); 16.165 n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces())); 16.166 - n += (sz->_signers_bytes = sz->count_array(signers())); 16.167 n += (sz->_fields_bytes = sz->count_array(fields())); 16.168 n += (sz->_inner_classes_bytes = sz->count_array(inner_classes())); 16.169 sz->_ro_bytes += n; 16.170 @@ -3206,17 +3209,11 @@ 16.171 guarantee(constants()->is_metadata(), "should be in metaspace"); 16.172 guarantee(constants()->is_constantPool(), "should be constant pool"); 16.173 } 16.174 - if (protection_domain() != NULL) { 16.175 - guarantee(protection_domain()->is_oop(), "should be oop"); 16.176 - } 16.177 const Klass* host = host_klass(); 16.178 if (host != NULL) { 16.179 guarantee(host->is_metadata(), "should be in metaspace"); 16.180 guarantee(host->is_klass(), "should be klass"); 16.181 } 16.182 - if (signers() != NULL) { 16.183 - guarantee(signers()->is_objArray(), "should be obj array"); 16.184 - } 16.185 } 16.186 16.187 void InstanceKlass::oop_verify_on(oop obj, outputStream* st) {
17.1 --- a/src/share/vm/oops/instanceKlass.hpp Mon May 27 12:58:42 2013 +0200 17.2 +++ b/src/share/vm/oops/instanceKlass.hpp Fri May 31 09:55:35 2013 +0200 17.3 @@ -58,8 +58,6 @@ 17.4 // [fields ] 17.5 // [constants ] 17.6 // [class loader ] 17.7 -// [protection domain ] 17.8 -// [signers ] 17.9 // [source file name ] 17.10 // [inner classes ] 17.11 // [static field size ] 17.12 @@ -180,16 +178,6 @@ 17.13 static volatile int _total_instanceKlass_count; 17.14 17.15 protected: 17.16 - // Protection domain. 17.17 - oop _protection_domain; 17.18 - // Class signers. 17.19 - objArrayOop _signers; 17.20 - // Lock for (1) initialization; (2) access to the ConstantPool of this class. 17.21 - // Must be one per class and it has to be a VM internal object so java code 17.22 - // cannot lock it (like the mirror). 17.23 - // It has to be an object not a Mutex because it's held through java calls. 17.24 - volatile oop _init_lock; 17.25 - 17.26 // Annotations for this class 17.27 Annotations* _annotations; 17.28 // Array classes holding elements of this class. 17.29 @@ -527,8 +515,10 @@ 17.30 void set_constants(ConstantPool* c) { _constants = c; } 17.31 17.32 // protection domain 17.33 - oop protection_domain() { return _protection_domain; } 17.34 - void set_protection_domain(oop pd) { klass_oop_store(&_protection_domain, pd); } 17.35 + oop protection_domain() const; 17.36 + 17.37 + // signers 17.38 + objArrayOop signers() const; 17.39 17.40 // host class 17.41 Klass* host_klass() const { 17.42 @@ -575,10 +565,6 @@ 17.43 } 17.44 } 17.45 17.46 - // signers 17.47 - objArrayOop signers() const { return _signers; } 17.48 - void set_signers(objArrayOop s) { klass_oop_store((oop*)&_signers, s); } 17.49 - 17.50 // source file name 17.51 Symbol* source_file_name() const { return _source_file_name; } 17.52 void set_source_file_name(Symbol* n); 17.53 @@ -912,8 +898,6 @@ 17.54 Method* method_at_itable(Klass* holder, int index, TRAPS); 17.55 17.56 // Garbage collection 17.57 - virtual void oops_do(OopClosure* cl); 17.58 - 17.59 void oop_follow_contents(oop obj); 17.60 int oop_adjust_pointers(oop obj); 17.61 17.62 @@ -999,14 +983,12 @@ 17.63 17.64 // Lock during initialization 17.65 public: 17.66 - volatile oop init_lock() const {return _init_lock; } 17.67 + // Lock for (1) initialization; (2) access to the ConstantPool of this class. 17.68 + // Must be one per class and it has to be a VM internal object so java code 17.69 + // cannot lock it (like the mirror). 17.70 + // It has to be an object not a Mutex because it's held through java calls. 17.71 + volatile oop init_lock() const; 17.72 private: 17.73 - void set_init_lock(oop value) { klass_oop_store(&_init_lock, value); } 17.74 - 17.75 - // Offsets for memory management 17.76 - oop* adr_protection_domain() const { return (oop*)&this->_protection_domain;} 17.77 - oop* adr_signers() const { return (oop*)&this->_signers;} 17.78 - oop* adr_init_lock() const { return (oop*)&this->_init_lock;} 17.79 17.80 // Static methods that are used to implement member methods where an exposed this pointer 17.81 // is needed due to possible GCs 17.82 @@ -1040,7 +1022,8 @@ 17.83 // JSR-292 support 17.84 MemberNameTable* member_names() { return _member_names; } 17.85 void set_member_names(MemberNameTable* member_names) { _member_names = member_names; } 17.86 - void add_member_name(Handle member_name); 17.87 + void add_member_name(int index, Handle member_name); 17.88 + oop get_member_name(int index); 17.89 17.90 public: 17.91 // JVMTI support
18.1 --- a/src/share/vm/oops/klass.cpp Mon May 27 12:58:42 2013 +0200 18.2 +++ b/src/share/vm/oops/klass.cpp Fri May 31 09:55:35 2013 +0200 18.3 @@ -511,8 +511,9 @@ 18.4 // (same order as class file parsing) 18.5 loader_data->add_class(this); 18.6 18.7 - // Recreate the class mirror 18.8 - java_lang_Class::create_mirror(this, CHECK); 18.9 + // Recreate the class mirror. The protection_domain is always null for 18.10 + // boot loader, for now. 18.11 + java_lang_Class::create_mirror(this, Handle(NULL), CHECK); 18.12 } 18.13 18.14 Klass* Klass::array_klass_or_null(int rank) {
19.1 --- a/src/share/vm/oops/klass.hpp Mon May 27 12:58:42 2013 +0200 19.2 +++ b/src/share/vm/oops/klass.hpp Fri May 31 09:55:35 2013 +0200 19.3 @@ -445,7 +445,7 @@ 19.4 Klass* array_klass_or_null(int rank); 19.5 Klass* array_klass_or_null(); 19.6 19.7 - virtual oop protection_domain() { return NULL; } 19.8 + virtual oop protection_domain() const = 0; 19.9 19.10 oop class_loader() const; 19.11
20.1 --- a/src/share/vm/oops/objArrayKlass.hpp Mon May 27 12:58:42 2013 +0200 20.2 +++ b/src/share/vm/oops/objArrayKlass.hpp Fri May 31 09:55:35 2013 +0200 20.3 @@ -75,7 +75,7 @@ 20.4 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 20.5 20.6 // Compute protection domain 20.7 - oop protection_domain() { return bottom_klass()->protection_domain(); } 20.8 + oop protection_domain() const { return bottom_klass()->protection_domain(); } 20.9 20.10 private: 20.11 // Either oop or narrowOop depending on UseCompressedOops.
21.1 --- a/src/share/vm/oops/typeArrayKlass.hpp Mon May 27 12:58:42 2013 +0200 21.2 +++ b/src/share/vm/oops/typeArrayKlass.hpp Fri May 31 09:55:35 2013 +0200 21.3 @@ -67,6 +67,8 @@ 21.4 typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); } 21.5 oop multi_allocate(int rank, jint* sizes, TRAPS); 21.6 21.7 + oop protection_domain() const { return NULL; } 21.8 + 21.9 // Copying 21.10 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 21.11
22.1 --- a/src/share/vm/prims/forte.cpp Mon May 27 12:58:42 2013 +0200 22.2 +++ b/src/share/vm/prims/forte.cpp Fri May 31 09:55:35 2013 +0200 22.3 @@ -35,6 +35,19 @@ 22.4 #include "runtime/vframe.hpp" 22.5 #include "runtime/vframeArray.hpp" 22.6 22.7 +// call frame copied from old .h file and renamed 22.8 +typedef struct { 22.9 + jint lineno; // line number in the source file 22.10 + jmethodID method_id; // method executed in this frame 22.11 +} ASGCT_CallFrame; 22.12 + 22.13 +// call trace copied from old .h file and renamed 22.14 +typedef struct { 22.15 + JNIEnv *env_id; // Env where trace was recorded 22.16 + jint num_frames; // number of frames in this trace 22.17 + ASGCT_CallFrame *frames; // frames 22.18 +} ASGCT_CallTrace; 22.19 + 22.20 // These name match the names reported by the forte quality kit 22.21 enum { 22.22 ticks_no_Java_frame = 0, 22.23 @@ -50,6 +63,8 @@ 22.24 ticks_safepoint = -10 22.25 }; 22.26 22.27 +#if INCLUDE_JVMTI 22.28 + 22.29 //------------------------------------------------------- 22.30 22.31 // Native interfaces for use by Forte tools. 22.32 @@ -360,20 +375,6 @@ 22.33 22.34 } 22.35 22.36 - 22.37 -// call frame copied from old .h file and renamed 22.38 -typedef struct { 22.39 - jint lineno; // line number in the source file 22.40 - jmethodID method_id; // method executed in this frame 22.41 -} ASGCT_CallFrame; 22.42 - 22.43 -// call trace copied from old .h file and renamed 22.44 -typedef struct { 22.45 - JNIEnv *env_id; // Env where trace was recorded 22.46 - jint num_frames; // number of frames in this trace 22.47 - ASGCT_CallFrame *frames; // frames 22.48 -} ASGCT_CallTrace; 22.49 - 22.50 static void forte_fill_call_trace_given_top(JavaThread* thd, 22.51 ASGCT_CallTrace* trace, 22.52 int depth, 22.53 @@ -634,3 +635,12 @@ 22.54 pointer_delta(end, start, sizeof(jbyte)), 0, NULL); 22.55 #endif // !_WINDOWS && !IA64 22.56 } 22.57 + 22.58 +#else // INCLUDE_JVMTI 22.59 +extern "C" { 22.60 + JNIEXPORT 22.61 + void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { 22.62 + trace->num_frames = ticks_no_class_load; // -1 22.63 + } 22.64 +} 22.65 +#endif // INCLUDE_JVMTI
23.1 --- a/src/share/vm/prims/jvm.cpp Mon May 27 12:58:42 2013 +0200 23.2 +++ b/src/share/vm/prims/jvm.cpp Fri May 31 09:55:35 2013 +0200 23.3 @@ -1072,11 +1072,7 @@ 23.4 return NULL; 23.5 } 23.6 23.7 - Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); 23.8 - objArrayOop signers = NULL; 23.9 - if (k->oop_is_instance()) { 23.10 - signers = InstanceKlass::cast(k)->signers(); 23.11 - } 23.12 + objArrayOop signers = java_lang_Class::signers(JNIHandles::resolve_non_null(cls)); 23.13 23.14 // If there are no signers set in the class, or if the class 23.15 // is an array, return NULL. 23.16 @@ -1102,7 +1098,7 @@ 23.17 // be called with an array. Only the bootstrap loader creates arrays. 23.18 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); 23.19 if (k->oop_is_instance()) { 23.20 - InstanceKlass::cast(k)->set_signers(objArrayOop(JNIHandles::resolve(signers))); 23.21 + java_lang_Class::set_signers(k->java_mirror(), objArrayOop(JNIHandles::resolve(signers))); 23.22 } 23.23 } 23.24 JVM_END 23.25 @@ -1119,8 +1115,8 @@ 23.26 return NULL; 23.27 } 23.28 23.29 - Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); 23.30 - return (jobject) JNIHandles::make_local(env, k->protection_domain()); 23.31 + oop pd = java_lang_Class::protection_domain(JNIHandles::resolve(cls)); 23.32 + return (jobject) JNIHandles::make_local(env, pd); 23.33 JVM_END 23.34 23.35 23.36 @@ -1139,7 +1135,7 @@ 23.37 if (k->oop_is_instance()) { 23.38 oop pd = JNIHandles::resolve(protection_domain); 23.39 assert(pd == NULL || pd->is_oop(), "just checking"); 23.40 - InstanceKlass::cast(k)->set_protection_domain(pd); 23.41 + java_lang_Class::set_protection_domain(k->java_mirror(), pd); 23.42 } 23.43 } 23.44 JVM_END
24.1 --- a/src/share/vm/prims/methodHandles.cpp Mon May 27 12:58:42 2013 +0200 24.2 +++ b/src/share/vm/prims/methodHandles.cpp Fri May 31 09:55:35 2013 +0200 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 24.6 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 24.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.8 * 24.9 * This code is free software; you can redistribute it and/or modify it 24.10 @@ -232,7 +232,8 @@ 24.11 // This is done eagerly, since it is readily available without 24.12 // constructing any new objects. 24.13 // TO DO: maybe intern mname_oop 24.14 - m->method_holder()->add_member_name(mname); 24.15 + m->method_holder()->add_member_name(m->method_idnum(), mname); 24.16 + 24.17 return mname(); 24.18 } 24.19 24.20 @@ -301,7 +302,6 @@ 24.21 // Although the fieldDescriptor::_index would also identify the field, 24.22 // we do not use it, because it is harder to decode. 24.23 // TO DO: maybe intern mname_oop 24.24 - InstanceKlass::cast(field_holder())->add_member_name(mname); 24.25 return mname(); 24.26 } 24.27 24.28 @@ -943,7 +943,8 @@ 24.29 // MemberNameTable 24.30 // 24.31 24.32 -MemberNameTable::MemberNameTable() : GrowableArray<jweak>(10, true) { 24.33 +MemberNameTable::MemberNameTable(int methods_cnt) 24.34 + : GrowableArray<jweak>(methods_cnt, true) { 24.35 assert_locked_or_safepoint(MemberNameTable_lock); 24.36 } 24.37 24.38 @@ -957,29 +958,18 @@ 24.39 } 24.40 } 24.41 24.42 -// Return entry index if found, return -1 otherwise. 24.43 -int MemberNameTable::find_member_name(oop mem_name) { 24.44 +void MemberNameTable::add_member_name(int index, jweak mem_name_wref) { 24.45 assert_locked_or_safepoint(MemberNameTable_lock); 24.46 - int len = this->length(); 24.47 - 24.48 - for (int idx = 0; idx < len; idx++) { 24.49 - jweak ref = this->at(idx); 24.50 - oop entry = JNIHandles::resolve(ref); 24.51 - if (entry == mem_name) { 24.52 - return idx; 24.53 - } 24.54 - } 24.55 - return -1; 24.56 + this->at_put_grow(index, mem_name_wref); 24.57 } 24.58 24.59 -void MemberNameTable::add_member_name(jweak mem_name_wref) { 24.60 +// Return a member name oop or NULL. 24.61 +oop MemberNameTable::get_member_name(int index) { 24.62 assert_locked_or_safepoint(MemberNameTable_lock); 24.63 - oop mem_name = JNIHandles::resolve(mem_name_wref); 24.64 24.65 - // Each member name may appear just once: add only if not found 24.66 - if (find_member_name(mem_name) == -1) { 24.67 - this->append(mem_name_wref); 24.68 - } 24.69 + jweak ref = this->at(index); 24.70 + oop mem_name = JNIHandles::resolve(ref); 24.71 + return mem_name; 24.72 } 24.73 24.74 #if INCLUDE_JVMTI
25.1 --- a/src/share/vm/prims/methodHandles.hpp Mon May 27 12:58:42 2013 +0200 25.2 +++ b/src/share/vm/prims/methodHandles.hpp Fri May 31 09:55:35 2013 +0200 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -219,7 +219,6 @@ 25.11 } 25.12 }; 25.13 25.14 - 25.15 //------------------------------------------------------------------------------ 25.16 // MethodHandlesAdapterGenerator 25.17 // 25.18 @@ -233,13 +232,13 @@ 25.19 //------------------------------------------------------------------------------ 25.20 // MemberNameTable 25.21 // 25.22 + 25.23 class MemberNameTable : public GrowableArray<jweak> { 25.24 public: 25.25 - MemberNameTable(); 25.26 + MemberNameTable(int methods_cnt); 25.27 ~MemberNameTable(); 25.28 - void add_member_name(jweak mem_name_ref); 25.29 - private: 25.30 - int find_member_name(oop mem_name); 25.31 + void add_member_name(int index, jweak mem_name_ref); 25.32 + oop get_member_name(int index); 25.33 25.34 #if INCLUDE_JVMTI 25.35 public:
26.1 --- a/src/share/vm/prims/whitebox.cpp Mon May 27 12:58:42 2013 +0200 26.2 +++ b/src/share/vm/prims/whitebox.cpp Fri May 31 09:55:35 2013 +0200 26.3 @@ -37,6 +37,7 @@ 26.4 #include "runtime/os.hpp" 26.5 #include "utilities/debug.hpp" 26.6 #include "utilities/macros.hpp" 26.7 +#include "utilities/exceptions.hpp" 26.8 26.9 #if INCLUDE_ALL_GCS 26.10 #include "gc_implementation/g1/concurrentMark.hpp" 26.11 @@ -330,8 +331,18 @@ 26.12 WB_END 26.13 26.14 26.15 -WB_ENTRY(jlong, WB_ReserveMemory(JNIEnv* env, jobject o, jlong size)) 26.16 - return (jlong)os::reserve_memory(size, NULL, 0); 26.17 +WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) 26.18 + // static+volatile in order to force the read to happen 26.19 + // (not be eliminated by the compiler) 26.20 + static char c; 26.21 + static volatile char* p; 26.22 + 26.23 + p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0); 26.24 + if (p == NULL) { 26.25 + THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory"); 26.26 + } 26.27 + 26.28 + c = *p; 26.29 WB_END 26.30 26.31 //Some convenience methods to deal with objects from java 26.32 @@ -437,7 +448,7 @@ 26.33 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, 26.34 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, 26.35 26.36 - {CC"reserveMemory", CC"(J)J", (void*)&WB_ReserveMemory }, 26.37 + {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, 26.38 }; 26.39 26.40 #undef CC
27.1 --- a/src/share/vm/runtime/vmStructs.cpp Mon May 27 12:58:42 2013 +0200 27.2 +++ b/src/share/vm/runtime/vmStructs.cpp Fri May 31 09:55:35 2013 +0200 27.3 @@ -292,10 +292,8 @@ 27.4 nonstatic_field(InstanceKlass, _transitive_interfaces, Array<Klass*>*) \ 27.5 nonstatic_field(InstanceKlass, _fields, Array<u2>*) \ 27.6 nonstatic_field(InstanceKlass, _java_fields_count, u2) \ 27.7 - nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ 27.8 + nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ 27.9 nonstatic_field(InstanceKlass, _class_loader_data, ClassLoaderData*) \ 27.10 - nonstatic_field(InstanceKlass, _protection_domain, oop) \ 27.11 - nonstatic_field(InstanceKlass, _signers, objArrayOop) \ 27.12 nonstatic_field(InstanceKlass, _source_file_name, Symbol*) \ 27.13 nonstatic_field(InstanceKlass, _source_debug_extension, char*) \ 27.14 nonstatic_field(InstanceKlass, _inner_classes, Array<jushort>*) \
28.1 --- a/src/share/vm/services/memTracker.cpp Mon May 27 12:58:42 2013 +0200 28.2 +++ b/src/share/vm/services/memTracker.cpp Fri May 31 09:55:35 2013 +0200 28.3 @@ -34,6 +34,7 @@ 28.4 #include "services/memReporter.hpp" 28.5 #include "services/memTracker.hpp" 28.6 #include "utilities/decoder.hpp" 28.7 +#include "utilities/defaultStream.hpp" 28.8 #include "utilities/globalDefinitions.hpp" 28.9 28.10 bool NMT_track_callsite = false; 28.11 @@ -77,7 +78,15 @@ 28.12 if (strcmp(option_line, "=summary") == 0) { 28.13 _tracking_level = NMT_summary; 28.14 } else if (strcmp(option_line, "=detail") == 0) { 28.15 - _tracking_level = NMT_detail; 28.16 + // detail relies on a stack-walking ability that may not 28.17 + // be available depending on platform and/or compiler flags 28.18 + if (PLATFORM_NMT_DETAIL_SUPPORTED) { 28.19 + _tracking_level = NMT_detail; 28.20 + } else { 28.21 + jio_fprintf(defaultStream::error_stream(), 28.22 + "NMT detail is not supported on this platform. Using NMT summary instead."); 28.23 + _tracking_level = NMT_summary; 28.24 + } 28.25 } else if (strcmp(option_line, "=off") != 0) { 28.26 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); 28.27 }
29.1 --- a/src/share/vm/utilities/globalDefinitions.hpp Mon May 27 12:58:42 2013 +0200 29.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp Fri May 31 09:55:35 2013 +0200 29.3 @@ -380,6 +380,14 @@ 29.4 # include "globalDefinitions_ppc.hpp" 29.5 #endif 29.6 29.7 +/* 29.8 + * If a platform does not support NMT_detail 29.9 + * the platform specific globalDefinitions (above) 29.10 + * can set PLATFORM_NMT_DETAIL_SUPPORTED to false 29.11 + */ 29.12 +#ifndef PLATFORM_NMT_DETAIL_SUPPORTED 29.13 +#define PLATFORM_NMT_DETAIL_SUPPORTED true 29.14 +#endif 29.15 29.16 // The byte alignment to be used by Arena::Amalloc. See bugid 4169348. 29.17 // Note: this value must be a power of 2
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/runtime/Metaspace/FragmentMetaspace.java Fri May 31 09:55:35 2013 +0200 30.3 @@ -0,0 +1,64 @@ 30.4 +/* 30.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.7 + * 30.8 + * This code is free software; you can redistribute it and/or modify it 30.9 + * under the terms of the GNU General Public License version 2 only, as 30.10 + * published by the Free Software Foundation. 30.11 + * 30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 30.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 30.15 + * version 2 for more details (a copy is included in the LICENSE file that 30.16 + * accompanied this code). 30.17 + * 30.18 + * You should have received a copy of the GNU General Public License version 30.19 + * 2 along with this work; if not, write to the Free Software Foundation, 30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 30.21 + * 30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 30.23 + * or visit www.oracle.com if you need additional information or have any 30.24 + * questions. 30.25 + */ 30.26 + 30.27 +/** 30.28 + * @test 30.29 + * @library /runtime/testlibrary 30.30 + * @build GeneratedClassLoader 30.31 + * @run main/othervm/timeout=200 FragmentMetaspace 30.32 + */ 30.33 + 30.34 +import java.io.IOException; 30.35 + 30.36 +/** 30.37 + * Test that tries to fragment the native memory used by class loaders. 30.38 + * This test creates class loaders that load classes of increasing size for every 30.39 + * iteration. By increasing the size of the class meta data needed for every iteration 30.40 + * we stress the subsystem for allocating native memory for meta data. 30.41 + */ 30.42 +public class FragmentMetaspace { 30.43 + 30.44 + public static void main(String... args) { 30.45 + runGrowing(Long.valueOf(System.getProperty("time", "80000"))); 30.46 + // try to clean up and unload classes to decrease 30.47 + // class verification time in debug vm 30.48 + System.gc(); 30.49 + } 30.50 + 30.51 + private static void runGrowing(long time) { 30.52 + long startTime = System.currentTimeMillis(); 30.53 + for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) { 30.54 + try { 30.55 + GeneratedClassLoader gcl = new GeneratedClassLoader(); 30.56 + 30.57 + Class<?> c = gcl.getGeneratedClasses(i, 100)[0]; 30.58 + c.newInstance(); 30.59 + c = null; 30.60 + 30.61 + gcl = null; 30.62 + } catch (IOException|InstantiationException|IllegalAccessException ex) { 30.63 + throw new RuntimeException(ex); 30.64 + } 30.65 + } 30.66 + } 30.67 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/runtime/Metaspace/FragmentMetaspaceSimple.java Fri May 31 09:55:35 2013 +0200 31.3 @@ -0,0 +1,69 @@ 31.4 +/* 31.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. 31.11 + * 31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.15 + * version 2 for more details (a copy is included in the LICENSE file that 31.16 + * accompanied this code). 31.17 + * 31.18 + * You should have received a copy of the GNU General Public License version 31.19 + * 2 along with this work; if not, write to the Free Software Foundation, 31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.21 + * 31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.23 + * or visit www.oracle.com if you need additional information or have any 31.24 + * questions. 31.25 + */ 31.26 + 31.27 +/** 31.28 + * @test 31.29 + * @library /runtime/testlibrary 31.30 + * @library classes 31.31 + * @build test.Empty ClassUnloadCommon 31.32 + * @run main/othervm/timeout=200 FragmentMetaspaceSimple 31.33 + */ 31.34 + 31.35 +import java.util.ArrayList; 31.36 + 31.37 +/** 31.38 + * Test that tries to fragment the native memory used by class loaders. 31.39 + * Keeps every other class loader alive in order to fragment the memory space 31.40 + * used to store classes and meta data. Since the memory is probably allocated in 31.41 + * chunks per class loader this will cause a lot of fragmentation if not handled 31.42 + * properly since every other chunk will be unused. 31.43 + */ 31.44 +public class FragmentMetaspaceSimple { 31.45 + public static void main(String... args) { 31.46 + runSimple(Long.valueOf(System.getProperty("time", "80000"))); 31.47 + System.gc(); 31.48 + } 31.49 + 31.50 + private static void runSimple(long time) { 31.51 + long startTime = System.currentTimeMillis(); 31.52 + ArrayList<ClassLoader> cls = new ArrayList<>(); 31.53 + for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) { 31.54 + ClassLoader ldr = ClassUnloadCommon.newClassLoader(); 31.55 + if (i % 1000 == 0) { 31.56 + cls.clear(); 31.57 + } 31.58 + // only keep every other class loader alive 31.59 + if (i % 2 == 1) { 31.60 + cls.add(ldr); 31.61 + } 31.62 + Class<?> c = null; 31.63 + try { 31.64 + c = ldr.loadClass("test.Empty"); 31.65 + } catch (ClassNotFoundException ex) { 31.66 + throw new RuntimeException(ex); 31.67 + } 31.68 + c = null; 31.69 + } 31.70 + cls = null; 31.71 + } 31.72 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/runtime/Metaspace/classes/test/Empty.java Fri May 31 09:55:35 2013 +0200 32.3 @@ -0,0 +1,28 @@ 32.4 +/* 32.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.7 + * 32.8 + * This code is free software; you can redistribute it and/or modify it 32.9 + * under the terms of the GNU General Public License version 2 only, as 32.10 + * published by the Free Software Foundation. 32.11 + * 32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32.15 + * version 2 for more details (a copy is included in the LICENSE file that 32.16 + * accompanied this code). 32.17 + * 32.18 + * You should have received a copy of the GNU General Public License version 32.19 + * 2 along with this work; if not, write to the Free Software Foundation, 32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 32.21 + * 32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 32.23 + * or visit www.oracle.com if you need additional information or have any 32.24 + * questions. 32.25 + */ 32.26 + 32.27 +package test; 32.28 + 32.29 +public class Empty { 32.30 +public String toString() { return "nothing"; } 32.31 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/runtime/contended/HasNonStatic.java Fri May 31 09:55:35 2013 +0200 33.3 @@ -0,0 +1,75 @@ 33.4 +/* 33.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.7 + * 33.8 + * This code is free software; you can redistribute it and/or modify it 33.9 + * under the terms of the GNU General Public License version 2 only, as 33.10 + * published by the Free Software Foundation. 33.11 + * 33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 33.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33.15 + * version 2 for more details (a copy is included in the LICENSE file that 33.16 + * accompanied this code). 33.17 + * 33.18 + * You should have received a copy of the GNU General Public License version 33.19 + * 2 along with this work; if not, write to the Free Software Foundation, 33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 33.21 + * 33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 33.23 + * or visit www.oracle.com if you need additional information or have any 33.24 + * questions. 33.25 + */ 33.26 + 33.27 +import java.io.BufferedReader; 33.28 +import java.io.InputStreamReader; 33.29 +import java.lang.Class; 33.30 +import java.lang.String; 33.31 +import java.lang.System; 33.32 +import java.lang.management.ManagementFactory; 33.33 +import java.lang.management.RuntimeMXBean; 33.34 +import java.util.ArrayList; 33.35 +import java.util.List; 33.36 +import java.util.concurrent.CyclicBarrier; 33.37 +import java.util.regex.Matcher; 33.38 +import java.util.regex.Pattern; 33.39 +import java.lang.reflect.Field; 33.40 +import java.lang.reflect.Modifier; 33.41 +import sun.misc.Unsafe; 33.42 +import sun.misc.Contended; 33.43 + 33.44 +/* 33.45 + * @test 33.46 + * @bug 8015270 33.47 + * @summary \@Contended: fix multiple issues in the layout code 33.48 + * 33.49 + * @run main/othervm -XX:-RestrictContended HasNonStatic 33.50 + */ 33.51 +public class HasNonStatic { 33.52 + 33.53 + public static void main(String[] args) throws Exception { 33.54 + R1 r1 = new R1(); 33.55 + R2 r2 = new R2(); 33.56 + R3 r3 = new R3(); 33.57 + R4 r4 = new R4(); 33.58 + } 33.59 + 33.60 + public static class R1 { 33.61 + @Contended 33.62 + Object o; 33.63 + } 33.64 + 33.65 + @Contended 33.66 + public static class R2 { 33.67 + Object o; 33.68 + } 33.69 + 33.70 + @Contended 33.71 + public static class R3 { 33.72 + } 33.73 + 33.74 + public static class R4 extends R3 { 33.75 + } 33.76 + 33.77 +} 33.78 +
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/runtime/contended/OopMaps.java Fri May 31 09:55:35 2013 +0200 34.3 @@ -0,0 +1,166 @@ 34.4 +/* 34.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.7 + * 34.8 + * This code is free software; you can redistribute it and/or modify it 34.9 + * under the terms of the GNU General Public License version 2 only, as 34.10 + * published by the Free Software Foundation. 34.11 + * 34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 34.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34.15 + * version 2 for more details (a copy is included in the LICENSE file that 34.16 + * accompanied this code). 34.17 + * 34.18 + * You should have received a copy of the GNU General Public License version 34.19 + * 2 along with this work; if not, write to the Free Software Foundation, 34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 34.21 + * 34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 34.23 + * or visit www.oracle.com if you need additional information or have any 34.24 + * questions. 34.25 + */ 34.26 + 34.27 +import java.io.BufferedReader; 34.28 +import java.io.InputStreamReader; 34.29 +import java.lang.Class; 34.30 +import java.lang.String; 34.31 +import java.lang.System; 34.32 +import java.lang.management.ManagementFactory; 34.33 +import java.lang.management.RuntimeMXBean; 34.34 +import java.util.ArrayList; 34.35 +import java.util.List; 34.36 +import java.util.concurrent.CyclicBarrier; 34.37 +import java.util.regex.Matcher; 34.38 +import java.util.regex.Pattern; 34.39 +import java.lang.reflect.Field; 34.40 +import java.lang.reflect.Modifier; 34.41 +import sun.misc.Unsafe; 34.42 +import sun.misc.Contended; 34.43 + 34.44 +/* 34.45 + * @test 34.46 + * @bug 8015270 34.47 + * @bug 8015493 34.48 + * @summary \@Contended: fix multiple issues in the layout code 34.49 + * 34.50 + * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMaps 34.51 + */ 34.52 +public class OopMaps { 34.53 + 34.54 + public static final int COUNT = 10000; 34.55 + 34.56 + public static void main(String[] args) throws Exception { 34.57 + Object o01 = new Object(); 34.58 + Object o02 = new Object(); 34.59 + Object o03 = new Object(); 34.60 + Object o04 = new Object(); 34.61 + Object o05 = new Object(); 34.62 + Object o06 = new Object(); 34.63 + Object o07 = new Object(); 34.64 + Object o08 = new Object(); 34.65 + Object o09 = new Object(); 34.66 + Object o10 = new Object(); 34.67 + Object o11 = new Object(); 34.68 + Object o12 = new Object(); 34.69 + Object o13 = new Object(); 34.70 + Object o14 = new Object(); 34.71 + 34.72 + R1[] rs = new R1[COUNT]; 34.73 + 34.74 + for (int i = 0; i < COUNT; i++) { 34.75 + R1 r1 = new R1(); 34.76 + r1.o01 = o01; 34.77 + r1.o02 = o02; 34.78 + r1.o03 = o03; 34.79 + r1.o04 = o04; 34.80 + r1.o05 = o05; 34.81 + r1.o06 = o06; 34.82 + r1.o07 = o07; 34.83 + r1.o08 = o08; 34.84 + r1.o09 = o09; 34.85 + r1.o10 = o10; 34.86 + r1.o11 = o11; 34.87 + r1.o12 = o12; 34.88 + r1.o13 = o13; 34.89 + r1.o14 = o14; 34.90 + r1.i1 = 1; 34.91 + r1.i2 = 2; 34.92 + r1.i3 = 3; 34.93 + r1.i4 = 4; 34.94 + rs[i] = r1; 34.95 + } 34.96 + 34.97 + System.gc(); 34.98 + 34.99 + for (int i = 0; i < COUNT; i++) { 34.100 + R1 r1 = rs[i]; 34.101 + if (r1.o01 != o01) throw new Error("Test Error: o01"); 34.102 + if (r1.o02 != o02) throw new Error("Test Error: o02"); 34.103 + if (r1.o03 != o03) throw new Error("Test Error: o03"); 34.104 + if (r1.o04 != o04) throw new Error("Test Error: o04"); 34.105 + if (r1.o05 != o05) throw new Error("Test Error: o05"); 34.106 + if (r1.o06 != o06) throw new Error("Test Error: o06"); 34.107 + if (r1.o07 != o07) throw new Error("Test Error: o07"); 34.108 + if (r1.o08 != o08) throw new Error("Test Error: o08"); 34.109 + if (r1.o09 != o09) throw new Error("Test Error: o09"); 34.110 + if (r1.o10 != o10) throw new Error("Test Error: o10"); 34.111 + if (r1.o11 != o11) throw new Error("Test Error: o11"); 34.112 + if (r1.o12 != o12) throw new Error("Test Error: o12"); 34.113 + if (r1.o13 != o13) throw new Error("Test Error: o13"); 34.114 + if (r1.o14 != o14) throw new Error("Test Error: o14"); 34.115 + if (r1.i1 != 1) throw new Error("Test Error: i1"); 34.116 + if (r1.i2 != 2) throw new Error("Test Error: i2"); 34.117 + if (r1.i3 != 3) throw new Error("Test Error: i3"); 34.118 + if (r1.i4 != 4) throw new Error("Test Error: i4"); 34.119 + } 34.120 + } 34.121 + 34.122 + public static class R0 { 34.123 + int i1; 34.124 + int i2; 34.125 + 34.126 + Object o01; 34.127 + Object o02; 34.128 + 34.129 + @Contended 34.130 + Object o03; 34.131 + 34.132 + @Contended 34.133 + Object o04; 34.134 + 34.135 + @Contended 34.136 + Object o05; 34.137 + 34.138 + @Contended 34.139 + Object o06; 34.140 + 34.141 + @Contended 34.142 + Object o07; 34.143 + } 34.144 + 34.145 + public static class R1 extends R0 { 34.146 + int i3; 34.147 + int i4; 34.148 + 34.149 + Object o08; 34.150 + Object o09; 34.151 + 34.152 + @Contended 34.153 + Object o10; 34.154 + 34.155 + @Contended 34.156 + Object o11; 34.157 + 34.158 + @Contended 34.159 + Object o12; 34.160 + 34.161 + @Contended 34.162 + Object o13; 34.163 + 34.164 + @Contended 34.165 + Object o14; 34.166 + } 34.167 + 34.168 +} 34.169 +
35.1 --- a/test/runtime/memory/ReserveMemory.java Mon May 27 12:58:42 2013 +0200 35.2 +++ b/test/runtime/memory/ReserveMemory.java Fri May 31 09:55:35 2013 +0200 35.3 @@ -34,29 +34,20 @@ 35.4 35.5 import com.oracle.java.testlibrary.*; 35.6 35.7 -import java.lang.reflect.Field; 35.8 import sun.hotspot.WhiteBox; 35.9 -import sun.misc.Unsafe; 35.10 35.11 public class ReserveMemory { 35.12 - private static Unsafe getUnsafe() throws Exception { 35.13 - Field f = Unsafe.class.getDeclaredField("theUnsafe"); 35.14 - f.setAccessible(true); 35.15 - return (Unsafe)f.get(null); 35.16 - } 35.17 - 35.18 private static boolean isWindows() { 35.19 return System.getProperty("os.name").toLowerCase().startsWith("win"); 35.20 } 35.21 35.22 + private static boolean isOsx() { 35.23 + return System.getProperty("os.name").toLowerCase().startsWith("mac"); 35.24 + } 35.25 + 35.26 public static void main(String args[]) throws Exception { 35.27 if (args.length > 0) { 35.28 - long address = WhiteBox.getWhiteBox().reserveMemory(4096); 35.29 - 35.30 - System.out.println("Reserved memory at address: 0x" + Long.toHexString(address)); 35.31 - System.out.println("Will now read from the address, expecting a crash!"); 35.32 - 35.33 - int x = getUnsafe().getInt(address); 35.34 + WhiteBox.getWhiteBox().readReservedMemory(); 35.35 35.36 throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"); 35.37 } 35.38 @@ -71,6 +62,8 @@ 35.39 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 35.40 if (isWindows()) { 35.41 output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); 35.42 + } else if (isOsx()) { 35.43 + output.shouldContain("SIGBUS"); 35.44 } else { 35.45 output.shouldContain("SIGSEGV"); 35.46 }
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/test/runtime/testlibrary/GeneratedClassLoader.java Fri May 31 09:55:35 2013 +0200 36.3 @@ -0,0 +1,202 @@ 36.4 +/* 36.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.7 + * 36.8 + * This code is free software; you can redistribute it and/or modify it 36.9 + * under the terms of the GNU General Public License version 2 only, as 36.10 + * published by the Free Software Foundation. 36.11 + * 36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36.15 + * version 2 for more details (a copy is included in the LICENSE file that 36.16 + * accompanied this code). 36.17 + * 36.18 + * You should have received a copy of the GNU General Public License version 36.19 + * 2 along with this work; if not, write to the Free Software Foundation, 36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 36.21 + * 36.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 36.23 + * or visit www.oracle.com if you need additional information or have any 36.24 + * questions. 36.25 + */ 36.26 + 36.27 +import java.io.DataInputStream; 36.28 +import java.io.File; 36.29 +import java.io.FileInputStream; 36.30 +import java.io.FileWriter; 36.31 +import java.io.IOException; 36.32 +import java.io.PrintWriter; 36.33 +import javax.tools.JavaCompiler; 36.34 +import javax.tools.ToolProvider; 36.35 + 36.36 +/** 36.37 + * A class loader that generates new classes. 36.38 + * The generated classes are made by first emitting java sources with nested 36.39 + * static classes, these are then compiled and the class files are read back. 36.40 + * Some efforts are made to make the class instances unique and of not insignificant 36.41 + * size. 36.42 + */ 36.43 +public class GeneratedClassLoader extends ClassLoader { 36.44 + /** 36.45 + * Holds a pair of class bytecodes and class name (for use with defineClass). 36.46 + */ 36.47 + private static class GeneratedClass { 36.48 + public byte[] bytes; 36.49 + public String name; 36.50 + public GeneratedClass(byte[] bytes, String name) { 36.51 + this.bytes = bytes; this.name = name; 36.52 + } 36.53 + } 36.54 + 36.55 + /** 36.56 + * Used to uniquely name every class generated. 36.57 + */ 36.58 + private static int count = 0; 36.59 + /** 36.60 + * Used to enable/disable keeping the class files and java sources for 36.61 + * the generated classes. 36.62 + */ 36.63 + private static boolean deleteFiles = Boolean.parseBoolean( 36.64 + System.getProperty("GeneratedClassLoader.deleteFiles", "true")); 36.65 + 36.66 + private static String bigstr = 36.67 + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " 36.68 + + "In facilisis scelerisque vehicula. Donec congue nisi a " 36.69 + + "leo posuere placerat lobortis felis ultrices. Pellentesque " 36.70 + + "habitant morbi tristique senectus et netus et malesuada " 36.71 + + "fames ac turpis egestas. Nam tristique velit at felis " 36.72 + + "iaculis at tempor sem vestibulum. Sed adipiscing lectus " 36.73 + + "non mi molestie sagittis. Morbi eu purus urna. Nam tempor " 36.74 + + "tristique massa eget semper. Mauris cursus, nulla et ornare " 36.75 + + "vehicula, leo dolor scelerisque metus, sit amet rutrum erat " 36.76 + + "sapien quis dui. Nullam eleifend risus et velit accumsan sed " 36.77 + + "suscipit felis pulvinar. Nullam faucibus suscipit gravida. " 36.78 + + "Pellentesque habitant morbi tristique senectus et netus et " 36.79 + + "malesuada fames ac turpis egestas. Nullam ut massa augue, " 36.80 + + "nec viverra mauris."; 36.81 + 36.82 + private static int getNextCount() { 36.83 + return count++; 36.84 + } 36.85 + 36.86 + ////// end statics 36.87 + 36.88 + private JavaCompiler javac; 36.89 + private String nameBase; 36.90 + 36.91 + public GeneratedClassLoader() { 36.92 + javac = ToolProvider.getSystemJavaCompiler(); 36.93 + nameBase = "TestSimpleClass"; 36.94 + } 36.95 + 36.96 + private long getBigValue(int which) { 36.97 + // > 65536 is too large to encode in the bytecode 36.98 + // so this will force us to emit a constant pool entry for this int 36.99 + return (long)which + 65537; 36.100 + } 36.101 + 36.102 + private String getBigString(int which) { 36.103 + return bigstr + which; 36.104 + } 36.105 + 36.106 + private String getClassName(int count) { 36.107 + return nameBase + count; 36.108 + } 36.109 + 36.110 + private String generateSource(int count, int sizeFactor, int numClasses) { 36.111 + StringBuilder sb = new StringBuilder(); 36.112 + sb.append("public class ").append(getClassName(count)).append("{\n"); 36.113 + for (int j = 0; j < numClasses; ++j) { 36.114 + sb.append("public static class ") 36.115 + .append("Class") 36.116 + .append(j) 36.117 + .append("{\n"); 36.118 + for (int i = 0; i < sizeFactor; ++i) { 36.119 + int value = i; 36.120 + sb.append("private long field") 36.121 + .append(i).append(" = ") 36.122 + .append(getBigValue(value++)) 36.123 + .append(";\n"); 36.124 + sb.append("public long method") 36.125 + .append(i) 36.126 + .append("() {\n"); 36.127 + sb.append("return ") 36.128 + .append(getBigValue(value++)) 36.129 + .append(";"); 36.130 + sb.append("}\n"); 36.131 + sb.append("private String str").append(i) 36.132 + .append(" = \"") 36.133 + .append(getBigString(i)) 36.134 + .append("\";"); 36.135 + } 36.136 + sb.append("\n}"); 36.137 + } 36.138 + sb.append("\n}"); 36.139 + return sb.toString(); 36.140 + } 36.141 + 36.142 + private GeneratedClass[] getGeneratedClass(int sizeFactor, int numClasses) throws IOException { 36.143 + int uniqueCount = getNextCount(); 36.144 + String src = generateSource(uniqueCount, sizeFactor, numClasses); 36.145 + String className = getClassName(uniqueCount); 36.146 + File file = new File(className + ".java"); 36.147 + try (PrintWriter pw = new PrintWriter(new FileWriter(file))) { 36.148 + pw.append(src); 36.149 + pw.flush(); 36.150 + } 36.151 + int exitcode = javac.run(null, null, null, file.getCanonicalPath()); 36.152 + if (exitcode != 0) { 36.153 + throw new RuntimeException("javac failure when compiling: " + 36.154 + file.getCanonicalPath()); 36.155 + } else { 36.156 + if (deleteFiles) { 36.157 + file.delete(); 36.158 + } 36.159 + } 36.160 + GeneratedClass[] gc = new GeneratedClass[numClasses]; 36.161 + for (int i = 0; i < numClasses; ++i) { 36.162 + String name = className + "$" + "Class" + i; 36.163 + File classFile = new File(name + ".class"); 36.164 + byte[] bytes; 36.165 + try (DataInputStream dis = new DataInputStream(new FileInputStream(classFile))) { 36.166 + bytes = new byte[dis.available()]; 36.167 + dis.readFully(bytes); 36.168 + } 36.169 + if (deleteFiles) { 36.170 + classFile.delete(); 36.171 + } 36.172 + gc[i] = new GeneratedClass(bytes, name); 36.173 + } 36.174 + if (deleteFiles) { 36.175 + new File(className + ".class").delete(); 36.176 + } 36.177 + return gc; 36.178 + } 36.179 + 36.180 + /** 36.181 + * Generate a single class, compile it and load it. 36.182 + * @param sizeFactor Fuzzy measure of how large the class should be. 36.183 + * @return the Class instance. 36.184 + * @throws IOException 36.185 + */ 36.186 + public Class<?> generateClass(int sizeFactor) throws IOException { 36.187 + return getGeneratedClasses(sizeFactor, 1)[0]; 36.188 + } 36.189 + 36.190 + /** 36.191 + * Generate several classes, compile and load them. 36.192 + * @param sizeFactor Fuzzy measure of how large each class should be. 36.193 + * @param numClasses The number of classes to create 36.194 + * @return an array of the Class instances. 36.195 + * @throws IOException 36.196 + */ 36.197 + public Class<?>[] getGeneratedClasses(int sizeFactor, int numClasses) throws IOException { 36.198 + GeneratedClass[] gc = getGeneratedClass(sizeFactor, numClasses); 36.199 + Class<?>[] classes = new Class[numClasses]; 36.200 + for (int i = 0; i < numClasses; ++i) { 36.201 + classes[i] = defineClass(gc[i].name, gc[i].bytes, 0 , gc[i].bytes.length); 36.202 + } 36.203 + return classes; 36.204 + } 36.205 +}
37.1 --- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Mon May 27 12:58:42 2013 +0200 37.2 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Fri May 31 09:55:35 2013 +0200 37.3 @@ -115,7 +115,7 @@ 37.4 public native boolean isInStringTable(String str); 37.5 37.6 // Memory 37.7 - public native long reserveMemory(long size); 37.8 + public native void readReservedMemory(); 37.9 37.10 // force Full GC 37.11 public native void fullGC();