# HG changeset patch # User lana # Date 1295492495 28800 # Node ID c19058ce05e8b58286d0ca0431733a81ed4957a1 # Parent d534dd80da9fe4531b770dd363043be31ee53ae7# Parent f1df068076986679ea1105532a65529d63a89060 Merge diff -r d534dd80da9f -r c19058ce05e8 .hgtags --- a/.hgtags Tue Jan 18 08:37:05 2011 -0800 +++ b/.hgtags Wed Jan 19 19:01:35 2011 -0800 @@ -98,3 +98,5 @@ 0ce0a2c3a6926677dc507839a820ab6625541e5a jdk7-b121 6f09ea1c034f087916d2a8cf0d22be768400118f jdk7-b122 142129d8599d1f56b29387e7f9a5fad53b6d61df jdk7-b123 +aa894c225b1a517b665ac2a58295217ea2245134 jdk7-b124 +f658ec2730fa29323c36d23c27e54c7219ef5e16 jdk7-b125 diff -r d534dd80da9f -r c19058ce05e8 .hgtags-top-repo --- a/.hgtags-top-repo Tue Jan 18 08:37:05 2011 -0800 +++ b/.hgtags-top-repo Wed Jan 19 19:01:35 2011 -0800 @@ -98,3 +98,5 @@ 2c2d4f88637b488014c37e1a2eb401f68bca8838 jdk7-b121 f1591eed71f64f6eba79fb7426f5616cc4dfea73 jdk7-b122 ed6950da30cf1e8904b4bdb034d471647942271f jdk7-b123 +024a6755895bf91b5a3c98984c89ee018efbf538 jdk7-b124 +5c4df7e992775c102f08e9f1c0a124b324641b70 jdk7-b125 diff -r d534dd80da9f -r c19058ce05e8 corba/.hgtags --- a/corba/.hgtags Tue Jan 18 08:37:05 2011 -0800 +++ b/corba/.hgtags Wed Jan 19 19:01:35 2011 -0800 @@ -98,3 +98,5 @@ 2cc9f32992101732b23730b737740e64ebc5fa89 jdk7-b121 1523a060032c8a5b7840198da8911abeff88118f jdk7-b122 a230c142628cea22475ab9dc5cd544266ddf2466 jdk7-b123 +f90b3e014e831eb4f32ef035a1dad2b8ba87949f jdk7-b124 +1ce58c72b7892cb813eb920276c7e7f17a1b79fe jdk7-b125 diff -r d534dd80da9f -r c19058ce05e8 hotspot/.hgtags --- a/hotspot/.hgtags Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/.hgtags Wed Jan 19 19:01:35 2011 -0800 @@ -138,3 +138,6 @@ 5484e7c53fa7da5e869902437ee08a9ae10c1c69 hs20-b03 9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 jdk7-b123 9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 hs20-b04 +0a8e0d4345b37b71ec49dda08ee03b68c4f1b592 jdk7-b124 +0a8e0d4345b37b71ec49dda08ee03b68c4f1b592 hs20-b05 +e24ab3fa6aafad3efabbe7dba9918c5f461a20b1 jdk7-b125 diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,15 +99,8 @@ long typeEntrySizeOffset; long typeEntryArrayStride; - typeEntryTypeNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset"); - typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset"); - typeEntryIsOopTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset"); - typeEntryIsIntegerTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset"); - typeEntryIsUnsignedOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset"); - typeEntrySizeOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset"); - typeEntryArrayStride = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride"); - - // Fetch the address of the VMTypeEntry* + // Fetch the address of the VMTypeEntry*. We get this symbol first + // and try to use it to make sure that symbol lookup is working. Address entryAddr = lookupInProcess("gHotSpotVMTypes"); // System.err.println("gHotSpotVMTypes address = " + entryAddr); // Dereference this once to get the pointer to the first VMTypeEntry @@ -118,6 +111,14 @@ throw new RuntimeException("gHotSpotVMTypes was not initialized properly in the remote process; can not continue"); } + typeEntryTypeNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset"); + typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset"); + typeEntryIsOopTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset"); + typeEntryIsIntegerTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset"); + typeEntryIsUnsignedOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset"); + typeEntrySizeOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset"); + typeEntryArrayStride = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride"); + // Start iterating down it until we find an entry with no name Address typeNameAddr = null; do { diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,10 +122,14 @@ private MemoizedObject[] sectionHeaders; private MemoizedObject[] symbols; + // Init stringTable at decl time since other fields init'ed in the + // constructor need the String Table. private MemoizedObject stringTable = new MemoizedObject() { public Object computeValue() { + // the String Table follows the Symbol Table int ptr = getPointerToSymbolTable(); if (ptr == 0) { + // no Symbol Table so no String Table return new StringTable(0); } else { return new StringTable(ptr + SYMBOL_SIZE * getNumberOfSymbols()); @@ -140,6 +144,8 @@ timeDateStamp = readInt(); pointerToSymbolTable = readInt(); numberOfSymbols = readInt(); + // String Table can be accessed at this point because + // pointerToSymbolTable and numberOfSymbols fields are set. sizeOfOptionalHeader = readShort(); characteristics = readShort(); @@ -222,6 +228,8 @@ private MemoizedObject windowsSpecificFields; private MemoizedObject dataDirectories; + // We use an offset of 2 because OptionalHeaderStandardFieldsImpl doesn't + // include the 'magic' field. private static final int STANDARD_FIELDS_OFFSET = 2; private static final int PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET = 28; private static final int PE32_DATA_DIRECTORIES_OFFSET = 96; @@ -288,7 +296,7 @@ private int sizeOfUninitializedData; private int addressOfEntryPoint; private int baseOfCode; - private int baseOfData; + private int baseOfData; // only set in PE32 OptionalHeaderStandardFieldsImpl(int offset, boolean isPE32Plus) { @@ -301,7 +309,8 @@ sizeOfUninitializedData = readInt(); addressOfEntryPoint = readInt(); baseOfCode = readInt(); - if (isPE32Plus) { + if (!isPE32Plus) { + // only available in PE32 baseOfData = readInt(); } } @@ -433,7 +442,10 @@ if (dir.getRVA() == 0 || dir.getSize() == 0) { return null; } - return new ExportDirectoryTableImpl(rvaToFileOffset(dir.getRVA()), dir.getSize()); + // ExportDirectoryTableImpl needs both the RVA and the + // RVA converted to a file offset. + return new + ExportDirectoryTableImpl(dir.getRVA(), dir.getSize()); } }; @@ -526,6 +538,7 @@ } class ExportDirectoryTableImpl implements ExportDirectoryTable { + private int exportDataDirRVA; private int offset; private int size; @@ -548,8 +561,9 @@ private MemoizedObject exportOrdinalTable; private MemoizedObject exportAddressTable; - ExportDirectoryTableImpl(int offset, int size) { - this.offset = offset; + ExportDirectoryTableImpl(int exportDataDirRVA, int size) { + this.exportDataDirRVA = exportDataDirRVA; + offset = rvaToFileOffset(exportDataDirRVA); this.size = size; seek(offset); exportFlags = readInt(); @@ -595,6 +609,7 @@ exportOrdinalTable = new MemoizedObject() { public Object computeValue() { + // number of ordinals is same as the number of name pointers short[] ordinals = new short[getNumberOfNamePointers()]; seek(rvaToFileOffset(getOrdinalTableRVA())); for (int i = 0; i < ordinals.length; i++) { @@ -608,14 +623,18 @@ public Object computeValue() { int[] addresses = new int[getNumberOfAddressTableEntries()]; seek(rvaToFileOffset(getExportAddressTableRVA())); - // Must make two passes to avoid rvaToFileOffset - // destroying seek() position + // The Export Address Table values are a union of two + // possible values: + // Export RVA - The address of the exported symbol when + // loaded into memory, relative to the image base. + // This value doesn't get converted into a file offset. + // Forwarder RVA - The pointer to a null-terminated ASCII + // string in the export section. This value gets + // converted into a file offset because we have to + // fetch the string. for (int i = 0; i < addresses.length; i++) { addresses[i] = readInt(); } - for (int i = 0; i < addresses.length; i++) { - addresses[i] = rvaToFileOffset(addresses[i]); - } return addresses; } }; @@ -648,11 +667,12 @@ public boolean isExportAddressForwarder(short ordinal) { int addr = getExportAddress(ordinal); - return ((offset <= addr) && (addr < (offset + size))); + return ((exportDataDirRVA <= addr) && + (addr < (exportDataDirRVA + size))); } public String getExportAddressForwarder(short ordinal) { - seek(getExportAddress(ordinal)); + seek(rvaToFileOffset(getExportAddress(ordinal))); return readCString(); } @@ -3371,10 +3391,17 @@ throw new COFFException(e); } // Look up in string table + // FIXME: this index value is assumed to be in the valid range name = getStringTable().get(index); } else { try { - name = new String(tmpName, US_ASCII); + int length = 0; + // find last non-NULL + for (; length < tmpName.length && tmpName[length] != '\0';) { + length++; + } + // don't include NULL chars in returned name String + name = new String(tmpName, 0, length, US_ASCII); } catch (UnsupportedEncodingException e) { throw new COFFException(e); } @@ -3487,6 +3514,7 @@ tmpName[5] << 16 | tmpName[6] << 8 | tmpName[7]); + // FIXME: stringOffset is assumed to be in the valid range name = getStringTable().getAtOffset(stringOffset); } @@ -3698,12 +3726,13 @@ StringTable(int offset) { if (offset == 0) { + // no String Table strings = new COFFString[0]; return; } seek(offset); - int length = readInt(); + int length = readInt(); // length includes itself byte[] data = new byte[length - 4]; int numBytesRead = readBytes(data); if (numBytesRead != data.length) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,35 +37,48 @@ String filename = args[0]; COFFFile file = COFFFileParser.getParser().parse(filename); - ExportDirectoryTable exports = - file.getHeader(). - getOptionalHeader(). - getDataDirectories(). - getExportDirectoryTable(); + + // get common point for both things we want to dump + OptionalHeaderDataDirectories dataDirs = file.getHeader().getOptionalHeader(). + getDataDirectories(); + + // dump the header data directory for the Export Table: + DataDirectory dir = dataDirs.getExportTable(); + System.out.println("Export table: RVA = " + dir.getRVA() + "/0x" + + Integer.toHexString(dir.getRVA()) + ", size = " + dir.getSize() + "/0x" + + Integer.toHexString(dir.getSize())); + + System.out.println(file.getHeader().getNumberOfSections() + " sections in file"); + for (int i = 1; i <= file.getHeader().getNumberOfSections(); i++) { + SectionHeader sec = file.getHeader().getSectionHeader(i); + System.out.println(" Section " + i + ":"); + System.out.println(" Name = '" + sec.getName() + "'"); + System.out.println(" VirtualSize = " + sec.getSize() + "/0x" + + Integer.toHexString(sec.getSize())); + System.out.println(" VirtualAddress = " + sec.getVirtualAddress() + "/0x" + + Integer.toHexString(sec.getVirtualAddress())); + System.out.println(" SizeOfRawData = " + sec.getSizeOfRawData() + "/0x" + + Integer.toHexString(sec.getSizeOfRawData())); + System.out.println(" PointerToRawData = " + sec.getPointerToRawData() + "/0x" + + Integer.toHexString(sec.getPointerToRawData())); + } + + ExportDirectoryTable exports = dataDirs.getExportDirectoryTable(); if (exports == null) { System.out.println("No exports found."); } else { - System.out.println(file.getHeader().getNumberOfSections() + " sections in file"); - for (int i = 0; i < file.getHeader().getNumberOfSections(); i++) { - System.out.println(" Section " + i + ": " + file.getHeader().getSectionHeader(1 + i).getName()); - } - - DataDirectory dir = file.getHeader().getOptionalHeader().getDataDirectories().getExportTable(); - System.out.println("Export table: RVA = 0x" + Integer.toHexString(dir.getRVA()) + - ", size = 0x" + Integer.toHexString(dir.getSize())); - System.out.println("DLL name: " + exports.getDLLName()); System.out.println("Time/date stamp 0x" + Integer.toHexString(exports.getTimeDateStamp())); System.out.println("Major version 0x" + Integer.toHexString(exports.getMajorVersion() & 0xFFFF)); System.out.println("Minor version 0x" + Integer.toHexString(exports.getMinorVersion() & 0xFFFF)); - System.out.println(exports.getNumberOfNamePointers() + " functions found"); + System.out.println(exports.getNumberOfNamePointers() + " exports found"); for (int i = 0; i < exports.getNumberOfNamePointers(); i++) { - System.out.println(" 0x" + - Integer.toHexString(exports.getExportAddress(exports.getExportOrdinal(i))) + - " " + - (exports.isExportAddressForwarder(exports.getExportOrdinal(i)) ? - ("Forwarded to " + exports.getExportAddressForwarder(exports.getExportOrdinal(i))) : - exports.getExportName(i))); + short ordinal = exports.getExportOrdinal(i); + System.out.print("[" + i + "] '" + exports.getExportName(i) + "': [" + + ordinal + "] = 0x" + Integer.toHexString(exports.getExportAddress(ordinal))); + System.out.println(exports.isExportAddressForwarder(ordinal) + ? " Forwarded to '" + exports.getExportAddressForwarder(ordinal) + "'" + : ""); } } } diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,8 +42,8 @@ COFFHeader header = file.getHeader(); int numSections = header.getNumberOfSections(); System.out.println(numSections + " sections detected."); - for (int i = 0; i < numSections; i++) { - SectionHeader secHeader = header.getSectionHeader(1 + i); + for (int i = 1; i <= numSections; i++) { + SectionHeader secHeader = header.getSectionHeader(i); System.out.println(secHeader.getName()); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -506,7 +506,6 @@ throw new DebuggerException("Unimplemented"); } - private static String DTFWHome; private static String imagePath; private static String symbolPath; private static boolean useNativeLookup; @@ -514,81 +513,143 @@ static { /* - * sawindbg.dll depends on dbgeng.dll which - * itself depends on dbghelp.dll. dbgeng.dll and dbghelp.dll. - * On systems newer than Windows 2000, these two .dlls are - * in the standard system directory so we will find them there. - * On Windows 2000 and earlier, these files do not exist. - * The user must download Debugging Tools For Windows (DTFW) - * and install it in order to use SA. + * sawindbg.dll depends on dbgeng.dll which itself depends on + * dbghelp.dll. We have to make sure that the dbgeng.dll and + * dbghelp.dll that we load are compatible with each other. We + * load both of those libraries from the same directory based + * on the theory that co-located libraries are compatible. + * + * On Windows 2000 and earlier, dbgeng.dll and dbghelp.dll were + * not included as part of the standard system directory. On + * systems newer than Windows 2000, dbgeng.dll and dbghelp.dll + * are included in the standard system directory. However, the + * versions included in the standard system directory may not + * be able to handle symbol information for the newer compilers. + * + * We search for and explicitly load the libraries using the + * following directory search order: * - * We have to make sure we use the two files from the same directory - * in case there are more than one copy on the system because - * one version of dbgeng.dll might not be compatible with a - * different version of dbghelp.dll. - * We first look for them in the directory pointed at by - * env. var. DEBUGGINGTOOLSFORWINDOWS, next in the default - * installation dir for DTFW, and lastly in the standard - * system directory. We expect that that we will find - * them in the standard system directory on all systems - * newer than Windows 2000. + * - java.home/bin (same as $JAVA_HOME/jre/bin) + * - dir named by DEBUGGINGTOOLSFORWINDOWS environment variable + * - various "Debugging Tools For Windows" program directories + * - the system directory ($SYSROOT/system32) + * + * If SA is invoked with -Dsun.jvm.hotspot.loadLibrary.DEBUG=1, + * then debug messages about library loading are printed to + * System.err. */ - String dirName = null; - DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); - if (DTFWHome == null) { - // See if we have the files in the default location. - String sysRoot = System.getenv("SYSTEMROOT"); - DTFWHome = sysRoot + File.separator + - ".." + File.separator + "Program Files" + - File.separator + "Debugging Tools For Windows"; - } + String dbgengPath = null; + String dbghelpPath = null; + String sawindbgPath = null; + List searchList = new ArrayList(); + + boolean loadLibraryDEBUG = + System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null; { - String dbghelp = DTFWHome + File.separator + "dbghelp.dll"; - String dbgeng = DTFWHome + File.separator + "dbgeng.dll"; - File fhelp = new File(dbghelp); - File feng = new File(dbgeng); - if (fhelp.exists() && feng.exists()) { - // found both, we are happy. - // NOTE: The order of loads is important! If we load dbgeng.dll - // first, then the dependency - dbghelp.dll - will be loaded - // from usual DLL search thereby defeating the purpose! - System.load(dbghelp); - System.load(dbgeng); - } else if (! fhelp.exists() && ! feng.exists()) { - // neither exist. We will ignore this dir and assume - // they are in the system dir. - DTFWHome = null; - } else { - // one exists but not the other - //System.err.println("Error: Both files dbghelp.dll and dbgeng.dll " - // "must exist in directory " + DTFWHome); - throw new UnsatisfiedLinkError("Both files dbghelp.dll and " + - "dbgeng.dll must exist in " + - "directory " + DTFWHome); + // First place to search is co-located with sawindbg.dll in + // $JAVA_HOME/jre/bin (java.home property is set to $JAVA_HOME/jre): + searchList.add(System.getProperty("java.home") + File.separator + "bin"); + sawindbgPath = (String) searchList.get(0) + File.separator + + "sawindbg.dll"; + + // second place to search is specified by an environment variable: + String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); + if (DTFWHome != null) { + searchList.add(DTFWHome); } - } - if (DTFWHome == null) { - // The files better be in the system dir. - String sysDir = System.getenv("SYSTEMROOT") + - File.separator + "system32"; - File feng = new File(sysDir + File.separator + "dbgeng.dll"); - if (!feng.exists()) { - throw new UnsatisfiedLinkError("File dbgeng.dll does not exist in " + - sysDir + ". Please search microsoft.com " + - "for Debugging Tools For Windows, and " + - "either download it to the default " + - "location, or download it to a custom " + - "location and set environment variable " + - " DEBUGGINGTOOLSFORWINDOWS " + - "to the pathname of that location."); - } + // The third place to search is the install directory for the + // "Debugging Tools For Windows" package; so far there are three + // name variations that we know of: + String sysRoot = System.getenv("SYSTEMROOT"); + DTFWHome = sysRoot + File.separator + ".." + File.separator + + "Program Files" + File.separator + "Debugging Tools For Windows"; + searchList.add(DTFWHome); + searchList.add(DTFWHome + " (x86)"); + searchList.add(DTFWHome + " (x64)"); + + // The last place to search is the system directory: + searchList.add(sysRoot + File.separator + "system32"); } + for (int i = 0; i < searchList.size(); i++) { + File dir = new File((String) searchList.get(i)); + if (!dir.exists()) { + if (loadLibraryDEBUG) { + System.err.println("DEBUG: '" + searchList.get(i) + + "': directory does not exist."); + } + // this search directory doesn't exist so skip it + continue; + } + + dbgengPath = (String) searchList.get(i) + File.separator + "dbgeng.dll"; + dbghelpPath = (String) searchList.get(i) + File.separator + "dbghelp.dll"; + + File feng = new File(dbgengPath); + File fhelp = new File(dbghelpPath); + if (feng.exists() && fhelp.exists()) { + // both files exist so we have a match + break; + } + + // At least one of the files does not exist; no warning if both + // don't exist. If just one doesn't exist then we don't check + // loadLibraryDEBUG because we have a mis-configured system. + if (feng.exists()) { + System.err.println("WARNING: found '" + dbgengPath + + "' but did not find '" + dbghelpPath + "'; ignoring '" + + dbgengPath + "'."); + } else if (fhelp.exists()) { + System.err.println("WARNING: found '" + dbghelpPath + + "' but did not find '" + dbgengPath + "'; ignoring '" + + dbghelpPath + "'."); + } else if (loadLibraryDEBUG) { + System.err.println("DEBUG: searched '" + searchList.get(i) + + "': dbgeng.dll and dbghelp.dll were not found."); + } + dbgengPath = null; + dbghelpPath = null; + } + + if (dbgengPath == null || dbghelpPath == null) { + // at least one of the files wasn't found anywhere we searched + String mesg = null; + + if (dbgengPath == null && dbghelpPath == null) { + mesg = "dbgeng.dll and dbghelp.dll cannot be found. "; + } else if (dbgengPath == null) { + mesg = "dbgeng.dll cannot be found (dbghelp.dll was found). "; + } else { + mesg = "dbghelp.dll cannot be found (dbgeng.dll was found). "; + } + throw new UnsatisfiedLinkError(mesg + + "Please search microsoft.com for 'Debugging Tools For Windows', " + + "and either download it to the default location, or download it " + + "to a custom location and set environment variable " + + "'DEBUGGINGTOOLSFORWINDOWS' to the pathname of that location."); + } + + // NOTE: The order of loads is important! If we load dbgeng.dll + // first, then the dependency - dbghelp.dll - will be loaded + // from usual DLL search thereby defeating the purpose! + if (loadLibraryDEBUG) { + System.err.println("DEBUG: loading '" + dbghelpPath + "'."); + } + System.load(dbghelpPath); + if (loadLibraryDEBUG) { + System.err.println("DEBUG: loading '" + dbgengPath + "'."); + } + System.load(dbgengPath); + // Now, load sawindbg.dll - System.loadLibrary("sawindbg"); + if (loadLibraryDEBUG) { + System.err.println("DEBUG: loading '" + sawindbgPath + "'."); + } + System.load(sawindbgPath); + // where do I find '.exe', '.dll' files? imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath"); if (imagePath == null) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Wed Jan 19 19:01:35 2011 -0800 @@ -30,6 +30,7 @@ import sun.jvm.hotspot.asm.sparc.*; import sun.jvm.hotspot.asm.x86.*; import sun.jvm.hotspot.asm.ia64.*; +import sun.jvm.hotspot.asm.amd64.*; import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; import sun.jvm.hotspot.debugger.*; @@ -198,6 +199,8 @@ cpuHelper = new SPARCHelper(); } else if (cpu.equals("x86")) { cpuHelper = new X86Helper(); + } else if (cpu.equals("amd64")) { + cpuHelper = new AMD64Helper(); } else if (cpu.equals("ia64")) { cpuHelper = new IA64Helper(); } else { diff -r d534dd80da9f -r c19058ce05e8 hotspot/make/hotspot_version --- a/hotspot/make/hotspot_version Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/make/hotspot_version Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -31,11 +31,11 @@ # # Don't put quotes (fail windows build). -HOTSPOT_VM_COPYRIGHT=Copyright 2010 +HOTSPOT_VM_COPYRIGHT=Copyright 2011 HS_MAJOR_VER=20 HS_MINOR_VER=0 -HS_BUILD_NUMBER=05 +HS_BUILD_NUMBER=06 JDK_MAJOR_VER=1 JDK_MINOR_VER=7 diff -r d534dd80da9f -r c19058ce05e8 hotspot/make/jprt.properties --- a/hotspot/make/jprt.properties Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/make/jprt.properties Wed Jan 19 19:01:35 2011 -0800 @@ -150,6 +150,7 @@ jprt.my.solaris.sparc.test.targets= \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jvm98, \ + ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-scimark, \ ${jprt.my.solaris.sparc}-product-{c1|c2}-runThese, \ ${jprt.my.solaris.sparc}-fastdebug-c1-runThese_Xshare, \ @@ -168,6 +169,7 @@ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_G1, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_ParOldGC, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_default, \ + ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_SerialGC, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_ParallelGC, \ ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_CMS, \ @@ -176,6 +178,7 @@ jprt.my.solaris.sparcv9.test.targets= \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98, \ + ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-scimark, \ ${jprt.my.solaris.sparcv9}-product-c2-runThese, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCBasher_default, \ @@ -193,6 +196,7 @@ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCOld_G1, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCOld_ParOldGC, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_default, \ + ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_SerialGC, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_ParallelGC, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_CMS, \ @@ -201,6 +205,7 @@ jprt.my.solaris.x64.test.targets= \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jvm98, \ + ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-scimark, \ ${jprt.my.solaris.x64}-product-c2-runThese, \ ${jprt.my.solaris.x64}-product-c2-runThese_Xcomp, \ @@ -219,6 +224,7 @@ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_G1, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_default, \ + ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_SerialGC, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_CMS, \ @@ -227,6 +233,7 @@ jprt.my.solaris.i586.test.targets= \ ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-jvm98, \ + ${jprt.my.solaris.i586}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-scimark, \ ${jprt.my.solaris.i586}-product-{c1|c2}-runThese_Xcomp, \ ${jprt.my.solaris.i586}-fastdebug-c1-runThese_Xcomp, \ @@ -253,6 +260,7 @@ ${jprt.my.solaris.i586}-product-c1-GCOld_G1, \ ${jprt.my.solaris.i586}-product-c1-GCOld_ParOldGC, \ ${jprt.my.solaris.i586}-fastdebug-c2-jbb_default, \ + ${jprt.my.solaris.i586}-fastdebug-c2-jbb_default_tiered, \ ${jprt.my.solaris.i586}-fastdebug-c2-jbb_ParallelGC, \ ${jprt.my.solaris.i586}-fastdebug-c2-jbb_CMS, \ ${jprt.my.solaris.i586}-fastdebug-c2-jbb_G1, \ @@ -260,6 +268,7 @@ jprt.my.linux.i586.test.targets = \ ${jprt.my.linux.i586}-{product|fastdebug}-{c1|c2}-jvm98, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.linux.i586}-{product|fastdebug}-{c1|c2}-scimark, \ ${jprt.my.linux.i586}-product-c1-runThese_Xcomp, \ ${jprt.my.linux.i586}-fastdebug-c1-runThese_Xshare, \ @@ -279,6 +288,7 @@ ${jprt.my.linux.i586}-product-{c1|c2}-GCOld_G1, \ ${jprt.my.linux.i586}-product-{c1|c2}-GCOld_ParOldGC, \ ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_default, \ + ${jprt.my.linux.i586}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_ParallelGC, \ ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_CMS, \ ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_G1, \ @@ -286,6 +296,7 @@ jprt.my.linux.x64.test.targets = \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-jvm98, \ + ${jprt.my.linux.x64}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-scimark, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCBasher_default, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCBasher_SerialGC, \ @@ -302,12 +313,14 @@ ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCOld_G1, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_default, \ + ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_G1, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_ParOldGC jprt.my.windows.i586.test.targets = \ ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-jvm98, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-scimark, \ ${jprt.my.windows.i586}-product-{c1|c2}-runThese, \ ${jprt.my.windows.i586}-product-{c1|c2}-runThese_Xcomp, \ @@ -327,6 +340,7 @@ ${jprt.my.windows.i586}-product-{c1|c2}-GCOld_G1, \ ${jprt.my.windows.i586}-product-{c1|c2}-GCOld_ParOldGC, \ ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-jbb_default, \ + ${jprt.my.windows.i586}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.windows.i586}-product-{c1|c2}-jbb_ParallelGC, \ ${jprt.my.windows.i586}-product-{c1|c2}-jbb_CMS, \ ${jprt.my.windows.i586}-product-{c1|c2}-jbb_G1, \ @@ -334,6 +348,7 @@ jprt.my.windows.x64.test.targets = \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-jvm98, \ + ${jprt.my.windows.x64}-{product|fastdebug}-c2-jvm98_tiered, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-scimark, \ ${jprt.my.windows.x64}-product-c2-runThese, \ ${jprt.my.windows.x64}-product-c2-runThese_Xcomp, \ @@ -351,6 +366,7 @@ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_G1, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-jbb_default, \ + ${jprt.my.windows.x64}-{product|fastdebug}-c2-jbb_default_tiered, \ ${jprt.my.windows.x64}-product-c2-jbb_CMS, \ ${jprt.my.windows.x64}-product-c2-jbb_ParallelGC, \ ${jprt.my.windows.x64}-product-c2-jbb_G1, \ diff -r d534dd80da9f -r c19058ce05e8 hotspot/make/solaris/makefiles/buildtree.make --- a/hotspot/make/solaris/makefiles/buildtree.make Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/make/solaris/makefiles/buildtree.make Wed Jan 19 19:01:35 2011 -0800 @@ -61,7 +61,7 @@ QUIETLY$(MAKE_VERBOSE) = @ # For now, until the compiler is less wobbly: -TESTFLAGS = -Xbatch -showversion +TESTFLAGS = -Xbatch -Xmx32m -showversion ### maye ARCH_XXX instead? ifdef USE_GCC diff -r d534dd80da9f -r c19058ce05e8 hotspot/make/solaris/makefiles/vm.make --- a/hotspot/make/solaris/makefiles/vm.make Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/make/solaris/makefiles/vm.make Wed Jan 19 19:01:35 2011 -0800 @@ -119,6 +119,10 @@ LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc -ldemangle endif # sparcWorks +ifeq ("${Platform_arch}", "sparc") +LIBS += -lkstat +endif + # By default, link the *.o into the library, not the executable. LINK_INTO$(LINK_INTO) = LIBJVM diff -r d534dd80da9f -r c19058ce05e8 hotspot/make/windows/makefiles/compile.make --- a/hotspot/make/windows/makefiles/compile.make Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/make/windows/makefiles/compile.make Wed Jan 19 19:01:35 2011 -0800 @@ -152,7 +152,7 @@ !endif # Always add the _STATIC_CPPLIB flag -STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB +STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION) CPP_FLAGS=$(CPP_FLAGS) $(MS_RUNTIME_OPTION) diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/assembler_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "asm/assembler.hpp" #include "assembler_sparc.inline.hpp" #include "gc_interface/collectedHeap.inline.hpp" #include "interpreter/interpreter.hpp" @@ -1327,37 +1328,38 @@ } -int MacroAssembler::size_of_sethi(address a, bool worst_case) { +int MacroAssembler::insts_for_sethi(address a, bool worst_case) { #ifdef _LP64 - if (worst_case) return 7; - intptr_t iaddr = (intptr_t)a; - int hi32 = (int)(iaddr >> 32); - int lo32 = (int)(iaddr); - int inst_count; - if (hi32 == 0 && lo32 >= 0) - inst_count = 1; - else if (hi32 == -1) - inst_count = 2; + if (worst_case) return 7; + intptr_t iaddr = (intptr_t) a; + int msb32 = (int) (iaddr >> 32); + int lsb32 = (int) (iaddr); + int count; + if (msb32 == 0 && lsb32 >= 0) + count = 1; + else if (msb32 == -1) + count = 2; else { - inst_count = 2; - if ( hi32 & 0x3ff ) - inst_count++; - if ( lo32 & 0xFFFFFC00 ) { - if( (lo32 >> 20) & 0xfff ) inst_count += 2; - if( (lo32 >> 10) & 0x3ff ) inst_count += 2; + count = 2; + if (msb32 & 0x3ff) + count++; + if (lsb32 & 0xFFFFFC00 ) { + if ((lsb32 >> 20) & 0xfff) count += 2; + if ((lsb32 >> 10) & 0x3ff) count += 2; } } - return BytesPerInstWord * inst_count; + return count; #else - return BytesPerInstWord; + return 1; #endif } -int MacroAssembler::worst_case_size_of_set() { - return size_of_sethi(NULL, true) + 1; +int MacroAssembler::worst_case_insts_for_set() { + return insts_for_sethi(NULL, true) + 1; } +// Keep in sync with MacroAssembler::insts_for_internal_set void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) { intptr_t value = addrlit.value(); @@ -1379,6 +1381,23 @@ } } +// Keep in sync with MacroAssembler::internal_set +int MacroAssembler::insts_for_internal_set(intptr_t value) { + // can optimize + if (-4096 <= value && value <= 4095) { + return 1; + } + if (inv_hi22(hi22(value)) == value) { + return insts_for_sethi((address) value); + } + int count = insts_for_sethi((address) value); + AddressLiteral al(value); + if (al.low10() != 0) { + count++; + } + return count; +} + void MacroAssembler::set(const AddressLiteral& al, Register d) { internal_set(al, d, false); } @@ -1443,11 +1462,11 @@ } } -int MacroAssembler::size_of_set64(jlong value) { +int MacroAssembler::insts_for_set64(jlong value) { v9_dep(); - int hi = (int)(value >> 32); - int lo = (int)(value & ~0); + int hi = (int) (value >> 32); + int lo = (int) (value & ~0); int count = 0; // (Matcher::isSimpleConstant64 knows about the following optimizations.) @@ -4083,11 +4102,15 @@ store_klass(t2, top); verify_oop(top); + ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t1); + sub(top, t1, t1); // size of tlab's allocated portion + incr_allocated_bytes(t1, 0, t2); + // refill the tlab with an eden allocation bind(do_refill); ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1); sll_ptr(t1, LogHeapWordSize, t1); - // add object_size ?? + // allocate new tlab, address returned in top eden_allocate(top, t1, 0, t2, t3, slow_case); st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset())); @@ -4115,6 +4138,22 @@ delayed()->nop(); } +void MacroAssembler::incr_allocated_bytes(Register var_size_in_bytes, + int con_size_in_bytes, + Register t1) { + // Bump total bytes allocated by this thread + assert(t1->is_global(), "must be global reg"); // so all 64 bits are saved on a context switch + assert_different_registers(var_size_in_bytes, t1); + // v8 support has gone the way of the dodo + ldx(G2_thread, in_bytes(JavaThread::allocated_bytes_offset()), t1); + if (var_size_in_bytes->is_valid()) { + add(t1, var_size_in_bytes, t1); + } else { + add(t1, con_size_in_bytes, t1); + } + stx(t1, G2_thread, in_bytes(JavaThread::allocated_bytes_offset())); +} + Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) { switch (cond) { // Note some conditions are synonyms for others diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/assembler_sparc.hpp --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1884,23 +1884,24 @@ void sethi(const AddressLiteral& addrlit, Register d); void patchable_sethi(const AddressLiteral& addrlit, Register d); - // compute the size of a sethi/set - static int size_of_sethi( address a, bool worst_case = false ); - static int worst_case_size_of_set(); + // compute the number of instructions for a sethi/set + static int insts_for_sethi( address a, bool worst_case = false ); + static int worst_case_insts_for_set(); // set may be either setsw or setuw (high 32 bits may be zero or sign) private: void internal_set(const AddressLiteral& al, Register d, bool ForceRelocatable); + static int insts_for_internal_set(intptr_t value); public: void set(const AddressLiteral& addrlit, Register d); void set(intptr_t value, Register d); void set(address addr, Register d, RelocationHolder const& rspec); + static int insts_for_set(intptr_t value) { return insts_for_internal_set(value); } + void patchable_set(const AddressLiteral& addrlit, Register d); void patchable_set(intptr_t value, Register d); void set64(jlong value, Register d, Register tmp); - - // Compute size of set64. - static int size_of_set64(jlong value); + static int insts_for_set64(jlong value); // sign-extend 32 to 64 inline void signx( Register s, Register d ) { sra( s, G0, d); } @@ -2388,6 +2389,7 @@ Label& slow_case // continuation point if fast allocation fails ); void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); + void incr_allocated_bytes(Register var_size_in_bytes, int con_size_in_bytes, Register t1); // interface method calling void lookup_interface_method(Register recv_klass, diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1705,8 +1705,7 @@ } -void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) { - +void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) { Assembler::Condition acond; switch (condition) { case lir_cond_equal: acond = Assembler::equal; break; @@ -1737,7 +1736,12 @@ ShouldNotReachHere(); } Label skip; - __ br(acond, false, Assembler::pt, skip); +#ifdef _LP64 + if (type == T_INT) { + __ br(acond, false, Assembler::pt, skip); + } else +#endif + __ brx(acond, false, Assembler::pt, skip); // checks icc on 32bit and xcc on 64bit if (opr1->is_constant() && opr1->type() == T_INT) { Register dest = result->as_register(); if (Assembler::is_simm13(opr1->as_jint())) { @@ -2688,6 +2692,11 @@ #ifdef _LP64 __ mov(cmp_value_lo, t1); __ mov(new_value_lo, t2); + // perform the compare and swap operation + __ casx(addr, t1, t2); + // generate condition code - if the swap succeeded, t2 ("new value" reg) was + // overwritten with the original value in "addr" and will be equal to t1. + __ cmp(t1, t2); #else // move high and low halves of long values into single registers __ sllx(cmp_value_hi, 32, t1); // shift high half into temp reg @@ -2696,13 +2705,15 @@ __ sllx(new_value_hi, 32, t2); __ srl(new_value_lo, 0, new_value_lo); __ or3(t2, new_value_lo, t2); // t2 holds 64-bit value to swap -#endif // perform the compare and swap operation __ casx(addr, t1, t2); // generate condition code - if the swap succeeded, t2 ("new value" reg) was // overwritten with the original value in "addr" and will be equal to t1. - __ cmp(t1, t2); - + // Produce icc flag for 32bit. + __ sub(t1, t2, t2); + __ srlx(t2, 32, t1); + __ orcc(t2, t1, G0); +#endif } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) { Register addr = op->addr()->as_pointer_register(); Register cmp_value = op->cmp_value()->as_register(); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -662,7 +662,7 @@ // generate conditional move of boolean result LIR_Opr result = rlock_result(x); - __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result); + __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result, T_LONG); } @@ -699,10 +699,10 @@ else { ShouldNotReachHere(); } - // generate conditional move of boolean result LIR_Opr result = rlock_result(x); - __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result); + __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), + result, as_BasicType(type)); if (type == objectType) { // Write-barrier needed for Object fields. // Precise card mark since could either be object or array post_barrier(addr, val.result()); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -166,7 +166,7 @@ Register obj, // result: pointer to object after successful allocation Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise int con_size_in_bytes, // object size in bytes if known at compile time - Register t1, // temp register + Register t1, // temp register, must be global register for incr_allocated_bytes Register t2, // temp register Label& slow_case // continuation point if fast allocation fails ) { @@ -174,6 +174,7 @@ tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case); } else { eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case); + incr_allocated_bytes(var_size_in_bytes, con_size_in_bytes, t1); } } @@ -214,7 +215,7 @@ void C1_MacroAssembler::allocate_object( Register obj, // result: pointer to object after successful allocation Register t1, // temp register - Register t2, // temp register + Register t2, // temp register, must be a global register for try_allocate Register t3, // temp register int hdr_size, // object header size in words int obj_size, // object size in words diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp --- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -448,7 +448,9 @@ // get the instance size __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size); + __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path); + __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); __ verify_oop(O0_obj); __ mov(O0, I0); @@ -459,6 +461,8 @@ // get the instance size __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size); __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path); + __ incr_allocated_bytes(G1_obj_size, 0, G3_t1); + __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); __ verify_oop(O0_obj); __ mov(O0, I0); @@ -573,6 +577,7 @@ __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size + __ incr_allocated_bytes(G1_arr_size, 0, G3_t1); __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -395,18 +395,23 @@ // // Generate an "entry" field for a method handle. // This determines how the method handle will respond to calls. -void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { +void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) { // Here is the register state during an interpreted call, // as set up by generate_method_handle_interpreter_entry(): // - G5: garbage temp (was MethodHandle.invoke methodOop, unused) // - G3: receiver method handle // - O5_savedSP: sender SP (must preserve) - Register O0_argslot = O0; - Register O1_scratch = O1; - Register O2_scratch = O2; - Register O3_scratch = O3; - Register G5_index = G5; + const Register O0_argslot = O0; + const Register O1_scratch = O1; + const Register O2_scratch = O2; + const Register O3_scratch = O3; + const Register G5_index = G5; + + // Argument registers for _raise_exception. + const Register O0_code = O0; + const Register O1_actual = O1; + const Register O2_required = O2; guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets"); @@ -439,48 +444,36 @@ case _raise_exception: { // Not a real MH entry, but rather shared code for raising an - // exception. Extra local arguments are passed in scratch - // registers, as required type in O3, failing object (or NULL) - // in O2, failing bytecode type in O1. + // exception. Since we use a C2I adapter to set up the + // interpreter state, arguments are expected in compiler + // argument registers. + methodHandle mh(raise_exception_method()); + address c2i_entry = methodOopDesc::make_adapters(mh, CATCH); __ mov(O5_savedSP, SP); // Cut the stack back to where the caller started. - // Push arguments as if coming from the interpreter. - Register O0_scratch = O0_argslot; - int stackElementSize = Interpreter::stackElementSize; - - // Make space on the stack for the arguments and set Gargs - // correctly. - __ sub(SP, 4*stackElementSize, SP); // Keep stack aligned. - __ add(SP, (frame::varargs_offset)*wordSize - 1*Interpreter::stackElementSize + STACK_BIAS + BytesPerWord, Gargs); - - // void raiseException(int code, Object actual, Object required) - __ st( O1_scratch, Address(Gargs, 2*stackElementSize)); // code - __ st_ptr(O2_scratch, Address(Gargs, 1*stackElementSize)); // actual - __ st_ptr(O3_scratch, Address(Gargs, 0*stackElementSize)); // required - - Label no_method; + Label L_no_method; // FIXME: fill in _raise_exception_method with a suitable sun.dyn method __ set(AddressLiteral((address) &_raise_exception_method), G5_method); __ ld_ptr(Address(G5_method, 0), G5_method); __ tst(G5_method); - __ brx(Assembler::zero, false, Assembler::pn, no_method); + __ brx(Assembler::zero, false, Assembler::pn, L_no_method); __ delayed()->nop(); - int jobject_oop_offset = 0; + const int jobject_oop_offset = 0; __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method); __ tst(G5_method); - __ brx(Assembler::zero, false, Assembler::pn, no_method); + __ brx(Assembler::zero, false, Assembler::pn, L_no_method); __ delayed()->nop(); __ verify_oop(G5_method); - __ jump_indirect_to(G5_method_fie, O1_scratch); + __ jump_to(AddressLiteral(c2i_entry), O3_scratch); __ delayed()->nop(); // If we get here, the Java runtime did not do its job of creating the exception. // Do something that is at least causes a valid throw from the interpreter. - __ bind(no_method); - __ unimplemented("_raise_exception no method"); + __ bind(L_no_method); + __ unimplemented("call throw_WrongMethodType_entry"); } break; @@ -570,10 +563,10 @@ // Throw an exception. // For historical reasons, it will be IncompatibleClassChangeError. __ unimplemented("not tested yet"); - __ ld_ptr(Address(O1_intf, java_mirror_offset), O3_scratch); // required interface - __ mov(O0_klass, O2_scratch); // bad receiver - __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot); - __ delayed()->mov(Bytecodes::_invokeinterface, O1_scratch); // who is complaining? + __ ld_ptr(Address(O1_intf, java_mirror_offset), O2_required); // required interface + __ mov( O0_klass, O1_actual); // bad receiver + __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch); + __ delayed()->mov(Bytecodes::_invokeinterface, O0_code); // who is complaining? } break; @@ -663,11 +656,10 @@ __ check_klass_subtype(O1_scratch, G5_klass, O0_argslot, O2_scratch, done); // If we get here, the type check failed! - __ ldsw(G3_amh_vmargslot, O0_argslot); // reload argslot field - __ load_heap_oop(G3_amh_argument, O3_scratch); // required class - __ ld_ptr(vmarg, O2_scratch); // bad object - __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot); - __ delayed()->mov(Bytecodes::_checkcast, O1_scratch); // who is complaining? + __ load_heap_oop(G3_amh_argument, O2_required); // required class + __ ld_ptr( vmarg, O1_actual); // bad object + __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch); + __ delayed()->mov(Bytecodes::_checkcast, O0_code); // who is complaining? __ bind(done); // Get the new MH: diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/sparc.ad --- a/hotspot/src/cpu/sparc/vm/sparc.ad Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/sparc.ad Wed Jan 19 19:01:35 2011 -0800 @@ -1086,9 +1086,9 @@ uint MachConstantBaseNode::size(PhaseRegAlloc*) const { if (UseRDPCForConstantTableBase) { // This is really the worst case but generally it's only 1 instruction. - return 4 /*rdpc*/ + 4 /*sub*/ + MacroAssembler::worst_case_size_of_set(); + return (1 /*rdpc*/ + 1 /*sub*/ + MacroAssembler::worst_case_insts_for_set()) * BytesPerInstWord; } else { - return MacroAssembler::worst_case_size_of_set(); + return MacroAssembler::worst_case_insts_for_set() * BytesPerInstWord; } } @@ -1240,7 +1240,7 @@ int MachEpilogNode::safepoint_offset() const { assert( do_polling(), "no return for this epilog node"); - return MacroAssembler::size_of_sethi(os::get_polling_page()); + return MacroAssembler::insts_for_sethi(os::get_polling_page()) * BytesPerInstWord; } //============================================================================= @@ -3553,9 +3553,10 @@ interface(CONST_INTER); %} -// Pointer Immediate: 32 or 64-bit +#ifdef _LP64 +// Pointer Immediate: 64-bit operand immP_set() %{ - predicate(!VM_Version::is_niagara1_plus()); + predicate(!VM_Version::is_niagara_plus()); match(ConP); op_cost(5); @@ -3564,10 +3565,10 @@ interface(CONST_INTER); %} -// Pointer Immediate: 32 or 64-bit +// Pointer Immediate: 64-bit // From Niagara2 processors on a load should be better than materializing. operand immP_load() %{ - predicate(VM_Version::is_niagara1_plus()); + predicate(VM_Version::is_niagara_plus() && (n->bottom_type()->isa_oop_ptr() || (MacroAssembler::insts_for_set(n->get_ptr()) > 3))); match(ConP); op_cost(5); @@ -3576,6 +3577,18 @@ interface(CONST_INTER); %} +// Pointer Immediate: 64-bit +operand immP_no_oop_cheap() %{ + predicate(VM_Version::is_niagara_plus() && !n->bottom_type()->isa_oop_ptr() && (MacroAssembler::insts_for_set(n->get_ptr()) <= 3)); + match(ConP); + + op_cost(5); + // formats are generated automatically for constants and base registers + format %{ %} + interface(CONST_INTER); +%} +#endif + operand immP13() %{ predicate((-4096 < n->get_ptr()) && (n->get_ptr() <= 4095)); match(ConP); @@ -3673,7 +3686,7 @@ // Long Immediate: cheap (materialize in <= 3 instructions) operand immL_cheap() %{ - predicate(!VM_Version::is_niagara1_plus() || MacroAssembler::size_of_set64(n->get_long()) <= 3); + predicate(!VM_Version::is_niagara_plus() || MacroAssembler::insts_for_set64(n->get_long()) <= 3); match(ConL); op_cost(0); @@ -3683,7 +3696,7 @@ // Long Immediate: expensive (materialize in > 3 instructions) operand immL_expensive() %{ - predicate(VM_Version::is_niagara1_plus() && MacroAssembler::size_of_set64(n->get_long()) > 3); + predicate(VM_Version::is_niagara_plus() && MacroAssembler::insts_for_set64(n->get_long()) > 3); match(ConL); op_cost(0); @@ -6094,8 +6107,18 @@ ins_cost(MEMORY_REF_COST); format %{ "LD [$constanttablebase + $constantoffset],$dst\t! load from constant table: ptr=$con" %} ins_encode %{ - RegisterOrConstant con_offset = __ ensure_simm13_or_reg($constantoffset($con), $dst$$Register); - __ ld_ptr($constanttablebase, con_offset, $dst$$Register); + RegisterOrConstant con_offset = __ ensure_simm13_or_reg($constantoffset($con), $dst$$Register); + __ ld_ptr($constanttablebase, con_offset, $dst$$Register); + %} + ins_pipe(loadConP); +%} + +instruct loadConP_no_oop_cheap(iRegP dst, immP_no_oop_cheap con) %{ + match(Set dst con); + ins_cost(DEFAULT_COST * 3/2); + format %{ "SET $con,$dst\t! non-oop ptr" %} + ins_encode %{ + __ set($con$$constant, $dst$$Register); %} ins_pipe(loadConP); %} diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3393,21 +3393,21 @@ __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset())); if (allow_shared_alloc) { - // Check if tlab should be discarded (refill_waste_limit >= free) - __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue); - __ sub(RendValue, RoldTopValue, RfreeValue); + // Check if tlab should be discarded (refill_waste_limit >= free) + __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue); + __ sub(RendValue, RoldTopValue, RfreeValue); #ifdef _LP64 - __ srlx(RfreeValue, LogHeapWordSize, RfreeValue); + __ srlx(RfreeValue, LogHeapWordSize, RfreeValue); #else - __ srl(RfreeValue, LogHeapWordSize, RfreeValue); + __ srl(RfreeValue, LogHeapWordSize, RfreeValue); #endif - __ cmp(RtlabWasteLimitValue, RfreeValue); - __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small - __ delayed()->nop(); - - // increment waste limit to prevent getting stuck on this slow path - __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue); - __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset())); + __ cmp(RtlabWasteLimitValue, RfreeValue); + __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small + __ delayed()->nop(); + + // increment waste limit to prevent getting stuck on this slow path + __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue); + __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset())); } else { // No allocation in the shared eden. __ br(Assembler::always, false, Assembler::pt, slow_case); @@ -3445,6 +3445,9 @@ __ cmp(RoldTopValue, RnewTopValue); __ brx(Assembler::notEqual, false, Assembler::pn, retry); __ delayed()->nop(); + + // bump total bytes allocated by this thread + __ incr_allocated_bytes(Roffset, 0, G1_scratch); } if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -38,12 +38,6 @@ int VM_Version::_features = VM_Version::unknown_m; const char* VM_Version::_features_str = ""; -bool VM_Version::is_niagara1_plus() { - // This is a placeholder until the real test is determined. - return is_niagara1() && - (os::processor_count() > maximum_niagara1_processor_count()); -} - void VM_Version::initialize() { _features = determine_features(); PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); @@ -69,11 +63,21 @@ _supports_cx8 = has_v9(); - if (is_niagara1()) { + if (is_niagara()) { // Indirect branch is the same cost as direct if (FLAG_IS_DEFAULT(UseInlineCaches)) { FLAG_SET_DEFAULT(UseInlineCaches, false); } + // Align loops on a single instruction boundary. + if (FLAG_IS_DEFAULT(OptoLoopAlignment)) { + FLAG_SET_DEFAULT(OptoLoopAlignment, 4); + } + // When using CMS, we cannot use memset() in BOT updates because + // the sun4v/CMT version in libc_psr uses BIS which exposes + // "phantom zeros" to concurrent readers. See 6948537. + if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) { + FLAG_SET_DEFAULT(UseMemSetInBOT, false); + } #ifdef _LP64 // 32-bit oops don't make sense for the 64-bit VM on sparc // since the 32-bit VM has the same registers and smaller objects. @@ -89,7 +93,7 @@ if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) { FLAG_SET_DEFAULT(InteriorEntryAlignment, 4); } - if (is_niagara1_plus()) { + if (is_niagara_plus()) { if (has_blk_init() && AllocatePrefetchStyle > 0 && FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { // Use BIS instruction for allocation prefetch. @@ -105,15 +109,6 @@ } } #endif - if (FLAG_IS_DEFAULT(OptoLoopAlignment)) { - FLAG_SET_DEFAULT(OptoLoopAlignment, 4); - } - // When using CMS, we cannot use memset() in BOT updates because - // the sun4v/CMT version in libc_psr uses BIS which exposes - // "phantom zeros" to concurrent readers. See 6948537. - if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) { - FLAG_SET_DEFAULT(UseMemSetInBOT, false); - } } // Use hardware population count instruction if available. @@ -129,17 +124,18 @@ #endif char buf[512]; - jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", (has_v8() ? ", has_v8" : ""), (has_v9() ? ", has_v9" : ""), (has_hardware_popc() ? ", popc" : ""), (has_vis1() ? ", has_vis1" : ""), (has_vis2() ? ", has_vis2" : ""), + (has_vis3() ? ", has_vis3" : ""), (has_blk_init() ? ", has_blk_init" : ""), (is_ultra3() ? ", is_ultra3" : ""), (is_sun4v() ? ", is_sun4v" : ""), - (is_niagara1() ? ", is_niagara1" : ""), - (is_niagara1_plus() ? ", is_niagara1_plus" : ""), + (is_niagara() ? ", is_niagara" : ""), + (is_niagara_plus() ? ", is_niagara_plus" : ""), (is_sparc64() ? ", is_sparc64" : ""), (!has_hardware_mul32() ? ", no-mul32" : ""), (!has_hardware_div32() ? ", no-div32" : ""), @@ -190,17 +186,18 @@ warning("Cannot recognize SPARC version. Default to V9"); } - if (UseNiagaraInstrs) { - if (is_niagara1(features)) { + assert(is_T_family(features) == is_niagara(features), "Niagara should be T series"); + if (UseNiagaraInstrs) { // Force code generation for Niagara + if (is_T_family(features)) { // Happy to accomodate... } else { NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");) - features = niagara1_m; + features |= T_family_m; } } else { - if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) { + if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) { NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");) - features &= ~niagara1_unique_m; + features &= ~(T_family_m | T1_model_m); } else { // Happy to accomodate... } @@ -222,7 +219,7 @@ unsigned int VM_Version::calc_parallel_worker_threads() { unsigned int result; - if (is_niagara1_plus()) { + if (is_niagara_plus()) { result = nof_parallel_worker_threads(5, 16, 8); } else { result = nof_parallel_worker_threads(5, 8, 8); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -41,7 +41,12 @@ vis2_instructions = 7, sun4v_instructions = 8, blk_init_instructions = 9, - fmaf_instructions = 10 + fmaf_instructions = 10, + fmau_instructions = 11, + vis3_instructions = 12, + sparc64_family = 13, + T_family = 14, + T1_model = 15 }; enum Feature_Flag_Set { @@ -59,6 +64,11 @@ sun4v_m = 1 << sun4v_instructions, blk_init_instructions_m = 1 << blk_init_instructions, fmaf_instructions_m = 1 << fmaf_instructions, + fmau_instructions_m = 1 << fmau_instructions, + vis3_instructions_m = 1 << vis3_instructions, + sparc64_family_m = 1 << sparc64_family, + T_family_m = 1 << T_family, + T1_model_m = 1 << T1_model, generic_v8_m = v8_instructions_m | hardware_mul32_m | hardware_div32_m | hardware_fsmuld_m, generic_v9_m = generic_v8_m | v9_instructions_m, @@ -76,8 +86,13 @@ static int determine_features(); static int platform_features(int features); - static bool is_niagara1(int features) { return (features & sun4v_m) != 0; } - static bool is_sparc64(int features) { return (features & fmaf_instructions_m) != 0; } + // Returns true if the platform is in the niagara line (T series) + static bool is_T_family(int features) { return (features & T_family_m) != 0; } + static bool is_niagara() { return is_T_family(_features); } + DEBUG_ONLY( static bool is_niagara(int features) { return (features & sun4v_m) != 0; } ) + + // Returns true if it is niagara1 (T1). + static bool is_T1_model(int features) { return is_T_family(features) && ((features & T1_model_m) != 0); } static int maximum_niagara1_processor_count() { return 32; } @@ -94,6 +109,7 @@ static bool has_hardware_popc() { return (_features & hardware_popc_m) != 0; } static bool has_vis1() { return (_features & vis1_instructions_m) != 0; } static bool has_vis2() { return (_features & vis2_instructions_m) != 0; } + static bool has_vis3() { return (_features & vis3_instructions_m) != 0; } static bool has_blk_init() { return (_features & blk_init_instructions_m) != 0; } static bool supports_compare_and_exchange() @@ -101,14 +117,14 @@ static bool is_ultra3() { return (_features & ultra3_m) == ultra3_m; } static bool is_sun4v() { return (_features & sun4v_m) != 0; } - static bool is_niagara1() { return is_niagara1(_features); } - // Returns true if the platform is in the niagara line and - // newer than the niagara1. - static bool is_niagara1_plus(); - static bool is_sparc64() { return is_sparc64(_features); } + // Returns true if the platform is in the niagara line (T series) + // and newer than the niagara1. + static bool is_niagara_plus() { return is_T_family(_features) && !is_T1_model(_features); } + // Fujitsu SPARC64 + static bool is_sparc64() { return (_features & sparc64_family_m) != 0; } - static bool has_fast_fxtof() { return has_v9() && !is_ultra3(); } - static bool has_fast_idiv() { return is_niagara1_plus() || is_sparc64(); } + static bool has_fast_fxtof() { return is_niagara() || is_sparc64() || has_v9() && !is_ultra3(); } + static bool has_fast_idiv() { return is_niagara_plus() || is_sparc64(); } static const char* cpu_features() { return _features_str; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/assembler_x86.cpp --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -820,7 +820,20 @@ } -// Now the Assembler instruction (identical for 32/64 bits) +// Now the Assembler instructions (identical for 32/64 bits) + +void Assembler::adcl(Address dst, int32_t imm32) { + InstructionMark im(this); + prefix(dst); + emit_arith_operand(0x81, rdx, dst, imm32); +} + +void Assembler::adcl(Address dst, Register src) { + InstructionMark im(this); + prefix(dst, src); + emit_byte(0x11); + emit_operand(src, dst); +} void Assembler::adcl(Register dst, int32_t imm32) { prefix(dst); @@ -2195,9 +2208,7 @@ void Assembler::orl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); - emit_byte(0x81); - emit_operand(rcx, dst, 4); - emit_long(imm32); + emit_arith_operand(0x81, rcx, dst, imm32); } void Assembler::orl(Register dst, int32_t imm32) { @@ -2205,7 +2216,6 @@ emit_arith(0x81, 0xC8, dst, imm32); } - void Assembler::orl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -2213,7 +2223,6 @@ emit_operand(dst, src); } - void Assembler::orl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x0B, 0xC0, dst, src); @@ -2692,20 +2701,7 @@ void Assembler::subl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); - if (is8bit(imm32)) { - emit_byte(0x83); - emit_operand(rbp, dst, 1); - emit_byte(imm32 & 0xFF); - } else { - emit_byte(0x81); - emit_operand(rbp, dst, 4); - emit_long(imm32); - } -} - -void Assembler::subl(Register dst, int32_t imm32) { - prefix(dst); - emit_arith(0x81, 0xE8, dst, imm32); + emit_arith_operand(0x81, rbp, dst, imm32); } void Assembler::subl(Address dst, Register src) { @@ -2715,6 +2711,11 @@ emit_operand(src, dst); } +void Assembler::subl(Register dst, int32_t imm32) { + prefix(dst); + emit_arith(0x81, 0xE8, dst, imm32); +} + void Assembler::subl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -4333,6 +4334,7 @@ emit_byte(0xD3); emit_byte(0xF8 | encode); } + void Assembler::sbbq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); @@ -4392,20 +4394,7 @@ void Assembler::subq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); - if (is8bit(imm32)) { - emit_byte(0x83); - emit_operand(rbp, dst, 1); - emit_byte(imm32 & 0xFF); - } else { - emit_byte(0x81); - emit_operand(rbp, dst, 4); - emit_long(imm32); - } -} - -void Assembler::subq(Register dst, int32_t imm32) { - (void) prefixq_and_encode(dst->encoding()); - emit_arith(0x81, 0xE8, dst, imm32); + emit_arith_operand(0x81, rbp, dst, imm32); } void Assembler::subq(Address dst, Register src) { @@ -4415,6 +4404,11 @@ emit_operand(src, dst); } +void Assembler::subq(Register dst, int32_t imm32) { + (void) prefixq_and_encode(dst->encoding()); + emit_arith(0x81, 0xE8, dst, imm32); +} + void Assembler::subq(Register dst, Address src) { InstructionMark im(this); prefixq(src, dst); @@ -7136,9 +7130,9 @@ } // Preserves rbx, and rdx. -void MacroAssembler::tlab_refill(Label& retry, - Label& try_eden, - Label& slow_case) { +Register MacroAssembler::tlab_refill(Label& retry, + Label& try_eden, + Label& slow_case) { Register top = rax; Register t1 = rcx; Register t2 = rsi; @@ -7185,7 +7179,7 @@ // if tlab is currently allocated (top or end != null) then // fill [top, end + alignment_reserve) with array object - testptr (top, top); + testptr(top, top); jcc(Assembler::zero, do_refill); // set up the mark word @@ -7197,16 +7191,20 @@ movl(Address(top, arrayOopDesc::length_offset_in_bytes()), t1); // set klass to intArrayKlass // dubious reloc why not an oop reloc? - movptr(t1, ExternalAddress((address) Universe::intArrayKlassObj_addr())); + movptr(t1, ExternalAddress((address)Universe::intArrayKlassObj_addr())); // store klass last. concurrent gcs assumes klass length is valid if // klass field is not null. store_klass(top, t1); + movptr(t1, top); + subptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset()))); + incr_allocated_bytes(thread_reg, t1, 0); + // refill the tlab with an eden allocation bind(do_refill); movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset()))); shlptr(t1, LogHeapWordSize); - // add object_size ?? + // allocate new tlab, address returned in top eden_allocate(top, t1, 0, t2, slow_case); // Check that t1 was preserved in eden_allocate. @@ -7234,6 +7232,34 @@ movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top); verify_tlab(); jmp(retry); + + return thread_reg; // for use by caller +} + +void MacroAssembler::incr_allocated_bytes(Register thread, + Register var_size_in_bytes, + int con_size_in_bytes, + Register t1) { +#ifdef _LP64 + if (var_size_in_bytes->is_valid()) { + addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes); + } else { + addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes); + } +#else + if (!thread->is_valid()) { + assert(t1->is_valid(), "need temp reg"); + thread = t1; + get_thread(thread); + } + + if (var_size_in_bytes->is_valid()) { + addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes); + } else { + addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes); + } + adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0); +#endif } static const double pi_4 = 0.7853981633974483; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/assembler_x86.hpp --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -674,12 +674,14 @@ // Utilities #ifdef _LP64 - static bool is_simm(int64_t x, int nbits) { return -( CONST64(1) << (nbits-1) ) <= x && x < ( CONST64(1) << (nbits-1) ); } + static bool is_simm(int64_t x, int nbits) { return -(CONST64(1) << (nbits-1)) <= x && + x < (CONST64(1) << (nbits-1)); } static bool is_simm32(int64_t x) { return x == (int64_t)(int32_t)x; } #else - static bool is_simm(int32_t x, int nbits) { return -( 1 << (nbits-1) ) <= x && x < ( 1 << (nbits-1) ); } + static bool is_simm(int32_t x, int nbits) { return -(1 << (nbits-1)) <= x && + x < (1 << (nbits-1)); } static bool is_simm32(int32_t x) { return true; } -#endif // LP64 +#endif // _LP64 // Generic instructions // Does 32bit or 64bit as needed for the platform. In some sense these @@ -705,7 +707,6 @@ void push(void* v); void pop(void* v); - // These do register sized moves/scans void rep_mov(); void rep_set(); @@ -716,6 +717,8 @@ // Vanilla instructions in lexical order + void adcl(Address dst, int32_t imm32); + void adcl(Address dst, Register src); void adcl(Register dst, int32_t imm32); void adcl(Register dst, Address src); void adcl(Register dst, Register src); @@ -724,7 +727,6 @@ void adcq(Register dst, Address src); void adcq(Register dst, Register src); - void addl(Address dst, int32_t imm32); void addl(Address dst, Register src); void addl(Register dst, int32_t imm32); @@ -737,7 +739,6 @@ void addq(Register dst, Address src); void addq(Register dst, Register src); - void addr_nop_4(); void addr_nop_5(); void addr_nop_7(); @@ -759,7 +760,6 @@ void andq(Register dst, Address src); void andq(Register dst, Register src); - // Bitwise Logical AND of Packed Double-Precision Floating-Point Values void andpd(XMMRegister dst, Address src); void andpd(XMMRegister dst, XMMRegister src); @@ -1151,7 +1151,7 @@ #ifdef _LP64 void movq(Register dst, Register src); void movq(Register dst, Address src); - void movq(Address dst, Register src); + void movq(Address dst, Register src); #endif void movq(Address dst, MMXRegister src ); @@ -1177,7 +1177,7 @@ void movsbq(Register dst, Register src); // Move signed 32bit immediate to 64bit extending sign - void movslq(Address dst, int32_t imm64); + void movslq(Address dst, int32_t imm64); void movslq(Register dst, int32_t imm64); void movslq(Register dst, Address src); @@ -1857,7 +1857,10 @@ Register t2, // temp register Label& slow_case // continuation point if fast allocation fails ); - void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); + Register tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); // returns TLS address + void incr_allocated_bytes(Register thread, + Register var_size_in_bytes, int con_size_in_bytes, + Register t1 = noreg); // interface method calling void lookup_interface_method(Register recv_klass, @@ -2180,9 +2183,9 @@ void divss(XMMRegister dst, Address src) { Assembler::divss(dst, src); } void divss(XMMRegister dst, AddressLiteral src) { Assembler::divss(dst, as_Address(src)); } - void movsd(XMMRegister dst, XMMRegister src) { Assembler::movsd(dst, src); } - void movsd(Address dst, XMMRegister src) { Assembler::movsd(dst, src); } - void movsd(XMMRegister dst, Address src) { Assembler::movsd(dst, src); } + void movsd(XMMRegister dst, XMMRegister src) { Assembler::movsd(dst, src); } + void movsd(Address dst, XMMRegister src) { Assembler::movsd(dst, src); } + void movsd(XMMRegister dst, Address src) { Assembler::movsd(dst, src); } void movsd(XMMRegister dst, AddressLiteral src) { Assembler::movsd(dst, as_Address(src)); } void mulsd(XMMRegister dst, XMMRegister src) { Assembler::mulsd(dst, src); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -2036,7 +2036,7 @@ } } -void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) { +void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) { Assembler::Condition acond, ncond; switch (condition) { case lir_cond_equal: acond = Assembler::equal; ncond = Assembler::notEqual; break; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -741,7 +741,7 @@ // generate conditional move of boolean result LIR_Opr result = rlock_result(x); - __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result); + __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result, T_LONG); } @@ -810,7 +810,8 @@ // generate conditional move of boolean result LIR_Opr result = rlock_result(x); - __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result); + __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), + result, as_BasicType(type)); if (type == objectType) { // Write-barrier needed for Object fields. // Seems to be precise post_barrier(addr, val.result()); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp --- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -141,6 +141,7 @@ tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case); } else { eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case); + incr_allocated_bytes(noreg, var_size_in_bytes, con_size_in_bytes, t1); } } @@ -234,7 +235,7 @@ void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) { assert(obj == rax, "obj must be in rax, for cmpxchg"); - assert(obj != t1 && obj != t2 && t1 != t2, "registers must be different"); // XXX really? + assert_different_registers(obj, t1, t2); // XXX really? assert(header_size >= 0 && object_size >= header_size, "illegal sizes"); try_allocate(obj, noreg, object_size * BytesPerWord, t1, t2, slow_case); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp --- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -977,7 +977,6 @@ // verify that that there is really a valid exception in rax, __ verify_not_null_oop(exception_oop); - oop_maps = new OopMapSet(); OopMap* oop_map = generate_oop_map(sasm, 1); generate_handle_exception(sasm, oop_maps, oop_map); @@ -1037,13 +1036,16 @@ // if we got here then the TLAB allocation failed, so try // refilling the TLAB or allocating directly from eden. Label retry_tlab, try_eden; - __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass) + const Register thread = + __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass), returns rdi __ bind(retry_tlab); // get the instance size (size is postive so movl is fine for 64bit) __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); + __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path); + __ initialize_object(obj, klass, obj_size, 0, t1, t2); __ verify_oop(obj); __ pop(rbx); @@ -1053,7 +1055,10 @@ __ bind(try_eden); // get the instance size (size is postive so movl is fine for 64bit) __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); + __ eden_allocate(obj, obj_size, 0, t1, slow_path); + __ incr_allocated_bytes(thread, obj_size, 0); + __ initialize_object(obj, klass, obj_size, 0, t1, t2); __ verify_oop(obj); __ pop(rbx); @@ -1143,12 +1148,13 @@ // if we got here then the TLAB allocation failed, so try // refilling the TLAB or allocating directly from eden. Label retry_tlab, try_eden; - __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx, & rdx + const Register thread = + __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx & rdx, returns rdi __ bind(retry_tlab); // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) - // since size is postive movl does right thing on 64bit + // since size is positive movl does right thing on 64bit __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); // since size is postive movl does right thing on 64bit __ movl(arr_size, length); @@ -1175,7 +1181,7 @@ __ bind(try_eden); // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F)) - // since size is postive movl does right thing on 64bit + // since size is positive movl does right thing on 64bit __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes())); // since size is postive movl does right thing on 64bit __ movl(arr_size, length); @@ -1188,6 +1194,7 @@ __ andptr(arr_size, ~MinObjAlignmentInBytesMask); __ eden_allocate(obj, arr_size, 0, t1, slow_path); // preserves arr_size + __ incr_allocated_bytes(thread, arr_size, 0); __ initialize_header(obj, klass, length, t1, t2); __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte))); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/methodHandles_x86.cpp --- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -385,9 +385,12 @@ // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS. } +//------------------------------------------------------------------------------ +// MethodHandles::generate_method_handle_stub +// // Generate an "entry" field for a method handle. // This determines how the method handle will respond to calls. -void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) { +void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) { // Here is the register state during an interpreted call, // as set up by generate_method_handle_interpreter_entry(): // - rbx: garbage temp (was MethodHandle.invoke methodOop, unused) @@ -396,14 +399,21 @@ // - rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted) // - rdx: garbage temp, can blow away - Register rcx_recv = rcx; - Register rax_argslot = rax; - Register rbx_temp = rbx; - Register rdx_temp = rdx; + const Register rcx_recv = rcx; + const Register rax_argslot = rax; + const Register rbx_temp = rbx; + const Register rdx_temp = rdx; // This guy is set up by prepare_to_jump_from_interpreted (from interpreted calls) // and gen_c2i_adapter (from compiled calls): - Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi); + const Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi); + + // Argument registers for _raise_exception. + // 32-bit: Pass first two oop/int args in registers ECX and EDX. + const Register rarg0_code = LP64_ONLY(j_rarg0) NOT_LP64(rcx); + const Register rarg1_actual = LP64_ONLY(j_rarg1) NOT_LP64(rdx); + const Register rarg2_required = LP64_ONLY(j_rarg2) NOT_LP64(rdi); + assert_different_registers(rarg0_code, rarg1_actual, rarg2_required, saved_last_sp); guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets"); @@ -437,47 +447,41 @@ switch ((int) ek) { case _raise_exception: { - // Not a real MH entry, but rather shared code for raising an exception. - // Extra local arguments are pushed on stack, as required type at TOS+8, - // failing object (or NULL) at TOS+4, failing bytecode type at TOS. - // Beyond those local arguments are the PC, of course. - Register rdx_code = rdx_temp; - Register rcx_fail = rcx_recv; - Register rax_want = rax_argslot; - Register rdi_pc = rdi; - __ pop(rdx_code); // TOS+0 - __ pop(rcx_fail); // TOS+4 - __ pop(rax_want); // TOS+8 - __ pop(rdi_pc); // caller PC + // Not a real MH entry, but rather shared code for raising an + // exception. Since we use a C2I adapter to set up the + // interpreter state, arguments are expected in compiler + // argument registers. + methodHandle mh(raise_exception_method()); + address c2i_entry = methodOopDesc::make_adapters(mh, CHECK); - __ mov(rsp, rsi); // cut the stack back to where the caller started - - // Repush the arguments as if coming from the interpreter. - __ push(rdx_code); - __ push(rcx_fail); - __ push(rax_want); + const Register rdi_pc = rax; + __ pop(rdi_pc); // caller PC + __ mov(rsp, saved_last_sp); // cut the stack back to where the caller started Register rbx_method = rbx_temp; - Label no_method; + Label L_no_method; // FIXME: fill in _raise_exception_method with a suitable sun.dyn method __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method)); __ testptr(rbx_method, rbx_method); - __ jccb(Assembler::zero, no_method); - int jobject_oop_offset = 0; + __ jccb(Assembler::zero, L_no_method); + + const int jobject_oop_offset = 0; __ movptr(rbx_method, Address(rbx_method, jobject_oop_offset)); // dereference the jobject __ testptr(rbx_method, rbx_method); - __ jccb(Assembler::zero, no_method); + __ jccb(Assembler::zero, L_no_method); __ verify_oop(rbx_method); - __ push(rdi_pc); // and restore caller PC - __ jmp(rbx_method_fie); + + // 32-bit: push remaining arguments as if coming from the compiler. + NOT_LP64(__ push(rarg2_required)); + + __ push(rdi_pc); // restore caller PC + __ jump(ExternalAddress(c2i_entry)); // do C2I transition // If we get here, the Java runtime did not do its job of creating the exception. // Do something that is at least causes a valid throw from the interpreter. - __ bind(no_method); - __ pop(rax_want); - __ pop(rcx_fail); - __ push(rax_want); - __ push(rcx_fail); + __ bind(L_no_method); + __ push(rarg2_required); + __ push(rarg1_actual); __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); } break; @@ -572,9 +576,11 @@ __ bind(no_such_interface); // Throw an exception. // For historical reasons, it will be IncompatibleClassChangeError. - __ pushptr(Address(rdx_intf, java_mirror_offset)); // required interface - __ push(rcx_recv); // bad receiver - __ push((int)Bytecodes::_invokeinterface); // who is complaining? + __ mov(rbx_temp, rcx_recv); // rarg2_required might be RCX + assert_different_registers(rarg2_required, rbx_temp); + __ movptr(rarg2_required, Address(rdx_intf, java_mirror_offset)); // required interface + __ mov( rarg1_actual, rbx_temp); // bad receiver + __ movl( rarg0_code, (int) Bytecodes::_invokeinterface); // who is complaining? __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); } break; @@ -669,10 +675,10 @@ __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field __ movptr(rdx_temp, vmarg); - __ load_heap_oop(rbx_klass, rcx_amh_argument); // required class - __ push(rbx_klass); - __ push(rdx_temp); // bad object - __ push((int)Bytecodes::_checkcast); // who is complaining? + assert_different_registers(rarg2_required, rdx_temp); + __ load_heap_oop(rarg2_required, rcx_amh_argument); // required class + __ mov( rarg1_actual, rdx_temp); // bad object + __ movl( rarg0_code, (int) Bytecodes::_checkcast); // who is complaining? __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); __ bind(done); @@ -1189,16 +1195,18 @@ __ bind(bad_array_klass); UNPUSH_RSI_RDI; - __ pushptr(Address(rdx_array_klass, java_mirror_offset)); // required type - __ pushptr(vmarg); // bad array - __ push((int)Bytecodes::_aaload); // who is complaining? + assert(!vmarg.uses(rarg2_required), "must be different registers"); + __ movptr(rarg2_required, Address(rdx_array_klass, java_mirror_offset)); // required type + __ movptr(rarg1_actual, vmarg); // bad array + __ movl( rarg0_code, (int) Bytecodes::_aaload); // who is complaining? __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); __ bind(bad_array_length); UNPUSH_RSI_RDI; - __ push(rcx_recv); // AMH requiring a certain length - __ pushptr(vmarg); // bad array - __ push((int)Bytecodes::_arraylength); // who is complaining? + assert(!vmarg.uses(rarg2_required), "must be different registers"); + __ mov (rarg2_required, rcx_recv); // AMH requiring a certain length + __ movptr(rarg1_actual, vmarg); // bad array + __ movl( rarg0_code, (int) Bytecodes::_arraylength); // who is complaining? __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); #undef UNPUSH_RSI_RDI diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp --- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3203,10 +3203,12 @@ const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; + const Register thread = rcx; + if (UseTLAB || allow_shared_alloc) { + __ get_thread(thread); + } + if (UseTLAB) { - const Register thread = rcx; - - __ get_thread(thread); __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset()))); __ lea(rbx, Address(rax, rdx, Address::times_1)); __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset()))); @@ -3247,6 +3249,8 @@ // if someone beat us on the allocation, try again, otherwise continue __ jcc(Assembler::notEqual, retry); + + __ incr_allocated_bytes(thread, rdx, 0); } if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { @@ -3256,12 +3260,12 @@ __ decrement(rdx, sizeof(oopDesc)); __ jcc(Assembler::zero, initialize_header); - // Initialize topmost object field, divide rdx by 8, check if odd and - // test if zero. + // Initialize topmost object field, divide rdx by 8, check if odd and + // test if zero. __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd - // rdx must have been multiple of 8 + // rdx must have been multiple of 8 #ifdef ASSERT // make sure rdx was multiple of 8 Label L; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp --- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3266,6 +3266,8 @@ // if someone beat us on the allocation, try again, otherwise continue __ jcc(Assembler::notEqual, retry); + + __ incr_allocated_bytes(r15_thread, rdx, 0); } if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os/linux/vm/perfMemory_linux.cpp --- a/hotspot/src/os/linux/vm/perfMemory_linux.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os/linux/vm/perfMemory_linux.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -635,7 +635,29 @@ return -1; } - return fd; + // Verify that we have enough disk space for this file. + // We'll get random SIGBUS crashes on memory accesses if + // we don't. + + for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) { + int zero_int = 0; + result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos)); + if (result == -1 ) break; + RESTARTABLE(::write(fd, &zero_int, 1), result); + if (result != 1) { + if (errno == ENOSPC) { + warning("Insufficient space for shared memory file:\n %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename); + } + break; + } + } + + if (result != -1) { + return fd; + } else { + RESTARTABLE(::close(fd), result); + return -1; + } } // open the shared memory file for the given user and vmid. returns diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os/posix/launcher/java_md.c --- a/hotspot/src/os/posix/launcher/java_md.c Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os/posix/launcher/java_md.c Wed Jan 19 19:01:35 2011 -0800 @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os/solaris/vm/os_solaris.cpp --- a/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,6 +80,7 @@ // put OS-includes here # include # include +# include # include # include # include @@ -282,7 +283,7 @@ is_error_reported(), "sp must be inside of selected thread stack"); - thread->_self_raw_id = raw_id; // mark for quick retrieval + thread->set_self_raw_id(raw_id); // mark for quick retrieval _get_thread_cache[ index ] = thread; } return thread; @@ -1475,6 +1476,13 @@ return &allowdebug_blocked_sigs; } + +void _handle_uncaught_cxx_exception() { + VMError err("An uncaught C++ exception"); + err.report_and_die(); +} + + // First crack at OS-specific initialization, from inside the new thread. void os::initialize_thread() { int r = thr_main() ; @@ -1564,6 +1572,7 @@ // use the dynamic check for T2 libthread. os::Solaris::init_thread_fpu_state(); + std::set_terminate(_handle_uncaught_cxx_exception); } @@ -3081,7 +3090,7 @@ if (addr == NULL) { jio_snprintf(buf, sizeof(buf), ": %s", strerror(err)); } - warning("attempt_reserve_memory_at: couldn't reserve %d bytes at " + warning("attempt_reserve_memory_at: couldn't reserve " SIZE_FORMAT " bytes at " PTR_FORMAT ": reserve_memory_helper returned " PTR_FORMAT "%s", bytes, requested_addr, addr, buf); } @@ -5188,7 +5197,7 @@ int o_delete = (oflag & O_DELETE); oflag = oflag & ~O_DELETE; - fd = ::open(path, oflag, mode); + fd = ::open64(path, oflag, mode); if (fd == -1) return -1; //If the open succeeded, the file might still be a directory diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os/solaris/vm/thread_solaris.inline.hpp --- a/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,10 +53,10 @@ uintptr_t raw = pd_raw_thread_id(); int ix = pd_cache_index(raw); - Thread *Candidate = ThreadLocalStorage::_get_thread_cache[ix]; - if (Candidate->_self_raw_id == raw) { + Thread* candidate = ThreadLocalStorage::_get_thread_cache[ix]; + if (candidate->self_raw_id() == raw) { // hit - return Candidate; + return candidate; } else { return ThreadLocalStorage::get_thread_via_cache_slowly(raw, ix); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os/windows/vm/os_windows.cpp --- a/hotspot/src/os/windows/vm/os_windows.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * CopyrighT (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2004,6 +2004,16 @@ int number; }; +// All Visual C++ exceptions thrown from code generated by the Microsoft Visual +// C++ compiler contain this error code. Because this is a compiler-generated +// error, the code is not listed in the Win32 API header files. +// The code is actually a cryptic mnemonic device, with the initial "E" +// standing for "exception" and the final 3 bytes (0x6D7363) representing the +// ASCII values of "msc". + +#define EXCEPTION_UNCAUGHT_CXX_EXCEPTION 0xE06D7363 + + struct siglabel exceptlabels[] = { def_excpt(EXCEPTION_ACCESS_VIOLATION), def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT), @@ -2028,6 +2038,7 @@ def_excpt(EXCEPTION_INVALID_DISPOSITION), def_excpt(EXCEPTION_GUARD_PAGE), def_excpt(EXCEPTION_INVALID_HANDLE), + def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION), NULL, 0 }; @@ -2261,7 +2272,6 @@ } } - if (t != NULL && t->is_Java_thread()) { JavaThread* thread = (JavaThread*) t; bool in_java = thread->thread_state() == _thread_in_Java; @@ -2465,8 +2475,9 @@ } // switch } #ifndef _WIN64 - if ((thread->thread_state() == _thread_in_Java) || - (thread->thread_state() == _thread_in_native) ) + if (((thread->thread_state() == _thread_in_Java) || + (thread->thread_state() == _thread_in_native)) && + exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) { LONG result=Handle_FLT_Exception(exceptionInfo); if (result==EXCEPTION_CONTINUE_EXECUTION) return result; @@ -2490,6 +2501,7 @@ case EXCEPTION_ILLEGAL_INSTRUCTION_2: case EXCEPTION_INT_OVERFLOW: case EXCEPTION_INT_DIVIDE_BY_ZERO: + case EXCEPTION_UNCAUGHT_CXX_EXCEPTION: { report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, exceptionInfo->ContextRecord); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -585,6 +585,13 @@ sigaddset(&newset, sig); sigprocmask(SIG_UNBLOCK, &newset, NULL); + // Determine which sort of error to throw. Out of swap may signal + // on the thread stack, which could get a mapping error when touched. + address addr = (address) info->si_addr; + if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { + vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); + } + VMError err(t, sig, pc, info, ucVoid); err.report_and_die(); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp --- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -29,6 +29,7 @@ # include # include # include +# include // We need to keep these here as long as we have to build on Solaris // versions before 10. @@ -96,11 +97,23 @@ #ifndef AV_SPARC_ASI_BLK_INIT #define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */ #endif + if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; + #ifndef AV_SPARC_FMAF -#define AV_SPARC_FMAF 0x0100 /* Sparc64 Fused Multiply-Add */ +#define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */ #endif - if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m; + +#ifndef AV_SPARC_FMAU +#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */ +#endif + if (av & AV_SPARC_FMAU) features |= fmau_instructions_m; + +#ifndef AV_SPARC_VIS3 +#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */ +#endif + if (av & AV_SPARC_VIS3) features |= vis3_instructions_m; + } else { // getisax(2) failed, use the old legacy code. #ifndef PRODUCT @@ -140,5 +153,59 @@ // Determine the machine type. do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m); + { + // Using kstat to determine the machine type. + kstat_ctl_t* kc = kstat_open(); + kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL); + const char* implementation = "UNKNOWN"; + if (ksp != NULL) { + if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) { + kstat_named_t* knm = (kstat_named_t *)ksp->ks_data; + for (int i = 0; i < ksp->ks_ndata; i++) { + if (strcmp((const char*)&(knm[i].name),"implementation") == 0) { +#ifndef KSTAT_DATA_STRING +#define KSTAT_DATA_STRING 9 +#endif + if (knm[i].data_type == KSTAT_DATA_CHAR) { + // VM is running on Solaris 8 which does not have value.str. + implementation = &(knm[i].value.c[0]); + } else if (knm[i].data_type == KSTAT_DATA_STRING) { + // VM is running on Solaris 10. +#ifndef KSTAT_NAMED_STR_PTR + // Solaris 8 was used to build VM, define the structure it misses. + struct str_t { + union { + char *ptr; /* NULL-term string */ + char __pad[8]; /* 64-bit padding */ + } addr; + uint32_t len; /* # bytes for strlen + '\0' */ + }; +#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr) +#endif + implementation = KSTAT_NAMED_STR_PTR(&knm[i]); + } +#ifndef PRODUCT + if (PrintMiscellaneous && Verbose) { + tty->print_cr("cpu_info.implementation: %s", implementation); + } +#endif + if (strncmp(implementation, "SPARC64", 7) == 0) { + features |= sparc64_family_m; + } else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) { + features |= T_family_m; + if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) { + features |= T1_model_m; + } + } + break; + } + } // for( + } + } + assert(strcmp(implementation, "UNKNOWN") != 0, + "unknown cpu info (changed kstat interface?)"); + kstat_close(kc); + } + return features; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -742,6 +742,13 @@ sigaddset(&newset, sig); sigprocmask(SIG_UNBLOCK, &newset, NULL); + // Determine which sort of error to throw. Out of swap may signal + // on the thread stack, which could get a mapping error when touched. + address addr = (address) info->si_addr; + if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { + vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); + } + VMError err(t, sig, pc, info, ucVoid); err.report_and_die(); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/adlc/dict2.cpp --- a/hotspot/src/share/vm/adlc/dict2.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/adlc/dict2.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -34,7 +34,7 @@ #define MAXID 20 static char initflag = 0; // True after 1st initialization static char shft[MAXID] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6}; -static short xsum[MAXID + 1]; +static short xsum[MAXID]; //------------------------------bucket--------------------------------------- class bucket { @@ -66,7 +66,7 @@ // Precompute table of null character hashes if( !initflag ) { // Not initializated yet? xsum[0] = (1<> 1); // Hash key, un-modulo'd table size } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_Compilation.cpp --- a/hotspot/src/share/vm/c1/c1_Compilation.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -245,7 +245,7 @@ } -void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { +bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) { // Preinitialize the consts section to some large size: int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo)); char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); @@ -253,15 +253,20 @@ locs_buffer_size / sizeof(relocInfo)); code->initialize_consts_size(Compilation::desired_max_constant_size()); // Call stubs + two deopt handlers (regular and MH) + exception handler - code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) + - LIR_Assembler::exception_handler_size + - 2 * LIR_Assembler::deopt_handler_size); + int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) + + LIR_Assembler::exception_handler_size + + (2 * LIR_Assembler::deopt_handler_size); + if (stub_size >= code->insts_capacity()) return false; + code->initialize_stubs_size(stub_size); + return true; } int Compilation::emit_code_body() { // emit code - setup_code_buffer(code(), allocator()->num_calls()); + if (!setup_code_buffer(code(), allocator()->num_calls())) { + BAILOUT_("size requested greater than avail code buffer size", 0); + } code()->initialize_oop_recorder(env()->oop_recorder()); _masm = new C1_MacroAssembler(code()); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_Compilation.hpp --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -192,7 +192,7 @@ return desired_max_code_buffer_size() / 10; } - static void setup_code_buffer(CodeBuffer* cb, int call_stub_estimate); + static bool setup_code_buffer(CodeBuffer* cb, int call_stub_estimate); // timers static void print_timers(); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_FrameMap.cpp --- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -92,7 +92,7 @@ if (opr->is_address()) { LIR_Address* addr = opr->as_address_ptr(); assert(addr->disp() == (int)addr->disp(), "out of range value"); - out_preserve = MAX2(out_preserve, (intptr_t)addr->disp() / 4); + out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4); } i += type2size[t]; } @@ -143,7 +143,7 @@ args->append(opr); if (opr->is_address()) { LIR_Address* addr = opr->as_address_ptr(); - out_preserve = MAX2(out_preserve, (intptr_t)addr->disp() / 4); + out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4); } i += type2size[t]; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LIR.hpp --- a/hotspot/src/share/vm/c1/c1_LIR.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LIR.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1568,15 +1568,16 @@ assert(code == lir_cmp, "code check"); } - LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) + LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) : LIR_Op(code, result, NULL) , _opr1(opr1) , _opr2(opr2) - , _type(T_ILLEGAL) + , _type(type) , _condition(condition) , _fpu_stack_size(0) , _tmp(LIR_OprFact::illegalOpr) { assert(code == lir_cmove, "code check"); + assert(type != T_ILLEGAL, "cmove should have type"); } LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr, @@ -1993,8 +1994,8 @@ void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info); - void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst) { - append(new LIR_Op2(lir_cmove, condition, src1, src2, dst)); + void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst, BasicType type) { + append(new LIR_Op2(lir_cmove, condition, src1, src2, dst, type)); } void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value, diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LIRAssembler.cpp --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -685,7 +685,7 @@ break; case lir_cmove: - cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr()); + cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->type()); break; case lir_shl: diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LIRAssembler.hpp --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -217,7 +217,7 @@ void volatile_move_op(LIR_Opr src, LIR_Opr result, BasicType type, CodeEmitInfo* info); void comp_mem_op(LIR_Opr src, LIR_Opr result, BasicType type, CodeEmitInfo* info); // info set for null exceptions void comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr result, LIR_Op2* op); - void cmove(LIR_Condition code, LIR_Opr left, LIR_Opr right, LIR_Opr result); + void cmove(LIR_Condition code, LIR_Opr left, LIR_Opr right, LIR_Opr result, BasicType type); void call( LIR_OpJavaCall* op, relocInfo::relocType rtype); void ic_call( LIR_OpJavaCall* op); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LIRGenerator.cpp --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -856,7 +856,7 @@ __ cmove(lir_cond(cond), LIR_OprFact::intptrConst(taken_count_offset), LIR_OprFact::intptrConst(not_taken_count_offset), - data_offset_reg); + data_offset_reg, as_BasicType(if_instr->x()->type())); // MDO cells are intptr_t, so the data_reg width is arch-dependent. LIR_Opr data_reg = new_pointer_register(); @@ -2591,7 +2591,7 @@ LIR_Opr reg = rlock_result(x); __ cmp(lir_cond(x->cond()), left.result(), right.result()); - __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg); + __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type())); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LinearScan.cpp --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -90,6 +90,7 @@ , _intervals(0) // initialized later with correct length , _new_intervals_from_allocation(new IntervalList()) , _sorted_intervals(NULL) + , _needs_full_resort(false) , _lir_ops(0) // initialized later with correct length , _block_of_op(0) // initialized later with correct length , _has_info(0) @@ -1520,6 +1521,14 @@ void LinearScan::sort_intervals_before_allocation() { TIME_LINEAR_SCAN(timer_sort_intervals_before); + if (_needs_full_resort) { + // There is no known reason why this should occur but just in case... + assert(false, "should never occur"); + // Re-sort existing interval list because an Interval::from() has changed + _sorted_intervals->sort(interval_cmp); + _needs_full_resort = false; + } + IntervalList* unsorted_list = &_intervals; int unsorted_len = unsorted_list->length(); int sorted_len = 0; @@ -1559,11 +1568,18 @@ } } _sorted_intervals = sorted_list; + assert(is_sorted(_sorted_intervals), "intervals unsorted"); } void LinearScan::sort_intervals_after_allocation() { TIME_LINEAR_SCAN(timer_sort_intervals_after); + if (_needs_full_resort) { + // Re-sort existing interval list because an Interval::from() has changed + _sorted_intervals->sort(interval_cmp); + _needs_full_resort = false; + } + IntervalArray* old_list = _sorted_intervals; IntervalList* new_list = _new_intervals_from_allocation; int old_len = old_list->length(); @@ -1571,6 +1587,7 @@ if (new_len == 0) { // no intervals have been added during allocation, so sorted list is already up to date + assert(is_sorted(_sorted_intervals), "intervals unsorted"); return; } @@ -1593,6 +1610,7 @@ } _sorted_intervals = combined_list; + assert(is_sorted(_sorted_intervals), "intervals unsorted"); } @@ -1825,6 +1843,8 @@ interval = interval->split(from_op_id); interval->assign_reg(reg, regHi); append_interval(interval); + } else { + _needs_full_resort = true; } assert(interval->from() == from_op_id, "must be true now"); @@ -4492,7 +4512,8 @@ } } else { type_name = type2name(type()); - if (assigned_reg() != -1) { + if (assigned_reg() != -1 && + (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) { opr = LinearScan::calc_operand_for_interval(this); } } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/c1/c1_LinearScan.hpp --- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -148,6 +148,7 @@ IntervalList _intervals; // mapping from register number to interval IntervalList* _new_intervals_from_allocation; // list with all intervals created during allocation when an existing interval is split IntervalArray* _sorted_intervals; // intervals sorted by Interval::from() + bool _needs_full_resort; // set to true if an Interval::from() is changed and _sorted_intervals must be resorted LIR_OpArray _lir_ops; // mapping from LIR_Op id to LIR_Op node BlockBeginArray _block_of_op; // mapping from LIR_Op id to the BlockBegin containing this instruction diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/classfile/classFileParser.cpp --- a/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -2386,19 +2386,21 @@ valid_cp_range(bootstrap_method_index, cp_size) && cp->tag_at(bootstrap_method_index).is_method_handle(), "bootstrap_method_index %u has bad constant type in class file %s", + bootstrap_method_index, CHECK); operands->short_at_put(operand_fill_index++, bootstrap_method_index); operands->short_at_put(operand_fill_index++, argument_count); cfs->guarantee_more(sizeof(u2) * argument_count, CHECK); // argv[argc] for (int j = 0; j < argument_count; j++) { - u2 arg_index = cfs->get_u2_fast(); + u2 argument_index = cfs->get_u2_fast(); check_property( - valid_cp_range(arg_index, cp_size) && - cp->tag_at(arg_index).is_loadable_constant(), + valid_cp_range(argument_index, cp_size) && + cp->tag_at(argument_index).is_loadable_constant(), "argument_index %u has bad constant type in class file %s", + argument_index, CHECK); - operands->short_at_put(operand_fill_index++, arg_index); + operands->short_at_put(operand_fill_index++, argument_index); } } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/code/codeCache.cpp --- a/hotspot/src/share/vm/code/codeCache.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/code/codeCache.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -939,7 +939,9 @@ _heap->high(), _heap->high_boundary()); st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT - " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT, + " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT + " largest_free_block=" SIZE_FORMAT, CodeCache::nof_blobs(), CodeCache::nof_nmethods(), - CodeCache::nof_adapters(), CodeCache::unallocated_capacity()); + CodeCache::nof_adapters(), CodeCache::unallocated_capacity(), + CodeCache::largest_free_block()); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/code/codeCache.hpp --- a/hotspot/src/share/vm/code/codeCache.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/code/codeCache.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -158,6 +158,7 @@ static size_t capacity() { return _heap->capacity(); } static size_t max_capacity() { return _heap->max_capacity(); } static size_t unallocated_capacity() { return _heap->unallocated_capacity(); } + static size_t largest_free_block() { return _heap->largest_free_block(); } static bool needs_flushing() { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; } static bool needs_cache_clean() { return _needs_cache_clean; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/code/nmethod.cpp --- a/hotspot/src/share/vm/code/nmethod.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/code/nmethod.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -811,9 +811,11 @@ _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs()); // Exception handler and deopt handler are in the stub section + assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set"); + assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set"); _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); - if (has_method_handle_invokes()) { + if (offsets->value(CodeOffsets::DeoptMH) != -1) { _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH); } else { _deoptimize_mh_offset = -1; @@ -1909,6 +1911,7 @@ break; } } + assert(has_method_handle_invokes() == (_deoptimize_mh_offset != -1), "must have deopt mh handler"); int size = count * sizeof(PcDesc); assert(scopes_pcs_size() >= size, "oob"); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/compiler/abstractCompiler.cpp --- a/hotspot/src/share/vm/compiler/abstractCompiler.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/compiler/abstractCompiler.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -33,6 +33,7 @@ bool do_initialization = false; { ThreadInVMfromNative tv(thread); + ResetNoHandleMark rnhm; MutexLocker only_one(CompileThread_lock, thread); if ( *state == uninitialized) { do_initialization = true; @@ -53,6 +54,7 @@ // To in_vm so we can use the lock ThreadInVMfromNative tv(thread); + ResetNoHandleMark rnhm; MutexLocker only_one(CompileThread_lock, thread); assert(*state == initializing, "wrong state"); *state = initialized; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/compiler/compilerOracle.cpp --- a/hotspot/src/share/vm/compiler/compilerOracle.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -332,7 +332,7 @@ "command_names size mismatch"); *bytes_read = 0; - char command[32]; + char command[33]; int result = sscanf(line, "%32[a-z]%n", command, bytes_read); for (uint i = 0; i < ARRAY_SIZE(command_names); i++) { if (strcmp(command, command_names[i]) == 0) { @@ -470,6 +470,12 @@ OracleCommand command = parse_command_name(line, &bytes_read); line += bytes_read; + if (command == UnknownCommand) { + tty->print_cr("CompilerOracle: unrecognized line"); + tty->print_cr(" \"%s\"", original_line); + return; + } + if (command == QuietCommand) { _quiet = true; return; @@ -498,7 +504,7 @@ line += bytes_read; // there might be a signature following the method. // signatures always begin with ( so match that by hand - if (1 == sscanf(line, "%*[ \t](%254[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) { + if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) { sig[0] = '('; line += bytes_read; signature = oopFactory::new_symbol_handle(sig, CHECK); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp --- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,6 +153,7 @@ check_for_non_bad_heap_word_value(result, size)); assert(!HAS_PENDING_EXCEPTION, "Unexpected exception, will result in uninitialized storage"); + THREAD->incr_allocated_bytes(size * HeapWordSize); return result; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/memory/heap.cpp --- a/hotspot/src/share/vm/memory/heap.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/memory/heap.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -315,6 +315,15 @@ return l; } +size_t CodeHeap::largest_free_block() const { + size_t len = 0; + for (FreeBlock* b = _freelist; b != NULL; b = b->link()) { + if (b->length() > len) + len = b->length(); + } + return size(len); +} + // Free list management FreeBlock *CodeHeap::following_block(FreeBlock *b) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/memory/heap.hpp --- a/hotspot/src/share/vm/memory/heap.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/memory/heap.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -161,6 +161,7 @@ size_t max_capacity() const; size_t allocated_capacity() const; size_t unallocated_capacity() const { return max_capacity() - allocated_capacity(); } + size_t largest_free_block() const; // Debugging void verify(); diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp --- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,6 +114,11 @@ void ThreadLocalAllocBuffer::make_parsable(bool retire) { if (end() != NULL) { invariants(); + + if (retire) { + myThread()->incr_allocated_bytes(used_bytes()); + } + CollectedHeap::fill_with_object(top(), hard_end(), retire); if (retire || ZeroTLAB) { // "Reset" the TLAB diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/memory/threadLocalAllocBuffer.hpp --- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.hpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.hpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,6 +112,8 @@ HeapWord* top() const { return _top; } HeapWord* pf_top() const { return _pf_top; } size_t desired_size() const { return _desired_size; } + size_t used() const { return pointer_delta(top(), start()); } + size_t used_bytes() const { return pointer_delta(top(), start(), 1); } size_t free() const { return pointer_delta(end(), top()); } // Don't discard tlab if remaining space is larger than this. size_t refill_waste_limit() const { return _refill_waste_limit; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/memory/universe.cpp --- a/hotspot/src/share/vm/memory/universe.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/memory/universe.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -934,7 +934,8 @@ // See needs_explicit_null_check. // Only set the heap base for compressed oops because it indicates // compressed oops for pstack code. - if (PrintCompressedOopsMode) { + bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose); + if (verbose) { tty->cr(); tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M); @@ -943,12 +944,12 @@ // Can't reserve heap below 32Gb. Universe::set_narrow_oop_base(Universe::heap()->base() - os::vm_page_size()); Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); - if (PrintCompressedOopsMode) { + if (verbose) { tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base()); } } else { Universe::set_narrow_oop_base(0); - if (PrintCompressedOopsMode) { + if (verbose) { tty->print(", zero based Compressed Oops"); } #ifdef _WIN64 @@ -963,12 +964,12 @@ Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); } else { Universe::set_narrow_oop_shift(0); - if (PrintCompressedOopsMode) { + if (verbose) { tty->print(", 32-bits Oops"); } } } - if (PrintCompressedOopsMode) { + if (verbose) { tty->cr(); tty->cr(); } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/opto/compile.cpp --- a/hotspot/src/share/vm/opto/compile.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/opto/compile.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -444,22 +444,32 @@ } +//-----------------------init_scratch_buffer_blob------------------------------ +// Construct a temporary BufferBlob and cache it for this compile. void Compile::init_scratch_buffer_blob(int const_size) { - if (scratch_buffer_blob() != NULL) return; + // If there is already a scratch buffer blob allocated and the + // constant section is big enough, use it. Otherwise free the + // current and allocate a new one. + BufferBlob* blob = scratch_buffer_blob(); + if ((blob != NULL) && (const_size <= _scratch_const_size)) { + // Use the current blob. + } else { + if (blob != NULL) { + BufferBlob::free(blob); + } - // Construct a temporary CodeBuffer to have it construct a BufferBlob - // Cache this BufferBlob for this compile. - ResourceMark rm; - _scratch_const_size = const_size; - int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); - BufferBlob* blob = BufferBlob::create("Compile::scratch_buffer", size); - // Record the buffer blob for next time. - set_scratch_buffer_blob(blob); - // Have we run out of code space? - if (scratch_buffer_blob() == NULL) { - // Let CompilerBroker disable further compilations. - record_failure("Not enough space for scratch buffer in CodeCache"); - return; + ResourceMark rm; + _scratch_const_size = const_size; + int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size); + blob = BufferBlob::create("Compile::scratch_buffer", size); + // Record the buffer blob for next time. + set_scratch_buffer_blob(blob); + // Have we run out of code space? + if (scratch_buffer_blob() == NULL) { + // Let CompilerBroker disable further compilations. + record_failure("Not enough space for scratch buffer in CodeCache"); + return; + } } // Initialize the relocation buffers @@ -468,13 +478,6 @@ } -void Compile::clear_scratch_buffer_blob() { - assert(scratch_buffer_blob(), "no BufferBlob set"); - set_scratch_buffer_blob(NULL); - set_scratch_locs_memory(NULL); -} - - //-----------------------scratch_emit_size------------------------------------- // Helper function that computes size by emitting code uint Compile::scratch_emit_size(const Node* n) { diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/opto/escape.cpp --- a/hotspot/src/share/vm/opto/escape.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/opto/escape.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1609,10 +1609,11 @@ // // Normally only 1-3 passes needed to build // Connection Graph depending on graph complexity. - // Set limit to 10 to catch situation when something + // Observed 8 passes in jvm2008 compiler.compiler. + // Set limit to 20 to catch situation when something // did go wrong and recompile the method without EA. -#define CG_BUILD_ITER_LIMIT 10 +#define CG_BUILD_ITER_LIMIT 20 uint length = worklist.length(); int iterations = 0; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/opto/macro.cpp --- a/hotspot/src/share/vm/opto/macro.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/opto/macro.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1158,7 +1158,7 @@ // Note: We set the control input on "eden_end" and "old_eden_top" when using // a TLAB to work around a bug where these values were being moved across // a safepoint. These are not oops, so they cannot be include in the oop - // map, but the can be changed by a GC. The proper way to fix this would + // map, but they can be changed by a GC. The proper way to fix this would // be to set the raw memory state when generating a SafepointNode. However // this will require extensive changes to the loop optimization in order to // prevent a degradation of the optimization. @@ -1167,24 +1167,24 @@ // allocate the Region and Phi nodes for the result result_region = new (C, 3) RegionNode(3); - result_phi_rawmem = new (C, 3) PhiNode( result_region, Type::MEMORY, TypeRawPtr::BOTTOM ); - result_phi_rawoop = new (C, 3) PhiNode( result_region, TypeRawPtr::BOTTOM ); - result_phi_i_o = new (C, 3) PhiNode( result_region, Type::ABIO ); // I/O is used for Prefetch + result_phi_rawmem = new (C, 3) PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM); + result_phi_rawoop = new (C, 3) PhiNode(result_region, TypeRawPtr::BOTTOM); + result_phi_i_o = new (C, 3) PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch // We need a Region for the loop-back contended case. enum { fall_in_path = 1, contended_loopback_path = 2 }; Node *contended_region; Node *contended_phi_rawmem; - if( UseTLAB ) { + if (UseTLAB) { contended_region = toobig_false; contended_phi_rawmem = mem; } else { contended_region = new (C, 3) RegionNode(3); - contended_phi_rawmem = new (C, 3) PhiNode( contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); + contended_phi_rawmem = new (C, 3) PhiNode(contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); // Now handle the passing-too-big test. We fall into the contended // loop-back merge point. - contended_region ->init_req( fall_in_path, toobig_false ); - contended_phi_rawmem->init_req( fall_in_path, mem ); + contended_region ->init_req(fall_in_path, toobig_false); + contended_phi_rawmem->init_req(fall_in_path, mem); transform_later(contended_region); transform_later(contended_phi_rawmem); } @@ -1192,78 +1192,101 @@ // Load(-locked) the heap top. // See note above concerning the control input when using a TLAB Node *old_eden_top = UseTLAB - ? new (C, 3) LoadPNode ( ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM ) - : new (C, 3) LoadPLockedNode( contended_region, contended_phi_rawmem, eden_top_adr ); + ? new (C, 3) LoadPNode (ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM) + : new (C, 3) LoadPLockedNode(contended_region, contended_phi_rawmem, eden_top_adr); transform_later(old_eden_top); // Add to heap top to get a new heap top - Node *new_eden_top = new (C, 4) AddPNode( top(), old_eden_top, size_in_bytes ); + Node *new_eden_top = new (C, 4) AddPNode(top(), old_eden_top, size_in_bytes); transform_later(new_eden_top); // Check for needing a GC; compare against heap end - Node *needgc_cmp = new (C, 3) CmpPNode( new_eden_top, eden_end ); + Node *needgc_cmp = new (C, 3) CmpPNode(new_eden_top, eden_end); transform_later(needgc_cmp); - Node *needgc_bol = new (C, 2) BoolNode( needgc_cmp, BoolTest::ge ); + Node *needgc_bol = new (C, 2) BoolNode(needgc_cmp, BoolTest::ge); transform_later(needgc_bol); - IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN ); + IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN); transform_later(needgc_iff); // Plug the failing-heap-space-need-gc test into the slow-path region - Node *needgc_true = new (C, 1) IfTrueNode( needgc_iff ); + Node *needgc_true = new (C, 1) IfTrueNode(needgc_iff); transform_later(needgc_true); - if( initial_slow_test ) { - slow_region ->init_req( need_gc_path, needgc_true ); + if (initial_slow_test) { + slow_region->init_req(need_gc_path, needgc_true); // This completes all paths into the slow merge point transform_later(slow_region); } else { // No initial slow path needed! // Just fall from the need-GC path straight into the VM call. - slow_region = needgc_true; + slow_region = needgc_true; } // No need for a GC. Setup for the Store-Conditional - Node *needgc_false = new (C, 1) IfFalseNode( needgc_iff ); + Node *needgc_false = new (C, 1) IfFalseNode(needgc_iff); transform_later(needgc_false); // Grab regular I/O before optional prefetch may change it. // Slow-path does no I/O so just set it to the original I/O. - result_phi_i_o->init_req( slow_result_path, i_o ); + result_phi_i_o->init_req(slow_result_path, i_o); i_o = prefetch_allocation(i_o, needgc_false, contended_phi_rawmem, old_eden_top, new_eden_top, length); + // Name successful fast-path variables + Node* fast_oop = old_eden_top; + Node* fast_oop_ctrl; + Node* fast_oop_rawmem; + // Store (-conditional) the modified eden top back down. // StorePConditional produces flags for a test PLUS a modified raw // memory state. - Node *store_eden_top; - Node *fast_oop_ctrl; - if( UseTLAB ) { - store_eden_top = new (C, 4) StorePNode( needgc_false, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, new_eden_top ); + if (UseTLAB) { + Node* store_eden_top = + new (C, 4) StorePNode(needgc_false, contended_phi_rawmem, eden_top_adr, + TypeRawPtr::BOTTOM, new_eden_top); transform_later(store_eden_top); fast_oop_ctrl = needgc_false; // No contention, so this is the fast path + fast_oop_rawmem = store_eden_top; } else { - store_eden_top = new (C, 5) StorePConditionalNode( needgc_false, contended_phi_rawmem, eden_top_adr, new_eden_top, old_eden_top ); + Node* store_eden_top = + new (C, 5) StorePConditionalNode(needgc_false, contended_phi_rawmem, eden_top_adr, + new_eden_top, fast_oop/*old_eden_top*/); transform_later(store_eden_top); - Node *contention_check = new (C, 2) BoolNode( store_eden_top, BoolTest::ne ); + Node *contention_check = new (C, 2) BoolNode(store_eden_top, BoolTest::ne); transform_later(contention_check); store_eden_top = new (C, 1) SCMemProjNode(store_eden_top); transform_later(store_eden_top); // If not using TLABs, check to see if there was contention. - IfNode *contention_iff = new (C, 2) IfNode ( needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN ); + IfNode *contention_iff = new (C, 2) IfNode (needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN); transform_later(contention_iff); - Node *contention_true = new (C, 1) IfTrueNode( contention_iff ); + Node *contention_true = new (C, 1) IfTrueNode(contention_iff); transform_later(contention_true); // If contention, loopback and try again. - contended_region->init_req( contended_loopback_path, contention_true ); - contended_phi_rawmem->init_req( contended_loopback_path, store_eden_top ); + contended_region->init_req(contended_loopback_path, contention_true); + contended_phi_rawmem->init_req(contended_loopback_path, store_eden_top); // Fast-path succeeded with no contention! - Node *contention_false = new (C, 1) IfFalseNode( contention_iff ); + Node *contention_false = new (C, 1) IfFalseNode(contention_iff); transform_later(contention_false); fast_oop_ctrl = contention_false; + + // Bump total allocated bytes for this thread + Node* thread = new (C, 1) ThreadLocalNode(); + transform_later(thread); + Node* alloc_bytes_adr = basic_plus_adr(top()/*not oop*/, thread, + in_bytes(JavaThread::allocated_bytes_offset())); + Node* alloc_bytes = make_load(fast_oop_ctrl, store_eden_top, alloc_bytes_adr, + 0, TypeLong::LONG, T_LONG); +#ifdef _LP64 + Node* alloc_size = size_in_bytes; +#else + Node* alloc_size = new (C, 2) ConvI2LNode(size_in_bytes); + transform_later(alloc_size); +#endif + Node* new_alloc_bytes = new (C, 3) AddLNode(alloc_bytes, alloc_size); + transform_later(new_alloc_bytes); + fast_oop_rawmem = make_store(fast_oop_ctrl, store_eden_top, alloc_bytes_adr, + 0, new_alloc_bytes, T_LONG); } - // Rename successful fast-path variables to make meaning more obvious - Node* fast_oop = old_eden_top; - Node* fast_oop_rawmem = store_eden_top; fast_oop_rawmem = initialize_object(alloc, fast_oop_ctrl, fast_oop_rawmem, fast_oop, klass_node, length, size_in_bytes); @@ -1282,11 +1305,11 @@ call->init_req(TypeFunc::Parms+0, thread); call->init_req(TypeFunc::Parms+1, fast_oop); - call->init_req( TypeFunc::Control, fast_oop_ctrl ); - call->init_req( TypeFunc::I_O , top() ) ; // does no i/o - call->init_req( TypeFunc::Memory , fast_oop_rawmem ); - call->init_req( TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr) ); - call->init_req( TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr) ); + call->init_req(TypeFunc::Control, fast_oop_ctrl); + call->init_req(TypeFunc::I_O , top()); // does no i/o + call->init_req(TypeFunc::Memory , fast_oop_rawmem); + call->init_req(TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr)); + call->init_req(TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr)); transform_later(call); fast_oop_ctrl = new (C, 1) ProjNode(call,TypeFunc::Control); transform_later(fast_oop_ctrl); @@ -1295,10 +1318,10 @@ } // Plug in the successful fast-path into the result merge point - result_region ->init_req( fast_result_path, fast_oop_ctrl ); - result_phi_rawoop->init_req( fast_result_path, fast_oop ); - result_phi_i_o ->init_req( fast_result_path, i_o ); - result_phi_rawmem->init_req( fast_result_path, fast_oop_rawmem ); + result_region ->init_req(fast_result_path, fast_oop_ctrl); + result_phi_rawoop->init_req(fast_result_path, fast_oop); + result_phi_i_o ->init_req(fast_result_path, i_o); + result_phi_rawmem->init_req(fast_result_path, fast_oop_rawmem); } else { slow_region = ctrl; } diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/opto/output.cpp --- a/hotspot/src/share/vm/opto/output.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/opto/output.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -1746,9 +1746,6 @@ // Walk backwards over each basic block, computing the needed alignment // Walk over all the basic blocks scheduling.DoScheduling(); - - // Clear the BufferBlob used for scheduling. - clear_scratch_buffer_blob(); } //------------------------------ComputeLocalLatenciesForward------------------- diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/opto/stringopts.cpp --- a/hotspot/src/share/vm/opto/stringopts.cpp Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/opto/stringopts.cpp Wed Jan 19 19:01:35 2011 -0800 @@ -59,7 +59,8 @@ enum { StringMode, IntMode, - CharMode + CharMode, + StringNullCheckMode }; StringConcat(PhaseStringOpts* stringopts, CallStaticJavaNode* end): @@ -114,6 +115,9 @@ void push_string(Node* value) { push(value, StringMode); } + void push_string_null_check(Node* value) { + push(value, StringNullCheckMode); + } void push_int(Node* value) { push(value, IntMode); } @@ -416,7 +420,19 @@ if (sig == ciSymbol::string_void_signature()) { // StringBuilder(String) so pick this up as the first argument assert(use->in(TypeFunc::Parms + 1) != NULL, "what?"); - sc->push_string(use->in(TypeFunc::Parms + 1)); + const Type* type = _gvn->type(use->in(TypeFunc::Parms + 1)); + if (type == TypePtr::NULL_PTR) { + // StringBuilder(null) throws exception. +#ifndef PRODUCT + if (PrintOptimizeStringConcat) { + tty->print("giving up because StringBuilder(null) throws exception"); + alloc->jvms()->dump_spec(tty); tty->cr(); + } +#endif + return NULL; + } + // StringBuilder(str) argument needs null check. + sc->push_string_null_check(use->in(TypeFunc::Parms + 1)); } // The int variant takes an initial size for the backing // array so just treat it like the void version. @@ -436,7 +452,7 @@ #ifndef PRODUCT if (PrintOptimizeStringConcat) { tty->print("giving up because couldn't find constructor "); - alloc->jvms()->dump_spec(tty); + alloc->jvms()->dump_spec(tty); tty->cr(); } #endif break; @@ -1269,6 +1285,25 @@ string_sizes->init_req(argi, string_size); break; } + case StringConcat::StringNullCheckMode: { + const Type* type = kit.gvn().type(arg); + assert(type != TypePtr::NULL_PTR, "missing check"); + if (!type->higher_equal(TypeInstPtr::NOTNULL)) { + // Null check with uncommont trap since + // StringBuilder(null) throws exception. + // Use special uncommon trap instead of + // calling normal do_null_check(). + Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne); + IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN); + overflow->add_req(__ IfFalse(iff)); + Node* notnull = __ IfTrue(iff); + kit.set_control(notnull); // set control for the cast_not_null + arg = kit.cast_not_null(arg, false); + sc->set_argument(argi, arg); + } + assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity"); + // Fallthrough to add string length. + } case StringConcat::StringMode: { const Type* type = kit.gvn().type(arg); if (type == TypePtr::NULL_PTR) { @@ -1328,6 +1363,7 @@ // Hook PreserveJVMState pjvms(&kit); kit.set_control(overflow); + C->record_for_igvn(overflow); kit.uncommon_trap(Deoptimization::Reason_intrinsic, Deoptimization::Action_make_not_entrant); } @@ -1363,6 +1399,7 @@ start = end; break; } + case StringConcat::StringNullCheckMode: case StringConcat::StringMode: { start = copy_string(kit, arg, char_array, start); break; diff -r d534dd80da9f -r c19058ce05e8 hotspot/src/share/vm/prims/jvmti.xml --- a/hotspot/src/share/vm/prims/jvmti.xml Tue Jan 18 08:37:05 2011 -0800 +++ b/hotspot/src/share/vm/prims/jvmti.xml Wed Jan 19 19:01:35 2011 -0800 @@ -1,7 +1,7 @@ - - - WindowWithWarningTest - -
-  This test will run automatically.
-  
- - - - - diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.java --- a/jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.java Tue Jan 18 08:37:05 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,315 +0,0 @@ -/* - * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - test - @bug 6391770 - @summary Content of the Window should be laid out in the area left after WarningWindow was added. - @author yuri nesterenko: area= - @run applet WindowWithWarningTest.html -*/ - -// Note there is no @ in front of test above. This is so that the -// harness will not mistake this file as a test file. It should -// only see the html file as a test file. (the harness runs all -// valid test files, so it would run this test twice if this file -// were valid as well as the html file.) -// Also, note the area= after Your Name in the author tag. Here, you -// should put which functional area the test falls in. See the -// AWT-core home page -> test areas and/or -> AWT team for a list of -// areas. -// Note also the 'AutomaticAppletTest.html' in the run tag. This should -// be changed to the name of the test. - - -/** - * WindowWithWarningTest.java - * - * summary: - */ - -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -//Automated tests should run as applet tests if possible because they -// get their environments cleaned up, including AWT threads, any -// test created threads, and any system resources used by the test -// such as file descriptors. (This is normally not a problem as -// main tests usually run in a separate VM, however on some platforms -// such as the Mac, separate VMs are not possible and non-applet -// tests will cause problems). Also, you don't have to worry about -// synchronisation stuff in Applet tests they way you do in main -// tests... - - -public class WindowWithWarningTest extends Applet -{ - //Declare things used in the test, like buttons and labels here - boolean buttonClicked = false; - public static final int MAX_COUNT = 100; - - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - - this.setLayout (new BorderLayout ()); - - String[] instructions = - { - "This is an AUTOMATIC test", - "simply wait until it is done" - }; - //Sysout.createDialog( ); - //Sysout.printInstructions( instructions ); - - }//End init() - public void start () - { - //Get things going. Request focus, set size, et cetera - System.setSecurityManager( new SecurityManager() { - // deny AWTPermission("showWindowWithoutWarningBanner") - public boolean checkTopLevelWindow(Object window) { - return false; - } - }); - JFrame frame = new JFrame("Window Test"); - frame.setBounds(50, 50, 200, 200); - frame.show(); - - JWindow window = new JWindow( frame ); - JButton jbutton1 = new JButton( "First" ); - jbutton1.addMouseListener( new MouseAdapter() { - public void mousePressed( MouseEvent me ) { - buttonClicked = true; - } - }); - JButton jbutton2 = new JButton( "Second" ); - window.setLocation( 300, 300 ); - - window.add("North", jbutton1); - window.add("South", jbutton2); - - window.pack(); - window.show(); - //wait for frame to show: - getLocation( frame ); - window.toFront(); - - Dimension size0 = window.getSize(); - Dimension size1 = null; - try { - Robot robot = new Robot(); - - robot.delay(500); - window.pack(); - robot.delay(500); - window.pack(); - // size1 must be the same as size0 - size1 = window.getSize(); - robot.delay(500); - Point pt = jbutton1.getLocationOnScreen(); - robot.mouseMove((int) jbutton1.getLocationOnScreen().x + jbutton1.getWidth() / 2, - (int) jbutton1.getLocationOnScreen().y + jbutton1.getHeight() / 2); - robot.delay(500); - robot.mousePress(MouseEvent.BUTTON1_MASK); - robot.delay(100); - robot.mouseRelease(MouseEvent.BUTTON1_MASK); - robot.delay(2000); - }catch(Exception e) { - throw new RuntimeException( "Exception "+e ); - } - if( !size0.equals(size1) ) { - throw new RuntimeException( "Wrong Window size after multiple pack()s"); - } - if( !buttonClicked ) { - throw new RuntimeException( "Button was not clicked"); - } - window.dispose(); - frame.dispose(); - - System.out.println("Test Passed."); - }// start() - public static Point getLocation( Component co ) throws RuntimeException { - Point pt = null; - boolean bFound = false; - int count = 0; - while( !bFound ) { - try { - pt = co.getLocationOnScreen(); - bFound = true; - }catch( Exception ex ) { - bFound = false; - count++; - } - if( !bFound && count > MAX_COUNT ) { - throw new RuntimeException("don't see a component to get location"); - } - } - return pt; - } - - -}// class AutomaticAppletTest - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. - */ - -class Sysout -{ - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - -}// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog -{ - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("Center", messageText); - - pack(); - - show(); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - System.out.println(messageIn); - } - -}// TestDialog class diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/awt/PrintJob/Text/StringWidth.java --- a/jdk/test/java/awt/PrintJob/Text/StringWidth.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/awt/PrintJob/Text/StringWidth.java Wed Jan 19 19:01:35 2011 -0800 @@ -60,7 +60,6 @@ pg.dispose(); pj.end(); setVisible(false); - System.exit(0); } public static void main(String[] args) { diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/awt/image/IncorrectSampleMaskTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/image/IncorrectSampleMaskTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,113 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6782574 + * @summary Test verifies that incorrect sample masks are correctly handled + * by the constructor of the SinglePixelPackedSampleModel class + * and do not cause internal error in the medialib glue code. + * + * @run main IncorrectSampleMaskTest + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImageOp; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferUShort; +import java.awt.image.Raster; +import java.awt.image.RasterOp; +import java.awt.image.WritableRaster; +import java.awt.image.SinglePixelPackedSampleModel; + +public class IncorrectSampleMaskTest { + public static void main(String[] args) { + int[] dataTypes = new int[] { + DataBuffer.TYPE_BYTE, + DataBuffer.TYPE_USHORT, + DataBuffer.TYPE_INT }; + + for (int type : dataTypes) { + doTest(type); + } + } + + private static final int w = 100; + private static final int h = 100; + + private static AffineTransform at = + AffineTransform.getScaleInstance(0.5, 0.5); + + private static RasterOp op = + new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + + private static void doTest(int dataType) { + int maxSize = DataBuffer.getDataTypeSize(dataType); + System.out.println("Type size: " + maxSize); + + int theMask = (int)(1L << (maxSize + 2)) - 1; + System.out.printf("theMask=%x\n", theMask); + + SinglePixelPackedSampleModel sm = + new SinglePixelPackedSampleModel(dataType, w, h, + new int[] { theMask }); + + + int[] sampleSize = sm.getSampleSize(); + for (int s : sampleSize) { + if (s > maxSize) { + throw new RuntimeException("Test failed: sample size is too big:" + s); + } + } + + System.out.println("Test medialib..."); + DataBuffer buf = createDataBuffer(dataType); + + WritableRaster wr = Raster.createWritableRaster(sm, buf, null); + + op.filter(wr, null); + System.out.println("Test PASSED."); + } + + private static DataBuffer createDataBuffer(int type) { + switch (type) { + case DataBuffer.TYPE_BYTE: { + byte[] buf = new byte[w * h]; + return new DataBufferByte(buf, buf.length); + } + case DataBuffer.TYPE_USHORT: { + short[] buf = new short[w * h]; + return new DataBufferUShort(buf, buf.length); + } + case DataBuffer.TYPE_INT: { + int[] buf = new int[w * h]; + return new DataBufferInt(buf, buf.length); + } + default : + throw new RuntimeException("Unsupported data type."); + } + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/awt/xembed/server/TestXEmbedServer.java --- a/jdk/test/java/awt/xembed/server/TestXEmbedServer.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/awt/xembed/server/TestXEmbedServer.java Wed Jan 19 19:01:35 2011 -0800 @@ -31,6 +31,9 @@ import java.awt.datatransfer.*; public abstract class TestXEmbedServer { + // vertical position of server AND client windows + private static final int VERTICAL_POSITION = 200; + private static final Logger log = Logger.getLogger("test.xembed"); Frame f; Canvas client; @@ -161,10 +164,10 @@ dummy = new JFrame("Dummy"); dummy.getContentPane().add(new JButton("Button")); dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - dummy.setBounds(0, 0, 100, 100); + dummy.setBounds(0, VERTICAL_POSITION, 100, 100); dummy.setVisible(true); - f.setBounds(300, 0, 800, 300); + f.setBounds(300, VERTICAL_POSITION, 800, 300); f.setVisible(true); } diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/io/Serializable/NPEProvoker/NPEProvoker.java --- a/jdk/test/java/io/Serializable/NPEProvoker/NPEProvoker.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/io/Serializable/NPEProvoker/NPEProvoker.java Wed Jan 19 19:01:35 2011 -0800 @@ -56,7 +56,7 @@ public static void main(String[] args) { System.err.println("\n Regression test for bug 6541870\n"); try { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.add(new NPEProvoker()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/lang/instrument/ilib/Inject.java --- a/jdk/test/java/lang/instrument/ilib/Inject.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/lang/instrument/ilib/Inject.java Wed Jan 19 19:01:35 2011 -0800 @@ -107,7 +107,7 @@ class IndexedInjector implements TrackerInjector { int counter = 0; int tracker; - List infoList = new ArrayList(); + List infoList = new ArrayList<>(); public int stackSize(int currentSize) { return currentSize + 1; diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/lang/instrument/ilib/InjectBytecodes.java --- a/jdk/test/java/lang/instrument/ilib/InjectBytecodes.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/lang/instrument/ilib/InjectBytecodes.java Wed Jan 19 19:01:35 2011 -0800 @@ -50,7 +50,7 @@ private final Injector[] after = new Injector[256]; private final String className; private final String methodName; - private final Map snippets = new HashMap(); + private final Map snippets = new HashMap<>(); private int pos; private int newPos; diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java --- a/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java Wed Jan 19 19:01:35 2011 -0800 @@ -103,7 +103,7 @@ } } - private static final Set checking = new HashSet(); + private static final Set checking = new HashSet<>(); private static void check(Type t, String what) { if (t == null || !checking.add(t)) diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/text/Format/DateFormat/ISO8601ZoneTest.java --- a/jdk/test/java/text/Format/DateFormat/ISO8601ZoneTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/text/Format/DateFormat/ISO8601ZoneTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -60,48 +60,51 @@ "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", }; + // badData[][0] - format + // badData[][1] - (bad) text to be parsed + // badData[][2] - subtext at the end of which a parse error is detected static final String[][] badData = { - { "X", "1" }, - { "X", "+1" }, - { "X", "-2" }, - { "X", "-24" }, - { "X", "+24" }, + { "X", "1", "1" }, + { "X", "+1", "+1" }, + { "X", "-2", "-2" }, + { "X", "-24", "-2" }, + { "X", "+24", "+2" }, - { "XX", "9" }, - { "XX", "23" }, - { "XX", "234" }, - { "XX", "3456" }, - { "XX", "23456" }, - { "XX", "+1" }, - { "XX", "-12" }, - { "XX", "+123" }, - { "XX", "-12:34" }, - { "XX", "+12:34" }, - { "XX", "-2423" }, - { "XX", "+2423" }, - { "XX", "-1260" }, - { "XX", "+1260" }, + { "XX", "9", "9" }, + { "XX", "23", "2" }, + { "XX", "234", "2" }, + { "XX", "3456", "3" }, + { "XX", "23456", "2" }, + { "XX", "+1", "+1" }, + { "XX", "-12", "-12" }, + { "XX", "+123", "+123" }, + { "XX", "-12:34", "-12" }, + { "XX", "+12:34", "+12" }, + { "XX", "-2423", "-2" }, + { "XX", "+2423", "+2" }, + { "XX", "-1260", "-126" }, + { "XX", "+1260", "+126" }, - { "XXX", "9" }, - { "XXX", "23" }, - { "XXX", "234" }, - { "XXX", "3456" }, - { "XXX", "23456" }, - { "XXX", "2:34" }, - { "XXX", "12:4" }, - { "XXX", "12:34" }, - { "XXX", "-1" }, - { "XXX", "+1" }, - { "XXX", "-12" }, - { "XXX", "+12" }, - { "XXX", "-123" }, - { "XXX", "+123" }, - { "XXX", "-1234" }, - { "XXX", "+1234" }, - { "XXX", "+24:23" }, - { "XXX", "+12:60" }, - { "XXX", "+1:23" }, - { "XXX", "+12:3" }, + { "XXX", "9", "9" }, + { "XXX", "23", "2" }, + { "XXX", "234", "2" }, + { "XXX", "3456", "3" }, + { "XXX", "23456", "2" }, + { "XXX", "2:34", "2" }, + { "XXX", "12:4", "1" }, + { "XXX", "12:34", "1" }, + { "XXX", "-1", "-1" }, + { "XXX", "+1", "+1" }, + { "XXX", "-12", "-12" }, + { "XXX", "+12", "+12" }, + { "XXX", "-123", "-12" }, + { "XXX", "+123", "+12" }, + { "XXX", "-1234", "-12" }, + { "XXX", "+1234", "+12" }, + { "XXX", "+24:23", "+2" }, + { "XXX", "+12:60", "+12:6" }, + { "XXX", "+1:23", "+1" }, + { "XXX", "+12:3", "+12:3" }, }; static String[] badFormats = { @@ -110,6 +113,8 @@ public static void main(String[] args) throws Exception { TimeZone tz = TimeZone.getDefault(); + Locale loc = Locale.getDefault(); + Locale.setDefault(Locale.US); try { for (int i = 0; i < formatData.length; i++) { @@ -128,7 +133,7 @@ } for (String[] d : badData) { - badDataParsing(d[0], d[1]); + badDataParsing(d[0], d[1], d[2].length()); } for (String fmt : badFormats) { @@ -136,6 +141,7 @@ } } finally { TimeZone.setDefault(tz); + Locale.setDefault(loc); } } @@ -188,15 +194,24 @@ } - static void badDataParsing(String fmt, String text) { + static void badDataParsing(String fmt, String text, int expectedErrorIndex) { + SimpleDateFormat sdf = new SimpleDateFormat(fmt); try { - SimpleDateFormat sdf = new SimpleDateFormat(fmt); sdf.parse(text); throw new RuntimeException("didn't throw an exception: fmt=" + fmt + ", text=" + text); } catch (ParseException e) { // OK } + + ParsePosition pos = new ParsePosition(0); + Date d = sdf.parse(text, pos); + int errorIndex = pos.getErrorIndex(); + if (d != null || errorIndex != expectedErrorIndex) { + throw new RuntimeException("Bad error index=" + errorIndex + + ", expected=" + expectedErrorIndex + + ", fmt=" + fmt + ", text=" + text); + } } static void badFormat(String fmt) { diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/text/Format/MessageFormat/Bug7003643.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/text/Format/MessageFormat/Bug7003643.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7003643 + * @summary Make sure MessageFormat.toPattern produces correct quoting. (SPI part is tested in PluggableLocale tests.) + */ + +import java.text.*; +import java.util.*; + +public class Bug7003643 { + private static final int N = 5; + + private static final String[] elements = { + "'{'", "'{", "{", "''", "}", "a", "'", + }; + + public static void main(String[] args) { + Random rand = new Random(); + int count = 0; + int max = (int) (Math.pow((double)elements.length, (double)N)/0.52); + while (count < max) { + // Create a random pattern. If the produced pattern is + // valid, then proceed with the round-trip testing. + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < N; i++) { + sb.append(elements[rand.nextInt(elements.length)]); + } + String pattern = sb.toString(); + MessageFormat mf = null; + try { + mf = new MessageFormat(pattern); + } catch (IllegalArgumentException e) { + // bad pattern data + } + if (mf == null) { + continue; + } + count++; + String res1 = MessageFormat.format(pattern, 123); + String toPattern = mf.toPattern(); + String res2 = MessageFormat.format(toPattern, 123); + if (!res1.equals(res2)) { + String s = String.format("Failed%n pattern=\"%s\" => result=\"%s\"%n" + + " toPattern()=\"%s\" => result=\"%s\"%n", + pattern, res1, toPattern, res2); + throw new RuntimeException(s); + } + } + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/Locale/LocaleTest.java --- a/jdk/test/java/util/Locale/LocaleTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/Locale/LocaleTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -24,7 +24,8 @@ * @test * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 - * 4147315 4147317 4147552 4335196 4778440 5010672 6475525 6544471 6627549 6786276 + * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549 + * 6786276 * @summary test Locales */ /* @@ -895,17 +896,28 @@ } /** - * @bug 4147317 - * java.util.Locale.getISO3Language() works wrong for non ISO-3166 codes. - * Should throw an exception for unknown locales + * @bug 4147317 4940539 + * java.util.Locale.getISO3Language() works wrong for non ISO-639 codes. + * Should throw an exception for unknown locales, except they have three + * letter language codes. */ public void Test4147317() { - // Try with codes that are the wrong length but happen to match text - // at a valid offset in the mapping table + // Try a three letter language code, and check whether it is + // returned as is. Locale locale = new Locale("aaa", "CCC"); + String result = locale.getISO3Language(); + if (!result.equals("aaa")) { + errln("ERROR: getISO3Language() returns: " + result + + " for locale '" + locale + "' rather than returning it as is" ); + } + + // Try an invalid two letter language code, and check whether it + // throws a MissingResourceException. + locale = new Locale("zz", "CCC"); + try { - String result = locale.getISO3Language(); + result = locale.getISO3Language(); errln("ERROR: getISO3Language() returns: " + result + " for locale '" + locale + "' rather than exception" ); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/DateFormatProviderTest.java --- a/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ availableLocalesTest(); objectValidityTest(); extendedVariantTest(); + messageFormatTest(); } void availableLocalesTest() { @@ -118,4 +119,48 @@ } } } + + + private static final String[] TYPES = { + "date", + "time" + }; + private static final String[] MODIFIERS = { + "", + "short", + "medium", // Same as DEFAULT + "long", + "full" + }; + + void messageFormatTest() { + for (Locale target : providerloc) { + for (String type : TYPES) { + for (String modifier : MODIFIERS) { + String pattern, expected; + if (modifier.equals("")) { + pattern = String.format("%s={0,%s}", type, type); + } else { + pattern = String.format("%s={0,%s,%s}", type, type, modifier); + } + if (modifier.equals("medium")) { + // medium is default. + expected = String.format("%s={0,%s}", type, type); + } else { + expected = pattern; + } + MessageFormat mf = new MessageFormat(pattern, target); + Format[] fmts = mf.getFormats(); + if (fmts[0] instanceof SimpleDateFormat) { + continue; + } + String toPattern = mf.toPattern(); + if (!toPattern.equals(expected)) { + throw new RuntimeException("messageFormatTest: got '" + toPattern + + "', expected '" + expected + "'"); + } + } + } + } + } } diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/DateFormatProviderTest.sh --- a/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.sh Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/DateFormatProviderTest.sh Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,6 @@ #!/bin/sh # # @test -# @bug 4052440 +# @bug 4052440 7003643 # @summary DateFormatProvider tests # @run shell ExecTest.sh foo DateFormatProviderTest true diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.java --- a/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,8 @@ import sun.util.*; import sun.util.resources.*; +import com.foo.FooNumberFormat; + public class NumberFormatProviderTest extends ProviderTest { com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl(); @@ -43,6 +45,7 @@ NumberFormatProviderTest() { availableLocalesTest(); objectValidityTest(); + messageFormatTest(); } void availableLocalesTest() { @@ -72,14 +75,10 @@ } // result object - String resultCur = - ((DecimalFormat)NumberFormat.getCurrencyInstance(target)).toPattern(); - String resultInt = - ((DecimalFormat)NumberFormat.getIntegerInstance(target)).toPattern(); - String resultNum = - ((DecimalFormat)NumberFormat.getNumberInstance(target)).toPattern(); - String resultPer = - ((DecimalFormat)NumberFormat.getPercentInstance(target)).toPattern(); + String resultCur = getPattern(NumberFormat.getCurrencyInstance(target)); + String resultInt = getPattern(NumberFormat.getIntegerInstance(target)); + String resultNum = getPattern(NumberFormat.getNumberInstance(target)); + String resultPer = getPattern(NumberFormat.getPercentInstance(target)); // provider's object (if any) String providersCur = null; @@ -87,21 +86,21 @@ String providersNum = null; String providersPer = null; if (providerloc.contains(target)) { - DecimalFormat dfCur = (DecimalFormat)nfp.getCurrencyInstance(target); + NumberFormat dfCur = nfp.getCurrencyInstance(target); if (dfCur != null) { - providersCur = dfCur.toPattern(); + providersCur = getPattern(dfCur); } - DecimalFormat dfInt = (DecimalFormat)nfp.getIntegerInstance(target); + NumberFormat dfInt = nfp.getIntegerInstance(target); if (dfInt != null) { - providersInt = dfInt.toPattern(); + providersInt = getPattern(dfInt); } - DecimalFormat dfNum = (DecimalFormat)nfp.getNumberInstance(target); + NumberFormat dfNum = nfp.getNumberInstance(target); if (dfNum != null) { - providersNum = dfNum.toPattern(); + providersNum = getPattern(dfNum); } - DecimalFormat dfPer = (DecimalFormat)nfp.getPercentInstance(target); + NumberFormat dfPer = nfp.getPercentInstance(target); if (dfPer != null) { - providersPer = dfPer.toPattern(); + providersPer = getPattern(dfPer); } } @@ -174,4 +173,35 @@ } } } + + private static String getPattern(NumberFormat nf) { + if (nf instanceof DecimalFormat) { + return ((DecimalFormat)nf).toPattern(); + } + if (nf instanceof FooNumberFormat) { + return ((FooNumberFormat)nf).toPattern(); + } + return null; + } + + private static final String[] NUMBER_PATTERNS = { + "num={0,number}", + "num={0,number,currency}", + "num={0,number,percent}", + "num={0,number,integer}" + }; + + void messageFormatTest() { + for (Locale target : providerloc) { + for (String pattern : NUMBER_PATTERNS) { + MessageFormat mf = new MessageFormat(pattern, target); + String toPattern = mf.toPattern(); + if (!pattern.equals(toPattern)) { + throw new RuntimeException("MessageFormat.toPattern: got '" + + toPattern + + "', expected '" + pattern + "'"); + } + } + } + } } diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.sh --- a/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.sh Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.sh Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,6 @@ #!/bin/sh # # @test -# @bug 4052440 +# @bug 4052440 7003643 # @summary NumberFormatProvider tests # @run shell ExecTest.sh foo NumberFormatProviderTest true diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/fooprovider.jar Binary file jdk/test/java/util/PluggableLocale/fooprovider.jar has changed diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/providersrc/DateFormatProviderImpl.java --- a/jdk/test/java/util/PluggableLocale/providersrc/DateFormatProviderImpl.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/providersrc/DateFormatProviderImpl.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ static String[] datePattern = { "yyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern - "yyyy/MM/dd", // long date pattern + "yyyy/MMM/dd", // long date pattern "yyyy/MM/dd", // medium date pattern "yy/MM/dd" // short date pattern }; @@ -68,7 +68,7 @@ public DateFormat getDateInstance(int style, Locale locale) { for (int i = 0; i < avail.length; i ++) { if (Utils.supportsLocale(avail[i], locale)) { - return new SimpleDateFormat(datePattern[style]+dialect[i], locale); + return new FooDateFormat(datePattern[style]+dialect[i], locale); } } throw new IllegalArgumentException("locale is not supported: "+locale); @@ -77,7 +77,7 @@ public DateFormat getTimeInstance(int style, Locale locale) { for (int i = 0; i < avail.length; i ++) { if (Utils.supportsLocale(avail[i], locale)) { - return new SimpleDateFormat(timePattern[style]+dialect[i], locale); + return new FooDateFormat(timePattern[style]+dialect[i], locale); } } throw new IllegalArgumentException("locale is not supported: "+locale); @@ -86,7 +86,7 @@ public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { for (int i = 0; i < avail.length; i ++) { if (Utils.supportsLocale(avail[i], locale)) { - return new SimpleDateFormat( + return new FooDateFormat( datePattern[dateStyle]+" "+timePattern[timeStyle]+dialect[i], locale); } } diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/providersrc/FooDateFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/PluggableLocale/providersrc/FooDateFormat.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.foo; + +import java.text.*; +import java.util.*; + +/** + * FooDateFormat provides SimpleDateFormat methods required for the SPI testing. + */ +public class FooDateFormat extends DateFormat { + private SimpleDateFormat sdf; + + public FooDateFormat(String pattern, Locale loc) { + sdf = new SimpleDateFormat(pattern, loc); + } + + @Override + public StringBuffer format(Date date, + StringBuffer toAppendTo, + FieldPosition fieldPosition) { + return sdf.format(date, toAppendTo, fieldPosition); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return sdf.parse(source, pos); + } + + @Override + public boolean equals(Object other) { + return other instanceof FooDateFormat + && sdf.equals(((FooDateFormat)other).sdf); + } + + @Override + public int hashCode() { + return sdf.hashCode(); + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/providersrc/FooNumberFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/PluggableLocale/providersrc/FooNumberFormat.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.foo; + +import java.text.*; + +/** + * FooNumberFormat provides DecimalFormat methods required for the SPI testing. + */ +public class FooNumberFormat extends NumberFormat { + private DecimalFormat df; + + public FooNumberFormat(String pattern, DecimalFormatSymbols dfs) { + df = new DecimalFormat(pattern, dfs); + } + + @Override + public StringBuffer format(double number, + StringBuffer toAppendTo, + FieldPosition pos) { + return df.format(number, toAppendTo, pos); + } + + @Override + public StringBuffer format(long number, + StringBuffer toAppendTo, + FieldPosition pos) { + return df.format(number, toAppendTo, pos); + } + + @Override + public Number parse(String source, ParsePosition parsePosition) { + return df.parse(source, parsePosition); + } + + @Override + public boolean equals(Object other) { + return other instanceof FooNumberFormat + && df.equals(((FooNumberFormat)other).df); + } + + @Override + public int hashCode() { + return df.hashCode(); + } + + // DecimalFormat specific methods required for testing + + public String toPattern() { + return df.toPattern(); + } + + public DecimalFormatSymbols getDecimalFormatSymbols() { + return df.getDecimalFormatSymbols(); + } + + public void setDecimalSeparatorAlwaysShown(boolean newValue) { + df.setDecimalSeparatorAlwaysShown(newValue); + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/providersrc/Makefile --- a/jdk/test/java/util/PluggableLocale/providersrc/Makefile Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/providersrc/Makefile Wed Jan 19 19:01:35 2011 -0800 @@ -28,6 +28,8 @@ DateFormatSymbolsProviderImpl.java \ DecimalFormatSymbolsProviderImpl.java \ NumberFormatProviderImpl.java \ + FooDateFormat.java \ + FooNumberFormat.java \ Utils.java BARFILES_JAVA = \ diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/PluggableLocale/providersrc/NumberFormatProviderImpl.java --- a/jdk/test/java/util/PluggableLocale/providersrc/NumberFormatProviderImpl.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/PluggableLocale/providersrc/NumberFormatProviderImpl.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,13 +49,15 @@ static String[] patterns = { "#,##0.###{0};-#,##0.###{1}", // decimal pattern + "#{0};(#){1}", // integer pattern "\u00A4#,##0{0};-\u00A4#,##0{1}", // currency pattern "#,##0%{0}" // percent pattern }; // Constants used by factory methods to specify a style of format. static final int NUMBERSTYLE = 0; - static final int CURRENCYSTYLE = 1; - static final int PERCENTSTYLE = 2; + static final int INTEGERSTYLE = 1; + static final int CURRENCYSTYLE = 2; + static final int PERCENTSTYLE = 3; public Locale[] getAvailableLocales() { return avail; @@ -68,10 +70,10 @@ MessageFormat.format(patterns[CURRENCYSTYLE], dialect[i], dialect[i]); - DecimalFormat df = new DecimalFormat(pattern, + FooNumberFormat nf = new FooNumberFormat(pattern, DecimalFormatSymbols.getInstance(locale)); - adjustForCurrencyDefaultFractionDigits(df); - return df; + adjustForCurrencyDefaultFractionDigits(nf); + return nf; } } throw new IllegalArgumentException("locale is not supported: "+locale); @@ -81,15 +83,15 @@ for (int i = 0; i < avail.length; i ++) { if (Utils.supportsLocale(avail[i], locale)) { String pattern = - MessageFormat.format(patterns[NUMBERSTYLE], + MessageFormat.format(patterns[INTEGERSTYLE], dialect[i], dialect[i]); - DecimalFormat df = new DecimalFormat(pattern, + FooNumberFormat nf = new FooNumberFormat(pattern, DecimalFormatSymbols.getInstance(locale)); - df.setMaximumFractionDigits(0); - df.setDecimalSeparatorAlwaysShown(false); - df.setParseIntegerOnly(true); - return df; + nf.setMaximumFractionDigits(0); + nf.setDecimalSeparatorAlwaysShown(false); + nf.setParseIntegerOnly(true); + return nf; } } throw new IllegalArgumentException("locale is not supported: "+locale); @@ -102,7 +104,7 @@ MessageFormat.format(patterns[NUMBERSTYLE], dialect[i], dialect[i]); - return new DecimalFormat(pattern, + return new FooNumberFormat(pattern, DecimalFormatSymbols.getInstance(locale)); } } @@ -115,7 +117,7 @@ String pattern = MessageFormat.format(patterns[PERCENTSTYLE], dialect[i]); - return new DecimalFormat(pattern, + return new FooNumberFormat(pattern, DecimalFormatSymbols.getInstance(locale)); } } @@ -126,8 +128,8 @@ * Adjusts the minimum and maximum fraction digits to values that * are reasonable for the currency's default fraction digits. */ - void adjustForCurrencyDefaultFractionDigits(DecimalFormat df) { - DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); + void adjustForCurrencyDefaultFractionDigits(FooNumberFormat nf) { + DecimalFormatSymbols dfs = nf.getDecimalFormatSymbols(); Currency currency = dfs.getCurrency(); if (currency == null) { try { @@ -138,15 +140,15 @@ if (currency != null) { int digits = currency.getDefaultFractionDigits(); if (digits != -1) { - int oldMinDigits = df.getMinimumFractionDigits(); + int oldMinDigits = nf.getMinimumFractionDigits(); // Common patterns are "#.##", "#.00", "#". // Try to adjust all of them in a reasonable way. - if (oldMinDigits == df.getMaximumFractionDigits()) { - df.setMinimumFractionDigits(digits); - df.setMaximumFractionDigits(digits); + if (oldMinDigits == nf.getMaximumFractionDigits()) { + nf.setMinimumFractionDigits(digits); + nf.setMaximumFractionDigits(digits); } else { - df.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); - df.setMaximumFractionDigits(digits); + nf.setMinimumFractionDigits(Math.min(digits, oldMinDigits)); + nf.setMaximumFractionDigits(digits); } } } diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/Random/DistinctSeeds.java --- a/jdk/test/java/util/Random/DistinctSeeds.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/Random/DistinctSeeds.java Wed Jan 19 19:01:35 2011 -0800 @@ -59,7 +59,7 @@ } } final int threadCount = 2; - List collectors = new ArrayList(); + List collectors = new ArrayList<>(); List threads = new ArrayList(); for (int i = 0; i < threadCount; i++) { RandomCollector r = new RandomCollector(); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/logging/ClassLoaderLeakTest.java --- a/jdk/test/java/util/logging/ClassLoaderLeakTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/java/util/logging/ClassLoaderLeakTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -89,7 +89,7 @@ MyClassLoader appClassLoader = new MyClassLoader(urls, "test0"); WeakReference ref = - new WeakReference(appClassLoader); + new WeakReference<>(appClassLoader); Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0"); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 7007609 7009618 + * @summary Check that ZipFile objects are always collected + */ + +import java.io.*; +import java.nio.*; +import java.util.Random; +import java.util.zip.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class FinalizeZipFile { + + private final static CountDownLatch finalizersDone = new CountDownLatch(3); + + private static class InstrumentedZipFile extends ZipFile { + + public InstrumentedZipFile(File f) throws Exception { + super(f); + System.out.printf("Using %s%n", f.getPath()); + } + protected void finalize() throws IOException { + System.out.printf("Killing %s%n", getName()); + super.finalize(); + finalizersDone.countDown(); + } + } + + private static void makeGarbage() throws Throwable { + final Random rnd = new Random(); + final String javaHome = System.getProperty("java.home"); + // Create some ZipFiles. + // Find some .jar files in JDK's lib directory. + final File lib = new File(javaHome, "lib"); + check(lib.isDirectory()); + final File[] jars = lib.listFiles( + new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".jar");}}); + check(jars.length > 1); + + new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]).close(); + new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]).close(); + + // Create a ZipFile and get an input stream from it + ZipFile zf = new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]); + ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF"); + InputStream is = zf.getInputStream(ze); + } + + public static void realMain(String[] args) throws Throwable { + makeGarbage(); + + System.gc(); + finalizersDone.await(5, TimeUnit.SECONDS); + + // Not all ZipFiles were collected? + equal(finalizersDone.getCount(), 0L); + } + + //--------------------- Infrastructure --------------------------- + static volatile int passed = 0, failed = 0; + static void pass() {passed++;} + static void fail() {failed++; Thread.dumpStack();} + static void fail(String msg) {System.out.println(msg); fail();} + static void unexpected(Throwable t) {failed++; t.printStackTrace();} + static void check(boolean cond) {if (cond) pass(); else fail();} + static void equal(Object x, Object y) { + if (x == null ? y == null : x.equals(y)) pass(); + else fail(x + " not equal to " + y);} + public static void main(String[] args) throws Throwable { + try {realMain(args);} catch (Throwable t) {unexpected(t);} + System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); + if (failed > 0) throw new AssertionError("Some tests failed");} +} + diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/script/E4XErrorTest.java --- a/jdk/test/javax/script/E4XErrorTest.java Tue Jan 18 08:37:05 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6346734 6705893 - * @summary We do *not* support E4X (ECMAScript for XML) in our - * implementation. We want to throw error on XML literals - * as early as possible rather than at "runtime" - i.e., when - * engine looks for "XML" constructor. - */ - -import javax.script.*; -import java.util.Locale; - -public class E4XErrorTest { - - public static void main(String[] args) throws Exception { - ScriptEngineManager manager = new ScriptEngineManager(); - ScriptEngine jsengine = Helper.getJsEngine(manager); - if (jsengine == null) { - System.out.println("Warning: No js engine found; test vacuously passes."); - return; - } - - // The test below depends on the error message content - // that is loaded from resource bundles. So, we force - // English Locale to compare correct value.. - Locale.setDefault(Locale.US); - - try { - jsengine.eval("var v = ;"); - } catch (ScriptException se) { - String msg = se.getMessage(); - if (msg.indexOf("syntax error") == -1) { - throw new RuntimeException("syntax error expected, got " + - msg); - } - return; - } - // should not reach here.. exception should have been thrown. - throw new RuntimeException("Huh! E4X is supported??"); - } -} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/script/VersionTest.java --- a/jdk/test/javax/script/VersionTest.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/javax/script/VersionTest.java Wed Jan 19 19:01:35 2011 -0800 @@ -32,8 +32,8 @@ public class VersionTest { - private static final String JS_LANG_VERSION = "1.6"; - private static final String JS_ENGINE_VERSION = "1.6 release 2"; + private static final String JS_LANG_VERSION = "1.8"; + private static final String JS_ENGINE_VERSION = "1.7 release 3 PRERELEASE"; public static void main(String[] args) throws Exception { ScriptEngineManager manager = new ScriptEngineManager(); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/swing/JFileChooser/4847375/bug4847375.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JFileChooser/4847375/bug4847375.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4847375 + * @summary JFileChooser Create New Folder button is disabled incorrectly + * @author Pavel Porvatov + */ + +import sun.awt.OSInfo; +import sun.awt.shell.ShellFolder; + +import javax.swing.*; +import java.awt.*; +import java.lang.reflect.Method; + +public class bug4847375 { + private final String newFolderToolTipText; + + private final String lookAndFeel; + + public static void main(String[] args) throws Exception { + if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + System.out.println("The test is suitable only for Windows OS. Skipped."); + + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + new bug4847375("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + new bug4847375("javax.swing.plaf.metal.MetalLookAndFeel"); + } + }); + } + + private static Object[][] DIRECTORIES = new Object[][]{ + {"getDesktop", Boolean.TRUE}, + {"getDrives", Boolean.FALSE}, // My computer + {"getRecent", Boolean.TRUE}, + {"getNetwork", Boolean.FALSE}, + {"getPersonal", Boolean.TRUE}, + }; + + private bug4847375(String lookAndFeel) { + this.lookAndFeel = lookAndFeel; + + try { + UIManager.setLookAndFeel(lookAndFeel); + } catch (Exception e) { + fail("Cannot set LookAndFeel", e); + } + + JFileChooser fileChooser = new JFileChooser(); + + // Find button NewFolder + newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText", fileChooser.getLocale()); + + if (newFolderToolTipText == null || newFolderToolTipText.length() == 0) { + fail("Cannot find NewFolderButton in FileChooser (tooltip doesn't exist)"); + + return; + } + + JButton newFolderButton = findNewFolderButton(fileChooser); + + if (newFolderButton == null) { + fail("Cannot find NewFolderButton in FileChooser"); + + return; + } + + for (Object[] objects : DIRECTORIES) { + String getterName = (String) objects[0]; + Boolean enabledNewFolder = (Boolean) objects[1]; + + fileChooser.setCurrentDirectory(getWin32Folder(getterName)); + + if (newFolderButton.isEnabled() != enabledNewFolder) { + fail("Enabled state of NewFolderButton should be " + enabledNewFolder + + " for Win32ShellFolderManager2." + getterName + "()"); + } + } + } + + private JButton findNewFolderButton(Container container) { + JButton result = null; + + for (int i = 0; i < container.getComponentCount(); i++) { + Component c = container.getComponent(i); + + if (c instanceof JButton && newFolderToolTipText.equals(((JButton) c).getToolTipText())) { + if (result != null) { + fail("Two or more NewFolderButton found in FileChooser"); + } + + result = (JButton) c; + } + + if (c instanceof Container) { + JButton button = findNewFolderButton((Container) c); + + if (result == null) { + result = button; + } else { + if (button != null) { + fail("Two or more NewFolderButton found in FileChooser"); + } + } + } + } + + return result; + } + + private ShellFolder getWin32Folder(String getterName) { + try { + Class win32ShellFolderManager2 = Class.forName("sun.awt.shell.Win32ShellFolderManager2"); + + Method method = win32ShellFolderManager2.getDeclaredMethod(getterName); + method.setAccessible(true); + + return (ShellFolder) method.invoke(null); + } catch (Exception e) { + fail("Cannot call '" + getterName + "' in the Win32ShellFolderManager2 class", e); + + return null; + } + } + + private void fail(String s) { + throw new RuntimeException("Test failed: " + s); + } + + private void fail(String s, Throwable e) { + throw new RuntimeException("Test failed for LookAndFeel " + lookAndFeel + ": " + s, e); + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java --- a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java Wed Jan 19 19:01:35 2011 -0800 @@ -40,11 +40,13 @@ private static MyScrollBarUI ui; public static void main(String[] args) throws Exception { - Robot robot = new Robot(); + final Robot robot = new Robot(); robot.setAutoDelay(10); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + final Rectangle[] thumbBounds = new Rectangle[1]; + SwingUtilities.invokeAndWait(new Runnable() { public void run() { final JFrame frame = new JFrame("bug6542335"); @@ -63,25 +65,39 @@ rangeModel.setValue(50); sb.setModel(rangeModel); - frame.add(sb); + frame.add(sb, BorderLayout.NORTH); frame.setSize(200, 100); frame.setVisible(true); + + thumbBounds[0] = new Rectangle(ui.getThumbBounds()); } }); - Rectangle thumbBounds = new Rectangle(ui.getThumbBounds()); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Point l = sb.getLocationOnScreen(); + + robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + }); toolkit.realSync(); - Point l = sb.getLocationOnScreen(); - robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight()/2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Rectangle newThumbBounds = ui.getThumbBounds(); - if (!thumbBounds.equals(ui.getThumbBounds())) { - throw new RuntimeException("Test failed"); - } + if (!thumbBounds[0].equals(newThumbBounds)) { + throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] + + "\nNew bounds: " + newThumbBounds); + } + } + }); } static class MyScrollBarUI extends BasicScrollBarUI { diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/swing/JSpinner/6532833/bug6532833.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JSpinner/6532833/bug6532833.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 6532833 + @summary PIT: Metal LAF - The right side border is not shown for the Spinner after the removing the buttons + @author Pavel Porvatov +*/ + +import javax.swing.*; +import java.awt.*; + +public class bug6532833 { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + JSpinner[] spinners = new JSpinner[2]; + + for (int i = 0; i < spinners.length; i++) { + JSpinner spinner = new JSpinner(); + + spinner.setValue(2010); + + Component arrowUp = spinner.getComponent(0); + Component arrowDown = spinner.getComponent(1); + + LayoutManager layout = spinner.getLayout(); + + layout.removeLayoutComponent(arrowUp); + layout.removeLayoutComponent(arrowDown); + + if (i == 1) { + spinner.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + + spinners[i] = spinner; + } + + // Do layout of spinners components + JFrame frame = new JFrame(); + + for (JSpinner spinner : spinners) { + frame.getContentPane().add(spinner); + } + + frame.pack(); + + for (JSpinner spinner : spinners) { + Insets insets = spinner.getInsets(); + + if (spinner.getWidth() != insets.left + insets.right + spinner.getEditor().getWidth()) { + throw new RuntimeException("Spinner editor width is invalid"); + } + } + + frame.dispose(); + } + }); + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/javax/swing/SwingWorker/6480289/bug6480289.java --- a/jdk/test/javax/swing/SwingWorker/6480289/bug6480289.java Tue Jan 18 08:37:05 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - * - * @bug 6480289 - * @author Igor Kushnirskiy - * @summary tests if consequent workers are executed on the same thread and that VM can exit. - */ - -import java.util.*; -import javax.swing.SwingWorker; - -public class bug6480289 { - private static final int ITERATIONS = 5; - private static final Map threadMap = - Collections.synchronizedMap(new HashMap()); - public static void main(String[] args) throws Exception { - - for (int i = 0; i < ITERATIONS; i++) { - if (i != 0) { - Thread.sleep(1000 * 5); - } - SwingWorker worker = - new SwingWorker() { - @Override - protected Void doInBackground() { - Integer value = threadMap.get(Thread.currentThread()); - value = Integer.valueOf( - ((value == null) ? 0 : value.intValue()) - + 1); - threadMap.put(Thread.currentThread(), value); - return null; - } - }; - worker.execute(); - } - if (threadMap.keySet().size() != 1) { - throw new RuntimeException("failed. More than one thread."); - } - } -} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/security/krb5/auto/BasicKrb5Test.java --- a/jdk/test/sun/security/krb5/auto/BasicKrb5Test.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/sun/security/krb5/auto/BasicKrb5Test.java Wed Jan 19 19:01:35 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,34 @@ * @test * @bug 6706974 * @summary Add krb5 test infrastructure + * @run main/othervm BasicKrb5Test + * @run main/othervm BasicKrb5Test des-cbc-crc + * @run main/othervm BasicKrb5Test des-cbc-md5 + * @run main/othervm BasicKrb5Test des3-cbc-sha1 + * @run main/othervm BasicKrb5Test aes128-cts + * @run main/othervm BasicKrb5Test aes256-cts + * @run main/othervm BasicKrb5Test rc4-hmac + * @run main/othervm BasicKrb5Test -s + * @run main/othervm BasicKrb5Test des-cbc-crc -s + * @run main/othervm BasicKrb5Test des-cbc-md5 -s + * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s + * @run main/othervm BasicKrb5Test aes128-cts -s + * @run main/othervm BasicKrb5Test aes256-cts -s + * @run main/othervm BasicKrb5Test rc4-hmac -s + * @run main/othervm BasicKrb5Test -C + * @run main/othervm BasicKrb5Test des-cbc-crc -C + * @run main/othervm BasicKrb5Test des-cbc-md5 -C + * @run main/othervm BasicKrb5Test des3-cbc-sha1 -C + * @run main/othervm BasicKrb5Test aes128-cts -C + * @run main/othervm BasicKrb5Test aes256-cts -C + * @run main/othervm BasicKrb5Test rc4-hmac -C + * @run main/othervm BasicKrb5Test -s -C + * @run main/othervm BasicKrb5Test des-cbc-crc -s -C + * @run main/othervm BasicKrb5Test des-cbc-md5 -s -C + * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s -C + * @run main/othervm BasicKrb5Test aes128-cts -s -C + * @run main/othervm BasicKrb5Test aes256-cts -s -C + * @run main/othervm BasicKrb5Test rc4-hmac -s -C */ import org.ietf.jgss.GSSName; @@ -39,6 +67,7 @@ */ public class BasicKrb5Test { + private static boolean conf = true; /** * @param args empty or etype */ @@ -46,8 +75,10 @@ throws Exception { String etype = null; - if (args.length > 0) { - etype = args[0]; + for (String arg: args) { + if (arg.equals("-s")) Context.usingStream = true; + else if(arg.equals("-C")) conf = false; + else etype = arg; } // Creates and starts the KDC. This line must be put ahead of etype check @@ -56,8 +87,9 @@ System.out.println("Testing etype " + etype); if (etype != null && !EType.isSupported(Config.getInstance().getType(etype))) { + // aes256 is not enabled on all systems System.out.println("Not supported."); - System.exit(0); + return; } new BasicKrb5Test().go(OneKDC.SERVER, OneKDC.BACKEND); @@ -71,6 +103,7 @@ c.startAsClient(server, GSSUtil.GSS_KRB5_MECH_OID); c.x().requestCredDeleg(true); + c.x().requestConf(conf); s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); c.status(); @@ -90,6 +123,7 @@ s = null; s2.startAsClient(backend, GSSUtil.GSS_KRB5_MECH_OID); + s2.x().requestConf(conf); b.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); s2.status(); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/security/krb5/auto/Context.java --- a/jdk/test/sun/security/krb5/auto/Context.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/sun/security/krb5/auto/Context.java Wed Jan 19 19:01:35 2011 -0800 @@ -42,7 +42,8 @@ import com.sun.security.jgss.ExtendedGSSContext; import com.sun.security.jgss.InquireType; import com.sun.security.jgss.AuthorizationDataEntry; -import java.io.File; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; /** * Context of a JGSS subject, encapsulating Subject and GSSContext. @@ -78,6 +79,8 @@ private String name; private GSSCredential cred; // see static method delegated(). + static boolean usingStream = false; + private Context() {} /** @@ -365,7 +368,14 @@ public byte[] run(Context me, byte[] dummy) throws Exception { System.out.println("wrap"); MessageProp p1 = new MessageProp(0, true); - byte[] out = me.x.wrap(messageBytes, 0, messageBytes.length, p1); + byte[] out; + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.wrap(new ByteArrayInputStream(messageBytes), os, p1); + out = os.toByteArray(); + } else { + out = me.x.wrap(messageBytes, 0, messageBytes.length, p1); + } System.out.println(printProp(p1)); return out; } @@ -375,27 +385,46 @@ @Override public byte[] run(Context me, byte[] input) throws Exception { MessageProp p1 = new MessageProp(0, true); - byte[] bytes = me.x.unwrap(input, 0, input.length, p1); + byte[] bytes; + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.unwrap(new ByteArrayInputStream(input), os, p1); + bytes = os.toByteArray(); + } else { + bytes = me.x.unwrap(input, 0, input.length, p1); + } if (!Arrays.equals(messageBytes, bytes)) throw new Exception("wrap/unwrap mismatch"); System.out.println("unwrap"); System.out.println(printProp(p1)); p1 = new MessageProp(0, true); System.out.println("getMIC"); - bytes = me.x.getMIC(bytes, 0, bytes.length, p1); + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.getMIC(new ByteArrayInputStream(messageBytes), os, p1); + bytes = os.toByteArray(); + } else { + bytes = me.x.getMIC(messageBytes, 0, messageBytes.length, p1); + } System.out.println(printProp(p1)); return bytes; } }, t); + // Re-unwrap should make p2.isDuplicateToken() returns true s1.doAs(new Action() { @Override public byte[] run(Context me, byte[] input) throws Exception { MessageProp p1 = new MessageProp(0, true); System.out.println("verifyMIC"); - me.x.verifyMIC(input, 0, input.length, - messageBytes, 0, messageBytes.length, - p1); + if (usingStream) { + me.x.verifyMIC(new ByteArrayInputStream(input), + new ByteArrayInputStream(messageBytes), p1); + } else { + me.x.verifyMIC(input, 0, input.length, + messageBytes, 0, messageBytes.length, + p1); + } System.out.println(printProp(p1)); return null; } @@ -416,7 +445,9 @@ sb.append(prop.isGapToken()?"gap, ":""); sb.append(prop.isOldToken()?"old, ":""); sb.append(prop.isUnseqToken()?"unseq, ":""); - sb.append(prop.getMinorString()+ "(" + prop.getMinorStatus()+")"); + if (prop.getMinorStatus() != 0) { + sb.append(prop.getMinorString()+ "(" + prop.getMinorStatus()+")"); + } return sb.toString(); } @@ -442,7 +473,13 @@ return null; } else { System.out.println(c.name + " call initSecContext"); - return me.x.initSecContext(input, 0, input.length); + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.initSecContext(new ByteArrayInputStream(input), os); + return os.size() == 0 ? null : os.toByteArray(); + } else { + return me.x.initSecContext(input, 0, input.length); + } } } }, t); @@ -460,7 +497,13 @@ return null; } else { System.out.println(s.name + " called acceptSecContext"); - return me.x.acceptSecContext(input, 0, input.length); + if (usingStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + me.x.acceptSecContext(new ByteArrayInputStream(input), os); + return os.size() == 0 ? null : os.toByteArray(); + } else { + return me.x.acceptSecContext(input, 0, input.length); + } } } }, t); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/security/krb5/auto/basic.sh --- a/jdk/test/sun/security/krb5/auto/basic.sh Tue Jan 18 08:37:05 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -# -# Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 6706974 -# @summary Add krb5 test infrastructure -# @run shell/timeout=300 basic.sh -# - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi - -# set platform-dependent variables -OS=`uname -s` -case "$OS" in - Windows_* ) - FS="\\" - SEP=";" - ;; - CYGWIN* ) - FS="/" - SEP=";" - ;; - * ) - FS="/" - SEP=":" - ;; -esac - -${TESTJAVA}${FS}bin${FS}javac -XDignore.symbol.file -d . \ - ${TESTSRC}${FS}BasicKrb5Test.java \ - ${TESTSRC}${FS}KDC.java \ - ${TESTSRC}${FS}OneKDC.java \ - ${TESTSRC}${FS}Action.java \ - ${TESTSRC}${FS}Context.java \ - || exit 10 - -# Add $TESTSRC to classpath so that customized nameservice can be used -J="${TESTJAVA}${FS}bin${FS}java -cp $TESTSRC${SEP}. BasicKrb5Test" - -$J || exit 100 -$J des-cbc-crc || exit 1 -$J des-cbc-md5 || exit 3 -$J des3-cbc-sha1 || exit 16 -$J aes128-cts || exit 17 -$J aes256-cts || exit 18 -$J rc4-hmac || exit 23 - -exit 0 diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/** + * @test + * @bug 6581254 + * @summary Allow "~" in config to support windows short path + * @author Valerie Peng + */ + +import java.security.*; +import java.io.*; + +public class ConfigShortPath { + + public static void main(String[] args) { + String testSrc = System.getProperty("test.src", "."); + String configFile = testSrc + File.separator + "csp.cfg"; + System.out.println("Testing against " + configFile); + try { + Provider p = new sun.security.pkcs11.SunPKCS11(configFile); + } catch (ProviderException pe) { + String cause = pe.getCause().getMessage(); + if (cause.indexOf("Unexpected token") != -1) { + // re-throw to indicate test failure + throw pe; + } + } + } +} diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/security/pkcs11/Provider/csp.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/security/pkcs11/Provider/csp.cfg Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,4 @@ +showInfo = false +name = NSSTrust +nssSecmodDirectory = C:/DOCUME~1/dtftest/LOCALS~1/Temp/Work/exec/jsn_7.0_int-7.0_nightly_sec_win_32_part2-2007-07-16-09-06-04-0209/dtftest.Windows_2003.x86/NSS//db +nssLibraryDirectory = Y:/xml/CC_DTF/knight_ws/suites/jsn_7.0_int/security/tools/lib/nss/WINNT/ diff -r d534dd80da9f -r c19058ce05e8 jdk/test/sun/tools/jstat/gcNewCapacityOutput1.awk --- a/jdk/test/sun/tools/jstat/gcNewCapacityOutput1.awk Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/sun/tools/jstat/gcNewCapacityOutput1.awk Wed Jan 19 19:01:35 2011 -0800 @@ -4,7 +4,7 @@ # specific values. # # NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC -# 2176.0 7232.0 2176.0 64.0 192.0 192.0 64.0 6848.0 2048.0 1 0 +# 2176.0 7232.0 2176.0 192.0 64.0 192.0 64.0 6848.0 2048.0 1 0 BEGIN { diff -r d534dd80da9f -r c19058ce05e8 jdk/test/tools/launcher/Settings.java --- a/jdk/test/tools/launcher/Settings.java Tue Jan 18 08:37:05 2011 -0800 +++ b/jdk/test/tools/launcher/Settings.java Wed Jan 19 19:01:35 2011 -0800 @@ -74,8 +74,15 @@ static void runTestOptionDefault() throws IOException { TestHelper.TestResult tr = null; - tr = TestHelper.doExec(TestHelper.javaCmd, "-Xmx512m", "-Xss128k", - "-XshowSettings", "-jar", testJar.getAbsolutePath()); + tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms64m", "-Xmx512m", + "-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath()); + containsAllOptions(tr); + if (!tr.isOK()) { + System.out.println(tr.status); + throw new RuntimeException("test fails"); + } + tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms65536k", "-Xmx712m", + "-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath()); containsAllOptions(tr); if (!tr.isOK()) { System.out.println(tr.status); diff -r d534dd80da9f -r c19058ce05e8 jdk/test/tools/pack200/T7007157.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/pack200/T7007157.java Wed Jan 19 19:01:35 2011 -0800 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; +import java.util.jar.JarFile; +import java.util.jar.Pack200; +/* + * @test + * @bug 7007157 + * @summary make sure the strip command works on an attribute + * @compile -XDignore.symbol.file Utils.java T7007157.java + * @run main T7007157 + * @author ksrini + */ +public class T7007157 { + + public static void main(String... args) throws IOException { + File sdkHome = Utils.JavaSDK; + File testJar = new File(new File(sdkHome, "lib"), "tools.jar"); + JarFile jarFile = new JarFile(testJar); + File packFile = new File("foo.pack"); + Pack200.Packer packer = Pack200.newPacker(); + Map p = packer.properties(); + // Take the time optimization vs. space + p.put(packer.EFFORT, "1"); // CAUTION: do not use 0. + // Make the memory consumption as effective as possible + p.put(packer.SEGMENT_LIMIT, "10000"); + // ignore all JAR deflation requests to save time + p.put(packer.DEFLATE_HINT, packer.FALSE); + // save the file ordering of the original JAR + p.put(packer.KEEP_FILE_ORDER, packer.TRUE); + // strip the StackMapTables + p.put(packer.CODE_ATTRIBUTE_PFX + "StackMapTable", packer.STRIP); + FileOutputStream fos = null; + try { + // Write out to a jtreg scratch area + fos = new FileOutputStream(packFile); + // Call the packer + packer.pack(jarFile, fos); + } finally { + Utils.close(fos); + Utils.close(jarFile); + } + } +} diff -r d534dd80da9f -r c19058ce05e8 langtools/.hgtags --- a/langtools/.hgtags Tue Jan 18 08:37:05 2011 -0800 +++ b/langtools/.hgtags Wed Jan 19 19:01:35 2011 -0800 @@ -98,3 +98,5 @@ 1bf969e9792f977a8593496681539840a54fe644 jdk7-b121 11e7b4c0476e4d6085d8d28c4aa2833d46714a2a jdk7-b122 a3b5b531542a372f30e014b1543a619a15a90780 jdk7-b123 +4868a36f6fd8972505c466013813eeb28f0482ea jdk7-b124 +4b0560c72b529d4b952924b2da94d8436af79d05 jdk7-b125