Fri, 07 Jan 2011 03:58:11 -0800
Merge
1.1 --- a/.hgtags Thu Jan 06 16:03:20 2011 -0800 1.2 +++ b/.hgtags Fri Jan 07 03:58:11 2011 -0800 1.3 @@ -134,4 +134,7 @@ 1.4 5484e7c53fa7da5e869902437ee08a9ae10c1c69 jdk7-b119 1.5 f5603a6e50422046ebc0d2f1671d55cb8f1bf1e9 jdk7-b120 1.6 3f3653ab7af8dc1ddb9fa75dad56bf94f89e81a8 jdk7-b121 1.7 +3a548dc9cb456110ca8fc1514441a8c3bda0014d jdk7-b122 1.8 5484e7c53fa7da5e869902437ee08a9ae10c1c69 hs20-b03 1.9 +9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 jdk7-b123 1.10 +9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 hs20-b04
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Thu Jan 06 16:03:20 2011 -0800 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Fri Jan 07 03:58:11 2011 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -99,15 +99,8 @@ 2.11 long typeEntrySizeOffset; 2.12 long typeEntryArrayStride; 2.13 2.14 - typeEntryTypeNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset"); 2.15 - typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset"); 2.16 - typeEntryIsOopTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset"); 2.17 - typeEntryIsIntegerTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset"); 2.18 - typeEntryIsUnsignedOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset"); 2.19 - typeEntrySizeOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset"); 2.20 - typeEntryArrayStride = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride"); 2.21 - 2.22 - // Fetch the address of the VMTypeEntry* 2.23 + // Fetch the address of the VMTypeEntry*. We get this symbol first 2.24 + // and try to use it to make sure that symbol lookup is working. 2.25 Address entryAddr = lookupInProcess("gHotSpotVMTypes"); 2.26 // System.err.println("gHotSpotVMTypes address = " + entryAddr); 2.27 // Dereference this once to get the pointer to the first VMTypeEntry 2.28 @@ -118,6 +111,14 @@ 2.29 throw new RuntimeException("gHotSpotVMTypes was not initialized properly in the remote process; can not continue"); 2.30 } 2.31 2.32 + typeEntryTypeNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset"); 2.33 + typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset"); 2.34 + typeEntryIsOopTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset"); 2.35 + typeEntryIsIntegerTypeOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset"); 2.36 + typeEntryIsUnsignedOffset = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset"); 2.37 + typeEntrySizeOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset"); 2.38 + typeEntryArrayStride = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride"); 2.39 + 2.40 // Start iterating down it until we find an entry with no name 2.41 Address typeNameAddr = null; 2.42 do {
3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java Thu Jan 06 16:03:20 2011 -0800 3.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java Fri Jan 07 03:58:11 2011 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -122,10 +122,14 @@ 3.11 private MemoizedObject[] sectionHeaders; 3.12 private MemoizedObject[] symbols; 3.13 3.14 + // Init stringTable at decl time since other fields init'ed in the 3.15 + // constructor need the String Table. 3.16 private MemoizedObject stringTable = new MemoizedObject() { 3.17 public Object computeValue() { 3.18 + // the String Table follows the Symbol Table 3.19 int ptr = getPointerToSymbolTable(); 3.20 if (ptr == 0) { 3.21 + // no Symbol Table so no String Table 3.22 return new StringTable(0); 3.23 } else { 3.24 return new StringTable(ptr + SYMBOL_SIZE * getNumberOfSymbols()); 3.25 @@ -140,6 +144,8 @@ 3.26 timeDateStamp = readInt(); 3.27 pointerToSymbolTable = readInt(); 3.28 numberOfSymbols = readInt(); 3.29 + // String Table can be accessed at this point because 3.30 + // pointerToSymbolTable and numberOfSymbols fields are set. 3.31 sizeOfOptionalHeader = readShort(); 3.32 characteristics = readShort(); 3.33 3.34 @@ -222,6 +228,8 @@ 3.35 private MemoizedObject windowsSpecificFields; 3.36 private MemoizedObject dataDirectories; 3.37 3.38 + // We use an offset of 2 because OptionalHeaderStandardFieldsImpl doesn't 3.39 + // include the 'magic' field. 3.40 private static final int STANDARD_FIELDS_OFFSET = 2; 3.41 private static final int PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET = 28; 3.42 private static final int PE32_DATA_DIRECTORIES_OFFSET = 96; 3.43 @@ -288,7 +296,7 @@ 3.44 private int sizeOfUninitializedData; 3.45 private int addressOfEntryPoint; 3.46 private int baseOfCode; 3.47 - private int baseOfData; 3.48 + private int baseOfData; // only set in PE32 3.49 3.50 OptionalHeaderStandardFieldsImpl(int offset, 3.51 boolean isPE32Plus) { 3.52 @@ -301,7 +309,8 @@ 3.53 sizeOfUninitializedData = readInt(); 3.54 addressOfEntryPoint = readInt(); 3.55 baseOfCode = readInt(); 3.56 - if (isPE32Plus) { 3.57 + if (!isPE32Plus) { 3.58 + // only available in PE32 3.59 baseOfData = readInt(); 3.60 } 3.61 } 3.62 @@ -433,7 +442,10 @@ 3.63 if (dir.getRVA() == 0 || dir.getSize() == 0) { 3.64 return null; 3.65 } 3.66 - return new ExportDirectoryTableImpl(rvaToFileOffset(dir.getRVA()), dir.getSize()); 3.67 + // ExportDirectoryTableImpl needs both the RVA and the 3.68 + // RVA converted to a file offset. 3.69 + return new 3.70 + ExportDirectoryTableImpl(dir.getRVA(), dir.getSize()); 3.71 } 3.72 }; 3.73 3.74 @@ -526,6 +538,7 @@ 3.75 } 3.76 3.77 class ExportDirectoryTableImpl implements ExportDirectoryTable { 3.78 + private int exportDataDirRVA; 3.79 private int offset; 3.80 private int size; 3.81 3.82 @@ -548,8 +561,9 @@ 3.83 private MemoizedObject exportOrdinalTable; 3.84 private MemoizedObject exportAddressTable; 3.85 3.86 - ExportDirectoryTableImpl(int offset, int size) { 3.87 - this.offset = offset; 3.88 + ExportDirectoryTableImpl(int exportDataDirRVA, int size) { 3.89 + this.exportDataDirRVA = exportDataDirRVA; 3.90 + offset = rvaToFileOffset(exportDataDirRVA); 3.91 this.size = size; 3.92 seek(offset); 3.93 exportFlags = readInt(); 3.94 @@ -595,6 +609,7 @@ 3.95 3.96 exportOrdinalTable = new MemoizedObject() { 3.97 public Object computeValue() { 3.98 + // number of ordinals is same as the number of name pointers 3.99 short[] ordinals = new short[getNumberOfNamePointers()]; 3.100 seek(rvaToFileOffset(getOrdinalTableRVA())); 3.101 for (int i = 0; i < ordinals.length; i++) { 3.102 @@ -608,14 +623,18 @@ 3.103 public Object computeValue() { 3.104 int[] addresses = new int[getNumberOfAddressTableEntries()]; 3.105 seek(rvaToFileOffset(getExportAddressTableRVA())); 3.106 - // Must make two passes to avoid rvaToFileOffset 3.107 - // destroying seek() position 3.108 + // The Export Address Table values are a union of two 3.109 + // possible values: 3.110 + // Export RVA - The address of the exported symbol when 3.111 + // loaded into memory, relative to the image base. 3.112 + // This value doesn't get converted into a file offset. 3.113 + // Forwarder RVA - The pointer to a null-terminated ASCII 3.114 + // string in the export section. This value gets 3.115 + // converted into a file offset because we have to 3.116 + // fetch the string. 3.117 for (int i = 0; i < addresses.length; i++) { 3.118 addresses[i] = readInt(); 3.119 } 3.120 - for (int i = 0; i < addresses.length; i++) { 3.121 - addresses[i] = rvaToFileOffset(addresses[i]); 3.122 - } 3.123 return addresses; 3.124 } 3.125 }; 3.126 @@ -648,11 +667,12 @@ 3.127 3.128 public boolean isExportAddressForwarder(short ordinal) { 3.129 int addr = getExportAddress(ordinal); 3.130 - return ((offset <= addr) && (addr < (offset + size))); 3.131 + return ((exportDataDirRVA <= addr) && 3.132 + (addr < (exportDataDirRVA + size))); 3.133 } 3.134 3.135 public String getExportAddressForwarder(short ordinal) { 3.136 - seek(getExportAddress(ordinal)); 3.137 + seek(rvaToFileOffset(getExportAddress(ordinal))); 3.138 return readCString(); 3.139 } 3.140 3.141 @@ -3371,10 +3391,17 @@ 3.142 throw new COFFException(e); 3.143 } 3.144 // Look up in string table 3.145 + // FIXME: this index value is assumed to be in the valid range 3.146 name = getStringTable().get(index); 3.147 } else { 3.148 try { 3.149 - name = new String(tmpName, US_ASCII); 3.150 + int length = 0; 3.151 + // find last non-NULL 3.152 + for (; length < tmpName.length && tmpName[length] != '\0';) { 3.153 + length++; 3.154 + } 3.155 + // don't include NULL chars in returned name String 3.156 + name = new String(tmpName, 0, length, US_ASCII); 3.157 } catch (UnsupportedEncodingException e) { 3.158 throw new COFFException(e); 3.159 } 3.160 @@ -3487,6 +3514,7 @@ 3.161 tmpName[5] << 16 | 3.162 tmpName[6] << 8 | 3.163 tmpName[7]); 3.164 + // FIXME: stringOffset is assumed to be in the valid range 3.165 name = getStringTable().getAtOffset(stringOffset); 3.166 } 3.167 3.168 @@ -3698,12 +3726,13 @@ 3.169 3.170 StringTable(int offset) { 3.171 if (offset == 0) { 3.172 + // no String Table 3.173 strings = new COFFString[0]; 3.174 return; 3.175 } 3.176 3.177 seek(offset); 3.178 - int length = readInt(); 3.179 + int length = readInt(); // length includes itself 3.180 byte[] data = new byte[length - 4]; 3.181 int numBytesRead = readBytes(data); 3.182 if (numBytesRead != data.length) {
4.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java Thu Jan 06 16:03:20 2011 -0800 4.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java Fri Jan 07 03:58:11 2011 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -37,35 +37,48 @@ 4.11 4.12 String filename = args[0]; 4.13 COFFFile file = COFFFileParser.getParser().parse(filename); 4.14 - ExportDirectoryTable exports = 4.15 - file.getHeader(). 4.16 - getOptionalHeader(). 4.17 - getDataDirectories(). 4.18 - getExportDirectoryTable(); 4.19 + 4.20 + // get common point for both things we want to dump 4.21 + OptionalHeaderDataDirectories dataDirs = file.getHeader().getOptionalHeader(). 4.22 + getDataDirectories(); 4.23 + 4.24 + // dump the header data directory for the Export Table: 4.25 + DataDirectory dir = dataDirs.getExportTable(); 4.26 + System.out.println("Export table: RVA = " + dir.getRVA() + "/0x" + 4.27 + Integer.toHexString(dir.getRVA()) + ", size = " + dir.getSize() + "/0x" + 4.28 + Integer.toHexString(dir.getSize())); 4.29 + 4.30 + System.out.println(file.getHeader().getNumberOfSections() + " sections in file"); 4.31 + for (int i = 1; i <= file.getHeader().getNumberOfSections(); i++) { 4.32 + SectionHeader sec = file.getHeader().getSectionHeader(i); 4.33 + System.out.println(" Section " + i + ":"); 4.34 + System.out.println(" Name = '" + sec.getName() + "'"); 4.35 + System.out.println(" VirtualSize = " + sec.getSize() + "/0x" + 4.36 + Integer.toHexString(sec.getSize())); 4.37 + System.out.println(" VirtualAddress = " + sec.getVirtualAddress() + "/0x" + 4.38 + Integer.toHexString(sec.getVirtualAddress())); 4.39 + System.out.println(" SizeOfRawData = " + sec.getSizeOfRawData() + "/0x" + 4.40 + Integer.toHexString(sec.getSizeOfRawData())); 4.41 + System.out.println(" PointerToRawData = " + sec.getPointerToRawData() + "/0x" + 4.42 + Integer.toHexString(sec.getPointerToRawData())); 4.43 + } 4.44 + 4.45 + ExportDirectoryTable exports = dataDirs.getExportDirectoryTable(); 4.46 if (exports == null) { 4.47 System.out.println("No exports found."); 4.48 } else { 4.49 - System.out.println(file.getHeader().getNumberOfSections() + " sections in file"); 4.50 - for (int i = 0; i < file.getHeader().getNumberOfSections(); i++) { 4.51 - System.out.println(" Section " + i + ": " + file.getHeader().getSectionHeader(1 + i).getName()); 4.52 - } 4.53 - 4.54 - DataDirectory dir = file.getHeader().getOptionalHeader().getDataDirectories().getExportTable(); 4.55 - System.out.println("Export table: RVA = 0x" + Integer.toHexString(dir.getRVA()) + 4.56 - ", size = 0x" + Integer.toHexString(dir.getSize())); 4.57 - 4.58 System.out.println("DLL name: " + exports.getDLLName()); 4.59 System.out.println("Time/date stamp 0x" + Integer.toHexString(exports.getTimeDateStamp())); 4.60 System.out.println("Major version 0x" + Integer.toHexString(exports.getMajorVersion() & 0xFFFF)); 4.61 System.out.println("Minor version 0x" + Integer.toHexString(exports.getMinorVersion() & 0xFFFF)); 4.62 - System.out.println(exports.getNumberOfNamePointers() + " functions found"); 4.63 + System.out.println(exports.getNumberOfNamePointers() + " exports found"); 4.64 for (int i = 0; i < exports.getNumberOfNamePointers(); i++) { 4.65 - System.out.println(" 0x" + 4.66 - Integer.toHexString(exports.getExportAddress(exports.getExportOrdinal(i))) + 4.67 - " " + 4.68 - (exports.isExportAddressForwarder(exports.getExportOrdinal(i)) ? 4.69 - ("Forwarded to " + exports.getExportAddressForwarder(exports.getExportOrdinal(i))) : 4.70 - exports.getExportName(i))); 4.71 + short ordinal = exports.getExportOrdinal(i); 4.72 + System.out.print("[" + i + "] '" + exports.getExportName(i) + "': [" + 4.73 + ordinal + "] = 0x" + Integer.toHexString(exports.getExportAddress(ordinal))); 4.74 + System.out.println(exports.isExportAddressForwarder(ordinal) 4.75 + ? " Forwarded to '" + exports.getExportAddressForwarder(ordinal) + "'" 4.76 + : ""); 4.77 } 4.78 } 4.79 }
5.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java Thu Jan 06 16:03:20 2011 -0800 5.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java Fri Jan 07 03:58:11 2011 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -42,8 +42,8 @@ 5.11 COFFHeader header = file.getHeader(); 5.12 int numSections = header.getNumberOfSections(); 5.13 System.out.println(numSections + " sections detected."); 5.14 - for (int i = 0; i < numSections; i++) { 5.15 - SectionHeader secHeader = header.getSectionHeader(1 + i); 5.16 + for (int i = 1; i <= numSections; i++) { 5.17 + SectionHeader secHeader = header.getSectionHeader(i); 5.18 System.out.println(secHeader.getName()); 5.19 } 5.20
6.1 --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Thu Jan 06 16:03:20 2011 -0800 6.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Fri Jan 07 03:58:11 2011 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -506,7 +506,6 @@ 6.11 throw new DebuggerException("Unimplemented"); 6.12 } 6.13 6.14 - private static String DTFWHome; 6.15 private static String imagePath; 6.16 private static String symbolPath; 6.17 private static boolean useNativeLookup; 6.18 @@ -514,81 +513,143 @@ 6.19 static { 6.20 6.21 /* 6.22 - * sawindbg.dll depends on dbgeng.dll which 6.23 - * itself depends on dbghelp.dll. dbgeng.dll and dbghelp.dll. 6.24 - * On systems newer than Windows 2000, these two .dlls are 6.25 - * in the standard system directory so we will find them there. 6.26 - * On Windows 2000 and earlier, these files do not exist. 6.27 - * The user must download Debugging Tools For Windows (DTFW) 6.28 - * and install it in order to use SA. 6.29 + * sawindbg.dll depends on dbgeng.dll which itself depends on 6.30 + * dbghelp.dll. We have to make sure that the dbgeng.dll and 6.31 + * dbghelp.dll that we load are compatible with each other. We 6.32 + * load both of those libraries from the same directory based 6.33 + * on the theory that co-located libraries are compatible. 6.34 * 6.35 - * We have to make sure we use the two files from the same directory 6.36 - * in case there are more than one copy on the system because 6.37 - * one version of dbgeng.dll might not be compatible with a 6.38 - * different version of dbghelp.dll. 6.39 - * We first look for them in the directory pointed at by 6.40 - * env. var. DEBUGGINGTOOLSFORWINDOWS, next in the default 6.41 - * installation dir for DTFW, and lastly in the standard 6.42 - * system directory. We expect that that we will find 6.43 - * them in the standard system directory on all systems 6.44 - * newer than Windows 2000. 6.45 + * On Windows 2000 and earlier, dbgeng.dll and dbghelp.dll were 6.46 + * not included as part of the standard system directory. On 6.47 + * systems newer than Windows 2000, dbgeng.dll and dbghelp.dll 6.48 + * are included in the standard system directory. However, the 6.49 + * versions included in the standard system directory may not 6.50 + * be able to handle symbol information for the newer compilers. 6.51 + * 6.52 + * We search for and explicitly load the libraries using the 6.53 + * following directory search order: 6.54 + * 6.55 + * - java.home/bin (same as $JAVA_HOME/jre/bin) 6.56 + * - dir named by DEBUGGINGTOOLSFORWINDOWS environment variable 6.57 + * - various "Debugging Tools For Windows" program directories 6.58 + * - the system directory ($SYSROOT/system32) 6.59 + * 6.60 + * If SA is invoked with -Dsun.jvm.hotspot.loadLibrary.DEBUG=1, 6.61 + * then debug messages about library loading are printed to 6.62 + * System.err. 6.63 */ 6.64 - String dirName = null; 6.65 - DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); 6.66 6.67 - if (DTFWHome == null) { 6.68 - // See if we have the files in the default location. 6.69 + String dbgengPath = null; 6.70 + String dbghelpPath = null; 6.71 + String sawindbgPath = null; 6.72 + List searchList = new ArrayList(); 6.73 + 6.74 + boolean loadLibraryDEBUG = 6.75 + System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null; 6.76 + 6.77 + { 6.78 + // First place to search is co-located with sawindbg.dll in 6.79 + // $JAVA_HOME/jre/bin (java.home property is set to $JAVA_HOME/jre): 6.80 + searchList.add(System.getProperty("java.home") + File.separator + "bin"); 6.81 + sawindbgPath = (String) searchList.get(0) + File.separator + 6.82 + "sawindbg.dll"; 6.83 + 6.84 + // second place to search is specified by an environment variable: 6.85 + String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS"); 6.86 + if (DTFWHome != null) { 6.87 + searchList.add(DTFWHome); 6.88 + } 6.89 + 6.90 + // The third place to search is the install directory for the 6.91 + // "Debugging Tools For Windows" package; so far there are three 6.92 + // name variations that we know of: 6.93 String sysRoot = System.getenv("SYSTEMROOT"); 6.94 - DTFWHome = sysRoot + File.separator + 6.95 - ".." + File.separator + "Program Files" + 6.96 - File.separator + "Debugging Tools For Windows"; 6.97 + DTFWHome = sysRoot + File.separator + ".." + File.separator + 6.98 + "Program Files" + File.separator + "Debugging Tools For Windows"; 6.99 + searchList.add(DTFWHome); 6.100 + searchList.add(DTFWHome + " (x86)"); 6.101 + searchList.add(DTFWHome + " (x64)"); 6.102 + 6.103 + // The last place to search is the system directory: 6.104 + searchList.add(sysRoot + File.separator + "system32"); 6.105 } 6.106 6.107 - { 6.108 - String dbghelp = DTFWHome + File.separator + "dbghelp.dll"; 6.109 - String dbgeng = DTFWHome + File.separator + "dbgeng.dll"; 6.110 - File fhelp = new File(dbghelp); 6.111 - File feng = new File(dbgeng); 6.112 - if (fhelp.exists() && feng.exists()) { 6.113 - // found both, we are happy. 6.114 - // NOTE: The order of loads is important! If we load dbgeng.dll 6.115 - // first, then the dependency - dbghelp.dll - will be loaded 6.116 - // from usual DLL search thereby defeating the purpose! 6.117 - System.load(dbghelp); 6.118 - System.load(dbgeng); 6.119 - } else if (! fhelp.exists() && ! feng.exists()) { 6.120 - // neither exist. We will ignore this dir and assume 6.121 - // they are in the system dir. 6.122 - DTFWHome = null; 6.123 - } else { 6.124 - // one exists but not the other 6.125 - //System.err.println("Error: Both files dbghelp.dll and dbgeng.dll " 6.126 - // "must exist in directory " + DTFWHome); 6.127 - throw new UnsatisfiedLinkError("Both files dbghelp.dll and " + 6.128 - "dbgeng.dll must exist in " + 6.129 - "directory " + DTFWHome); 6.130 + for (int i = 0; i < searchList.size(); i++) { 6.131 + File dir = new File((String) searchList.get(i)); 6.132 + if (!dir.exists()) { 6.133 + if (loadLibraryDEBUG) { 6.134 + System.err.println("DEBUG: '" + searchList.get(i) + 6.135 + "': directory does not exist."); 6.136 + } 6.137 + // this search directory doesn't exist so skip it 6.138 + continue; 6.139 } 6.140 - } 6.141 - if (DTFWHome == null) { 6.142 - // The files better be in the system dir. 6.143 - String sysDir = System.getenv("SYSTEMROOT") + 6.144 - File.separator + "system32"; 6.145 6.146 - File feng = new File(sysDir + File.separator + "dbgeng.dll"); 6.147 - if (!feng.exists()) { 6.148 - throw new UnsatisfiedLinkError("File dbgeng.dll does not exist in " + 6.149 - sysDir + ". Please search microsoft.com " + 6.150 - "for Debugging Tools For Windows, and " + 6.151 - "either download it to the default " + 6.152 - "location, or download it to a custom " + 6.153 - "location and set environment variable " + 6.154 - " DEBUGGINGTOOLSFORWINDOWS " + 6.155 - "to the pathname of that location."); 6.156 + dbgengPath = (String) searchList.get(i) + File.separator + "dbgeng.dll"; 6.157 + dbghelpPath = (String) searchList.get(i) + File.separator + "dbghelp.dll"; 6.158 + 6.159 + File feng = new File(dbgengPath); 6.160 + File fhelp = new File(dbghelpPath); 6.161 + if (feng.exists() && fhelp.exists()) { 6.162 + // both files exist so we have a match 6.163 + break; 6.164 } 6.165 + 6.166 + // At least one of the files does not exist; no warning if both 6.167 + // don't exist. If just one doesn't exist then we don't check 6.168 + // loadLibraryDEBUG because we have a mis-configured system. 6.169 + if (feng.exists()) { 6.170 + System.err.println("WARNING: found '" + dbgengPath + 6.171 + "' but did not find '" + dbghelpPath + "'; ignoring '" + 6.172 + dbgengPath + "'."); 6.173 + } else if (fhelp.exists()) { 6.174 + System.err.println("WARNING: found '" + dbghelpPath + 6.175 + "' but did not find '" + dbgengPath + "'; ignoring '" + 6.176 + dbghelpPath + "'."); 6.177 + } else if (loadLibraryDEBUG) { 6.178 + System.err.println("DEBUG: searched '" + searchList.get(i) + 6.179 + "': dbgeng.dll and dbghelp.dll were not found."); 6.180 + } 6.181 + dbgengPath = null; 6.182 + dbghelpPath = null; 6.183 } 6.184 6.185 + if (dbgengPath == null || dbghelpPath == null) { 6.186 + // at least one of the files wasn't found anywhere we searched 6.187 + String mesg = null; 6.188 + 6.189 + if (dbgengPath == null && dbghelpPath == null) { 6.190 + mesg = "dbgeng.dll and dbghelp.dll cannot be found. "; 6.191 + } else if (dbgengPath == null) { 6.192 + mesg = "dbgeng.dll cannot be found (dbghelp.dll was found). "; 6.193 + } else { 6.194 + mesg = "dbghelp.dll cannot be found (dbgeng.dll was found). "; 6.195 + } 6.196 + throw new UnsatisfiedLinkError(mesg + 6.197 + "Please search microsoft.com for 'Debugging Tools For Windows', " + 6.198 + "and either download it to the default location, or download it " + 6.199 + "to a custom location and set environment variable " + 6.200 + "'DEBUGGINGTOOLSFORWINDOWS' to the pathname of that location."); 6.201 + } 6.202 + 6.203 + // NOTE: The order of loads is important! If we load dbgeng.dll 6.204 + // first, then the dependency - dbghelp.dll - will be loaded 6.205 + // from usual DLL search thereby defeating the purpose! 6.206 + if (loadLibraryDEBUG) { 6.207 + System.err.println("DEBUG: loading '" + dbghelpPath + "'."); 6.208 + } 6.209 + System.load(dbghelpPath); 6.210 + if (loadLibraryDEBUG) { 6.211 + System.err.println("DEBUG: loading '" + dbgengPath + "'."); 6.212 + } 6.213 + System.load(dbgengPath); 6.214 + 6.215 // Now, load sawindbg.dll 6.216 - System.loadLibrary("sawindbg"); 6.217 + if (loadLibraryDEBUG) { 6.218 + System.err.println("DEBUG: loading '" + sawindbgPath + "'."); 6.219 + } 6.220 + System.load(sawindbgPath); 6.221 + 6.222 // where do I find '.exe', '.dll' files? 6.223 imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath"); 6.224 if (imagePath == null) {
7.1 --- a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Thu Jan 06 16:03:20 2011 -0800 7.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java Fri Jan 07 03:58:11 2011 -0800 7.3 @@ -30,6 +30,7 @@ 7.4 import sun.jvm.hotspot.asm.sparc.*; 7.5 import sun.jvm.hotspot.asm.x86.*; 7.6 import sun.jvm.hotspot.asm.ia64.*; 7.7 +import sun.jvm.hotspot.asm.amd64.*; 7.8 import sun.jvm.hotspot.code.*; 7.9 import sun.jvm.hotspot.compiler.*; 7.10 import sun.jvm.hotspot.debugger.*; 7.11 @@ -198,6 +199,8 @@ 7.12 cpuHelper = new SPARCHelper(); 7.13 } else if (cpu.equals("x86")) { 7.14 cpuHelper = new X86Helper(); 7.15 + } else if (cpu.equals("amd64")) { 7.16 + cpuHelper = new AMD64Helper(); 7.17 } else if (cpu.equals("ia64")) { 7.18 cpuHelper = new IA64Helper(); 7.19 } else {
8.1 --- a/make/hotspot_version Thu Jan 06 16:03:20 2011 -0800 8.2 +++ b/make/hotspot_version Fri Jan 07 03:58:11 2011 -0800 8.3 @@ -35,7 +35,7 @@ 8.4 8.5 HS_MAJOR_VER=20 8.6 HS_MINOR_VER=0 8.7 -HS_BUILD_NUMBER=04 8.8 +HS_BUILD_NUMBER=05 8.9 8.10 JDK_MAJOR_VER=1 8.11 JDK_MINOR_VER=7
9.1 --- a/make/linux/makefiles/build_vm_def.sh Thu Jan 06 16:03:20 2011 -0800 9.2 +++ b/make/linux/makefiles/build_vm_def.sh Fri Jan 07 03:58:11 2011 -0800 9.3 @@ -1,7 +1,7 @@ 9.4 #!/bin/sh 9.5 9.6 # If we're cross compiling use that path for nm 9.7 -if [ "$ALT_COMPILER_PATH" != "" ]; then 9.8 +if [ "$CROSS_COMPILE_ARCH" != "" ]; then 9.9 NM=$ALT_COMPILER_PATH/nm 9.10 else 9.11 NM=nm
10.1 --- a/make/linux/makefiles/buildtree.make Thu Jan 06 16:03:20 2011 -0800 10.2 +++ b/make/linux/makefiles/buildtree.make Fri Jan 07 03:58:11 2011 -0800 10.3 @@ -124,7 +124,7 @@ 10.4 BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make 10.5 10.6 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \ 10.7 - env.sh env.csh .dbxrc test_gamma 10.8 + env.sh env.csh jdkpath.sh .dbxrc test_gamma 10.9 10.10 BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ 10.11 ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) 10.12 @@ -318,6 +318,13 @@ 10.13 sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \ 10.14 ) > $@ 10.15 10.16 +jdkpath.sh: $(BUILDTREE_MAKE) 10.17 + @echo Creating $@ ... 10.18 + $(QUIETLY) ( \ 10.19 + $(BUILDTREE_COMMENT); \ 10.20 + echo "JDK=${JAVA_HOME}"; \ 10.21 + ) > $@ 10.22 + 10.23 .dbxrc: $(BUILDTREE_MAKE) 10.24 @echo Creating $@ ... 10.25 $(QUIETLY) ( \
11.1 --- a/make/linux/makefiles/gcc.make Thu Jan 06 16:03:20 2011 -0800 11.2 +++ b/make/linux/makefiles/gcc.make Fri Jan 07 03:58:11 2011 -0800 11.3 @@ -25,7 +25,9 @@ 11.4 #------------------------------------------------------------------------ 11.5 # CC, CPP & AS 11.6 11.7 -ifdef ALT_COMPILER_PATH 11.8 +# When cross-compiling the ALT_COMPILER_PATH points 11.9 +# to the cross-compilation toolset 11.10 +ifdef CROSS_COMPILE_ARCH 11.11 CPP = $(ALT_COMPILER_PATH)/g++ 11.12 CC = $(ALT_COMPILER_PATH)/gcc 11.13 else
12.1 --- a/make/linux/makefiles/vm.make Thu Jan 06 16:03:20 2011 -0800 12.2 +++ b/make/linux/makefiles/vm.make Fri Jan 07 03:58:11 2011 -0800 12.3 @@ -168,7 +168,9 @@ 12.4 12.5 # Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. 12.6 define findsrc 12.7 - $(notdir $(shell find $(1) \( -name \*.c -o -name \*.cpp -o -name \*.s \) -a \! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \) )) 12.8 + $(notdir $(shell find $(1)/. ! -name . -prune \ 12.9 + -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ 12.10 + -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) 12.11 endef 12.12 12.13 Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
13.1 --- a/make/solaris/makefiles/buildtree.make Thu Jan 06 16:03:20 2011 -0800 13.2 +++ b/make/solaris/makefiles/buildtree.make Fri Jan 07 03:58:11 2011 -0800 13.3 @@ -117,7 +117,7 @@ 13.4 BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make 13.5 13.6 BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \ 13.7 - env.ksh env.csh .dbxrc test_gamma 13.8 + env.ksh env.csh jdkpath.sh .dbxrc test_gamma 13.9 13.10 BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ 13.11 ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) 13.12 @@ -314,6 +314,13 @@ 13.13 sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \ 13.14 ) > $@ 13.15 13.16 +jdkpath.sh: $(BUILDTREE_MAKE) 13.17 + @echo Creating $@ ... 13.18 + $(QUIETLY) ( \ 13.19 + $(BUILDTREE_COMMENT); \ 13.20 + echo "JDK=${JAVA_HOME}"; \ 13.21 + ) > $@ 13.22 + 13.23 .dbxrc: $(BUILDTREE_MAKE) 13.24 @echo Creating $@ ... 13.25 $(QUIETLY) ( \
14.1 --- a/make/solaris/makefiles/vm.make Thu Jan 06 16:03:20 2011 -0800 14.2 +++ b/make/solaris/makefiles/vm.make Fri Jan 07 03:58:11 2011 -0800 14.3 @@ -106,17 +106,17 @@ 14.4 # Not sure what the 'designed for' comment is referring too above. 14.5 # The order may not be too significant anymore, but I have placed this 14.6 # older libm before libCrun, just to make sure it's found and used first. 14.7 -LIBS += -lsocket -lsched -ldl $(LIBM) -lCrun -lthread -ldoor -lc 14.8 +LIBS += -lsocket -lsched -ldl $(LIBM) -lCrun -lthread -ldoor -lc -ldemangle 14.9 else 14.10 ifeq ($(COMPILER_REV_NUMERIC), 502) 14.11 # SC6.1 has it's own libm.so: specifying anything else provokes a name conflict. 14.12 -LIBS += -ldl -lthread -lsocket -lm -lsched -ldoor 14.13 +LIBS += -ldl -lthread -lsocket -lm -lsched -ldoor -ldemangle 14.14 else 14.15 -LIBS += -ldl -lthread -lsocket $(LIBM) -lsched -ldoor 14.16 +LIBS += -ldl -lthread -lsocket $(LIBM) -lsched -ldoor -ldemangle 14.17 endif # 502 14.18 endif # 505 14.19 else 14.20 -LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc 14.21 +LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc -ldemangle 14.22 endif # sparcWorks 14.23 14.24 ifeq ("${Platform_arch}", "sparc") 14.25 @@ -188,7 +188,9 @@ 14.26 14.27 # Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. 14.28 define findsrc 14.29 - $(notdir $(shell find $(1) \( -name \*.c -o -name \*.cpp -o -name \*.s \) -a \! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \) )) 14.30 + $(notdir $(shell find $(1)/. ! -name . -prune \ 14.31 + -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ 14.32 + -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) 14.33 endef 14.34 14.35 Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
15.1 --- a/make/windows/build_vm_def.sh Thu Jan 06 16:03:20 2011 -0800 15.2 +++ b/make/windows/build_vm_def.sh Fri Jan 07 03:58:11 2011 -0800 15.3 @@ -1,5 +1,5 @@ 15.4 # 15.5 -# Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 15.6 +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 15.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.8 # 15.9 # This code is free software; you can redistribute it and/or modify it 15.10 @@ -45,6 +45,9 @@ 15.11 echo "EXPORTS" > vm1.def 15.12 15.13 AWK="$MKS_HOME/awk.exe" 15.14 +if [ ! -e $AWK ]; then 15.15 + AWK="$MKS_HOME/gawk.exe" 15.16 +fi 15.17 GREP="$MKS_HOME/grep.exe" 15.18 SORT="$MKS_HOME/sort.exe" 15.19 UNIQ="$MKS_HOME/uniq.exe" 15.20 @@ -57,7 +60,7 @@ 15.21 LINK_VER="$1" 15.22 fi 15.23 15.24 -if [ "x$LINK_VER" != "x800" -a "x$LINK_VER" != "x900" ]; then 15.25 +if [ "x$LINK_VER" != "x800" -a "x$LINK_VER" != "x900" -a "x$LINK_VER" != "x1000" ]; then 15.26 $DUMPBIN /symbols *.obj | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def 15.27 else 15.28 # Can't use pipes when calling cl.exe or link.exe from IDE. Using transit file vm3.def
16.1 --- a/make/windows/create.bat Thu Jan 06 16:03:20 2011 -0800 16.2 +++ b/make/windows/create.bat Fri Jan 07 03:58:11 2011 -0800 16.3 @@ -36,6 +36,20 @@ 16.4 REM Note: Running this batch file from the Windows command shell requires 16.5 REM that "grep" be accessible on the PATH. An MKS install does this. 16.6 REM 16.7 + 16.8 +cl 2>NUL >NUL 16.9 +if %errorlevel% == 0 goto nexttest 16.10 +echo Make sure cl.exe is in your PATH before running this script. 16.11 +goto end 16.12 + 16.13 +:nexttest 16.14 +grep -V 2>NUL >NUL 16.15 +if %errorlevel% == 0 goto testit 16.16 +echo Make sure grep.exe is in your PATH before running this script. Either cygwin or MKS should work. 16.17 +goto end 16.18 + 16.19 + 16.20 +:testit 16.21 cl 2>&1 | grep "IA-64" >NUL 16.22 if %errorlevel% == 0 goto isia64 16.23 cl 2>&1 | grep "AMD64" >NUL 16.24 @@ -44,37 +58,40 @@ 16.25 set BUILDARCH=i486 16.26 set Platform_arch=x86 16.27 set Platform_arch_model=x86_32 16.28 -goto end 16.29 +goto done 16.30 :amd64 16.31 set ARCH=x86 16.32 set BUILDARCH=amd64 16.33 set Platform_arch=x86 16.34 set Platform_arch_model=x86_64 16.35 -goto end 16.36 +goto done 16.37 :isia64 16.38 set ARCH=ia64 16.39 set BUILDARCH=ia64 16.40 set Platform_arch=ia64 16.41 set Platform_arch_model=ia64 16.42 -:end 16.43 +:done 16.44 16.45 setlocal 16.46 16.47 if "%1" == "" goto usage 16.48 16.49 -if not "%4" == "" goto usage 16.50 +if not "%2" == "" goto usage 16.51 16.52 -set HotSpotWorkSpace=%1 16.53 -set HotSpotBuildSpace=%2 16.54 -set HotSpotJDKDist=%3 16.55 +REM Set HotSpotWorkSpace to the directy two steps above this script 16.56 +for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi) 16.57 +set HotSpotBuildRoot=%HotSpotWorkSpace%build 16.58 +set HotSpotBuildSpace=%HotSpotBuildRoot%\vs 16.59 +set HotSpotJDKDist=%1 16.60 + 16.61 16.62 REM figure out MSC version 16.63 for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i 16.64 16.65 echo ************************************************************** 16.66 -set ProjectFile=vm.vcproj 16.67 +set ProjectFile=jvm.vcproj 16.68 if "%MSC_VER%" == "1200" ( 16.69 -set ProjectFile=vm.dsp 16.70 +set ProjectFile=jvm.dsp 16.71 echo Will generate VC6 project {unsupported} 16.72 ) else ( 16.73 if "%MSC_VER%" == "1400" ( 16.74 @@ -83,10 +100,16 @@ 16.75 if "%MSC_VER%" == "1500" ( 16.76 echo Will generate VC9 {Visual Studio 2008} 16.77 ) else ( 16.78 +if "%MSC_VER%" == "1600" ( 16.79 +echo Detected Visual Studio 2010, but 16.80 +echo will generate VC9 {Visual Studio 2008} 16.81 +echo Use conversion wizard in VS 2010. 16.82 +) else ( 16.83 echo Will generate VC7 project {Visual Studio 2003 .NET} 16.84 ) 16.85 ) 16.86 ) 16.87 +) 16.88 echo %ProjectFile% 16.89 echo ************************************************************** 16.90 16.91 @@ -118,6 +141,8 @@ 16.92 16.93 :test3 16.94 if not "%HOTSPOTMKSHOME%" == "" goto makedir 16.95 +if exist c:\cygwin\bin set HOTSPOTMKSHOME=c:\cygwin\bin 16.96 +if not "%HOTSPOTMKSHOME%" == "" goto makedir 16.97 echo Warning: please set variable HOTSPOTMKSHOME to place where 16.98 echo your MKS/Cygwin installation is 16.99 echo. 16.100 @@ -133,21 +158,24 @@ 16.101 REM This is now safe to do. 16.102 :copyfiles 16.103 for /D %%i in (compiler1, compiler2, tiered, core, kernel) do ( 16.104 -if NOT EXIST %HotSpotBuildSpace%\%%i mkdir %HotSpotBuildSpace%\%%i 16.105 -copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\ > NUL 16.106 +if NOT EXIST %HotSpotBuildSpace%\%%i\generated mkdir %HotSpotBuildSpace%\%%i\generated 16.107 +copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\generated > NUL 16.108 ) 16.109 16.110 REM force regneration of ProjectFile 16.111 if exist %HotSpotBuildSpace%\%ProjectFile% del %HotSpotBuildSpace%\%ProjectFile% 16.112 16.113 for /D %%i in (compiler1, compiler2, tiered, core, kernel) do ( 16.114 - 16.115 -echo # Generated file! > %HotSpotBuildSpace%\%%i\local.make 16.116 +echo -- %%i -- 16.117 +echo # Generated file! > %HotSpotBuildSpace%\%%i\local.make 16.118 echo # Changing a variable below and then deleting %ProjectFile% will cause >> %HotSpotBuildSpace%\%%i\local.make 16.119 echo # %ProjectFile% to be regenerated with the new values. Changing the >> %HotSpotBuildSpace%\%%i\local.make 16.120 -echo # version requires rerunning create.bat. >> %HotSpotBuildSpace%\%%i\local.make 16.121 +echo # version requires rerunning create.bat. >> %HotSpotBuildSpace%\%%i\local.make 16.122 echo. >> %HotSpotBuildSpace%\%%i\local.make 16.123 +echo Variant=%%i >> %HotSpotBuildSpace%\%%i\local.make 16.124 +echo WorkSpace=%HotSpotWorkSpace% >> %HotSpotBuildSpace%\%%i\local.make 16.125 echo HOTSPOTWORKSPACE=%HotSpotWorkSpace% >> %HotSpotBuildSpace%\%%i\local.make 16.126 +echo HOTSPOTBUILDROOT=%HotSpotBuildRoot% >> %HotSpotBuildSpace%\%%i\local.make 16.127 echo HOTSPOTBUILDSPACE=%HotSpotBuildSpace% >> %HotSpotBuildSpace%\%%i\local.make 16.128 echo HOTSPOTJDKDIST=%HotSpotJDKDist% >> %HotSpotBuildSpace%\%%i\local.make 16.129 echo ARCH=%ARCH% >> %HotSpotBuildSpace%\%%i\local.make 16.130 @@ -155,42 +183,35 @@ 16.131 echo Platform_arch=%Platform_arch% >> %HotSpotBuildSpace%\%%i\local.make 16.132 echo Platform_arch_model=%Platform_arch_model% >> %HotSpotBuildSpace%\%%i\local.make 16.133 16.134 -pushd %HotSpotBuildSpace%\%%i 16.135 +for /D %%j in (debug, fastdebug, product) do ( 16.136 +if NOT EXIST %HotSpotBuildSpace%\%%i\%%j mkdir %HotSpotBuildSpace%\%%i\%%j 16.137 +) 16.138 + 16.139 +pushd %HotSpotBuildSpace%\%%i\generated 16.140 nmake /nologo 16.141 popd 16.142 16.143 ) 16.144 16.145 -pushd %HotSpotBuildSpace% 16.146 +pushd %HotSpotBuildRoot% 16.147 16.148 -echo # Generated file! > local.make 16.149 -echo # Changing a variable below and then deleting %ProjectFile% will cause >> local.make 16.150 -echo # %ProjectFile% to be regenerated with the new values. Changing the >> local.make 16.151 -echo # version requires rerunning create.bat. >> local.make 16.152 -echo. >> local.make 16.153 -echo HOTSPOTWORKSPACE=%HotSpotWorkSpace% >> local.make 16.154 -echo HOTSPOTBUILDSPACE=%HotSpotBuildSpace% >> local.make 16.155 -echo HOTSPOTJDKDIST=%HotSpotJDKDist% >> local.make 16.156 -echo ARCH=%ARCH% >> local.make 16.157 -echo BUILDARCH=%BUILDARCH% >> local.make 16.158 -echo Platform_arch=%Platform_arch% >> local.make 16.159 -echo Platform_arch_model=%Platform_arch_model% >> local.make 16.160 - 16.161 -nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile %HotSpotBuildSpace%/%ProjectFile% 16.162 +REM It doesn't matter which variant we use here, "compiler1" is as good as any of the others - we need the common variables 16.163 +nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\compiler1\local.make %HotSpotBuildRoot%/%ProjectFile% 16.164 16.165 popd 16.166 16.167 goto end 16.168 16.169 :usage 16.170 -echo Usage: create HotSpotWorkSpace HotSpotBuildSpace HotSpotJDKDist 16.171 +echo Usage: create HotSpotJDKDist 16.172 echo. 16.173 -echo This is the interactive build setup script (as opposed to the batch 16.174 -echo build execution script). It creates HotSpotBuildSpace if necessary, 16.175 -echo copies the appropriate files out of HotSpotWorkSpace into it, and 16.176 +echo This is the VS build setup script (as opposed to the batch 16.177 +echo build execution script). It creates a build directory if necessary, 16.178 +echo copies the appropriate files out of the workspace into it, and 16.179 echo builds and runs ProjectCreator in it. This has the side-effect of creating 16.180 echo the %ProjectFile% file in the build space, which is then used in Visual C++. 16.181 -echo The HotSpotJDKDist defines place where JVM binaries should be placed. 16.182 +echo. 16.183 +echo The HotSpotJDKDist defines the JDK that should be used when running the JVM. 16.184 echo Environment variable FORCE_MSC_VER allows to override MSVC version autodetection. 16.185 echo. 16.186 echo NOTE that it is now NOT safe to modify any of the files in the build
17.1 --- a/make/windows/create_obj_files.sh Thu Jan 06 16:03:20 2011 -0800 17.2 +++ b/make/windows/create_obj_files.sh Fri Jan 07 03:58:11 2011 -0800 17.3 @@ -107,8 +107,12 @@ 17.4 "x86_64") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} *x86_32*" ;; 17.5 esac 17.6 17.7 +# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. 17.8 function findsrc { 17.9 - $FIND ${1} \( -name \*.c -o -name \*.cpp -o -name \*.s \) -a \! \( -name ${Src_Files_EXCLUDE// / -o -name } \) | sed 's/.*\/\(.*\)/\1/'; 17.10 + $FIND ${1}/. ! -name . -prune \ 17.11 + -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ 17.12 + -a \! \( -name ${Src_Files_EXCLUDE// / -o -name } \) \ 17.13 + | sed 's/.*\/\(.*\)/\1/'; 17.14 } 17.15 17.16 Src_Files=
18.1 --- a/make/windows/makefiles/adlc.make Thu Jan 06 16:03:20 2011 -0800 18.2 +++ b/make/windows/makefiles/adlc.make Fri Jan 07 03:58:11 2011 -0800 18.3 @@ -22,7 +22,6 @@ 18.4 # 18.5 # 18.6 18.7 -!include $(WorkSpace)/make/windows/makefiles/compile.make 18.8 18.9 # Rules for building adlc.exe 18.10 18.11 @@ -46,15 +45,7 @@ 18.12 ADLCFLAGS=-q -T -U_LP64 18.13 !endif 18.14 18.15 -CPP_FLAGS=$(CPP_FLAGS) \ 18.16 - /D TARGET_OS_FAMILY_windows \ 18.17 - /D TARGET_ARCH_$(Platform_arch) \ 18.18 - /D TARGET_ARCH_MODEL_$(Platform_arch_model) \ 18.19 - /D TARGET_OS_ARCH_windows_$(Platform_arch) \ 18.20 - /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model) \ 18.21 - /D TARGET_COMPILER_visCPP 18.22 - 18.23 -CPP_FLAGS=$(CPP_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE 18.24 +ADLC_CPP_FLAGS=$(CPP_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE 18.25 18.26 CPP_INCLUDE_DIRS=\ 18.27 /I "..\generated" \ 18.28 @@ -92,10 +83,10 @@ 18.29 $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp 18.30 18.31 {$(WorkSpace)\src\share\vm\adlc}.cpp.obj:: 18.32 - $(CPP) $(CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $< 18.33 + $(CPP) $(ADLC_CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $< 18.34 18.35 {$(WorkSpace)\src\share\vm\opto}.cpp.obj:: 18.36 - $(CPP) $(CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $< 18.37 + $(CPP) $(ADLC_CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $< 18.38 18.39 adlc.exe: main.obj adlparse.obj archDesc.obj arena.obj dfa.obj dict2.obj filebuff.obj \ 18.40 forms.obj formsopt.obj formssel.obj opcodes.obj output_c.obj output_h.obj
19.1 --- a/make/windows/makefiles/compile.make Thu Jan 06 16:03:20 2011 -0800 19.2 +++ b/make/windows/makefiles/compile.make Fri Jan 07 03:58:11 2011 -0800 19.3 @@ -1,5 +1,5 @@ 19.4 # 19.5 -# Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 19.6 +# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 19.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 # 19.9 # This code is free software; you can redistribute it and/or modify it 19.10 @@ -80,6 +80,20 @@ 19.11 CPP=ARCH_ERROR 19.12 !endif 19.13 19.14 +CPP_FLAGS=$(CPP_FLAGS) /D "WIN32" /D "_WINDOWS" 19.15 + 19.16 +# Must specify this for sharedRuntimeTrig.cpp 19.17 +CPP_FLAGS=$(CPP_FLAGS) /D "VM_LITTLE_ENDIAN" 19.18 + 19.19 +# Used for platform dispatching 19.20 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_FAMILY_windows 19.21 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_$(Platform_arch) 19.22 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model) 19.23 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch) 19.24 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model) 19.25 +CPP_FLAGS=$(CPP_FLAGS) /D TARGET_COMPILER_visCPP 19.26 + 19.27 + 19.28 # MSC_VER is a 4 digit number that tells us what compiler is being used 19.29 # and is generated when the local.make file is created by build.make 19.30 # via the script get_msc_ver.sh 19.31 @@ -138,7 +152,7 @@ 19.32 !endif 19.33 19.34 # Always add the _STATIC_CPPLIB flag 19.35 -STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB 19.36 +STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB 19.37 MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION) 19.38 CPP_FLAGS=$(CPP_FLAGS) $(MS_RUNTIME_OPTION) 19.39
20.1 --- a/make/windows/makefiles/debug.make Thu Jan 06 16:03:20 2011 -0800 20.2 +++ b/make/windows/makefiles/debug.make Fri Jan 07 03:58:11 2011 -0800 20.3 @@ -26,7 +26,6 @@ 20.4 HS_FNAME=$(HS_INTERNAL_NAME).dll 20.5 AOUT=$(HS_FNAME) 20.6 SAWINDBG=sawindbg.dll 20.7 -LAUNCHER_NAME=hotspot.exe 20.8 GENERATED=../generated 20.9 20.10 # Allow the user to turn off precompiled headers from the command line. 20.11 @@ -34,7 +33,7 @@ 20.12 BUILD_PCH_FILE=_build_pch_file.obj 20.13 !endif 20.14 20.15 -default:: $(BUILD_PCH_FILE) $(AOUT) $(LAUNCHER_NAME) checkAndBuildSA 20.16 +default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA 20.17 20.18 !include ../local.make 20.19 !include compile.make 20.20 @@ -49,8 +48,10 @@ 20.21 # Force resources to be rebuilt every time 20.22 $(Res_Files): FORCE 20.23 20.24 -$(AOUT): $(Res_Files) $(Obj_Files) 20.25 +vm.def: $(Obj_Files) 20.26 sh $(WorkSpace)/make/windows/build_vm_def.sh 20.27 + 20.28 +$(AOUT): $(Res_Files) $(Obj_Files) vm.def 20.29 $(LINK) @<< 20.30 $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) 20.31 <<
21.1 --- a/make/windows/makefiles/fastdebug.make Thu Jan 06 16:03:20 2011 -0800 21.2 +++ b/make/windows/makefiles/fastdebug.make Fri Jan 07 03:58:11 2011 -0800 21.3 @@ -26,7 +26,6 @@ 21.4 HS_FNAME=$(HS_INTERNAL_NAME).dll 21.5 AOUT=$(HS_FNAME) 21.6 SAWINDBG=sawindbg.dll 21.7 -LAUNCHER_NAME=hotspot.exe 21.8 GENERATED=../generated 21.9 21.10 # Allow the user to turn off precompiled headers from the command line. 21.11 @@ -34,7 +33,7 @@ 21.12 BUILD_PCH_FILE=_build_pch_file.obj 21.13 !endif 21.14 21.15 -default:: $(BUILD_PCH_FILE) $(AOUT) $(LAUNCHER_NAME) checkAndBuildSA 21.16 +default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA 21.17 21.18 !include ../local.make 21.19 !include compile.make 21.20 @@ -49,8 +48,10 @@ 21.21 # Force resources to be rebuilt every time 21.22 $(Res_Files): FORCE 21.23 21.24 -$(AOUT): $(Res_Files) $(Obj_Files) 21.25 +vm.def: $(Obj_Files) 21.26 sh $(WorkSpace)/make/windows/build_vm_def.sh 21.27 + 21.28 +$(AOUT): $(Res_Files) $(Obj_Files) vm.def 21.29 $(LINK) @<< 21.30 $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) 21.31 <<
22.1 --- a/make/windows/makefiles/generated.make Thu Jan 06 16:03:20 2011 -0800 22.2 +++ b/make/windows/makefiles/generated.make Fri Jan 07 03:58:11 2011 -0800 22.3 @@ -51,6 +51,7 @@ 22.4 22.5 !if ("$(Variant)" == "compiler2") || ("$(Variant)" == "tiered") 22.6 22.7 +!include $(WorkSpace)/make/windows/makefiles/compile.make 22.8 !include $(WorkSpace)/make/windows/makefiles/adlc.make 22.9 22.10 !endif
23.1 --- a/make/windows/makefiles/launcher.make Thu Jan 06 16:03:20 2011 -0800 23.2 +++ b/make/windows/makefiles/launcher.make Fri Jan 07 03:58:11 2011 -0800 23.3 @@ -22,7 +22,8 @@ 23.4 # 23.5 # 23.6 23.7 -LAUNCHER_FLAGS=$(ARCHFLAG) \ 23.8 + 23.9 +LAUNCHER_FLAGS=$(CPP_FLAGS) $(ARCHFLAG) \ 23.10 /D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \ 23.11 /D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \ 23.12 /D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \ 23.13 @@ -32,9 +33,11 @@ 23.14 /D _CRT_SECURE_NO_DEPRECATE \ 23.15 /D LINK_INTO_LIBJVM \ 23.16 /I $(WorkSpace)\src\os\windows\launcher \ 23.17 - /I $(WorkSpace)\src\share\tools\launcher 23.18 - 23.19 -CPP_FLAGS=$(CPP_FLAGS) $(LAUNCHER_FLAGS) 23.20 + /I $(WorkSpace)\src\share\tools\launcher \ 23.21 + /I $(WorkSpace)\src\share\vm\prims \ 23.22 + /I $(WorkSpace)\src\share\vm \ 23.23 + /I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \ 23.24 + /I $(WorkSpace)\src\os\windows\vm 23.25 23.26 LINK_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console 23.27 23.28 @@ -46,22 +49,23 @@ 23.29 LINK_FLAGS = $(LINK_FLAGS) $(BUFFEROVERFLOWLIB) 23.30 !endif 23.31 23.32 -LAUNCHERDIR = $(GAMMADIR)/src/os/windows/launcher 23.33 -LAUNCHERDIR_SHARE = $(GAMMADIR)/src/share/tools/launcher 23.34 +LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher 23.35 +LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher 23.36 23.37 OUTDIR = launcher 23.38 23.39 {$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj: 23.40 - -mkdir $(OUTDIR) 23.41 - $(CPP) $(CPP_FLAGS) /c /Fo$@ $< 23.42 + -mkdir $(OUTDIR) 2>NUL >NUL 23.43 + $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $< 23.44 23.45 {$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj: 23.46 - -mkdir $(OUTDIR) 23.47 - $(CPP) $(CPP_FLAGS) /c /Fo$@ $< 23.48 + -mkdir $(OUTDIR) 2>NUL >NUL 23.49 + $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $< 23.50 23.51 $(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h 23.52 23.53 -$(LAUNCHER_NAME): $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj 23.54 - $(LINK) $(LINK_FLAGS) /out:$@ $** 23.55 +launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj 23.56 + echo $(JAVA_HOME) > jdkpath.txt 23.57 + $(LINK) $(LINK_FLAGS) /out:hotspot.exe $** 23.58 23.59
24.1 --- a/make/windows/makefiles/product.make Thu Jan 06 16:03:20 2011 -0800 24.2 +++ b/make/windows/makefiles/product.make Fri Jan 07 03:58:11 2011 -0800 24.3 @@ -25,7 +25,6 @@ 24.4 HS_INTERNAL_NAME=jvm 24.5 HS_FNAME=$(HS_INTERNAL_NAME).dll 24.6 AOUT=$(HS_FNAME) 24.7 -LAUNCHER_NAME=hotspot.exe 24.8 GENERATED=../generated 24.9 24.10 # Allow the user to turn off precompiled headers from the command line. 24.11 @@ -33,7 +32,7 @@ 24.12 BUILD_PCH_FILE=_build_pch_file.obj 24.13 !endif 24.14 24.15 -default:: $(BUILD_PCH_FILE) $(AOUT) $(LAUNCHER_NAME) checkAndBuildSA 24.16 +default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA 24.17 24.18 !include ../local.make 24.19 !include compile.make 24.20 @@ -59,8 +58,10 @@ 24.21 $(LINK_FLAGS) /out:$@ /implib:$*.lib $(Obj_Files) $(Res_Files) 24.22 << 24.23 !else 24.24 -$(AOUT): $(Res_Files) $(Obj_Files) 24.25 +vm.def: $(Obj_Files) 24.26 sh $(WorkSpace)/make/windows/build_vm_def.sh 24.27 + 24.28 +$(AOUT): $(Res_Files) $(Obj_Files) vm.def 24.29 $(LINK) @<< 24.30 $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) 24.31 <<
25.1 --- a/make/windows/makefiles/projectcreator.make Thu Jan 06 16:03:20 2011 -0800 25.2 +++ b/make/windows/makefiles/projectcreator.make Fri Jan 07 03:58:11 2011 -0800 25.3 @@ -84,11 +84,12 @@ 25.4 -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \ 25.5 -startAt src \ 25.6 -compiler $(VcVersion) \ 25.7 - -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \ 25.8 + -projectFileName $(HOTSPOTBUILDROOT)\$(ProjectFile) \ 25.9 -jdkTargetRoot $(HOTSPOTJDKDIST) \ 25.10 -define ALIGN_STACK_FRAMES \ 25.11 -define VM_LITTLE_ENDIAN \ 25.12 -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LINK_VER)" \ 25.13 + -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \ 25.14 -ignoreFile jsig.c \ 25.15 -ignoreFile jvmtiEnvRecommended.cpp \ 25.16 -ignoreFile jvmtiEnvStub.cpp \
26.1 --- a/make/windows/makefiles/rules.make Thu Jan 06 16:03:20 2011 -0800 26.2 +++ b/make/windows/makefiles/rules.make Fri Jan 07 03:58:11 2011 -0800 26.3 @@ -1,5 +1,5 @@ 26.4 # 26.5 -# Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. 26.6 +# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 26.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.8 # 26.9 # This code is free software; you can redistribute it and/or modify it 26.10 @@ -48,7 +48,7 @@ 26.11 JAVAC_FLAGS=-g -encoding ascii 26.12 BOOTSTRAP_JAVAC_FLAGS=$(JAVAC_FLAGS) -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION) 26.13 26.14 -ProjectFile=vm.vcproj 26.15 +ProjectFile=jvm.vcproj 26.16 26.17 !if "$(MSC_VER)" == "1200" 26.18 26.19 @@ -63,6 +63,11 @@ 26.20 26.21 VcVersion=VC9 26.22 26.23 +!elseif "$(MSC_VER)" == "1600" 26.24 + 26.25 +# for compatibility - we don't yet have a ProjectCreator for VC10 26.26 +VcVersion=VC9 26.27 + 26.28 !else 26.29 26.30 VcVersion=VC7
27.1 --- a/make/windows/makefiles/vm.make Thu Jan 06 16:03:20 2011 -0800 27.2 +++ b/make/windows/makefiles/vm.make Fri Jan 07 03:58:11 2011 -0800 27.3 @@ -71,22 +71,11 @@ 27.4 CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\"" 27.5 CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\"" 27.6 27.7 -CPP_FLAGS=$(CPP_FLAGS) /D "WIN32" /D "_WINDOWS" $(CPP_INCLUDE_DIRS) 27.8 - 27.9 -# Must specify this for sharedRuntimeTrig.cpp 27.10 -CPP_FLAGS=$(CPP_FLAGS) /D "VM_LITTLE_ENDIAN" 27.11 +CPP_FLAGS=$(CPP_FLAGS) $(CPP_INCLUDE_DIRS) 27.12 27.13 # Define that so jni.h is on correct side 27.14 CPP_FLAGS=$(CPP_FLAGS) /D "_JNI_IMPLEMENTATION_" 27.15 27.16 -# Used for platform dispatching 27.17 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_FAMILY_windows 27.18 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_$(Platform_arch) 27.19 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model) 27.20 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch) 27.21 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model) 27.22 -CPP_FLAGS=$(CPP_FLAGS) /D TARGET_COMPILER_visCPP 27.23 - 27.24 !if "$(BUILDARCH)" == "ia64" 27.25 STACK_SIZE="/STACK:1048576,262144" 27.26 !else 27.27 @@ -104,6 +93,8 @@ 27.28 !endif 27.29 !endif 27.30 27.31 +# If you modify exports below please do the corresponding changes in 27.32 +# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java 27.33 LINK_FLAGS=$(LINK_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \ 27.34 /export:JNI_GetDefaultJavaVMInitArgs \ 27.35 /export:JNI_CreateJavaVM \
28.1 --- a/make/windows/projectfiles/common/Makefile Thu Jan 06 16:03:20 2011 -0800 28.2 +++ b/make/windows/projectfiles/common/Makefile Fri Jan 07 03:58:11 2011 -0800 28.3 @@ -22,7 +22,10 @@ 28.4 # 28.5 # 28.6 28.7 -!include local.make 28.8 +!ifdef LOCAL_MAKE 28.9 +!include $(LOCAL_MAKE) 28.10 +!endif 28.11 + 28.12 28.13 WorkSpace=$(HOTSPOTWORKSPACE) 28.14 28.15 @@ -34,11 +37,18 @@ 28.16 !else 28.17 !ifdef JAVA_HOME 28.18 BootStrapDir=$(JAVA_HOME) 28.19 +!else 28.20 +!ifdef HOTSPOTJDKDIST 28.21 +BootStrapDir=$(HOTSPOTJDKDIST) 28.22 +!endif 28.23 !endif 28.24 !endif 28.25 !endif 28.26 28.27 + 28.28 + 28.29 !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/projectcreator.make 28.30 +!include $(WorkSpace)/make/windows/makefiles/compile.make 28.31 28.32 # Pick up rules for building JVMTI (JSR-163) 28.33 JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles 28.34 @@ -56,6 +66,9 @@ 28.35 !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make 28.36 !endif 28.37 28.38 +HS_INTERNAL_NAME=jvm 28.39 +!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/launcher.make 28.40 + 28.41 default:: $(AdditionalTargets) $(JvmtiGeneratedFiles) 28.42 28.43 !include $(HOTSPOTWORKSPACE)/make/hotspot_version 28.44 @@ -97,7 +110,7 @@ 28.45 -define JRE_RELEASE_VERSION=\\\"$(JRE_RELEASE_VERSION)\\\" \ 28.46 -define HOTSPOT_VM_DISTRO=\\\"$(HOTSPOT_VM_DISTRO)\\\" 28.47 28.48 -$(HOTSPOTBUILDSPACE)/$(ProjectFile): local.make $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class 28.49 +$(HOTSPOTBUILDROOT)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class 28.50 @$(RUN_JAVA) -Djava.class.path=$(HOTSPOTBUILDSPACE)/classes ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions) 28.51 28.52 clean:
29.1 --- a/make/windows/projectfiles/compiler1/Makefile Thu Jan 06 16:03:20 2011 -0800 29.2 +++ b/make/windows/projectfiles/compiler1/Makefile Fri Jan 07 03:58:11 2011 -0800 29.3 @@ -1,5 +1,5 @@ 29.4 # 29.5 -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 29.6 +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 29.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 # 29.9 # This code is free software; you can redistribute it and/or modify it 29.10 @@ -22,7 +22,6 @@ 29.11 # 29.12 # 29.13 29.14 -Variant=compiler1 29.15 -!include local.make 29.16 +!include ../local.make 29.17 29.18 !include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
30.1 --- a/make/windows/projectfiles/compiler1/vm.def Thu Jan 06 16:03:20 2011 -0800 30.2 +++ b/make/windows/projectfiles/compiler1/vm.def Fri Jan 07 03:58:11 2011 -0800 30.3 @@ -2,6 +2,6 @@ 30.4 ; This .DEF file is a placeholder for one which is automatically 30.5 ; generated during the build process. See 30.6 ; make\windows\build_vm_def.sh and 30.7 -; make\windows\makefiles\makedeps.make (esp. the "-prelink" 30.8 +; make\windows\makefiles\projectcreator.make (esp. the "-prelink" 30.9 ; options). 30.10 ;
31.1 --- a/make/windows/projectfiles/compiler2/Makefile Thu Jan 06 16:03:20 2011 -0800 31.2 +++ b/make/windows/projectfiles/compiler2/Makefile Fri Jan 07 03:58:11 2011 -0800 31.3 @@ -22,8 +22,7 @@ 31.4 # 31.5 # 31.6 31.7 -Variant=compiler2 31.8 -!include local.make 31.9 +!include ../local.make 31.10 AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles 31.11 AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp 31.12
32.1 --- a/make/windows/projectfiles/compiler2/vm.def Thu Jan 06 16:03:20 2011 -0800 32.2 +++ b/make/windows/projectfiles/compiler2/vm.def Fri Jan 07 03:58:11 2011 -0800 32.3 @@ -2,6 +2,6 @@ 32.4 ; This .DEF file is a placeholder for one which is automatically 32.5 ; generated during the build process. See 32.6 ; make\windows\build_vm_def.sh and 32.7 -; make\windows\makefiles\makedeps.make (esp. the "-prelink" 32.8 +; make\windows\makefiles\projectcreator.make (esp. the "-prelink" 32.9 ; options). 32.10 ;
33.1 --- a/make/windows/projectfiles/core/Makefile Thu Jan 06 16:03:20 2011 -0800 33.2 +++ b/make/windows/projectfiles/core/Makefile Fri Jan 07 03:58:11 2011 -0800 33.3 @@ -1,5 +1,5 @@ 33.4 # 33.5 -# Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. 33.6 +# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 33.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.8 # 33.9 # This code is free software; you can redistribute it and/or modify it 33.10 @@ -22,7 +22,6 @@ 33.11 # 33.12 # 33.13 33.14 -Variant=core 33.15 -!include local.make 33.16 +!include ../local.make 33.17 33.18 !include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
34.1 --- a/make/windows/projectfiles/core/vm.def Thu Jan 06 16:03:20 2011 -0800 34.2 +++ b/make/windows/projectfiles/core/vm.def Fri Jan 07 03:58:11 2011 -0800 34.3 @@ -2,6 +2,6 @@ 34.4 ; This .DEF file is a placeholder for one which is automatically 34.5 ; generated during the build process. See 34.6 ; make\windows\build_vm_def.sh and 34.7 -; make\windows\makefiles\makedeps.make (esp. the "-prelink" 34.8 +; make\windows\makefiles\projectcreator.make (esp. the "-prelink" 34.9 ; options). 34.10 ;
35.1 --- a/make/windows/projectfiles/kernel/Makefile Thu Jan 06 16:03:20 2011 -0800 35.2 +++ b/make/windows/projectfiles/kernel/Makefile Fri Jan 07 03:58:11 2011 -0800 35.3 @@ -1,5 +1,5 @@ 35.4 # 35.5 -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 35.6 +# Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved. 35.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.8 # 35.9 # This code is free software; you can redistribute it and/or modify it 35.10 @@ -22,7 +22,6 @@ 35.11 # 35.12 # 35.13 35.14 -Variant=kernel 35.15 -!include local.make 35.16 +!include ../local.make 35.17 35.18 !include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile
36.1 --- a/make/windows/projectfiles/kernel/vm.def Thu Jan 06 16:03:20 2011 -0800 36.2 +++ b/make/windows/projectfiles/kernel/vm.def Fri Jan 07 03:58:11 2011 -0800 36.3 @@ -2,6 +2,6 @@ 36.4 ; This .DEF file is a placeholder for one which is automatically 36.5 ; generated during the build process. See 36.6 ; make\windows\build_vm_def.sh and 36.7 -; make\windows\makefiles\makedeps.make (esp. the "-prelink" 36.8 +; make\windows\makefiles\projectcreator.make (esp. the "-prelink" 36.9 ; options). 36.10 ;
37.1 --- a/make/windows/projectfiles/tiered/Makefile Thu Jan 06 16:03:20 2011 -0800 37.2 +++ b/make/windows/projectfiles/tiered/Makefile Fri Jan 07 03:58:11 2011 -0800 37.3 @@ -22,8 +22,7 @@ 37.4 # 37.5 # 37.6 37.7 -Variant=tiered 37.8 -!include local.make 37.9 +!include ../local.make 37.10 AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles 37.11 AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp 37.12
38.1 --- a/make/windows/projectfiles/tiered/vm.def Thu Jan 06 16:03:20 2011 -0800 38.2 +++ b/make/windows/projectfiles/tiered/vm.def Fri Jan 07 03:58:11 2011 -0800 38.3 @@ -2,6 +2,6 @@ 38.4 ; This .DEF file is a placeholder for one which is automatically 38.5 ; generated during the build process. See 38.6 ; make\windows\build_vm_def.sh and 38.7 -; make\windows\makefiles\makedeps.make (esp. the "-prelink" 38.8 +; make\windows\makefiles\projectcreator.make (esp. the "-prelink" 38.9 ; options). 38.10 ;
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/src/os/linux/vm/decoder_linux.cpp Fri Jan 07 03:58:11 2011 -0800 39.3 @@ -0,0 +1,45 @@ 39.4 +/* 39.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. 39.11 + * 39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.15 + * version 2 for more details (a copy is included in the LICENSE file that 39.16 + * accompanied this code). 39.17 + * 39.18 + * You should have received a copy of the GNU General Public License version 39.19 + * 2 along with this work; if not, write to the Free Software Foundation, 39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.21 + * 39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.23 + * or visit www.oracle.com if you need additional information or have any 39.24 + * questions. 39.25 + * 39.26 + */ 39.27 + 39.28 +#include "prims/jvm.h" 39.29 +#include "utilities/decoder.hpp" 39.30 + 39.31 +#include <cxxabi.h> 39.32 + 39.33 +bool Decoder::demangle(const char* symbol, char *buf, int buflen) { 39.34 + int status; 39.35 + char* result; 39.36 + size_t size = (size_t)buflen; 39.37 + 39.38 + // Don't pass buf to __cxa_demangle. In case of the 'buf' is too small, 39.39 + // __cxa_demangle will call system "realloc" for additional memory, which 39.40 + // may use different malloc/realloc mechanism that allocates 'buf'. 39.41 + if ((result = abi::__cxa_demangle(symbol, NULL, NULL, &status)) != NULL) { 39.42 + jio_snprintf(buf, buflen, "%s", result); 39.43 + // call c library's free 39.44 + ::free(result); 39.45 + return true; 39.46 + } 39.47 + return false; 39.48 +}
40.1 --- a/src/os/linux/vm/os_linux.cpp Thu Jan 06 16:03:20 2011 -0800 40.2 +++ b/src/os/linux/vm/os_linux.cpp Fri Jan 07 03:58:11 2011 -0800 40.3 @@ -59,6 +59,7 @@ 40.4 #include "services/attachListener.hpp" 40.5 #include "services/runtimeService.hpp" 40.6 #include "thread_linux.inline.hpp" 40.7 +#include "utilities/decoder.hpp" 40.8 #include "utilities/defaultStream.hpp" 40.9 #include "utilities/events.hpp" 40.10 #include "utilities/growableArray.hpp" 40.11 @@ -114,6 +115,7 @@ 40.12 # include <link.h> 40.13 # include <stdint.h> 40.14 # include <inttypes.h> 40.15 +# include <sys/ioctl.h> 40.16 40.17 #define MAX_PATH (2 * K) 40.18 40.19 @@ -1688,14 +1690,23 @@ 40.20 Dl_info dlinfo; 40.21 40.22 if (dladdr((void*)addr, &dlinfo) && dlinfo.dli_sname != NULL) { 40.23 - if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 40.24 - if (offset) *offset = addr - (address)dlinfo.dli_saddr; 40.25 + if (buf != NULL) { 40.26 + if(!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) { 40.27 + jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 40.28 + } 40.29 + } 40.30 + if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 40.31 return true; 40.32 - } else { 40.33 - if (buf) buf[0] = '\0'; 40.34 - if (offset) *offset = -1; 40.35 - return false; 40.36 + } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 40.37 + if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 40.38 + dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { 40.39 + return true; 40.40 + } 40.41 } 40.42 + 40.43 + if (buf != NULL) buf[0] = '\0'; 40.44 + if (offset != NULL) *offset = -1; 40.45 + return false; 40.46 } 40.47 40.48 struct _address_to_library_name { 40.49 @@ -4423,6 +4434,15 @@ 40.50 return 1; 40.51 } 40.52 40.53 +int os::socket_available(int fd, jint *pbytes) { 40.54 + // Linux doc says EINTR not returned, unlike Solaris 40.55 + int ret = ::ioctl(fd, FIONREAD, pbytes); 40.56 + 40.57 + //%% note ioctl can return 0 when successful, JVM_SocketAvailable 40.58 + // is expected to return 0 on failure and 1 on success to the jdk. 40.59 + return (ret < 0) ? 0 : 1; 40.60 +} 40.61 + 40.62 // Map a block of memory. 40.63 char* os::map_memory(int fd, const char* file_name, size_t file_offset, 40.64 char *addr, size_t bytes, bool read_only,
41.1 --- a/src/os/linux/vm/os_linux.inline.hpp Thu Jan 06 16:03:20 2011 -0800 41.2 +++ b/src/os/linux/vm/os_linux.inline.hpp Fri Jan 07 03:58:11 2011 -0800 41.3 @@ -45,7 +45,6 @@ 41.4 #include <unistd.h> 41.5 #include <sys/socket.h> 41.6 #include <sys/poll.h> 41.7 -#include <sys/ioctl.h> 41.8 #include <netdb.h> 41.9 41.10 inline void* os::thread_local_storage_at(int index) { 41.11 @@ -268,16 +267,6 @@ 41.12 RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen)); 41.13 } 41.14 41.15 -inline int os::socket_available(int fd, jint *pbytes) { 41.16 - // Linux doc says EINTR not returned, unlike Solaris 41.17 - int ret = ::ioctl(fd, FIONREAD, pbytes); 41.18 - 41.19 - //%% note ioctl can return 0 when successful, JVM_SocketAvailable 41.20 - // is expected to return 0 on failure and 1 on success to the jdk. 41.21 - return (ret < 0) ? 0 : 1; 41.22 -} 41.23 - 41.24 - 41.25 inline int os::socket_shutdown(int fd, int howto){ 41.26 return ::shutdown(fd, howto); 41.27 }
42.1 --- a/src/os/linux/vm/perfMemory_linux.cpp Thu Jan 06 16:03:20 2011 -0800 42.2 +++ b/src/os/linux/vm/perfMemory_linux.cpp Fri Jan 07 03:58:11 2011 -0800 42.3 @@ -635,7 +635,29 @@ 42.4 return -1; 42.5 } 42.6 42.7 - return fd; 42.8 + // Verify that we have enough disk space for this file. 42.9 + // We'll get random SIGBUS crashes on memory accesses if 42.10 + // we don't. 42.11 + 42.12 + for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) { 42.13 + int zero_int = 0; 42.14 + result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos)); 42.15 + if (result == -1 ) break; 42.16 + RESTARTABLE(::write(fd, &zero_int, 1), result); 42.17 + if (result != 1) { 42.18 + if (errno == ENOSPC) { 42.19 + warning("Insufficient space for shared memory file:\n %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename); 42.20 + } 42.21 + break; 42.22 + } 42.23 + } 42.24 + 42.25 + if (result != -1) { 42.26 + return fd; 42.27 + } else { 42.28 + RESTARTABLE(::close(fd), result); 42.29 + return -1; 42.30 + } 42.31 } 42.32 42.33 // open the shared memory file for the given user and vmid. returns
43.1 --- a/src/os/posix/launcher/java_md.c Thu Jan 06 16:03:20 2011 -0800 43.2 +++ b/src/os/posix/launcher/java_md.c Fri Jan 07 03:58:11 2011 -0800 43.3 @@ -812,13 +812,10 @@ 43.4 43.5 #ifdef GAMMA 43.6 { 43.7 - /* gamma launcher uses JAVA_HOME or ALT_JAVA_HOME environment variable to find JDK/JRE */ 43.8 - char* java_home_var = getenv("ALT_JAVA_HOME"); 43.9 + /* gamma launcher uses JAVA_HOME environment variable to find JDK/JRE */ 43.10 + char* java_home_var = getenv("JAVA_HOME"); 43.11 if (java_home_var == NULL) { 43.12 - java_home_var = getenv("JAVA_HOME"); 43.13 - } 43.14 - if (java_home_var == NULL) { 43.15 - printf("JAVA_HOME or ALT_JAVA_HOME must point to a valid JDK/JRE to run gamma\n"); 43.16 + printf("JAVA_HOME must point to a valid JDK/JRE to run gamma\n"); 43.17 return JNI_FALSE; 43.18 } 43.19 snprintf(buf, bufsize, "%s", java_home_var); 43.20 @@ -1837,7 +1834,7 @@ 43.21 if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { 43.22 void * tmp; 43.23 pthread_join(tid, &tmp); 43.24 - rslt = (int)tmp; 43.25 + rslt = (int)(intptr_t)tmp; 43.26 } else { 43.27 /* 43.28 * Continue execution in current thread if for some reason (e.g. out of 43.29 @@ -1855,7 +1852,7 @@ 43.30 if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { 43.31 void * tmp; 43.32 thr_join(tid, NULL, &tmp); 43.33 - rslt = (int)tmp; 43.34 + rslt = (int)(intptr_t)tmp; 43.35 } else { 43.36 /* See above. Continue in current thread if thr_create() failed */ 43.37 rslt = continuation(args);
44.1 --- a/src/os/posix/launcher/launcher.script Thu Jan 06 16:03:20 2011 -0800 44.2 +++ b/src/os/posix/launcher/launcher.script Fri Jan 07 03:58:11 2011 -0800 44.3 @@ -95,17 +95,21 @@ 44.4 ;; 44.5 esac 44.6 44.7 +# Find out the absolute path to this script 44.8 +MYDIR=$(cd $(dirname $SCRIPT) && pwd) 44.9 + 44.10 +JDK= 44.11 if [ "${ALT_JAVA_HOME}" = "" ]; then 44.12 - if [ "${JAVA_HOME}" = "" ]; then 44.13 - echo "Neither ALT_JAVA_HOME nor JAVA_HOME is set. Aborting."; 44.14 - exit 1; 44.15 - else 44.16 - JDK=${JAVA_HOME%%/jre}; 44.17 - fi 44.18 + source ${MYDIR}/jdkpath.sh 44.19 else 44.20 JDK=${ALT_JAVA_HOME%%/jre}; 44.21 fi 44.22 44.23 +if [ "${JDK}" = "" ]; then 44.24 + echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found. 44.25 + exit 1 44.26 +fi 44.27 + 44.28 # We will set the LD_LIBRARY_PATH as follows: 44.29 # o $JVMPATH (directory portion only) 44.30 # o $JRE/lib/$ARCH
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/src/os/solaris/vm/decoder_solaris.cpp Fri Jan 07 03:58:11 2011 -0800 45.3 @@ -0,0 +1,31 @@ 45.4 +/* 45.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 + * 45.8 + * This code is free software; you can redistribute it and/or modify it 45.9 + * under the terms of the GNU General Public License version 2 only, as 45.10 + * published by the Free Software Foundation. 45.11 + * 45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.15 + * version 2 for more details (a copy is included in the LICENSE file that 45.16 + * accompanied this code). 45.17 + * 45.18 + * You should have received a copy of the GNU General Public License version 45.19 + * 2 along with this work; if not, write to the Free Software Foundation, 45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.21 + * 45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 45.23 + * or visit www.oracle.com if you need additional information or have any 45.24 + * questions. 45.25 + * 45.26 + */ 45.27 + 45.28 +#include "utilities/decoder.hpp" 45.29 + 45.30 +#include <demangle.h> 45.31 + 45.32 +bool Decoder::demangle(const char* symbol, char *buf, int buflen) { 45.33 + return !cplus_demangle(symbol, buf, (size_t)buflen); 45.34 +}
46.1 --- a/src/os/solaris/vm/os_solaris.cpp Thu Jan 06 16:03:20 2011 -0800 46.2 +++ b/src/os/solaris/vm/os_solaris.cpp Fri Jan 07 03:58:11 2011 -0800 46.3 @@ -57,6 +57,7 @@ 46.4 #include "services/attachListener.hpp" 46.5 #include "services/runtimeService.hpp" 46.6 #include "thread_solaris.inline.hpp" 46.7 +#include "utilities/decoder.hpp" 46.8 #include "utilities/defaultStream.hpp" 46.9 #include "utilities/events.hpp" 46.10 #include "utilities/growableArray.hpp" 46.11 @@ -79,6 +80,7 @@ 46.12 // put OS-includes here 46.13 # include <dlfcn.h> 46.14 # include <errno.h> 46.15 +# include <exception> 46.16 # include <link.h> 46.17 # include <poll.h> 46.18 # include <pthread.h> 46.19 @@ -1474,6 +1476,13 @@ 46.20 return &allowdebug_blocked_sigs; 46.21 } 46.22 46.23 + 46.24 +void _handle_uncaught_cxx_exception() { 46.25 + VMError err("An uncaught C++ exception"); 46.26 + err.report_and_die(); 46.27 +} 46.28 + 46.29 + 46.30 // First crack at OS-specific initialization, from inside the new thread. 46.31 void os::initialize_thread() { 46.32 int r = thr_main() ; 46.33 @@ -1563,6 +1572,7 @@ 46.34 // use the dynamic check for T2 libthread. 46.35 46.36 os::Solaris::init_thread_fpu_state(); 46.37 + std::set_terminate(_handle_uncaught_cxx_exception); 46.38 } 46.39 46.40 46.41 @@ -1969,27 +1979,42 @@ 46.42 Sym * info; 46.43 if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, 46.44 RTLD_DL_SYMENT)) { 46.45 - if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 46.46 - if (offset) *offset = addr - (address)dlinfo.dli_saddr; 46.47 - 46.48 - // check if the returned symbol really covers addr 46.49 - return ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr); 46.50 - } else { 46.51 - if (buf) buf[0] = '\0'; 46.52 - if (offset) *offset = -1; 46.53 - return false; 46.54 + if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) { 46.55 + if (buf != NULL) { 46.56 + if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 46.57 + jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 46.58 + } 46.59 + if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 46.60 + return true; 46.61 + } 46.62 } 46.63 + if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 46.64 + if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 46.65 + dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { 46.66 + return true; 46.67 + } 46.68 + } 46.69 + if (buf != NULL) buf[0] = '\0'; 46.70 + if (offset != NULL) *offset = -1; 46.71 + return false; 46.72 } else { 46.73 // no, only dladdr is available 46.74 - if(dladdr((void *)addr, &dlinfo)) { 46.75 - if (buf) jio_snprintf(buf, buflen, dlinfo.dli_sname); 46.76 - if (offset) *offset = addr - (address)dlinfo.dli_saddr; 46.77 + if (dladdr((void *)addr, &dlinfo)) { 46.78 + if (buf != NULL) { 46.79 + if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) 46.80 + jio_snprintf(buf, buflen, dlinfo.dli_sname); 46.81 + } 46.82 + if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; 46.83 + return true; 46.84 + } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { 46.85 + if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), 46.86 + dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { 46.87 return true; 46.88 - } else { 46.89 - if (buf) buf[0] = '\0'; 46.90 - if (offset) *offset = -1; 46.91 - return false; 46.92 + } 46.93 } 46.94 + if (buf != NULL) buf[0] = '\0'; 46.95 + if (offset != NULL) *offset = -1; 46.96 + return false; 46.97 } 46.98 } 46.99
47.1 --- a/src/os/windows/launcher/java_md.c Thu Jan 06 16:03:20 2011 -0800 47.2 +++ b/src/os/windows/launcher/java_md.c Fri Jan 07 03:58:11 2011 -0800 47.3 @@ -22,6 +22,7 @@ 47.4 * 47.5 */ 47.6 47.7 +#include <ctype.h> 47.8 #include <windows.h> 47.9 #include <io.h> 47.10 #include <process.h> 47.11 @@ -486,16 +487,62 @@ 47.12 47.13 #else /* ifndef GAMMA */ 47.14 47.15 - /* gamma launcher uses JAVA_HOME or ALT_JAVA_HOME environment variable to find JDK/JRE */ 47.16 - char* java_home_var = getenv("ALT_JAVA_HOME"); 47.17 - if (java_home_var == NULL) { 47.18 - java_home_var = getenv("JAVA_HOME"); 47.19 + char env[MAXPATHLEN + 1]; 47.20 + 47.21 + /* gamma launcher uses ALT_JAVA_HOME environment variable or jdkpath.txt file to find JDK/JRE */ 47.22 + 47.23 + if (getenv("ALT_JAVA_HOME") != NULL) { 47.24 + snprintf(buf, bufsize, "%s", getenv("ALT_JAVA_HOME")); 47.25 } 47.26 - if (java_home_var == NULL) { 47.27 - printf("JAVA_HOME or ALT_JAVA_HOME must point to a valid JDK/JRE to run gamma\n"); 47.28 - return JNI_FALSE; 47.29 + else { 47.30 + char path[MAXPATHLEN + 1]; 47.31 + char* p; 47.32 + int len; 47.33 + FILE* fp; 47.34 + 47.35 + // find the path to the currect executable 47.36 + len = GetModuleFileName(NULL, path, MAXPATHLEN + 1); 47.37 + if (len == 0 || len > MAXPATHLEN) { 47.38 + printf("Could not get directory of current executable."); 47.39 + return JNI_FALSE; 47.40 + } 47.41 + // remove last path component ("hotspot.exe") 47.42 + p = strrchr(path, '\\'); 47.43 + if (p == NULL) { 47.44 + printf("Could not parse directory of current executable.\n"); 47.45 + return JNI_FALSE; 47.46 + } 47.47 + *p = '\0'; 47.48 + 47.49 + // open jdkpath.txt and read JAVA_HOME from it 47.50 + if (strlen(path) + strlen("\\jdkpath.txt") + 1 >= MAXPATHLEN) { 47.51 + printf("Path too long: %s\n", path); 47.52 + return JNI_FALSE; 47.53 + } 47.54 + strcat(path, "\\jdkpath.txt"); 47.55 + fp = fopen(path, "r"); 47.56 + if (fp == NULL) { 47.57 + printf("Could not open file %s to get path to JDK.\n", path); 47.58 + return JNI_FALSE; 47.59 + } 47.60 + 47.61 + if (fgets(buf, bufsize, fp) == NULL) { 47.62 + printf("Could not read from file %s to get path to JDK.\n", path); 47.63 + fclose(fp); 47.64 + return JNI_FALSE; 47.65 + } 47.66 + // trim the buffer 47.67 + p = buf + strlen(buf) - 1; 47.68 + while(isspace(*p)) { 47.69 + *p = '\0'; 47.70 + p--; 47.71 + } 47.72 + fclose(fp); 47.73 } 47.74 - snprintf(buf, bufsize, "%s", java_home_var); 47.75 + 47.76 + _snprintf(env, MAXPATHLEN, "JAVA_HOME=%s", buf); 47.77 + _putenv(env); 47.78 + 47.79 return JNI_TRUE; 47.80 #endif /* ifndef GAMMA */ 47.81 }
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/src/os/windows/vm/decoder_windows.cpp Fri Jan 07 03:58:11 2011 -0800 48.3 @@ -0,0 +1,123 @@ 48.4 +/* 48.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 + * 48.8 + * This code is free software; you can redistribute it and/or modify it 48.9 + * under the terms of the GNU General Public License version 2 only, as 48.10 + * published by the Free Software Foundation. 48.11 + * 48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.15 + * version 2 for more details (a copy is included in the LICENSE file that 48.16 + * accompanied this code). 48.17 + * 48.18 + * You should have received a copy of the GNU General Public License version 48.19 + * 2 along with this work; if not, write to the Free Software Foundation, 48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.21 + * 48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.23 + * or visit www.oracle.com if you need additional information or have any 48.24 + * questions. 48.25 + * 48.26 + */ 48.27 + 48.28 +#include "precompiled.hpp" 48.29 +#include "prims/jvm.h" 48.30 +#include "utilities/decoder.hpp" 48.31 + 48.32 +HMODULE Decoder::_dbghelp_handle = NULL; 48.33 +bool Decoder::_can_decode_in_vm = false; 48.34 +pfn_SymGetSymFromAddr64 Decoder::_pfnSymGetSymFromAddr64 = NULL; 48.35 +pfn_UndecorateSymbolName Decoder::_pfnUndecorateSymbolName = NULL; 48.36 + 48.37 +void Decoder::initialize() { 48.38 + if (!_initialized) { 48.39 + _initialized = true; 48.40 + 48.41 + HMODULE handle = ::LoadLibrary("dbghelp.dll"); 48.42 + if (!handle) { 48.43 + _decoder_status = helper_not_found; 48.44 + return; 48.45 + } 48.46 + 48.47 + _dbghelp_handle = handle; 48.48 + 48.49 + pfn_SymSetOptions _pfnSymSetOptions = (pfn_SymSetOptions)::GetProcAddress(handle, "SymSetOptions"); 48.50 + pfn_SymInitialize _pfnSymInitialize = (pfn_SymInitialize)::GetProcAddress(handle, "SymInitialize"); 48.51 + _pfnSymGetSymFromAddr64 = (pfn_SymGetSymFromAddr64)::GetProcAddress(handle, "SymGetSymFromAddr64"); 48.52 + _pfnUndecorateSymbolName = (pfn_UndecorateSymbolName)GetProcAddress(handle, "UnDecorateSymbolName"); 48.53 + 48.54 + if (_pfnSymSetOptions == NULL || _pfnSymInitialize == NULL || _pfnSymGetSymFromAddr64 == NULL) { 48.55 + _pfnSymGetSymFromAddr64 = NULL; 48.56 + _pfnUndecorateSymbolName = NULL; 48.57 + ::FreeLibrary(handle); 48.58 + _dbghelp_handle = NULL; 48.59 + _decoder_status = helper_func_error; 48.60 + return; 48.61 + } 48.62 + 48.63 + _pfnSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); 48.64 + if (!_pfnSymInitialize(GetCurrentProcess(), NULL, TRUE)) { 48.65 + _pfnSymGetSymFromAddr64 = NULL; 48.66 + _pfnUndecorateSymbolName = NULL; 48.67 + ::FreeLibrary(handle); 48.68 + _dbghelp_handle = NULL; 48.69 + _decoder_status = helper_init_error; 48.70 + return; 48.71 + } 48.72 + 48.73 + // find out if jvm.dll contains private symbols, by decoding 48.74 + // current function and comparing the result 48.75 + address addr = (address)Decoder::initialize; 48.76 + char buf[MAX_PATH]; 48.77 + if (decode(addr, buf, sizeof(buf), NULL) == no_error) { 48.78 + _can_decode_in_vm = !strcmp(buf, "Decoder::initialize"); 48.79 + } 48.80 + } 48.81 +} 48.82 + 48.83 +void Decoder::uninitialize() { 48.84 + assert(_initialized, "Decoder not yet initialized"); 48.85 + _pfnSymGetSymFromAddr64 = NULL; 48.86 + _pfnUndecorateSymbolName = NULL; 48.87 + if (_dbghelp_handle != NULL) { 48.88 + ::FreeLibrary(_dbghelp_handle); 48.89 + } 48.90 + _initialized = false; 48.91 +} 48.92 + 48.93 +bool Decoder::can_decode_C_frame_in_vm() { 48.94 + initialize(); 48.95 + return _can_decode_in_vm; 48.96 +} 48.97 + 48.98 + 48.99 +Decoder::decoder_status Decoder::decode(address addr, char *buf, int buflen, int *offset) { 48.100 + assert(_initialized, "Decoder not yet initialized"); 48.101 + if (_pfnSymGetSymFromAddr64 != NULL) { 48.102 + PIMAGEHLP_SYMBOL64 pSymbol; 48.103 + char symbolInfo[MAX_PATH + sizeof(IMAGEHLP_SYMBOL64)]; 48.104 + pSymbol = (PIMAGEHLP_SYMBOL64)symbolInfo; 48.105 + pSymbol->MaxNameLength = MAX_PATH; 48.106 + pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); 48.107 + DWORD64 displacement; 48.108 + if (_pfnSymGetSymFromAddr64(::GetCurrentProcess(), (DWORD64)addr, &displacement, pSymbol)) { 48.109 + if (buf != NULL) { 48.110 + if (!demangle(pSymbol->Name, buf, buflen)) { 48.111 + jio_snprintf(buf, buflen, "%s", pSymbol->Name); 48.112 + } 48.113 + } 48.114 + if (offset != NULL) *offset = (int)displacement; 48.115 + return no_error; 48.116 + } 48.117 + } 48.118 + return helper_not_found; 48.119 +} 48.120 + 48.121 +bool Decoder::demangle(const char* symbol, char *buf, int buflen) { 48.122 + assert(_initialized, "Decoder not yet initialized"); 48.123 + return _pfnUndecorateSymbolName != NULL && 48.124 + _pfnUndecorateSymbolName(symbol, buf, buflen, UNDNAME_COMPLETE); 48.125 +} 48.126 +
49.1 --- a/src/os/windows/vm/os_windows.cpp Thu Jan 06 16:03:20 2011 -0800 49.2 +++ b/src/os/windows/vm/os_windows.cpp Fri Jan 07 03:58:11 2011 -0800 49.3 @@ -1,5 +1,5 @@ 49.4 /* 49.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 49.6 + * CopyrighT (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 49.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.8 * 49.9 * This code is free software; you can redistribute it and/or modify it 49.10 @@ -62,6 +62,7 @@ 49.11 #include "services/attachListener.hpp" 49.12 #include "services/runtimeService.hpp" 49.13 #include "thread_windows.inline.hpp" 49.14 +#include "utilities/decoder.hpp" 49.15 #include "utilities/defaultStream.hpp" 49.16 #include "utilities/events.hpp" 49.17 #include "utilities/growableArray.hpp" 49.18 @@ -1365,12 +1366,11 @@ 49.19 49.20 bool os::dll_address_to_function_name(address addr, char *buf, 49.21 int buflen, int *offset) { 49.22 - // Unimplemented on Windows - in order to use SymGetSymFromAddr(), 49.23 - // we need to initialize imagehlp/dbghelp, then load symbol table 49.24 - // for every module. That's too much work to do after a fatal error. 49.25 - // For an example on how to implement this function, see 1.4.2. 49.26 - if (offset) *offset = -1; 49.27 - if (buf) buf[0] = '\0'; 49.28 + if (Decoder::decode(addr, buf, buflen, offset) == Decoder::no_error) { 49.29 + return true; 49.30 + } 49.31 + if (offset != NULL) *offset = -1; 49.32 + if (buf != NULL) buf[0] = '\0'; 49.33 return false; 49.34 } 49.35 49.36 @@ -1711,14 +1711,11 @@ 49.37 buf[0] = '\0'; 49.38 if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) { 49.39 // Support for the gamma launcher. Check for an 49.40 - // ALT_JAVA_HOME or JAVA_HOME environment variable 49.41 + // JAVA_HOME environment variable 49.42 // and fix up the path so it looks like 49.43 // libjvm.so is installed there (append a fake suffix 49.44 // hotspot/libjvm.so). 49.45 - char* java_home_var = ::getenv("ALT_JAVA_HOME"); 49.46 - if (java_home_var == NULL) { 49.47 - java_home_var = ::getenv("JAVA_HOME"); 49.48 - } 49.49 + char* java_home_var = ::getenv("JAVA_HOME"); 49.50 if (java_home_var != NULL && java_home_var[0] != 0) { 49.51 49.52 strncpy(buf, java_home_var, buflen); 49.53 @@ -2007,6 +2004,16 @@ 49.54 int number; 49.55 }; 49.56 49.57 +// All Visual C++ exceptions thrown from code generated by the Microsoft Visual 49.58 +// C++ compiler contain this error code. Because this is a compiler-generated 49.59 +// error, the code is not listed in the Win32 API header files. 49.60 +// The code is actually a cryptic mnemonic device, with the initial "E" 49.61 +// standing for "exception" and the final 3 bytes (0x6D7363) representing the 49.62 +// ASCII values of "msc". 49.63 + 49.64 +#define EXCEPTION_UNCAUGHT_CXX_EXCEPTION 0xE06D7363 49.65 + 49.66 + 49.67 struct siglabel exceptlabels[] = { 49.68 def_excpt(EXCEPTION_ACCESS_VIOLATION), 49.69 def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT), 49.70 @@ -2031,6 +2038,7 @@ 49.71 def_excpt(EXCEPTION_INVALID_DISPOSITION), 49.72 def_excpt(EXCEPTION_GUARD_PAGE), 49.73 def_excpt(EXCEPTION_INVALID_HANDLE), 49.74 + def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION), 49.75 NULL, 0 49.76 }; 49.77 49.78 @@ -2264,7 +2272,6 @@ 49.79 } 49.80 } 49.81 49.82 - 49.83 if (t != NULL && t->is_Java_thread()) { 49.84 JavaThread* thread = (JavaThread*) t; 49.85 bool in_java = thread->thread_state() == _thread_in_Java; 49.86 @@ -2468,8 +2475,9 @@ 49.87 } // switch 49.88 } 49.89 #ifndef _WIN64 49.90 - if ((thread->thread_state() == _thread_in_Java) || 49.91 - (thread->thread_state() == _thread_in_native) ) 49.92 + if (((thread->thread_state() == _thread_in_Java) || 49.93 + (thread->thread_state() == _thread_in_native)) && 49.94 + exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) 49.95 { 49.96 LONG result=Handle_FLT_Exception(exceptionInfo); 49.97 if (result==EXCEPTION_CONTINUE_EXECUTION) return result; 49.98 @@ -2493,6 +2501,7 @@ 49.99 case EXCEPTION_ILLEGAL_INSTRUCTION_2: 49.100 case EXCEPTION_INT_OVERFLOW: 49.101 case EXCEPTION_INT_DIVIDE_BY_ZERO: 49.102 + case EXCEPTION_UNCAUGHT_CXX_EXCEPTION: 49.103 { report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord, 49.104 exceptionInfo->ContextRecord); 49.105 }
50.1 --- a/src/share/tools/ProjectCreator/BuildConfig.java Thu Jan 06 16:03:20 2011 -0800 50.2 +++ b/src/share/tools/ProjectCreator/BuildConfig.java Fri Jan 07 03:58:11 2011 -0800 50.3 @@ -22,8 +22,11 @@ 50.4 * 50.5 */ 50.6 50.7 -import java.util.*; 50.8 import java.io.File; 50.9 +import java.util.Enumeration; 50.10 +import java.util.Hashtable; 50.11 +import java.util.Iterator; 50.12 +import java.util.Vector; 50.13 50.14 class BuildConfig { 50.15 Hashtable vars; 50.16 @@ -57,7 +60,6 @@ 50.17 50.18 // ones mentioned above were needed to expand format 50.19 String buildBase = expandFormat(getFieldString(null, "BuildBase")); 50.20 - String jdkDir = getFieldString(null, "JdkTargetRoot"); 50.21 String sourceBase = getFieldString(null, "SourceBase"); 50.22 String outDir = buildBase; 50.23 50.24 @@ -65,7 +67,7 @@ 50.25 put("OutputDir", outDir); 50.26 put("SourceBase", sourceBase); 50.27 put("BuildBase", buildBase); 50.28 - put("OutputDll", jdkDir + Util.sep + outDll); 50.29 + put("OutputDll", outDir + Util.sep + outDll); 50.30 50.31 context = new String [] {flavourBuild, flavour, build, null}; 50.32 } 50.33 @@ -537,68 +539,75 @@ 50.34 } 50.35 } 50.36 50.37 -class C1DebugConfig extends GenericDebugConfig { 50.38 +abstract class GenericDebugNonKernelConfig extends GenericDebugConfig { 50.39 + protected void init(Vector includes, Vector defines) { 50.40 + super.init(includes, defines); 50.41 + getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags")); 50.42 + } 50.43 +} 50.44 + 50.45 +class C1DebugConfig extends GenericDebugNonKernelConfig { 50.46 String getOptFlag() { 50.47 return getCI().getNoOptFlag(); 50.48 } 50.49 50.50 C1DebugConfig() { 50.51 - initNames("compiler1", "debug", "fastdebug\\jre\\bin\\client\\jvm.dll"); 50.52 + initNames("compiler1", "debug", "jvm.dll"); 50.53 init(getIncludes(), getDefines()); 50.54 } 50.55 } 50.56 50.57 -class C1FastDebugConfig extends GenericDebugConfig { 50.58 +class C1FastDebugConfig extends GenericDebugNonKernelConfig { 50.59 String getOptFlag() { 50.60 return getCI().getOptFlag(); 50.61 } 50.62 50.63 C1FastDebugConfig() { 50.64 - initNames("compiler1", "fastdebug", "fastdebug\\jre\\bin\\client\\jvm.dll"); 50.65 + initNames("compiler1", "fastdebug", "jvm.dll"); 50.66 init(getIncludes(), getDefines()); 50.67 } 50.68 } 50.69 50.70 -class C2DebugConfig extends GenericDebugConfig { 50.71 +class C2DebugConfig extends GenericDebugNonKernelConfig { 50.72 String getOptFlag() { 50.73 return getCI().getNoOptFlag(); 50.74 } 50.75 50.76 C2DebugConfig() { 50.77 - initNames("compiler2", "debug", "fastdebug\\jre\\bin\\server\\jvm.dll"); 50.78 + initNames("compiler2", "debug", "jvm.dll"); 50.79 init(getIncludes(), getDefines()); 50.80 } 50.81 } 50.82 50.83 -class C2FastDebugConfig extends GenericDebugConfig { 50.84 +class C2FastDebugConfig extends GenericDebugNonKernelConfig { 50.85 String getOptFlag() { 50.86 return getCI().getOptFlag(); 50.87 } 50.88 50.89 C2FastDebugConfig() { 50.90 - initNames("compiler2", "fastdebug", "fastdebug\\jre\\bin\\server\\jvm.dll"); 50.91 + initNames("compiler2", "fastdebug", "jvm.dll"); 50.92 init(getIncludes(), getDefines()); 50.93 } 50.94 } 50.95 50.96 -class TieredDebugConfig extends GenericDebugConfig { 50.97 +class TieredDebugConfig extends GenericDebugNonKernelConfig { 50.98 String getOptFlag() { 50.99 return getCI().getNoOptFlag(); 50.100 } 50.101 50.102 TieredDebugConfig() { 50.103 - initNames("tiered", "debug", "fastdebug\\jre\\bin\\server\\jvm.dll"); 50.104 + initNames("tiered", "debug", "jvm.dll"); 50.105 init(getIncludes(), getDefines()); 50.106 } 50.107 } 50.108 50.109 -class TieredFastDebugConfig extends GenericDebugConfig { 50.110 +class TieredFastDebugConfig extends GenericDebugNonKernelConfig { 50.111 String getOptFlag() { 50.112 return getCI().getOptFlag(); 50.113 } 50.114 50.115 TieredFastDebugConfig() { 50.116 - initNames("tiered", "fastdebug", "fastdebug\\jre\\bin\\server\\jvm.dll"); 50.117 + initNames("tiered", "fastdebug", "jvm.dll"); 50.118 init(getIncludes(), getDefines()); 50.119 } 50.120 } 50.121 @@ -618,45 +627,45 @@ 50.122 50.123 class C1ProductConfig extends ProductConfig { 50.124 C1ProductConfig() { 50.125 - initNames("compiler1", "product", "jre\\bin\\client\\jvm.dll"); 50.126 + initNames("compiler1", "product", "jvm.dll"); 50.127 init(getIncludes(), getDefines()); 50.128 } 50.129 } 50.130 50.131 class C2ProductConfig extends ProductConfig { 50.132 C2ProductConfig() { 50.133 - initNames("compiler2", "product", "jre\\bin\\server\\jvm.dll"); 50.134 + initNames("compiler2", "product", "jvm.dll"); 50.135 init(getIncludes(), getDefines()); 50.136 } 50.137 } 50.138 50.139 class TieredProductConfig extends ProductConfig { 50.140 TieredProductConfig() { 50.141 - initNames("tiered", "product", "jre\\bin\\server\\jvm.dll"); 50.142 + initNames("tiered", "product", "jvm.dll"); 50.143 init(getIncludes(), getDefines()); 50.144 } 50.145 } 50.146 50.147 50.148 -class CoreDebugConfig extends GenericDebugConfig { 50.149 +class CoreDebugConfig extends GenericDebugNonKernelConfig { 50.150 String getOptFlag() { 50.151 return getCI().getNoOptFlag(); 50.152 } 50.153 50.154 CoreDebugConfig() { 50.155 - initNames("core", "debug", "fastdebug\\jre\\bin\\core\\jvm.dll"); 50.156 + initNames("core", "debug", "jvm.dll"); 50.157 init(getIncludes(), getDefines()); 50.158 } 50.159 } 50.160 50.161 50.162 -class CoreFastDebugConfig extends GenericDebugConfig { 50.163 +class CoreFastDebugConfig extends GenericDebugNonKernelConfig { 50.164 String getOptFlag() { 50.165 return getCI().getOptFlag(); 50.166 } 50.167 50.168 CoreFastDebugConfig() { 50.169 - initNames("core", "fastdebug", "fastdebug\\jre\\bin\\core\\jvm.dll"); 50.170 + initNames("core", "fastdebug", "jvm.dll"); 50.171 init(getIncludes(), getDefines()); 50.172 } 50.173 } 50.174 @@ -664,7 +673,7 @@ 50.175 50.176 class CoreProductConfig extends ProductConfig { 50.177 CoreProductConfig() { 50.178 - initNames("core", "product", "jre\\bin\\core\\jvm.dll"); 50.179 + initNames("core", "product", "jvm.dll"); 50.180 init(getIncludes(), getDefines()); 50.181 } 50.182 } 50.183 @@ -675,7 +684,7 @@ 50.184 } 50.185 50.186 KernelDebugConfig() { 50.187 - initNames("kernel", "debug", "fastdebug\\jre\\bin\\kernel\\jvm.dll"); 50.188 + initNames("kernel", "debug", "jvm.dll"); 50.189 init(getIncludes(), getDefines()); 50.190 } 50.191 } 50.192 @@ -687,7 +696,7 @@ 50.193 } 50.194 50.195 KernelFastDebugConfig() { 50.196 - initNames("kernel", "fastdebug", "fastdebug\\jre\\bin\\kernel\\jvm.dll"); 50.197 + initNames("kernel", "fastdebug", "jvm.dll"); 50.198 init(getIncludes(), getDefines()); 50.199 } 50.200 } 50.201 @@ -695,7 +704,7 @@ 50.202 50.203 class KernelProductConfig extends ProductConfig { 50.204 KernelProductConfig() { 50.205 - initNames("kernel", "product", "jre\\bin\\kernel\\jvm.dll"); 50.206 + initNames("kernel", "product", "jvm.dll"); 50.207 init(getIncludes(), getDefines()); 50.208 } 50.209 } 50.210 @@ -704,6 +713,7 @@ 50.211 abstract Vector getBaseLinkerFlags(String outDir, String outDll); 50.212 abstract Vector getDebugCompilerFlags(String opt); 50.213 abstract Vector getDebugLinkerFlags(); 50.214 + abstract void getAdditionalNonKernelLinkerFlags(Vector rv); 50.215 abstract Vector getProductCompilerFlags(); 50.216 abstract Vector getProductLinkerFlags(); 50.217 abstract String getOptFlag(); 50.218 @@ -713,4 +723,14 @@ 50.219 void addAttr(Vector receiver, String attr, String value) { 50.220 receiver.add(attr); receiver.add(value); 50.221 } 50.222 + void extAttr(Vector receiver, String attr, String value) { 50.223 + int attr_pos=receiver.indexOf(attr) ; 50.224 + if ( attr_pos == -1) { 50.225 + // If attr IS NOT present in the Vector - add it 50.226 + receiver.add(attr); receiver.add(value); 50.227 + } else { 50.228 + // If attr IS present in the Vector - append value to it 50.229 + receiver.set(attr_pos+1,receiver.get(attr_pos+1)+value); 50.230 + } 50.231 + } 50.232 }
51.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatform.java Thu Jan 06 16:03:20 2011 -0800 51.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatform.java Fri Jan 07 03:58:11 2011 -0800 51.3 @@ -22,8 +22,15 @@ 51.4 * 51.5 */ 51.6 51.7 -import java.io.*; 51.8 -import java.util.*; 51.9 +import java.io.File; 51.10 +import java.io.IOException; 51.11 +import java.io.PrintWriter; 51.12 +import java.util.Enumeration; 51.13 +import java.util.Hashtable; 51.14 +import java.util.Iterator; 51.15 +import java.util.List; 51.16 +import java.util.TreeSet; 51.17 +import java.util.Vector; 51.18 51.19 abstract class HsArgHandler extends ArgHandler { 51.20 static final int STRING = 1; 51.21 @@ -345,11 +352,23 @@ 51.22 new ArgsParser(args, 51.23 new ArgRule[] 51.24 { 51.25 - new HsArgRule("-sourceBase", 51.26 - "SourceBase", 51.27 - " (Did you set the HotSpotWorkSpace environment variable?)", 51.28 - HsArgHandler.STRING 51.29 - ), 51.30 + new ArgRule("-sourceBase", 51.31 + new HsArgHandler() { 51.32 + public void handle(ArgIterator it) { 51.33 + String cfg = getCfg(it.get()); 51.34 + if (nextNotKey(it)) { 51.35 + String sb = (String) it.get(); 51.36 + if (sb.endsWith(Util.sep)) { 51.37 + sb = sb.substring(0, sb.length() - 1); 51.38 + } 51.39 + BuildConfig.putField(cfg, "SourceBase", sb); 51.40 + it.next(); 51.41 + } else { 51.42 + empty("-sourceBase", null); 51.43 + } 51.44 + } 51.45 + } 51.46 + ), 51.47 51.48 new HsArgRule("-buildBase", 51.49 "BuildBase", 51.50 @@ -512,7 +531,6 @@ 51.51 new HsArgHandler() { 51.52 public void handle(ArgIterator it) { 51.53 if (nextNotKey(it)) { 51.54 - String build = it.get(); 51.55 if (nextNotKey(it)) { 51.56 String description = it.get(); 51.57 if (nextNotKey(it)) { 51.58 @@ -528,7 +546,28 @@ 51.59 empty(null, "** Error: wrong number of args to -prelink"); 51.60 } 51.61 } 51.62 - ) 51.63 + ), 51.64 + 51.65 + new ArgRule("-postbuild", 51.66 + new HsArgHandler() { 51.67 + public void handle(ArgIterator it) { 51.68 + if (nextNotKey(it)) { 51.69 + if (nextNotKey(it)) { 51.70 + String description = it.get(); 51.71 + if (nextNotKey(it)) { 51.72 + String command = it.get(); 51.73 + BuildConfig.putField(null, "PostbuildDescription", description); 51.74 + BuildConfig.putField(null, "PostbuildCommand", command); 51.75 + it.next(); 51.76 + return; 51.77 + } 51.78 + } 51.79 + } 51.80 + 51.81 + empty(null, "** Error: wrong number of args to -postbuild"); 51.82 + } 51.83 + } 51.84 + ), 51.85 }, 51.86 new ArgHandler() { 51.87 public void handle(ArgIterator it) { 51.88 @@ -618,10 +657,6 @@ 51.89 51.90 public int compareTo(Object o) { 51.91 FileInfo oo = (FileInfo)o; 51.92 - // Don't squelch identical short file names where the full 51.93 - // paths are different 51.94 - if (!attr.shortName.equals(oo.attr.shortName)) 51.95 - return attr.shortName.compareTo(oo.attr.shortName); 51.96 return full.compareTo(oo.full); 51.97 } 51.98
52.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java Thu Jan 06 16:03:20 2011 -0800 52.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java Fri Jan 07 03:58:11 2011 -0800 52.3 @@ -260,6 +260,8 @@ 52.4 return rv; 52.5 } 52.6 52.7 + void getAdditionalNonKernelLinkerFlags(Vector rv) {} 52.8 + 52.9 Vector getProductCompilerFlags() { 52.10 Vector rv = new Vector(); 52.11
53.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java Thu Jan 06 16:03:20 2011 -0800 53.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java Fri Jan 07 03:58:11 2011 -0800 53.3 @@ -22,8 +22,13 @@ 53.4 * 53.5 */ 53.6 53.7 -import java.io.*; 53.8 -import java.util.*; 53.9 +import java.io.FileWriter; 53.10 +import java.io.IOException; 53.11 +import java.io.PrintWriter; 53.12 +import java.util.Hashtable; 53.13 +import java.util.Iterator; 53.14 +import java.util.TreeSet; 53.15 +import java.util.Vector; 53.16 53.17 public class WinGammaPlatformVC7 extends WinGammaPlatform { 53.18 53.19 @@ -104,7 +109,9 @@ 53.20 53.21 53.22 boolean match(FileInfo fi) { 53.23 - return fi.full.regionMatches(true, baseLen, dir, 0, dirLen); 53.24 + int lastSlashIndex = fi.full.lastIndexOf('/'); 53.25 + String fullDir = fi.full.substring(0, lastSlashIndex); 53.26 + return fullDir.endsWith(dir); 53.27 } 53.28 } 53.29 53.30 @@ -217,65 +224,41 @@ 53.31 // - container filter just provides a container to group together real filters 53.32 // - real filter can select elements from the set according to some rule, put it into XML 53.33 // and remove from the list 53.34 - Vector makeFilters(TreeSet files) { 53.35 + Vector makeFilters(TreeSet<FileInfo> files) { 53.36 Vector rv = new Vector(); 53.37 String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/"); 53.38 53.39 - ContainerFilter rt = new ContainerFilter("Runtime"); 53.40 - rt.add(new DirectoryFilter("share/vm/prims", sbase)); 53.41 - rt.add(new DirectoryFilter("share/vm/runtime", sbase)); 53.42 - rt.add(new DirectoryFilter("share/vm/oops", sbase)); 53.43 - rv.add(rt); 53.44 + String currentDir = ""; 53.45 + DirectoryFilter container = null; 53.46 + for(FileInfo fileInfo : files) { 53.47 53.48 - ContainerFilter gc = new ContainerFilter("GC"); 53.49 - gc.add(new DirectoryFilter("share/vm/memory", sbase)); 53.50 - gc.add(new DirectoryFilter("share/vm/gc_interface", sbase)); 53.51 + if (!fileInfo.full.startsWith(sbase)) { 53.52 + continue; 53.53 + } 53.54 53.55 - ContainerFilter gc_impl = new ContainerFilter("Implementations"); 53.56 - gc_impl.add(new DirectoryFilter("CMS", 53.57 - "share/vm/gc_implementation/concurrentMarkSweep", 53.58 - sbase)); 53.59 - gc_impl.add(new DirectoryFilter("Parallel Scavenge", 53.60 - "share/vm/gc_implementation/parallelScavenge", 53.61 - sbase)); 53.62 - gc_impl.add(new DirectoryFilter("Shared", 53.63 - "share/vm/gc_implementation/shared", 53.64 - sbase)); 53.65 - // for all leftovers 53.66 - gc_impl.add(new DirectoryFilter("Misc", 53.67 - "share/vm/gc_implementation", 53.68 - sbase)); 53.69 + int lastSlash = fileInfo.full.lastIndexOf('/'); 53.70 + String dir = fileInfo.full.substring(sbase.length(), lastSlash); 53.71 + if(dir.equals("share/vm")) { 53.72 + // skip files directly in share/vm - should only be precompiled.hpp which is handled below 53.73 + continue; 53.74 + } 53.75 + if (!dir.equals(currentDir)) { 53.76 + currentDir = dir; 53.77 + if (container != null) { 53.78 + rv.add(container); 53.79 + } 53.80 53.81 - gc.add(gc_impl); 53.82 - rv.add(gc); 53.83 - 53.84 - rv.add(new DirectoryFilter("C1", "share/vm/c1", sbase)); 53.85 - 53.86 - rv.add(new DirectoryFilter("C2", "share/vm/opto", sbase)); 53.87 - 53.88 - ContainerFilter comp = new ContainerFilter("Compiler Common"); 53.89 - comp.add(new DirectoryFilter("share/vm/asm", sbase)); 53.90 - comp.add(new DirectoryFilter("share/vm/ci", sbase)); 53.91 - comp.add(new DirectoryFilter("share/vm/code", sbase)); 53.92 - comp.add(new DirectoryFilter("share/vm/compiler", sbase)); 53.93 - rv.add(comp); 53.94 - 53.95 - rv.add(new DirectoryFilter("Interpreter", 53.96 - "share/vm/interpreter", 53.97 - sbase)); 53.98 - 53.99 - ContainerFilter misc = new ContainerFilter("Misc"); 53.100 - misc.add(new DirectoryFilter("share/vm/libadt", sbase)); 53.101 - misc.add(new DirectoryFilter("share/vm/services", sbase)); 53.102 - misc.add(new DirectoryFilter("share/vm/utilities", sbase)); 53.103 - misc.add(new DirectoryFilter("share/vm/classfile", sbase)); 53.104 - rv.add(misc); 53.105 - 53.106 - rv.add(new DirectoryFilter("os_cpu", sbase)); 53.107 - 53.108 - rv.add(new DirectoryFilter("cpu", sbase)); 53.109 - 53.110 - rv.add(new DirectoryFilter("os", sbase)); 53.111 + // remove "share/vm/" from names 53.112 + String name = dir; 53.113 + if (dir.startsWith("share/vm/")) { 53.114 + name = dir.substring("share/vm/".length(), dir.length()); 53.115 + } 53.116 + container = new DirectoryFilter(name, dir, sbase); 53.117 + } 53.118 + } 53.119 + if (container != null) { 53.120 + rv.add(container); 53.121 + } 53.122 53.123 ContainerFilter generated = new ContainerFilter("Generated"); 53.124 ContainerFilter c1Generated = new ContainerFilter("C1"); 53.125 @@ -397,7 +380,6 @@ 53.126 "Name", cfg, 53.127 "ExcludedFromBuild", "TRUE" 53.128 }); 53.129 - tag("Tool", new String[] {"Name", "VCCLCompilerTool"}); 53.130 endTag("FileConfiguration"); 53.131 53.132 } 53.133 @@ -441,7 +423,11 @@ 53.134 53.135 tag("Tool", 53.136 new String[] { 53.137 - "Name", "VCPostBuildEventTool" 53.138 + "Name", "VCPostBuildEventTool", 53.139 + "Description", BuildConfig.getFieldString(null, "PostbuildDescription"), 53.140 + //Caution: String.replace(String,String) is available from JDK5 onwards only 53.141 + "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace 53.142 + ("\t", "
")) 53.143 } 53.144 ); 53.145 53.146 @@ -469,33 +455,6 @@ 53.147 "Culture", "1033" 53.148 } 53.149 ); 53.150 - tag("Tool", 53.151 - new String[] { 53.152 - "Name", "VCWebServiceProxyGeneratorTool" 53.153 - } 53.154 - ); 53.155 - 53.156 - tag ("Tool", 53.157 - new String[] { 53.158 - "Name", "VCXMLDataGeneratorTool" 53.159 - } 53.160 - ); 53.161 - 53.162 - tag("Tool", 53.163 - new String[] { 53.164 - "Name", "VCWebDeploymentTool" 53.165 - } 53.166 - ); 53.167 - tag("Tool", 53.168 - new String[] { 53.169 - "Name", "VCManagedWrapperGeneratorTool" 53.170 - } 53.171 - ); 53.172 - tag("Tool", 53.173 - new String[] { 53.174 - "Name", "VCAuxiliaryManagedWrapperGeneratorTool" 53.175 - } 53.176 - ); 53.177 53.178 tag("Tool", 53.179 new String[] { 53.180 @@ -597,7 +556,7 @@ 53.181 addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch"); 53.182 addAttr(rv, "AssemblerListingLocation", outDir); 53.183 addAttr(rv, "ObjectFile", outDir+Util.sep); 53.184 - addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"vm.pdb"); 53.185 + addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); 53.186 // Set /nologo optin 53.187 addAttr(rv, "SuppressStartupBanner", "TRUE"); 53.188 // Surpass the default /Tc or /Tp. 0 is compileAsDefault 53.189 @@ -631,17 +590,22 @@ 53.190 addAttr(rv, "AdditionalOptions", 53.191 "/export:JNI_GetDefaultJavaVMInitArgs " + 53.192 "/export:JNI_CreateJavaVM " + 53.193 + "/export:JVM_FindClassFromBootLoader "+ 53.194 "/export:JNI_GetCreatedJavaVMs "+ 53.195 "/export:jio_snprintf /export:jio_printf "+ 53.196 "/export:jio_fprintf /export:jio_vfprintf "+ 53.197 - "/export:jio_vsnprintf "); 53.198 + "/export:jio_vsnprintf "+ 53.199 + "/export:JVM_GetVersionInfo "+ 53.200 + "/export:JVM_GetThreadStateNames "+ 53.201 + "/export:JVM_GetThreadStateValues "+ 53.202 + "/export:JVM_InitAgentProperties "); 53.203 addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib"); 53.204 addAttr(rv, "OutputFile", outDll); 53.205 // Set /INCREMENTAL option. 1 is linkIncrementalNo 53.206 addAttr(rv, "LinkIncremental", "1"); 53.207 addAttr(rv, "SuppressStartupBanner", "TRUE"); 53.208 addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); 53.209 - addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"vm.pdb"); 53.210 + addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); 53.211 // Set /SUBSYSTEM option. 2 is subSystemWindows 53.212 addAttr(rv, "SubSystem", "2"); 53.213 addAttr(rv, "BaseAddress", "0x8000000"); 53.214 @@ -682,6 +646,11 @@ 53.215 return rv; 53.216 } 53.217 53.218 + void getAdditionalNonKernelLinkerFlags(Vector rv) { 53.219 + extAttr(rv, "AdditionalOptions", 53.220 + "/export:AsyncGetCallTrace "); 53.221 + } 53.222 + 53.223 void getProductCompilerFlags_common(Vector rv) { 53.224 // Set /O2 option. 2 is optimizeMaxSpeed 53.225 addAttr(rv, "Optimization", "2");
54.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatformVC8.java Thu Jan 06 16:03:20 2011 -0800 54.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC8.java Fri Jan 07 03:58:11 2011 -0800 54.3 @@ -22,7 +22,7 @@ 54.4 * 54.5 */ 54.6 54.7 -import java.util.*; 54.8 +import java.util.Vector; 54.9 54.10 public class WinGammaPlatformVC8 extends WinGammaPlatformVC7 { 54.11 54.12 @@ -41,6 +41,9 @@ 54.13 // Set /EHsc- option. 0 is cppExceptionHandlingNo 54.14 addAttr(rv, "ExceptionHandling", "0"); 54.15 54.16 + // enable multi process builds 54.17 + extAttr(rv, "AdditionalOptions", "/MP"); 54.18 + 54.19 return rv; 54.20 } 54.21
55.1 --- a/src/share/tools/launcher/java.c Thu Jan 06 16:03:20 2011 -0800 55.2 +++ b/src/share/tools/launcher/java.c Fri Jan 07 03:58:11 2011 -0800 55.3 @@ -275,6 +275,8 @@ 55.4 jvmpath, sizeof(jvmpath), 55.5 original_argv); 55.6 55.7 + printf("Using java runtime at: %s\n", jrepath); 55.8 + 55.9 ifn.CreateJavaVM = 0; 55.10 ifn.GetDefaultJavaVMInitArgs = 0; 55.11
56.1 --- a/src/share/tools/launcher/jli_util.c Thu Jan 06 16:03:20 2011 -0800 56.2 +++ b/src/share/tools/launcher/jli_util.c Fri Jan 07 03:58:11 2011 -0800 56.3 @@ -1,3 +1,4 @@ 56.4 + 56.5 /* 56.6 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 56.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.8 @@ -27,7 +28,7 @@ 56.9 #include "jli_util.h" 56.10 56.11 #ifdef GAMMA 56.12 -#ifdef _WINDOWS 56.13 +#ifdef TARGET_OS_FAMILY_windows 56.14 #define strdup _strdup 56.15 #endif 56.16 #endif
57.1 --- a/src/share/vm/code/nmethod.cpp Thu Jan 06 16:03:20 2011 -0800 57.2 +++ b/src/share/vm/code/nmethod.cpp Fri Jan 07 03:58:11 2011 -0800 57.3 @@ -619,8 +619,8 @@ 57.4 OopMapSet* oop_maps ) 57.5 : CodeBlob("native nmethod", code_buffer, sizeof(nmethod), 57.6 nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps), 57.7 - _compiled_synchronized_native_basic_lock_owner_sp_offset(basic_lock_owner_sp_offset), 57.8 - _compiled_synchronized_native_basic_lock_sp_offset(basic_lock_sp_offset) 57.9 + _native_receiver_sp_offset(basic_lock_owner_sp_offset), 57.10 + _native_basic_lock_sp_offset(basic_lock_sp_offset) 57.11 { 57.12 { 57.13 debug_only(No_Safepoint_Verifier nsv;) 57.14 @@ -696,8 +696,8 @@ 57.15 int frame_size) 57.16 : CodeBlob("dtrace nmethod", code_buffer, sizeof(nmethod), 57.17 nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, NULL), 57.18 - _compiled_synchronized_native_basic_lock_owner_sp_offset(in_ByteSize(-1)), 57.19 - _compiled_synchronized_native_basic_lock_sp_offset(in_ByteSize(-1)) 57.20 + _native_receiver_sp_offset(in_ByteSize(-1)), 57.21 + _native_basic_lock_sp_offset(in_ByteSize(-1)) 57.22 { 57.23 { 57.24 debug_only(No_Safepoint_Verifier nsv;) 57.25 @@ -790,8 +790,8 @@ 57.26 ) 57.27 : CodeBlob("nmethod", code_buffer, sizeof(nmethod), 57.28 nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps), 57.29 - _compiled_synchronized_native_basic_lock_owner_sp_offset(in_ByteSize(-1)), 57.30 - _compiled_synchronized_native_basic_lock_sp_offset(in_ByteSize(-1)) 57.31 + _native_receiver_sp_offset(in_ByteSize(-1)), 57.32 + _native_basic_lock_sp_offset(in_ByteSize(-1)) 57.33 { 57.34 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); 57.35 {
58.1 --- a/src/share/vm/code/nmethod.hpp Thu Jan 06 16:03:20 2011 -0800 58.2 +++ b/src/share/vm/code/nmethod.hpp Fri Jan 07 03:58:11 2011 -0800 58.3 @@ -210,7 +210,7 @@ 58.4 ExceptionCache *_exception_cache; 58.5 PcDescCache _pc_desc_cache; 58.6 58.7 - // These are only used for compiled synchronized native methods to 58.8 + // These are used for compiled synchronized native methods to 58.9 // locate the owner and stack slot for the BasicLock so that we can 58.10 // properly revoke the bias of the owner if necessary. They are 58.11 // needed because there is no debug information for compiled native 58.12 @@ -220,8 +220,10 @@ 58.13 // sharing between platforms. Note that currently biased locking 58.14 // will never cause Class instances to be biased but this code 58.15 // handles the static synchronized case as well. 58.16 - ByteSize _compiled_synchronized_native_basic_lock_owner_sp_offset; 58.17 - ByteSize _compiled_synchronized_native_basic_lock_sp_offset; 58.18 + // JVMTI's GetLocalInstance() also uses these offsets to find the receiver 58.19 + // for non-static native wrapper frames. 58.20 + ByteSize _native_receiver_sp_offset; 58.21 + ByteSize _native_basic_lock_sp_offset; 58.22 58.23 friend class nmethodLocker; 58.24 58.25 @@ -676,11 +678,11 @@ 58.26 bool is_patchable_at(address instr_address); 58.27 58.28 // UseBiasedLocking support 58.29 - ByteSize compiled_synchronized_native_basic_lock_owner_sp_offset() { 58.30 - return _compiled_synchronized_native_basic_lock_owner_sp_offset; 58.31 + ByteSize native_receiver_sp_offset() { 58.32 + return _native_receiver_sp_offset; 58.33 } 58.34 - ByteSize compiled_synchronized_native_basic_lock_sp_offset() { 58.35 - return _compiled_synchronized_native_basic_lock_sp_offset; 58.36 + ByteSize native_basic_lock_sp_offset() { 58.37 + return _native_basic_lock_sp_offset; 58.38 } 58.39 58.40 // support for code generation
59.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Thu Jan 06 16:03:20 2011 -0800 59.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Fri Jan 07 03:58:11 2011 -0800 59.3 @@ -1825,23 +1825,11 @@ 59.4 } 59.5 } 59.6 59.7 - 59.8 -class G1CMIsAliveClosure: public BoolObjectClosure { 59.9 - G1CollectedHeap* _g1; 59.10 - public: 59.11 - G1CMIsAliveClosure(G1CollectedHeap* g1) : 59.12 - _g1(g1) 59.13 - {} 59.14 - 59.15 - void do_object(oop obj) { 59.16 - assert(false, "not to be invoked"); 59.17 - } 59.18 - bool do_object_b(oop obj) { 59.19 - HeapWord* addr = (HeapWord*)obj; 59.20 - return addr != NULL && 59.21 - (!_g1->is_in_g1_reserved(addr) || !_g1->is_obj_ill(obj)); 59.22 - } 59.23 -}; 59.24 +bool G1CMIsAliveClosure::do_object_b(oop obj) { 59.25 + HeapWord* addr = (HeapWord*)obj; 59.26 + return addr != NULL && 59.27 + (!_g1->is_in_g1_reserved(addr) || !_g1->is_obj_ill(obj)); 59.28 +} 59.29 59.30 class G1CMKeepAliveClosure: public OopClosure { 59.31 G1CollectedHeap* _g1; 59.32 @@ -1896,16 +1884,15 @@ 59.33 rp->setup_policy(clear_all_soft_refs); 59.34 assert(_markStack.isEmpty(), "mark stack should be empty"); 59.35 59.36 - G1CMIsAliveClosure g1IsAliveClosure (g1h); 59.37 - G1CMKeepAliveClosure g1KeepAliveClosure(g1h, this, nextMarkBitMap()); 59.38 + G1CMIsAliveClosure g1_is_alive(g1h); 59.39 + G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap()); 59.40 G1CMDrainMarkingStackClosure 59.41 - g1DrainMarkingStackClosure(nextMarkBitMap(), &_markStack, 59.42 - &g1KeepAliveClosure); 59.43 + g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive); 59.44 59.45 // XXXYYY Also: copy the parallel ref processing code from CMS. 59.46 - rp->process_discovered_references(&g1IsAliveClosure, 59.47 - &g1KeepAliveClosure, 59.48 - &g1DrainMarkingStackClosure, 59.49 + rp->process_discovered_references(&g1_is_alive, 59.50 + &g1_keep_alive, 59.51 + &g1_drain_mark_stack, 59.52 NULL); 59.53 assert(_markStack.overflow() || _markStack.isEmpty(), 59.54 "mark stack should be empty (unless it overflowed)"); 59.55 @@ -1918,8 +1905,8 @@ 59.56 assert(!rp->discovery_enabled(), "should have been disabled"); 59.57 59.58 // Now clean up stale oops in SymbolTable and StringTable 59.59 - SymbolTable::unlink(&g1IsAliveClosure); 59.60 - StringTable::unlink(&g1IsAliveClosure); 59.61 + SymbolTable::unlink(&g1_is_alive); 59.62 + StringTable::unlink(&g1_is_alive); 59.63 } 59.64 59.65 void ConcurrentMark::swapMarkBitMaps() {
60.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Thu Jan 06 16:03:20 2011 -0800 60.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Fri Jan 07 03:58:11 2011 -0800 60.3 @@ -33,6 +33,25 @@ 60.4 typedef GenericTaskQueue<oop> CMTaskQueue; 60.5 typedef GenericTaskQueueSet<CMTaskQueue> CMTaskQueueSet; 60.6 60.7 +// Closure used by CM during concurrent reference discovery 60.8 +// and reference processing (during remarking) to determine 60.9 +// if a particular object is alive. It is primarily used 60.10 +// to determine if referents of discovered reference objects 60.11 +// are alive. An instance is also embedded into the 60.12 +// reference processor as the _is_alive_non_header field 60.13 +class G1CMIsAliveClosure: public BoolObjectClosure { 60.14 + G1CollectedHeap* _g1; 60.15 + public: 60.16 + G1CMIsAliveClosure(G1CollectedHeap* g1) : 60.17 + _g1(g1) 60.18 + {} 60.19 + 60.20 + void do_object(oop obj) { 60.21 + ShouldNotCallThis(); 60.22 + } 60.23 + bool do_object_b(oop obj); 60.24 +}; 60.25 + 60.26 // A generic CM bit map. This is essentially a wrapper around the BitMap 60.27 // class, with one bit per (1<<_shifter) HeapWords. 60.28
61.1 --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Thu Jan 06 16:03:20 2011 -0800 61.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Fri Jan 07 03:58:11 2011 -0800 61.3 @@ -277,7 +277,9 @@ 61.4 // completed. This will also notify the FullGCCount_lock in case a 61.5 // Java thread is waiting for a full GC to happen (e.g., it 61.6 // called System.gc() with +ExplicitGCInvokesConcurrent). 61.7 - g1->increment_full_collections_completed(true /* outer */); 61.8 + _sts.join(); 61.9 + g1->increment_full_collections_completed(true /* concurrent */); 61.10 + _sts.leave(); 61.11 } 61.12 assert(_should_terminate, "just checking"); 61.13
62.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Jan 06 16:03:20 2011 -0800 62.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Jan 07 03:58:11 2011 -0800 62.3 @@ -1192,6 +1192,7 @@ 62.4 return false; 62.5 } 62.6 62.7 + DTraceGCProbeMarker gc_probe_marker(true /* full */); 62.8 ResourceMark rm; 62.9 62.10 if (PrintHeapAtGC) { 62.11 @@ -1389,7 +1390,7 @@ 62.12 } 62.13 62.14 // Update the number of full collections that have been completed. 62.15 - increment_full_collections_completed(false /* outer */); 62.16 + increment_full_collections_completed(false /* concurrent */); 62.17 62.18 if (PrintHeapAtGC) { 62.19 Universe::print_heap_after_gc(); 62.20 @@ -1768,6 +1769,7 @@ 62.21 _g1_policy(policy_), 62.22 _dirty_card_queue_set(false), 62.23 _into_cset_dirty_card_queue_set(false), 62.24 + _is_alive_closure(this), 62.25 _ref_processor(NULL), 62.26 _process_strong_tasks(new SubTasksDone(G1H_PS_NumElements)), 62.27 _bot_shared(NULL), 62.28 @@ -2061,7 +2063,8 @@ 62.29 mr, // span 62.30 false, // Reference discovery is not atomic 62.31 true, // mt_discovery 62.32 - NULL, // is alive closure: need to fill this in for efficiency 62.33 + &_is_alive_closure, // is alive closure 62.34 + // for efficiency 62.35 ParallelGCThreads, 62.36 ParallelRefProcEnabled, 62.37 true); // Setting next fields of discovered 62.38 @@ -2176,9 +2179,14 @@ 62.39 (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); 62.40 } 62.41 62.42 -void G1CollectedHeap::increment_full_collections_completed(bool outer) { 62.43 +void G1CollectedHeap::increment_full_collections_completed(bool concurrent) { 62.44 MonitorLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag); 62.45 62.46 + // We assume that if concurrent == true, then the caller is a 62.47 + // concurrent thread that was joined the Suspendible Thread 62.48 + // Set. If there's ever a cheap way to check this, we should add an 62.49 + // assert here. 62.50 + 62.51 // We have already incremented _total_full_collections at the start 62.52 // of the GC, so total_full_collections() represents how many full 62.53 // collections have been started. 62.54 @@ -2192,17 +2200,18 @@ 62.55 // behind the number of full collections started. 62.56 62.57 // This is the case for the inner caller, i.e. a Full GC. 62.58 - assert(outer || 62.59 + assert(concurrent || 62.60 (full_collections_started == _full_collections_completed + 1) || 62.61 (full_collections_started == _full_collections_completed + 2), 62.62 - err_msg("for inner caller: full_collections_started = %u " 62.63 + err_msg("for inner caller (Full GC): full_collections_started = %u " 62.64 "is inconsistent with _full_collections_completed = %u", 62.65 full_collections_started, _full_collections_completed)); 62.66 62.67 // This is the case for the outer caller, i.e. the concurrent cycle. 62.68 - assert(!outer || 62.69 + assert(!concurrent || 62.70 (full_collections_started == _full_collections_completed + 1), 62.71 - err_msg("for outer caller: full_collections_started = %u " 62.72 + err_msg("for outer caller (concurrent cycle): " 62.73 + "full_collections_started = %u " 62.74 "is inconsistent with _full_collections_completed = %u", 62.75 full_collections_started, _full_collections_completed)); 62.76 62.77 @@ -2212,7 +2221,7 @@ 62.78 // we wake up any waiters (especially when ExplicitInvokesConcurrent 62.79 // is set) so that if a waiter requests another System.gc() it doesn't 62.80 // incorrectly see that a marking cyle is still in progress. 62.81 - if (outer) { 62.82 + if (concurrent) { 62.83 _cmThread->clear_in_progress(); 62.84 } 62.85 62.86 @@ -3205,13 +3214,14 @@ 62.87 return false; 62.88 } 62.89 62.90 + DTraceGCProbeMarker gc_probe_marker(false /* full */); 62.91 + ResourceMark rm; 62.92 + 62.93 if (PrintHeapAtGC) { 62.94 Universe::print_heap_before_gc(); 62.95 } 62.96 62.97 { 62.98 - ResourceMark rm; 62.99 - 62.100 // This call will decide whether this pause is an initial-mark 62.101 // pause. If it is, during_initial_mark_pause() will return true 62.102 // for the duration of this pause. 62.103 @@ -3950,8 +3960,6 @@ 62.104 // Now restore saved marks, if any. 62.105 if (_objs_with_preserved_marks != NULL) { 62.106 assert(_preserved_marks_of_objs != NULL, "Both or none."); 62.107 - assert(_objs_with_preserved_marks->length() == 62.108 - _preserved_marks_of_objs->length(), "Both or none."); 62.109 guarantee(_objs_with_preserved_marks->length() == 62.110 _preserved_marks_of_objs->length(), "Both or none."); 62.111 for (int i = 0; i < _objs_with_preserved_marks->length(); i++) { 62.112 @@ -4046,7 +4054,10 @@ 62.113 } 62.114 62.115 void G1CollectedHeap::preserve_mark_if_necessary(oop obj, markOop m) { 62.116 - if (m != markOopDesc::prototype()) { 62.117 + assert(evacuation_failed(), "Oversaving!"); 62.118 + // We want to call the "for_promotion_failure" version only in the 62.119 + // case of a promotion failure. 62.120 + if (m->must_be_preserved_for_promotion_failure(obj)) { 62.121 if (_objs_with_preserved_marks == NULL) { 62.122 assert(_preserved_marks_of_objs == NULL, "Both or none."); 62.123 _objs_with_preserved_marks =
63.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Thu Jan 06 16:03:20 2011 -0800 63.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Jan 07 03:58:11 2011 -0800 63.3 @@ -643,16 +643,16 @@ 63.4 // can happen in a nested fashion, i.e., we start a concurrent 63.5 // cycle, a Full GC happens half-way through it which ends first, 63.6 // and then the cycle notices that a Full GC happened and ends 63.7 - // too. The outer parameter is a boolean to help us do a bit tighter 63.8 - // consistency checking in the method. If outer is false, the caller 63.9 - // is the inner caller in the nesting (i.e., the Full GC). If outer 63.10 - // is true, the caller is the outer caller in this nesting (i.e., 63.11 - // the concurrent cycle). Further nesting is not currently 63.12 - // supported. The end of the this call also notifies the 63.13 - // FullGCCount_lock in case a Java thread is waiting for a full GC 63.14 - // to happen (e.g., it called System.gc() with 63.15 + // too. The concurrent parameter is a boolean to help us do a bit 63.16 + // tighter consistency checking in the method. If concurrent is 63.17 + // false, the caller is the inner caller in the nesting (i.e., the 63.18 + // Full GC). If concurrent is true, the caller is the outer caller 63.19 + // in this nesting (i.e., the concurrent cycle). Further nesting is 63.20 + // not currently supported. The end of the this call also notifies 63.21 + // the FullGCCount_lock in case a Java thread is waiting for a full 63.22 + // GC to happen (e.g., it called System.gc() with 63.23 // +ExplicitGCInvokesConcurrent). 63.24 - void increment_full_collections_completed(bool outer); 63.25 + void increment_full_collections_completed(bool concurrent); 63.26 63.27 unsigned int full_collections_completed() { 63.28 return _full_collections_completed; 63.29 @@ -849,6 +849,12 @@ 63.30 void print_gc_alloc_regions(); 63.31 #endif // !PRODUCT 63.32 63.33 + // Instance of the concurrent mark is_alive closure for embedding 63.34 + // into the reference processor as the is_alive_non_header. This 63.35 + // prevents unnecessary additions to the discovered lists during 63.36 + // concurrent discovery. 63.37 + G1CMIsAliveClosure _is_alive_closure; 63.38 + 63.39 // ("Weak") Reference processing support 63.40 ReferenceProcessor* _ref_processor; 63.41 63.42 @@ -893,7 +899,7 @@ 63.43 // specified by the policy object. 63.44 jint initialize(); 63.45 63.46 - void ref_processing_init(); 63.47 + virtual void ref_processing_init(); 63.48 63.49 void set_par_threads(int t) { 63.50 SharedHeap::set_par_threads(t);
64.1 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu Jan 06 16:03:20 2011 -0800 64.2 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Fri Jan 07 03:58:11 2011 -0800 64.3 @@ -1058,10 +1058,11 @@ 64.4 #endif 64.5 64.6 void ParNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) { 64.7 - if ((m != markOopDesc::prototype()) && 64.8 - (!UseBiasedLocking || (m != markOopDesc::biased_locking_prototype()))) { 64.9 + if (m->must_be_preserved_for_promotion_failure(obj)) { 64.10 + // We should really have separate per-worker stacks, rather 64.11 + // than use locking of a common pair of stacks. 64.12 MutexLocker ml(ParGCRareEvent_lock); 64.13 - DefNewGeneration::preserve_mark_if_necessary(obj, m); 64.14 + preserve_mark(obj, m); 64.15 } 64.16 } 64.17
65.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Thu Jan 06 16:03:20 2011 -0800 65.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Jan 07 03:58:11 2011 -0800 65.3 @@ -694,6 +694,8 @@ 65.4 void PSScavenge::oop_promotion_failed(oop obj, markOop obj_mark) { 65.5 _promotion_failed = true; 65.6 if (obj_mark->must_be_preserved_for_promotion_failure(obj)) { 65.7 + // Should use per-worker private stakcs hetre rather than 65.8 + // locking a common pair of stacks. 65.9 ThreadCritical tc; 65.10 _preserved_oop_stack.push(obj); 65.11 _preserved_mark_stack.push(obj_mark);
66.1 --- a/src/share/vm/gc_implementation/shared/vmGCOperations.hpp Thu Jan 06 16:03:20 2011 -0800 66.2 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.hpp Fri Jan 07 03:58:11 2011 -0800 66.3 @@ -209,4 +209,15 @@ 66.4 HeapWord* result() const { return _res; } 66.5 }; 66.6 66.7 +class DTraceGCProbeMarker : public StackObj { 66.8 +public: 66.9 + DTraceGCProbeMarker(bool full) { 66.10 + VM_GC_Operation::notify_gc_begin(full); 66.11 + } 66.12 + 66.13 + ~DTraceGCProbeMarker() { 66.14 + VM_GC_Operation::notify_gc_end(); 66.15 + } 66.16 +}; 66.17 + 66.18 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
67.1 --- a/src/share/vm/memory/defNewGeneration.cpp Thu Jan 06 16:03:20 2011 -0800 67.2 +++ b/src/share/vm/memory/defNewGeneration.cpp Fri Jan 07 03:58:11 2011 -0800 67.3 @@ -684,23 +684,28 @@ 67.4 _preserved_marks_of_objs.clear(true); 67.5 } 67.6 67.7 +void DefNewGeneration::preserve_mark(oop obj, markOop m) { 67.8 + assert(promotion_failed() && m->must_be_preserved_for_promotion_failure(obj), 67.9 + "Oversaving!"); 67.10 + _objs_with_preserved_marks.push(obj); 67.11 + _preserved_marks_of_objs.push(m); 67.12 +} 67.13 + 67.14 void DefNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) { 67.15 if (m->must_be_preserved_for_promotion_failure(obj)) { 67.16 - _objs_with_preserved_marks.push(obj); 67.17 - _preserved_marks_of_objs.push(m); 67.18 + preserve_mark(obj, m); 67.19 } 67.20 } 67.21 67.22 void DefNewGeneration::handle_promotion_failure(oop old) { 67.23 - preserve_mark_if_necessary(old, old->mark()); 67.24 - if (!_promotion_failed && PrintPromotionFailure) { 67.25 + if (PrintPromotionFailure && !_promotion_failed) { 67.26 gclog_or_tty->print(" (promotion failure size = " SIZE_FORMAT ") ", 67.27 old->size()); 67.28 } 67.29 - 67.30 + _promotion_failed = true; 67.31 + preserve_mark_if_necessary(old, old->mark()); 67.32 // forward to self 67.33 old->forward_to(old); 67.34 - _promotion_failed = true; 67.35 67.36 _promo_failure_scan_stack.push(old); 67.37
68.1 --- a/src/share/vm/memory/defNewGeneration.hpp Thu Jan 06 16:03:20 2011 -0800 68.2 +++ b/src/share/vm/memory/defNewGeneration.hpp Fri Jan 07 03:58:11 2011 -0800 68.3 @@ -85,6 +85,7 @@ 68.4 // Preserve the mark of "obj", if necessary, in preparation for its mark 68.5 // word being overwritten with a self-forwarding-pointer. 68.6 void preserve_mark_if_necessary(oop obj, markOop m); 68.7 + void preserve_mark(oop obj, markOop m); // work routine used by the above 68.8 68.9 // Together, these keep <object with a preserved mark, mark value> pairs. 68.10 // They should always contain the same number of elements.
69.1 --- a/src/share/vm/oops/instanceRefKlass.cpp Thu Jan 06 16:03:20 2011 -0800 69.2 +++ b/src/share/vm/oops/instanceRefKlass.cpp Fri Jan 07 03:58:11 2011 -0800 69.3 @@ -457,6 +457,12 @@ 69.4 } 69.5 } 69.6 69.7 +bool instanceRefKlass::owns_pending_list_lock(JavaThread* thread) { 69.8 + if (java_lang_ref_Reference::pending_list_lock() == NULL) return false; 69.9 + Handle h_lock(thread, java_lang_ref_Reference::pending_list_lock()); 69.10 + return ObjectSynchronizer::current_thread_holds_lock(thread, h_lock); 69.11 +} 69.12 + 69.13 void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) { 69.14 // we may enter this with pending exception set 69.15 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument
70.1 --- a/src/share/vm/oops/instanceRefKlass.hpp Thu Jan 06 16:03:20 2011 -0800 70.2 +++ b/src/share/vm/oops/instanceRefKlass.hpp Fri Jan 07 03:58:11 2011 -0800 70.3 @@ -89,6 +89,7 @@ 70.4 70.5 static void release_and_notify_pending_list_lock(BasicLock *pending_list_basic_lock); 70.6 static void acquire_pending_list_lock(BasicLock *pending_list_basic_lock); 70.7 + static bool owns_pending_list_lock(JavaThread* thread); 70.8 70.9 // Update non-static oop maps so 'referent', 'nextPending' and 70.10 // 'discovered' will look like non-oops
71.1 --- a/src/share/vm/oops/klassVtable.cpp Thu Jan 06 16:03:20 2011 -0800 71.2 +++ b/src/share/vm/oops/klassVtable.cpp Fri Jan 07 03:58:11 2011 -0800 71.3 @@ -518,18 +518,21 @@ 71.4 bool klassVtable::is_miranda(methodOop m, objArrayOop class_methods, klassOop super) { 71.5 symbolOop name = m->name(); 71.6 symbolOop signature = m->signature(); 71.7 + 71.8 if (instanceKlass::find_method(class_methods, name, signature) == NULL) { 71.9 - // did not find it in the method table of the current class 71.10 + // did not find it in the method table of the current class 71.11 if (super == NULL) { 71.12 // super doesn't exist 71.13 return true; 71.14 - } else { 71.15 - if (instanceKlass::cast(super)->lookup_method(name, signature) == NULL) { 71.16 - // super class hierarchy does not implement it 71.17 - return true; 71.18 - } 71.19 + } 71.20 + 71.21 + methodOop mo = instanceKlass::cast(super)->lookup_method(name, signature); 71.22 + if (mo == NULL || mo->access_flags().is_private() ) { 71.23 + // super class hierarchy does not implement it or protection is different 71.24 + return true; 71.25 } 71.26 } 71.27 + 71.28 return false; 71.29 } 71.30
72.1 --- a/src/share/vm/oops/markOop.inline.hpp Thu Jan 06 16:03:20 2011 -0800 72.2 +++ b/src/share/vm/oops/markOop.inline.hpp Fri Jan 07 03:58:11 2011 -0800 72.3 @@ -30,7 +30,7 @@ 72.4 #include "oops/markOop.hpp" 72.5 #include "runtime/globals.hpp" 72.6 72.7 -// Should this header be preserved during GC? 72.8 +// Should this header be preserved during GC (when biased locking is enabled)? 72.9 inline bool markOopDesc::must_be_preserved_with_bias(oop obj_containing_mark) const { 72.10 assert(UseBiasedLocking, "unexpected"); 72.11 if (has_bias_pattern()) { 72.12 @@ -47,14 +47,15 @@ 72.13 return (!is_unlocked() || !has_no_hash()); 72.14 } 72.15 72.16 +// Should this header be preserved during GC? 72.17 inline bool markOopDesc::must_be_preserved(oop obj_containing_mark) const { 72.18 if (!UseBiasedLocking) 72.19 return (!is_unlocked() || !has_no_hash()); 72.20 return must_be_preserved_with_bias(obj_containing_mark); 72.21 } 72.22 72.23 -// Should this header (including its age bits) be preserved in the 72.24 -// case of a promotion failure during scavenge? 72.25 +// Should this header be preserved in the case of a promotion failure 72.26 +// during scavenge (when biased locking is enabled)? 72.27 inline bool markOopDesc::must_be_preserved_with_bias_for_promotion_failure(oop obj_containing_mark) const { 72.28 assert(UseBiasedLocking, "unexpected"); 72.29 // We don't explicitly save off the mark words of biased and 72.30 @@ -70,18 +71,20 @@ 72.31 prototype_for_object(obj_containing_mark)->has_bias_pattern()) { 72.32 return true; 72.33 } 72.34 - return (this != prototype()); 72.35 + return (!is_unlocked() || !has_no_hash()); 72.36 } 72.37 72.38 +// Should this header be preserved in the case of a promotion failure 72.39 +// during scavenge? 72.40 inline bool markOopDesc::must_be_preserved_for_promotion_failure(oop obj_containing_mark) const { 72.41 if (!UseBiasedLocking) 72.42 - return (this != prototype()); 72.43 + return (!is_unlocked() || !has_no_hash()); 72.44 return must_be_preserved_with_bias_for_promotion_failure(obj_containing_mark); 72.45 } 72.46 72.47 72.48 -// Should this header (including its age bits) be preserved in the 72.49 -// case of a scavenge in which CMS is the old generation? 72.50 +// Same as must_be_preserved_with_bias_for_promotion_failure() except that 72.51 +// it takes a klassOop argument, instead of the object of which this is the mark word. 72.52 inline bool markOopDesc::must_be_preserved_with_bias_for_cms_scavenge(klassOop klass_of_obj_containing_mark) const { 72.53 assert(UseBiasedLocking, "unexpected"); 72.54 // CMS scavenges preserve mark words in similar fashion to promotion failures; see above 72.55 @@ -89,11 +92,14 @@ 72.56 klass_of_obj_containing_mark->klass_part()->prototype_header()->has_bias_pattern()) { 72.57 return true; 72.58 } 72.59 - return (this != prototype()); 72.60 + return (!is_unlocked() || !has_no_hash()); 72.61 } 72.62 + 72.63 +// Same as must_be_preserved_for_promotion_failure() except that 72.64 +// it takes a klassOop argument, instead of the object of which this is the mark word. 72.65 inline bool markOopDesc::must_be_preserved_for_cms_scavenge(klassOop klass_of_obj_containing_mark) const { 72.66 if (!UseBiasedLocking) 72.67 - return (this != prototype()); 72.68 + return (!is_unlocked() || !has_no_hash()); 72.69 return must_be_preserved_with_bias_for_cms_scavenge(klass_of_obj_containing_mark); 72.70 } 72.71
73.1 --- a/src/share/vm/oops/methodOop.cpp Thu Jan 06 16:03:20 2011 -0800 73.2 +++ b/src/share/vm/oops/methodOop.cpp Fri Jan 07 03:58:11 2011 -0800 73.3 @@ -309,6 +309,12 @@ 73.4 // Build a methodDataOop object to hold information about this method 73.5 // collected in the interpreter. 73.6 void methodOopDesc::build_interpreter_method_data(methodHandle method, TRAPS) { 73.7 + // Do not profile method if current thread holds the pending list lock, 73.8 + // which avoids deadlock for acquiring the MethodData_lock. 73.9 + if (instanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { 73.10 + return; 73.11 + } 73.12 + 73.13 // Grab a lock here to prevent multiple 73.14 // methodDataOops from being created. 73.15 MutexLocker ml(MethodData_lock, THREAD);
74.1 --- a/src/share/vm/prims/jvmti.xml Thu Jan 06 16:03:20 2011 -0800 74.2 +++ b/src/share/vm/prims/jvmti.xml Fri Jan 07 03:58:11 2011 -0800 74.3 @@ -5649,6 +5649,45 @@ 74.4 </errors> 74.5 </function> 74.6 74.7 + <function id="GetLocalInstance" num="155" since="1.2"> 74.8 + <synopsis>Get Local Instance</synopsis> 74.9 + <description> 74.10 + This function can be used to retrieve the value of the local object 74.11 + variable at slot 0 (the "<code>this</code>" object) from non-static 74.12 + frames. This function can retrieve the "<code>this</code>" object from 74.13 + native method frames, whereas <code>GetLocalObject()</code> would 74.14 + return <code>JVMTI_ERROR_OPAQUE_FRAME</code> in those cases. 74.15 + </description> 74.16 + <origin>new</origin> 74.17 + <capabilities> 74.18 + <required id="can_access_local_variables"></required> 74.19 + </capabilities> 74.20 + <parameters> 74.21 + <param id="thread"> 74.22 + <jthread null="current" frame="frame"/> 74.23 + <description> 74.24 + The thread of the frame containing the variable's value. 74.25 + </description> 74.26 + </param> 74.27 + <param id="depth"> 74.28 + <jframeID thread="thread"/> 74.29 + <description> 74.30 + The depth of the frame containing the variable's value. 74.31 + </description> 74.32 + </param> 74.33 + <param id="value_ptr"> 74.34 + <outptr><jobject/></outptr> 74.35 + <description> 74.36 + On return, points to the variable's value. 74.37 + </description> 74.38 + </param> 74.39 + </parameters> 74.40 + <errors> 74.41 + <error id="JVMTI_ERROR_INVALID_SLOT"> 74.42 + If the specified frame is a static method frame. 74.43 + </error> 74.44 + </errors> 74.45 + </function> 74.46 <function id="GetLocalInt" num="22"> 74.47 <synopsis>Get Local Variable - Int</synopsis> 74.48 <description>
75.1 --- a/src/share/vm/prims/jvmtiEnv.cpp Thu Jan 06 16:03:20 2011 -0800 75.2 +++ b/src/share/vm/prims/jvmtiEnv.cpp Fri Jan 07 03:58:11 2011 -0800 75.3 @@ -1796,6 +1796,29 @@ 75.4 } 75.5 } /* end GetLocalObject */ 75.6 75.7 +// Threads_lock NOT held, java_thread not protected by lock 75.8 +// java_thread - pre-checked 75.9 +// java_thread - unchecked 75.10 +// depth - pre-checked as non-negative 75.11 +// value - pre-checked for NULL 75.12 +jvmtiError 75.13 +JvmtiEnv::GetLocalInstance(JavaThread* java_thread, jint depth, jobject* value){ 75.14 + JavaThread* current_thread = JavaThread::current(); 75.15 + // rm object is created to clean up the javaVFrame created in 75.16 + // doit_prologue(), but after doit() is finished with it. 75.17 + ResourceMark rm(current_thread); 75.18 + 75.19 + VM_GetReceiver op(java_thread, current_thread, depth); 75.20 + VMThread::execute(&op); 75.21 + jvmtiError err = op.result(); 75.22 + if (err != JVMTI_ERROR_NONE) { 75.23 + return err; 75.24 + } else { 75.25 + *value = op.value().l; 75.26 + return JVMTI_ERROR_NONE; 75.27 + } 75.28 +} /* end GetLocalInstance */ 75.29 + 75.30 75.31 // Threads_lock NOT held, java_thread not protected by lock 75.32 // java_thread - pre-checked
76.1 --- a/src/share/vm/prims/jvmtiImpl.cpp Thu Jan 06 16:03:20 2011 -0800 76.2 +++ b/src/share/vm/prims/jvmtiImpl.cpp Fri Jan 07 03:58:11 2011 -0800 76.3 @@ -586,7 +586,6 @@ 76.4 { 76.5 } 76.6 76.7 - 76.8 vframe *VM_GetOrSetLocal::get_vframe() { 76.9 if (!_thread->has_last_Java_frame()) { 76.10 return NULL; 76.11 @@ -609,7 +608,7 @@ 76.12 } 76.13 javaVFrame *jvf = (javaVFrame*)vf; 76.14 76.15 - if (!vf->is_java_frame() || jvf->method()->is_native()) { 76.16 + if (!vf->is_java_frame()) { 76.17 _result = JVMTI_ERROR_OPAQUE_FRAME; 76.18 return NULL; 76.19 } 76.20 @@ -740,6 +739,15 @@ 76.21 _jvf = get_java_vframe(); 76.22 NULL_CHECK(_jvf, false); 76.23 76.24 + if (_jvf->method()->is_native()) { 76.25 + if (getting_receiver() && !_jvf->method()->is_static()) { 76.26 + return true; 76.27 + } else { 76.28 + _result = JVMTI_ERROR_OPAQUE_FRAME; 76.29 + return false; 76.30 + } 76.31 + } 76.32 + 76.33 if (!check_slot_type(_jvf)) { 76.34 return false; 76.35 } 76.36 @@ -781,40 +789,46 @@ 76.37 HandleMark hm; 76.38 76.39 switch (_type) { 76.40 - case T_INT: locals->set_int_at (_index, _value.i); break; 76.41 - case T_LONG: locals->set_long_at (_index, _value.j); break; 76.42 - case T_FLOAT: locals->set_float_at (_index, _value.f); break; 76.43 - case T_DOUBLE: locals->set_double_at(_index, _value.d); break; 76.44 - case T_OBJECT: { 76.45 - Handle ob_h(JNIHandles::resolve_external_guard(_value.l)); 76.46 - locals->set_obj_at (_index, ob_h); 76.47 - break; 76.48 - } 76.49 - default: ShouldNotReachHere(); 76.50 + case T_INT: locals->set_int_at (_index, _value.i); break; 76.51 + case T_LONG: locals->set_long_at (_index, _value.j); break; 76.52 + case T_FLOAT: locals->set_float_at (_index, _value.f); break; 76.53 + case T_DOUBLE: locals->set_double_at(_index, _value.d); break; 76.54 + case T_OBJECT: { 76.55 + Handle ob_h(JNIHandles::resolve_external_guard(_value.l)); 76.56 + locals->set_obj_at (_index, ob_h); 76.57 + break; 76.58 + } 76.59 + default: ShouldNotReachHere(); 76.60 } 76.61 _jvf->set_locals(locals); 76.62 } else { 76.63 - StackValueCollection *locals = _jvf->locals(); 76.64 + if (_jvf->method()->is_native() && _jvf->is_compiled_frame()) { 76.65 + assert(getting_receiver(), "Can only get here when getting receiver"); 76.66 + oop receiver = _jvf->fr().get_native_receiver(); 76.67 + _value.l = JNIHandles::make_local(_calling_thread, receiver); 76.68 + } else { 76.69 + StackValueCollection *locals = _jvf->locals(); 76.70 76.71 - if (locals->at(_index)->type() == T_CONFLICT) { 76.72 - memset(&_value, 0, sizeof(_value)); 76.73 - _value.l = NULL; 76.74 - return; 76.75 - } 76.76 + if (locals->at(_index)->type() == T_CONFLICT) { 76.77 + memset(&_value, 0, sizeof(_value)); 76.78 + _value.l = NULL; 76.79 + return; 76.80 + } 76.81 76.82 - switch (_type) { 76.83 - case T_INT: _value.i = locals->int_at (_index); break; 76.84 - case T_LONG: _value.j = locals->long_at (_index); break; 76.85 - case T_FLOAT: _value.f = locals->float_at (_index); break; 76.86 - case T_DOUBLE: _value.d = locals->double_at(_index); break; 76.87 - case T_OBJECT: { 76.88 - // Wrap the oop to be returned in a local JNI handle since 76.89 - // oops_do() no longer applies after doit() is finished. 76.90 - oop obj = locals->obj_at(_index)(); 76.91 - _value.l = JNIHandles::make_local(_calling_thread, obj); 76.92 - break; 76.93 - } 76.94 - default: ShouldNotReachHere(); 76.95 + switch (_type) { 76.96 + case T_INT: _value.i = locals->int_at (_index); break; 76.97 + case T_LONG: _value.j = locals->long_at (_index); break; 76.98 + case T_FLOAT: _value.f = locals->float_at (_index); break; 76.99 + case T_DOUBLE: _value.d = locals->double_at(_index); break; 76.100 + case T_OBJECT: { 76.101 + // Wrap the oop to be returned in a local JNI handle since 76.102 + // oops_do() no longer applies after doit() is finished. 76.103 + oop obj = locals->obj_at(_index)(); 76.104 + _value.l = JNIHandles::make_local(_calling_thread, obj); 76.105 + break; 76.106 + } 76.107 + default: ShouldNotReachHere(); 76.108 + } 76.109 } 76.110 } 76.111 } 76.112 @@ -825,6 +839,10 @@ 76.113 } 76.114 76.115 76.116 +VM_GetReceiver::VM_GetReceiver( 76.117 + JavaThread* thread, JavaThread* caller_thread, jint depth) 76.118 + : VM_GetOrSetLocal(thread, caller_thread, depth, 0) {} 76.119 + 76.120 ///////////////////////////////////////////////////////////////////////////////////////// 76.121 76.122 //
77.1 --- a/src/share/vm/prims/jvmtiImpl.hpp Thu Jan 06 16:03:20 2011 -0800 77.2 +++ b/src/share/vm/prims/jvmtiImpl.hpp Fri Jan 07 03:58:11 2011 -0800 77.3 @@ -355,7 +355,7 @@ 77.4 // to the thread simultaneously. 77.5 // 77.6 class VM_GetOrSetLocal : public VM_Operation { 77.7 -private: 77.8 + protected: 77.9 JavaThread* _thread; 77.10 JavaThread* _calling_thread; 77.11 jint _depth; 77.12 @@ -365,6 +365,10 @@ 77.13 javaVFrame* _jvf; 77.14 bool _set; 77.15 77.16 + // It is possible to get the receiver out of a non-static native wrapper 77.17 + // frame. Use VM_GetReceiver to do this. 77.18 + virtual bool getting_receiver() const { return false; } 77.19 + 77.20 jvmtiError _result; 77.21 77.22 vframe* get_vframe(); 77.23 @@ -395,6 +399,15 @@ 77.24 static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread); 77.25 }; 77.26 77.27 +class VM_GetReceiver : public VM_GetOrSetLocal { 77.28 + protected: 77.29 + virtual bool getting_receiver() const { return true; } 77.30 + 77.31 + public: 77.32 + VM_GetReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth); 77.33 + const char* name() const { return "get receiver"; } 77.34 +}; 77.35 + 77.36 77.37 /////////////////////////////////////////////////////////////// 77.38 //
78.1 --- a/src/share/vm/runtime/frame.cpp Thu Jan 06 16:03:20 2011 -0800 78.2 +++ b/src/share/vm/runtime/frame.cpp Fri Jan 07 03:58:11 2011 -0800 78.3 @@ -41,6 +41,8 @@ 78.4 #include "runtime/signature.hpp" 78.5 #include "runtime/stubCodeGenerator.hpp" 78.6 #include "runtime/stubRoutines.hpp" 78.7 +#include "utilities/decoder.hpp" 78.8 + 78.9 #ifdef TARGET_ARCH_x86 78.10 # include "nativeInst_x86.hpp" 78.11 #endif 78.12 @@ -652,7 +654,7 @@ 78.13 // names if pc is within jvm.dll or libjvm.so, because JVM only has 78.14 // JVM_xxxx and a few other symbols in the dynamic symbol table. Do this 78.15 // only for native libraries. 78.16 - if (!in_vm) { 78.17 + if (!in_vm || Decoder::can_decode_C_frame_in_vm()) { 78.18 found = os::dll_address_to_function_name(pc, buf, buflen, &offset); 78.19 78.20 if (found) { 78.21 @@ -1071,28 +1073,20 @@ 78.22 } 78.23 } 78.24 78.25 -BasicLock* frame::compiled_synchronized_native_monitor(nmethod* nm) { 78.26 - if (nm == NULL) { 78.27 - assert(_cb != NULL && _cb->is_nmethod() && 78.28 - nm->method()->is_native() && 78.29 - nm->method()->is_synchronized(), 78.30 - "should not call this otherwise"); 78.31 - nm = (nmethod*) _cb; 78.32 - } 78.33 - int byte_offset = in_bytes(nm->compiled_synchronized_native_basic_lock_sp_offset()); 78.34 +BasicLock* frame::get_native_monitor() { 78.35 + nmethod* nm = (nmethod*)_cb; 78.36 + assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(), 78.37 + "Should not call this unless it's a native nmethod"); 78.38 + int byte_offset = in_bytes(nm->native_basic_lock_sp_offset()); 78.39 assert(byte_offset >= 0, "should not see invalid offset"); 78.40 return (BasicLock*) &sp()[byte_offset / wordSize]; 78.41 } 78.42 78.43 -oop frame::compiled_synchronized_native_monitor_owner(nmethod* nm) { 78.44 - if (nm == NULL) { 78.45 - assert(_cb != NULL && _cb->is_nmethod() && 78.46 - nm->method()->is_native() && 78.47 - nm->method()->is_synchronized(), 78.48 - "should not call this otherwise"); 78.49 - nm = (nmethod*) _cb; 78.50 - } 78.51 - int byte_offset = in_bytes(nm->compiled_synchronized_native_basic_lock_owner_sp_offset()); 78.52 +oop frame::get_native_receiver() { 78.53 + nmethod* nm = (nmethod*)_cb; 78.54 + assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(), 78.55 + "Should not call this unless it's a native nmethod"); 78.56 + int byte_offset = in_bytes(nm->native_receiver_sp_offset()); 78.57 assert(byte_offset >= 0, "should not see invalid offset"); 78.58 oop owner = ((oop*) sp())[byte_offset / wordSize]; 78.59 assert( Universe::heap()->is_in(owner), "bad receiver" );
79.1 --- a/src/share/vm/runtime/frame.hpp Thu Jan 06 16:03:20 2011 -0800 79.2 +++ b/src/share/vm/runtime/frame.hpp Fri Jan 07 03:58:11 2011 -0800 79.3 @@ -254,10 +254,10 @@ 79.4 79.5 // Return the monitor owner and BasicLock for compiled synchronized 79.6 // native methods so that biased locking can revoke the receiver's 79.7 - // bias if necessary. Takes optional nmethod for this frame as 79.8 - // argument to avoid performing repeated lookups in code cache. 79.9 - BasicLock* compiled_synchronized_native_monitor (nmethod* nm = NULL); 79.10 - oop compiled_synchronized_native_monitor_owner(nmethod* nm = NULL); 79.11 + // bias if necessary. This is also used by JVMTI's GetLocalInstance method 79.12 + // (via VM_GetReceiver) to retrieve the receiver from a native wrapper frame. 79.13 + BasicLock* get_native_monitor(); 79.14 + oop get_native_receiver(); 79.15 79.16 // Find receiver for an invoke when arguments are just pushed on stack (i.e., callee stack-frame is 79.17 // not setup)
80.1 --- a/src/share/vm/runtime/vframe_hp.cpp Thu Jan 06 16:03:20 2011 -0800 80.2 +++ b/src/share/vm/runtime/vframe_hp.cpp Fri Jan 07 03:58:11 2011 -0800 80.3 @@ -207,8 +207,8 @@ 80.4 GrowableArray<MonitorInfo*> *monitors = new GrowableArray<MonitorInfo*>(1); 80.5 // Casting away const 80.6 frame& fr = (frame&) _fr; 80.7 - MonitorInfo* info = new MonitorInfo(fr.compiled_synchronized_native_monitor_owner(nm), 80.8 - fr.compiled_synchronized_native_monitor(nm), false, false); 80.9 + MonitorInfo* info = new MonitorInfo( 80.10 + fr.get_native_receiver(), fr.get_native_monitor(), false, false); 80.11 monitors->push(info); 80.12 return monitors; 80.13 }
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/src/share/vm/utilities/decoder.cpp Fri Jan 07 03:58:11 2011 -0800 81.3 @@ -0,0 +1,104 @@ 81.4 +/* 81.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 81.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 81.7 + * 81.8 + * This code is free software; you can redistribute it and/or modify it 81.9 + * under the terms of the GNU General Public License version 2 only, as 81.10 + * published by the Free Software Foundation. 81.11 + * 81.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 81.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 81.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 81.15 + * version 2 for more details (a copy is included in the LICENSE file that 81.16 + * accompanied this code). 81.17 + * 81.18 + * You should have received a copy of the GNU General Public License version 81.19 + * 2 along with this work; if not, write to the Free Software Foundation, 81.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 81.21 + * 81.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 81.23 + * or visit www.oracle.com if you need additional information or have any 81.24 + * questions. 81.25 + * 81.26 + */ 81.27 + 81.28 +#include "precompiled.hpp" 81.29 +#include "prims/jvm.h" 81.30 +#include "utilities/decoder.hpp" 81.31 + 81.32 +Decoder::decoder_status Decoder::_decoder_status = Decoder::no_error; 81.33 +bool Decoder::_initialized = false; 81.34 + 81.35 +#ifndef _WINDOWS 81.36 + 81.37 +// Implementation of common functionalities among Solaris and Linux 81.38 +#include "utilities/elfFile.hpp" 81.39 + 81.40 +ElfFile* Decoder::_opened_elf_files = NULL; 81.41 + 81.42 +bool Decoder::can_decode_C_frame_in_vm() { 81.43 + return true; 81.44 +} 81.45 + 81.46 +void Decoder::initialize() { 81.47 + _initialized = true; 81.48 +} 81.49 + 81.50 +void Decoder::uninitialize() { 81.51 + if (_opened_elf_files != NULL) { 81.52 + delete _opened_elf_files; 81.53 + _opened_elf_files = NULL; 81.54 + } 81.55 + _initialized = false; 81.56 +} 81.57 + 81.58 +Decoder::decoder_status Decoder::decode(address addr, const char* filepath, char *buf, int buflen, int *offset) { 81.59 + if (_decoder_status != no_error) { 81.60 + return _decoder_status; 81.61 + } 81.62 + 81.63 + ElfFile* file = get_elf_file(filepath); 81.64 + if (_decoder_status != no_error) { 81.65 + return _decoder_status; 81.66 + } 81.67 + 81.68 + const char* symbol = file->decode(addr, offset); 81.69 + if (file->get_status() == out_of_memory) { 81.70 + _decoder_status = out_of_memory; 81.71 + return _decoder_status; 81.72 + } else if (symbol != NULL) { 81.73 + if (!demangle(symbol, buf, buflen)) { 81.74 + jio_snprintf(buf, buflen, "%s", symbol); 81.75 + } 81.76 + return no_error; 81.77 + } else { 81.78 + return symbol_not_found; 81.79 + } 81.80 +} 81.81 + 81.82 +ElfFile* Decoder::get_elf_file(const char* filepath) { 81.83 + if (_decoder_status != no_error) { 81.84 + return NULL; 81.85 + } 81.86 + ElfFile* file = _opened_elf_files; 81.87 + while (file != NULL) { 81.88 + if (file->same_elf_file(filepath)) { 81.89 + return file; 81.90 + } 81.91 + file = file->m_next; 81.92 + } 81.93 + 81.94 + file = new ElfFile(filepath); 81.95 + if (file == NULL) { 81.96 + _decoder_status = out_of_memory; 81.97 + } 81.98 + if (_opened_elf_files != NULL) { 81.99 + file->m_next = _opened_elf_files; 81.100 + } 81.101 + 81.102 + _opened_elf_files = file; 81.103 + return file; 81.104 +} 81.105 + 81.106 +#endif 81.107 +
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/src/share/vm/utilities/decoder.hpp Fri Jan 07 03:58:11 2011 -0800 82.3 @@ -0,0 +1,102 @@ 82.4 +/* 82.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 82.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 82.7 + * 82.8 + * This code is free software; you can redistribute it and/or modify it 82.9 + * under the terms of the GNU General Public License version 2 only, as 82.10 + * published by the Free Software Foundation. 82.11 + * 82.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 82.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 82.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 82.15 + * version 2 for more details (a copy is included in the LICENSE file that 82.16 + * accompanied this code). 82.17 + * 82.18 + * You should have received a copy of the GNU General Public License version 82.19 + * 2 along with this work; if not, write to the Free Software Foundation, 82.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 82.21 + * 82.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 82.23 + * or visit www.oracle.com if you need additional information or have any 82.24 + * questions. 82.25 + * 82.26 + */ 82.27 + 82.28 + 82.29 +#ifndef __DECODER_HPP 82.30 +#define __DECODER_HPP 82.31 + 82.32 +#include "memory/allocation.hpp" 82.33 + 82.34 +#ifdef _WINDOWS 82.35 +#include <windows.h> 82.36 +#include <imagehlp.h> 82.37 + 82.38 +// functions needed for decoding symbols 82.39 +typedef DWORD (WINAPI *pfn_SymSetOptions)(DWORD); 82.40 +typedef BOOL (WINAPI *pfn_SymInitialize)(HANDLE, PCTSTR, BOOL); 82.41 +typedef BOOL (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64); 82.42 +typedef DWORD (WINAPI *pfn_UndecorateSymbolName)(const char*, char*, DWORD, DWORD); 82.43 + 82.44 +#else 82.45 + 82.46 +class ElfFile; 82.47 + 82.48 +#endif // _WINDOWS 82.49 + 82.50 + 82.51 +class Decoder: public StackObj { 82.52 + 82.53 + public: 82.54 + // status code for decoding native C frame 82.55 + enum decoder_status { 82.56 + no_error, // successfully decoded frames 82.57 + out_of_memory, // out of memory 82.58 + file_invalid, // invalid elf file 82.59 + file_not_found, // could not found symbol file (on windows), such as jvm.pdb or jvm.map 82.60 + helper_not_found, // could not load dbghelp.dll (Windows only) 82.61 + helper_func_error, // decoding functions not found (Windows only) 82.62 + helper_init_error, // SymInitialize failed (Windows only) 82.63 + symbol_not_found // could not find the symbol 82.64 + }; 82.65 + 82.66 + public: 82.67 + Decoder() { initialize(); }; 82.68 + ~Decoder() { uninitialize(); }; 82.69 + 82.70 + static bool can_decode_C_frame_in_vm(); 82.71 + 82.72 + static void initialize(); 82.73 + static void uninitialize(); 82.74 + 82.75 +#ifdef _WINDOWS 82.76 + static decoder_status decode(address addr, char *buf, int buflen, int *offset); 82.77 +#else 82.78 + static decoder_status decode(address addr, const char* filepath, char *buf, int buflen, int *offset); 82.79 +#endif 82.80 + 82.81 + static bool demangle(const char* symbol, char *buf, int buflen); 82.82 + 82.83 + static decoder_status get_status() { return _decoder_status; }; 82.84 + 82.85 +#ifndef _WINDOWS 82.86 + private: 82.87 + static ElfFile* get_elf_file(const char* filepath); 82.88 +#endif // _WINDOWS 82.89 + 82.90 + 82.91 + private: 82.92 + static decoder_status _decoder_status; 82.93 + static bool _initialized; 82.94 + 82.95 +#ifdef _WINDOWS 82.96 + static HMODULE _dbghelp_handle; 82.97 + static bool _can_decode_in_vm; 82.98 + static pfn_SymGetSymFromAddr64 _pfnSymGetSymFromAddr64; 82.99 + static pfn_UndecorateSymbolName _pfnUndecorateSymbolName; 82.100 +#else 82.101 + static ElfFile* _opened_elf_files; 82.102 +#endif // _WINDOWS 82.103 +}; 82.104 + 82.105 +#endif // __DECODER_HPP
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 83.2 +++ b/src/share/vm/utilities/elfFile.cpp Fri Jan 07 03:58:11 2011 -0800 83.3 @@ -0,0 +1,198 @@ 83.4 +/* 83.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 83.7 + * 83.8 + * This code is free software; you can redistribute it and/or modify it 83.9 + * under the terms of the GNU General Public License version 2 only, as 83.10 + * published by the Free Software Foundation. 83.11 + * 83.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 83.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 83.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 83.15 + * version 2 for more details (a copy is included in the LICENSE file that 83.16 + * accompanied this code). 83.17 + * 83.18 + * You should have received a copy of the GNU General Public License version 83.19 + * 2 along with this work; if not, write to the Free Software Foundation, 83.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 83.21 + * 83.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 83.23 + * or visit www.oracle.com if you need additional information or have any 83.24 + * questions. 83.25 + * 83.26 + */ 83.27 + 83.28 +#include "precompiled.hpp" 83.29 + 83.30 +#ifndef _WINDOWS 83.31 + 83.32 +#include <string.h> 83.33 +#include <stdio.h> 83.34 +#include <limits.h> 83.35 + 83.36 +#include "memory/allocation.inline.hpp" 83.37 +#include "utilities/decoder.hpp" 83.38 +#include "utilities/elfFile.hpp" 83.39 +#include "utilities/elfStringTable.hpp" 83.40 +#include "utilities/elfSymbolTable.hpp" 83.41 + 83.42 + 83.43 +ElfFile::ElfFile(const char* filepath) { 83.44 + assert(filepath, "null file path"); 83.45 + memset(&m_elfHdr, 0, sizeof(m_elfHdr)); 83.46 + m_string_tables = NULL; 83.47 + m_symbol_tables = NULL; 83.48 + m_next = NULL; 83.49 + m_status = Decoder::no_error; 83.50 + 83.51 + int len = strlen(filepath) + 1; 83.52 + m_filepath = NEW_C_HEAP_ARRAY(char, len); 83.53 + if (m_filepath != NULL) { 83.54 + strcpy((char*)m_filepath, filepath); 83.55 + m_file = fopen(filepath, "r"); 83.56 + if (m_file != NULL) { 83.57 + load_tables(); 83.58 + } else { 83.59 + m_status = Decoder::file_not_found; 83.60 + } 83.61 + } else { 83.62 + m_status = Decoder::out_of_memory; 83.63 + } 83.64 +} 83.65 + 83.66 +ElfFile::~ElfFile() { 83.67 + if (m_string_tables != NULL) { 83.68 + delete m_string_tables; 83.69 + } 83.70 + 83.71 + if (m_symbol_tables != NULL) { 83.72 + delete m_symbol_tables; 83.73 + } 83.74 + 83.75 + if (m_file != NULL) { 83.76 + fclose(m_file); 83.77 + } 83.78 + 83.79 + if (m_filepath != NULL) { 83.80 + FREE_C_HEAP_ARRAY(char, m_filepath); 83.81 + } 83.82 + 83.83 + if (m_next != NULL) { 83.84 + delete m_next; 83.85 + } 83.86 +}; 83.87 + 83.88 + 83.89 +//Check elf header to ensure the file is valid. 83.90 +bool ElfFile::is_elf_file(Elf_Ehdr& hdr) { 83.91 + return (ELFMAG0 == hdr.e_ident[EI_MAG0] && 83.92 + ELFMAG1 == hdr.e_ident[EI_MAG1] && 83.93 + ELFMAG2 == hdr.e_ident[EI_MAG2] && 83.94 + ELFMAG3 == hdr.e_ident[EI_MAG3] && 83.95 + ELFCLASSNONE != hdr.e_ident[EI_CLASS] && 83.96 + ELFDATANONE != hdr.e_ident[EI_DATA]); 83.97 +} 83.98 + 83.99 +bool ElfFile::load_tables() { 83.100 + assert(m_file, "file not open"); 83.101 + assert(m_status == Decoder::no_error, "already in error"); 83.102 + 83.103 + // read elf file header 83.104 + if (fread(&m_elfHdr, sizeof(m_elfHdr), 1, m_file) != 1) { 83.105 + m_status = Decoder::file_invalid; 83.106 + return false; 83.107 + } 83.108 + 83.109 + if (!is_elf_file(m_elfHdr)) { 83.110 + m_status = Decoder::file_invalid; 83.111 + return false; 83.112 + } 83.113 + 83.114 + // walk elf file's section headers, and load string tables 83.115 + Elf_Shdr shdr; 83.116 + if (!fseek(m_file, m_elfHdr.e_shoff, SEEK_SET)) { 83.117 + if (m_status != Decoder::no_error) return false; 83.118 + 83.119 + for (int index = 0; index < m_elfHdr.e_shnum; index ++) { 83.120 + if (fread((void*)&shdr, sizeof(Elf_Shdr), 1, m_file) != 1) { 83.121 + m_status = Decoder::file_invalid; 83.122 + return false; 83.123 + } 83.124 + // string table 83.125 + if (shdr.sh_type == SHT_STRTAB) { 83.126 + ElfStringTable* table = new ElfStringTable(m_file, shdr, index); 83.127 + if (table == NULL) { 83.128 + m_status = Decoder::out_of_memory; 83.129 + return false; 83.130 + } 83.131 + add_string_table(table); 83.132 + } else if (shdr.sh_type == SHT_SYMTAB || shdr.sh_type == SHT_DYNSYM) { 83.133 + ElfSymbolTable* table = new ElfSymbolTable(m_file, shdr); 83.134 + if (table == NULL) { 83.135 + m_status = Decoder::out_of_memory; 83.136 + return false; 83.137 + } 83.138 + add_symbol_table(table); 83.139 + } 83.140 + } 83.141 + } 83.142 + return true; 83.143 +} 83.144 + 83.145 +const char* ElfFile::decode(address addr, int* offset) { 83.146 + // something already went wrong, just give up 83.147 + if (m_status != Decoder::no_error) { 83.148 + return NULL; 83.149 + } 83.150 + 83.151 + ElfSymbolTable* symbol_table = m_symbol_tables; 83.152 + int string_table_index; 83.153 + int pos_in_string_table; 83.154 + int off = INT_MAX; 83.155 + bool found_symbol = false; 83.156 + while (symbol_table != NULL) { 83.157 + if (Decoder::no_error == symbol_table->lookup(addr, &string_table_index, &pos_in_string_table, &off)) { 83.158 + found_symbol = true; 83.159 + } 83.160 + symbol_table = symbol_table->m_next; 83.161 + } 83.162 + if (!found_symbol) return NULL; 83.163 + 83.164 + ElfStringTable* string_table = get_string_table(string_table_index); 83.165 + if (string_table == NULL) { 83.166 + m_status = Decoder::file_invalid; 83.167 + return NULL; 83.168 + } 83.169 + if (offset) *offset = off; 83.170 + return string_table->string_at(pos_in_string_table); 83.171 +} 83.172 + 83.173 + 83.174 +void ElfFile::add_symbol_table(ElfSymbolTable* table) { 83.175 + if (m_symbol_tables == NULL) { 83.176 + m_symbol_tables = table; 83.177 + } else { 83.178 + table->m_next = m_symbol_tables; 83.179 + m_symbol_tables = table; 83.180 + } 83.181 +} 83.182 + 83.183 +void ElfFile::add_string_table(ElfStringTable* table) { 83.184 + if (m_string_tables == NULL) { 83.185 + m_string_tables = table; 83.186 + } else { 83.187 + table->m_next = m_string_tables; 83.188 + m_string_tables = table; 83.189 + } 83.190 +} 83.191 + 83.192 +ElfStringTable* ElfFile::get_string_table(int index) { 83.193 + ElfStringTable* p = m_string_tables; 83.194 + while (p != NULL) { 83.195 + if (p->index() == index) return p; 83.196 + p = p->m_next; 83.197 + } 83.198 + return NULL; 83.199 +} 83.200 + 83.201 +#endif // _WINDOWS
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 84.2 +++ b/src/share/vm/utilities/elfFile.hpp Fri Jan 07 03:58:11 2011 -0800 84.3 @@ -0,0 +1,140 @@ 84.4 +/* 84.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 84.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 84.7 + * 84.8 + * This code is free software; you can redistribute it and/or modify it 84.9 + * under the terms of the GNU General Public License version 2 only, as 84.10 + * published by the Free Software Foundation. 84.11 + * 84.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 84.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 84.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 84.15 + * version 2 for more details (a copy is included in the LICENSE file that 84.16 + * accompanied this code). 84.17 + * 84.18 + * You should have received a copy of the GNU General Public License version 84.19 + * 2 along with this work; if not, write to the Free Software Foundation, 84.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 84.21 + * 84.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 84.23 + * or visit www.oracle.com if you need additional information or have any 84.24 + * questions. 84.25 + * 84.26 + */ 84.27 + 84.28 +#ifndef __ELF_FILE_HPP 84.29 +#define __ELF_FILE_HPP 84.30 + 84.31 +#ifndef _WINDOWS 84.32 + 84.33 +#include <elf.h> 84.34 +#include <stdio.h> 84.35 + 84.36 +#ifdef _LP64 84.37 + 84.38 +typedef Elf64_Half Elf_Half; 84.39 +typedef Elf64_Word Elf_Word; 84.40 +typedef Elf64_Off Elf_Off; 84.41 +typedef Elf64_Addr Elf_Addr; 84.42 + 84.43 +typedef Elf64_Ehdr Elf_Ehdr; 84.44 +typedef Elf64_Shdr Elf_Shdr; 84.45 +typedef Elf64_Sym Elf_Sym; 84.46 + 84.47 +#define ELF_ST_TYPE ELF64_ST_TYPE 84.48 + 84.49 +#else 84.50 + 84.51 +typedef Elf32_Half Elf_Half; 84.52 +typedef Elf32_Word Elf_Word; 84.53 +typedef Elf32_Off Elf_Off; 84.54 +typedef Elf32_Addr Elf_Addr; 84.55 + 84.56 + 84.57 +typedef Elf32_Ehdr Elf_Ehdr; 84.58 +typedef Elf32_Shdr Elf_Shdr; 84.59 +typedef Elf32_Sym Elf_Sym; 84.60 + 84.61 +#define ELF_ST_TYPE ELF32_ST_TYPE 84.62 +#endif 84.63 + 84.64 +#include "globalDefinitions.hpp" 84.65 +#include "memory/allocation.hpp" 84.66 +#include "utilities/decoder.hpp" 84.67 + 84.68 + 84.69 +class ElfStringTable; 84.70 +class ElfSymbolTable; 84.71 + 84.72 + 84.73 +// On Solaris/Linux platforms, libjvm.so does contain all private symbols. 84.74 +// ElfFile is basically an elf file parser, which can lookup the symbol 84.75 +// that is the nearest to the given address. 84.76 +// Beware, this code is called from vm error reporting code, when vm is already 84.77 +// in "error" state, so there are scenarios, lookup will fail. We want this 84.78 +// part of code to be very defensive, and bait out if anything went wrong. 84.79 + 84.80 +class ElfFile: public CHeapObj { 84.81 + friend class Decoder; 84.82 + public: 84.83 + ElfFile(const char* filepath); 84.84 + ~ElfFile(); 84.85 + 84.86 + const char* decode(address addr, int* offset); 84.87 + const char* filepath() { 84.88 + return m_filepath; 84.89 + } 84.90 + 84.91 + bool same_elf_file(const char* filepath) { 84.92 + assert(filepath, "null file path"); 84.93 + assert(m_filepath, "already out of memory"); 84.94 + return (m_filepath && !strcmp(filepath, m_filepath)); 84.95 + } 84.96 + 84.97 + Decoder::decoder_status get_status() { 84.98 + return m_status; 84.99 + } 84.100 + 84.101 + private: 84.102 + // sanity check, if the file is a real elf file 84.103 + bool is_elf_file(Elf_Ehdr&); 84.104 + 84.105 + // load string tables from the elf file 84.106 + bool load_tables(); 84.107 + 84.108 + // string tables are stored in a linked list 84.109 + void add_string_table(ElfStringTable* table); 84.110 + 84.111 + // symbol tables are stored in a linked list 84.112 + void add_symbol_table(ElfSymbolTable* table); 84.113 + 84.114 + // return a string table at specified section index 84.115 + ElfStringTable* get_string_table(int index); 84.116 + 84.117 + // look up an address and return the nearest symbol 84.118 + const char* look_up(Elf_Shdr shdr, address addr, int* offset); 84.119 + 84.120 + protected: 84.121 + ElfFile* m_next; 84.122 + 84.123 + private: 84.124 + // file 84.125 + const char* m_filepath; 84.126 + FILE* m_file; 84.127 + 84.128 + // Elf header 84.129 + Elf_Ehdr m_elfHdr; 84.130 + 84.131 + // symbol tables 84.132 + ElfSymbolTable* m_symbol_tables; 84.133 + 84.134 + // string tables 84.135 + ElfStringTable* m_string_tables; 84.136 + 84.137 + Decoder::decoder_status m_status; 84.138 +}; 84.139 + 84.140 +#endif // _WINDOWS 84.141 + 84.142 +#endif // __ELF_FILE_HPP 84.143 +
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 85.2 +++ b/src/share/vm/utilities/elfStringTable.cpp Fri Jan 07 03:58:11 2011 -0800 85.3 @@ -0,0 +1,89 @@ 85.4 +/* 85.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 85.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 85.7 + * 85.8 + * This code is free software; you can redistribute it and/or modify it 85.9 + * under the terms of the GNU General Public License version 2 only, as 85.10 + * published by the Free Software Foundation. 85.11 + * 85.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 85.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 85.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 85.15 + * version 2 for more details (a copy is included in the LICENSE file that 85.16 + * accompanied this code). 85.17 + * 85.18 + * You should have received a copy of the GNU General Public License version 85.19 + * 2 along with this work; if not, write to the Free Software Foundation, 85.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 85.21 + * 85.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 85.23 + * or visit www.oracle.com if you need additional information or have any 85.24 + * questions. 85.25 + * 85.26 + */ 85.27 + 85.28 +#include "precompiled.hpp" 85.29 + 85.30 +#ifndef _WINDOWS 85.31 + 85.32 +#include "memory/allocation.inline.hpp" 85.33 +#include "utilities/elfStringTable.hpp" 85.34 + 85.35 +// We will try to load whole string table into memory if we can. 85.36 +// Otherwise, fallback to more expensive file operation. 85.37 +ElfStringTable::ElfStringTable(FILE* file, Elf_Shdr shdr, int index) { 85.38 + assert(file, "null file handle"); 85.39 + m_table = NULL; 85.40 + m_index = index; 85.41 + m_next = NULL; 85.42 + m_file = file; 85.43 + m_status = Decoder::no_error; 85.44 + 85.45 + // try to load the string table 85.46 + long cur_offset = ftell(file); 85.47 + m_table = (char*)NEW_C_HEAP_ARRAY(char, shdr.sh_size); 85.48 + if (m_table != NULL) { 85.49 + // if there is an error, mark the error 85.50 + if (fseek(file, shdr.sh_offset, SEEK_SET) || 85.51 + fread((void*)m_table, shdr.sh_size, 1, file) != 1 || 85.52 + fseek(file, cur_offset, SEEK_SET)) { 85.53 + m_status = Decoder::file_invalid; 85.54 + FREE_C_HEAP_ARRAY(char, m_table); 85.55 + m_table = NULL; 85.56 + } 85.57 + } else { 85.58 + memcpy(&m_shdr, &shdr, sizeof(Elf_Shdr)); 85.59 + } 85.60 +} 85.61 + 85.62 +ElfStringTable::~ElfStringTable() { 85.63 + if (m_table != NULL) { 85.64 + FREE_C_HEAP_ARRAY(char, m_table); 85.65 + } 85.66 + 85.67 + if (m_next != NULL) { 85.68 + delete m_next; 85.69 + } 85.70 +} 85.71 + 85.72 +const char* ElfStringTable::string_at(int pos) { 85.73 + if (m_status != Decoder::no_error) { 85.74 + return NULL; 85.75 + } 85.76 + if (m_table != NULL) { 85.77 + return (const char*)(m_table + pos); 85.78 + } else { 85.79 + long cur_pos = ftell(m_file); 85.80 + if (cur_pos == -1 || 85.81 + fseek(m_file, m_shdr.sh_offset + pos, SEEK_SET) || 85.82 + fread(m_symbol, 1, MAX_SYMBOL_LEN, m_file) <= 0 || 85.83 + fseek(m_file, cur_pos, SEEK_SET)) { 85.84 + m_status = Decoder::file_invalid; 85.85 + return NULL; 85.86 + } 85.87 + return (const char*)m_symbol; 85.88 + } 85.89 +} 85.90 + 85.91 +#endif // _WINDOWS 85.92 +
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/src/share/vm/utilities/elfStringTable.hpp Fri Jan 07 03:58:11 2011 -0800 86.3 @@ -0,0 +1,82 @@ 86.4 +/* 86.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 86.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 86.7 + * 86.8 + * This code is free software; you can redistribute it and/or modify it 86.9 + * under the terms of the GNU General Public License version 2 only, as 86.10 + * published by the Free Software Foundation. 86.11 + * 86.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 86.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 86.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 86.15 + * version 2 for more details (a copy is included in the LICENSE file that 86.16 + * accompanied this code). 86.17 + * 86.18 + * You should have received a copy of the GNU General Public License version 86.19 + * 2 along with this work; if not, write to the Free Software Foundation, 86.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 86.21 + * 86.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 86.23 + * or visit www.oracle.com if you need additional information or have any 86.24 + * questions. 86.25 + * 86.26 + */ 86.27 + 86.28 +#ifndef __ELF_STRING_TABLE_HPP 86.29 +#define __ELF_STRING_TABLE_HPP 86.30 + 86.31 +#ifndef _WINDOWS 86.32 + 86.33 +#include "memory/allocation.hpp" 86.34 +#include "utilities/decoder.hpp" 86.35 +#include "utilities/elfFile.hpp" 86.36 + 86.37 + 86.38 +// The string table represents a string table section in an elf file. 86.39 +// Whenever there is enough memory, it will load whole string table as 86.40 +// one blob. Otherwise, it will load string from file when requested. 86.41 + 86.42 +#define MAX_SYMBOL_LEN 256 86.43 + 86.44 +class ElfStringTable: CHeapObj { 86.45 + friend class ElfFile; 86.46 + public: 86.47 + ElfStringTable(FILE* file, Elf_Shdr shdr, int index); 86.48 + ~ElfStringTable(); 86.49 + 86.50 + // section index 86.51 + int index() { return m_index; }; 86.52 + 86.53 + // get string at specified offset 86.54 + const char* string_at(int offset); 86.55 + 86.56 + // get status code 86.57 + Decoder::decoder_status get_status() { return m_status; }; 86.58 + 86.59 + protected: 86.60 + ElfStringTable* m_next; 86.61 + 86.62 + // section index 86.63 + int m_index; 86.64 + 86.65 + // holds complete string table if can 86.66 + // allocate enough memory 86.67 + const char* m_table; 86.68 + 86.69 + // file contains string table 86.70 + FILE* m_file; 86.71 + 86.72 + // section header 86.73 + Elf_Shdr m_shdr; 86.74 + 86.75 + // buffer for reading individual string 86.76 + char m_symbol[MAX_SYMBOL_LEN]; 86.77 + 86.78 + // error code 86.79 + Decoder::decoder_status m_status; 86.80 +}; 86.81 + 86.82 +#endif // _WINDOWS 86.83 + 86.84 +#endif // __ELF_STRING_TABLE_HPP 86.85 +
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 87.2 +++ b/src/share/vm/utilities/elfSymbolTable.cpp Fri Jan 07 03:58:11 2011 -0800 87.3 @@ -0,0 +1,125 @@ 87.4 +/* 87.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 87.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 87.7 + * 87.8 + * This code is free software; you can redistribute it and/or modify it 87.9 + * under the terms of the GNU General Public License version 2 only, as 87.10 + * published by the Free Software Foundation. 87.11 + * 87.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 87.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 87.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 87.15 + * version 2 for more details (a copy is included in the LICENSE file that 87.16 + * accompanied this code). 87.17 + * 87.18 + * You should have received a copy of the GNU General Public License version 87.19 + * 2 along with this work; if not, write to the Free Software Foundation, 87.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 87.21 + * 87.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 87.23 + * or visit www.oracle.com if you need additional information or have any 87.24 + * questions. 87.25 + * 87.26 + */ 87.27 + 87.28 +#include "precompiled.hpp" 87.29 + 87.30 +#ifndef _WINDOWS 87.31 + 87.32 +#include "memory/allocation.inline.hpp" 87.33 +#include "utilities/elfSymbolTable.hpp" 87.34 + 87.35 +ElfSymbolTable::ElfSymbolTable(FILE* file, Elf_Shdr shdr) { 87.36 + assert(file, "null file handle"); 87.37 + m_symbols = NULL; 87.38 + m_next = NULL; 87.39 + m_file = file; 87.40 + m_status = Decoder::no_error; 87.41 + 87.42 + // try to load the string table 87.43 + long cur_offset = ftell(file); 87.44 + if (cur_offset != -1) { 87.45 + m_symbols = (Elf_Sym*)NEW_C_HEAP_ARRAY(char, shdr.sh_size); 87.46 + if (m_symbols) { 87.47 + if (fseek(file, shdr.sh_offset, SEEK_SET) || 87.48 + fread((void*)m_symbols, shdr.sh_size, 1, file) != 1 || 87.49 + fseek(file, cur_offset, SEEK_SET)) { 87.50 + m_status = Decoder::file_invalid; 87.51 + FREE_C_HEAP_ARRAY(char, m_symbols); 87.52 + m_symbols = NULL; 87.53 + } 87.54 + } 87.55 + if (m_status == Decoder::no_error) { 87.56 + memcpy(&m_shdr, &shdr, sizeof(Elf_Shdr)); 87.57 + } 87.58 + } else { 87.59 + m_status = Decoder::file_invalid; 87.60 + } 87.61 +} 87.62 + 87.63 +ElfSymbolTable::~ElfSymbolTable() { 87.64 + if (m_symbols != NULL) { 87.65 + FREE_C_HEAP_ARRAY(char, m_symbols); 87.66 + } 87.67 + 87.68 + if (m_next != NULL) { 87.69 + delete m_next; 87.70 + } 87.71 +} 87.72 + 87.73 +Decoder::decoder_status ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex, int* offset) { 87.74 + assert(stringtableIndex, "null string table index pointer"); 87.75 + assert(posIndex, "null string table offset pointer"); 87.76 + assert(offset, "null offset pointer"); 87.77 + 87.78 + if (m_status != Decoder::no_error) { 87.79 + return m_status; 87.80 + } 87.81 + 87.82 + address pc = 0; 87.83 + size_t sym_size = sizeof(Elf_Sym); 87.84 + assert((m_shdr.sh_size % sym_size) == 0, "check size"); 87.85 + int count = m_shdr.sh_size / sym_size; 87.86 + if (m_symbols != NULL) { 87.87 + for (int index = 0; index < count; index ++) { 87.88 + if (STT_FUNC == ELF_ST_TYPE(m_symbols[index].st_info)) { 87.89 + address sym_addr = (address)m_symbols[index].st_value; 87.90 + if (sym_addr < addr && (addr - sym_addr) < *offset) { 87.91 + pc = (address)m_symbols[index].st_value; 87.92 + *offset = (int)(addr - pc); 87.93 + *posIndex = m_symbols[index].st_name; 87.94 + *stringtableIndex = m_shdr.sh_link; 87.95 + } 87.96 + } 87.97 + } 87.98 + } else { 87.99 + long cur_pos; 87.100 + if ((cur_pos = ftell(m_file)) == -1 || 87.101 + fseek(m_file, m_shdr.sh_offset, SEEK_SET)) { 87.102 + m_status = Decoder::file_invalid; 87.103 + return m_status; 87.104 + } 87.105 + 87.106 + Elf_Sym sym; 87.107 + for (int index = 0; index < count; index ++) { 87.108 + if (fread(&sym, sym_size, 1, m_file) == 1) { 87.109 + if (STT_FUNC == ELF_ST_TYPE(sym.st_info)) { 87.110 + address sym_addr = (address)sym.st_value; 87.111 + if (sym_addr < addr && (addr - sym_addr) < *offset) { 87.112 + pc = (address)sym.st_value; 87.113 + *offset = (int)(addr - pc); 87.114 + *posIndex = sym.st_name; 87.115 + *stringtableIndex = m_shdr.sh_link; 87.116 + } 87.117 + } 87.118 + } else { 87.119 + m_status = Decoder::file_invalid; 87.120 + return m_status; 87.121 + } 87.122 + } 87.123 + fseek(m_file, cur_pos, SEEK_SET); 87.124 + } 87.125 + return m_status; 87.126 +} 87.127 + 87.128 +#endif // _WINDOWS
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/src/share/vm/utilities/elfSymbolTable.hpp Fri Jan 07 03:58:11 2011 -0800 88.3 @@ -0,0 +1,73 @@ 88.4 +/* 88.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 88.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 88.7 + * 88.8 + * This code is free software; you can redistribute it and/or modify it 88.9 + * under the terms of the GNU General Public License version 2 only, as 88.10 + * published by the Free Software Foundation. 88.11 + * 88.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 88.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 88.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 88.15 + * version 2 for more details (a copy is included in the LICENSE file that 88.16 + * accompanied this code). 88.17 + * 88.18 + * You should have received a copy of the GNU General Public License version 88.19 + * 2 along with this work; if not, write to the Free Software Foundation, 88.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 88.21 + * 88.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 88.23 + * or visit www.oracle.com if you need additional information or have any 88.24 + * questions. 88.25 + * 88.26 + */ 88.27 + 88.28 +#ifndef __ELF_SYMBOL_TABLE_HPP 88.29 +#define __ELF_SYMBOL_TABLE_HPP 88.30 + 88.31 +#ifndef _WINDOWS 88.32 + 88.33 + 88.34 +#include "memory/allocation.hpp" 88.35 +#include "utilities/decoder.hpp" 88.36 +#include "utilities/elfFile.hpp" 88.37 + 88.38 +/* 88.39 + * symbol table object represents a symbol section in an elf file. 88.40 + * Whenever possible, it will load all symbols from the corresponding section 88.41 + * of the elf file into memory. Otherwise, it will walk the section in file 88.42 + * to look up the symbol that nearest the given address. 88.43 + */ 88.44 +class ElfSymbolTable: public CHeapObj { 88.45 + friend class ElfFile; 88.46 + public: 88.47 + ElfSymbolTable(FILE* file, Elf_Shdr shdr); 88.48 + ~ElfSymbolTable(); 88.49 + 88.50 + // search the symbol that is nearest to the specified address. 88.51 + Decoder::decoder_status lookup(address addr, int* stringtableIndex, int* posIndex, int* offset); 88.52 + 88.53 + Decoder::decoder_status get_status() { return m_status; }; 88.54 + 88.55 + protected: 88.56 + ElfSymbolTable* m_next; 88.57 + 88.58 + // holds a complete symbol table section if 88.59 + // can allocate enough memory 88.60 + Elf_Sym* m_symbols; 88.61 + 88.62 + // file contains string table 88.63 + FILE* m_file; 88.64 + 88.65 + // section header 88.66 + Elf_Shdr m_shdr; 88.67 + 88.68 + Decoder::decoder_status m_status; 88.69 +}; 88.70 + 88.71 +#endif // _WINDOWS 88.72 + 88.73 +#endif // __ELF_SYMBOL_TABLE_HPP 88.74 + 88.75 + 88.76 +
89.1 --- a/src/share/vm/utilities/vmError.cpp Thu Jan 06 16:03:20 2011 -0800 89.2 +++ b/src/share/vm/utilities/vmError.cpp Fri Jan 07 03:58:11 2011 -0800 89.3 @@ -33,6 +33,7 @@ 89.4 #include "runtime/vmThread.hpp" 89.5 #include "runtime/vm_operations.hpp" 89.6 #include "utilities/debug.hpp" 89.7 +#include "utilities/decoder.hpp" 89.8 #include "utilities/defaultStream.hpp" 89.9 #include "utilities/top.hpp" 89.10 #include "utilities/vmError.hpp" 89.11 @@ -516,8 +517,10 @@ 89.12 if (fr.pc()) { 89.13 st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)"); 89.14 89.15 + // initialize decoder to decode C frames 89.16 + Decoder decoder; 89.17 + 89.18 int count = 0; 89.19 - 89.20 while (count++ < StackPrintLimit) { 89.21 fr.print_on_error(st, buf, sizeof(buf)); 89.22 st->cr();