Mercurial > hg > openjdk > icedtea > jdk7 > hotspot
changeset 3599:a0c2fa4baeb6 hs23.2-b09
Merge
author | amurillo |
---|---|
date | Fri, 13 Jul 2012 13:29:49 -0700 |
parents | 0aea8f0afd27 (current diff) a4b60109cffc (diff) |
children | 1e31ae50c2cf |
files | |
diffstat | 10 files changed, 199 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java Wed Jul 11 11:22:49 2012 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java Fri Jul 13 13:29:49 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -141,18 +141,19 @@ public static String stringOopToString(Oop stringOop) { if (offsetField == null) { InstanceKlass k = (InstanceKlass) stringOop.getKlass(); - offsetField = (IntField) k.findField("offset", "I"); - countField = (IntField) k.findField("count", "I"); + offsetField = (IntField) k.findField("offset", "I"); // optional + countField = (IntField) k.findField("count", "I"); // optional valueField = (OopField) k.findField("value", "[C"); if (Assert.ASSERTS_ENABLED) { - Assert.that(offsetField != null && - countField != null && - valueField != null, "must find all java.lang.String fields"); + Assert.that(valueField != null, "Field \'value\' of java.lang.String not found"); } } - return charArrayToString((TypeArray) valueField.getValue(stringOop), - offsetField.getValue(stringOop), - countField.getValue(stringOop)); + if (offsetField != null && countField != null) { + return charArrayToString((TypeArray) valueField.getValue(stringOop), + offsetField.getValue(stringOop), + countField.getValue(stringOop)); + } + return charArrayToString((TypeArray) valueField.getValue(stringOop)); } public static String stringOopToEscapedString(Oop stringOop) {
--- a/agent/src/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java Wed Jul 11 11:22:49 2012 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java Fri Jul 13 13:29:49 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,21 @@ this(new ProcImageClassLoader()); } + static void debugPrintln(String msg) { + if (DEBUG) { + System.err.println("DEBUG>" + msg); + } + } + + static void debugPrintStackTrace(Exception exp) { + if (DEBUG) { + StackTraceElement[] els = exp.getStackTrace(); + for (int i = 0; i < els.length; i++) { + System.err.println("DEBUG>" + els[i].toString()); + } + } + } + public Object readObject(Oop oop) throws ClassNotFoundException { if (oop instanceof Instance) { return readInstance((Instance) oop); @@ -120,13 +135,96 @@ } protected Symbol javaLangString; + protected Symbol javaUtilHashtableEntry; + protected Symbol javaUtilHashtable; + protected Symbol javaUtilProperties; + + protected Symbol getVMSymbol(String name) { + return VM.getVM().getSymbolTable().probe(name); + } + protected Symbol javaLangString() { if (javaLangString == null) { - javaLangString = VM.getVM().getSymbolTable().probe("java/lang/String"); + javaLangString = getVMSymbol("java/lang/String"); } return javaLangString; } + protected Symbol javaUtilHashtableEntry() { + if (javaUtilHashtableEntry == null) { + javaUtilHashtableEntry = getVMSymbol("java/util/Hashtable$Entry"); + } + return javaUtilHashtableEntry; + } + + protected Symbol javaUtilHashtable() { + if (javaUtilHashtable == null) { + javaUtilHashtable = getVMSymbol("java/util/Hashtable"); + } + return javaUtilHashtable; + } + + protected Symbol javaUtilProperties() { + if (javaUtilProperties == null) { + javaUtilProperties = getVMSymbol("java/util/Properties"); + } + return javaUtilProperties; + } + + private void setHashtableEntry(java.util.Hashtable p, Oop oop) { + InstanceKlass ik = (InstanceKlass)oop.getKlass(); + OopField keyField = (OopField)ik.findField("key", "Ljava/lang/Object;"); + OopField valueField = (OopField)ik.findField("value", "Ljava/lang/Object;"); + OopField nextField = (OopField)ik.findField("next", "Ljava/util/Hashtable$Entry;"); + if (DEBUG) { + if (Assert.ASSERTS_ENABLED) { + Assert.that(ik.getName().equals(javaUtilHashtableEntry()), "Not a Hashtable$Entry?"); + Assert.that(keyField != null && valueField != null && nextField != null, "Invalid fields!"); + } + } + + Object key = null; + Object value = null; + Oop next = null; + try { + key = readObject(keyField.getValue(oop)); + value = readObject(valueField.getValue(oop)); + next = (Oop)nextField.getValue(oop); + // For Properties, should use setProperty(k, v). Since it only runs in SA + // using put(k, v) should be OK. + p.put(key, value); + if (next != null) { + setHashtableEntry(p, next); + } + } catch (ClassNotFoundException ce) { + if( DEBUG) { + debugPrintln("Class not found " + ce); + debugPrintStackTrace(ce); + } + } + } + + protected Object getHashtable(Instance oop, boolean isProperties) { + InstanceKlass k = (InstanceKlass)oop.getKlass(); + OopField tableField = (OopField)k.findField("table", "[Ljava/util/Hashtable$Entry;"); + if (tableField == null) { + debugPrintln("Could not find field of [Ljava/util/Hashtable$Entry;"); + return null; + } + java.util.Hashtable table = (isProperties) ? new java.util.Properties() + : new java.util.Hashtable(); + ObjArray kvs = (ObjArray)tableField.getValue(oop); + long size = kvs.getLength(); + debugPrintln("Hashtable$Entry Size = " + size); + for (long i=0; i<size; i++) { + Oop entry = kvs.getObjAt(i); + if (entry != null && entry.isInstance()) { + setHashtableEntry(table, entry); + } + } + return table; + } + public Object readInstance(Instance oop) throws ClassNotFoundException { Object result = getFromObjTable(oop); if (result == null) { @@ -134,11 +232,21 @@ // Handle java.lang.String instances differently. As part of JSR-133, fields of immutable // classes have been made final. The algorithm below will not be able to read Strings from // debuggee (can't use reflection to set final fields). But, need to read Strings is very - // important. FIXME: need a framework to handle many other special cases. + // important. + // Same for Hashtable, key and hash are final, could not be set in the algorithm too. + // FIXME: need a framework to handle many other special cases. if (kls.getName().equals(javaLangString())) { return OopUtilities.stringOopToString(oop); } + if (kls.getName().equals(javaUtilHashtable())) { + return getHashtable(oop, false); + } + + if (kls.getName().equals(javaUtilProperties())) { + return getHashtable(oop, true); + } + Class clz = readClass(kls); try { result = clz.newInstance(); @@ -164,8 +272,8 @@ break; } catch (Exception exp) { if (DEBUG) { - System.err.println("Can't create object using " + c); - exp.printStackTrace(); + debugPrintln("Can't create object using " + c); + debugPrintStackTrace(exp); } } } @@ -329,8 +437,8 @@ arrayObj[ifd.getIndex()] = readObject(field.getValue(getObj())); } catch (Exception e) { if (DEBUG) { - System.err.println("Array element set failed for " + ifd); - e.printStackTrace(); + debugPrintln("Array element set failed for " + ifd); + debugPrintStackTrace(e); } } } @@ -348,8 +456,8 @@ private void printFieldSetError(java.lang.reflect.Field f, Exception ex) { if (DEBUG) { - if (f != null) System.err.println("Field set failed for " + f); - ex.printStackTrace(); + if (f != null) debugPrintln("Field set failed for " + f); + debugPrintStackTrace(ex); } } @@ -601,7 +709,7 @@ return Class.forName(className, true, cl); } catch (Exception e) { if (DEBUG) { - System.err.println("Can't load class " + className); + debugPrintln("Can't load class " + className); } throw new RuntimeException(e); }
--- a/make/hotspot_version Wed Jul 11 11:22:49 2012 -0700 +++ b/make/hotspot_version Fri Jul 13 13:29:49 2012 -0700 @@ -35,7 +35,7 @@ HS_MAJOR_VER=23 HS_MINOR_VER=2 -HS_BUILD_NUMBER=08 +HS_BUILD_NUMBER=09 JDK_MAJOR_VER=1 JDK_MINOR_VER=7
--- a/make/pic.make Wed Jul 11 11:22:49 2012 -0700 +++ b/make/pic.make Fri Jul 13 13:29:49 2012 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,13 @@ ifneq ($(OSNAME), windows) ifndef LP64 + PARTIAL_NONPIC=1 + endif + PIC_ARCH = ppc + ifneq ("$(filter $(PIC_ARCH),$(BUILDARCH))","") + PARTIAL_NONPIC=0 + endif + ifeq ($(PARTIAL_NONPIC),1) NONPIC_DIRS = memory oops gc_implementation gc_interface NONPIC_DIRS := $(foreach dir,$(NONPIC_DIRS), $(GAMMADIR)/src/share/vm/$(dir)) # Look for source files under NONPIC_DIRS
--- a/src/share/vm/classfile/symbolTable.cpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/classfile/symbolTable.cpp Fri Jul 13 13:29:49 2012 -0700 @@ -40,7 +40,6 @@ SymbolTable* SymbolTable::_the_table = NULL; bool SymbolTable::_needs_rehashing = false; -jint SymbolTable::_seed = 0; Symbol* SymbolTable::allocate_symbol(const u1* name, int len, TRAPS) { assert (len <= Symbol::max_length(), "should be checked by caller"); @@ -112,12 +111,6 @@ } } -unsigned int SymbolTable::new_hash(Symbol* sym) { - ResourceMark rm; - // Use alternate hashing algorithm on this symbol. - return AltHashing::murmur3_32(seed(), (const jbyte*)sym->as_C_string(), sym->utf8_length()); -} - // Create a new table and using alternate hash code, populate the new table // with the existing strings. Set flag to use the alternate hash code afterwards. void SymbolTable::rehash_table() { @@ -127,10 +120,6 @@ // Create a new symbol table SymbolTable* new_table = new SymbolTable(); - // Initialize the global seed for hashing. - _seed = AltHashing::compute_seed(); - assert(seed() != 0, "shouldn't be zero"); - the_table()->move_to(new_table); // Delete the table and buckets (entries are reused in new table). @@ -582,7 +571,6 @@ StringTable* StringTable::_the_table = NULL; bool StringTable::_needs_rehashing = false; -jint StringTable::_seed = 0; // Pick hashing algorithm unsigned int StringTable::hash_string(const jchar* s, int len) { @@ -799,14 +787,6 @@ } -unsigned int StringTable::new_hash(oop string) { - ResourceMark rm; - int length; - jchar* chars = java_lang_String::as_unicode_string(string, length); - // Use alternate hashing algorithm on the string - return AltHashing::murmur3_32(seed(), chars, length); -} - // Create a new table and using alternate hash code, populate the new table // with the existing strings. Set flag to use the alternate hash code afterwards. void StringTable::rehash_table() { @@ -815,10 +795,6 @@ if (DumpSharedSpaces) return; StringTable* new_table = new StringTable(); - // Initialize new global seed for hashing. - _seed = AltHashing::compute_seed(); - assert(seed() != 0, "shouldn't be zero"); - // Rehash the table the_table()->move_to(new_table);
--- a/src/share/vm/classfile/symbolTable.hpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/classfile/symbolTable.hpp Fri Jul 13 13:29:49 2012 -0700 @@ -81,7 +81,6 @@ // Set if one bucket is out of balance due to hash algorithm deficiency static bool _needs_rehashing; - static jint _seed; // For statistics static int symbols_removed; @@ -118,10 +117,6 @@ : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t, number_of_entries) {} - static bool use_alternate_hashcode() { return _seed != 0; } - static jint seed() { return _seed; } - - unsigned int new_hash(Symbol* sym); public: enum { symbol_alloc_batch_size = 8 @@ -232,7 +227,6 @@ // Set if one bucket is out of balance due to hash algorithm deficiency static bool _needs_rehashing; - static jint _seed; static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS); oop basic_add(int index, Handle string_or_null, jchar* name, int len, @@ -246,11 +240,6 @@ StringTable(HashtableBucket* t, int number_of_entries) : Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t, number_of_entries) {} - - static bool use_alternate_hashcode() { return _seed != 0; } - static jint seed() { return _seed; } - - unsigned int new_hash(oop s); public: // The string table static StringTable* the_table() { return _the_table; }
--- a/src/share/vm/compiler/compilerOracle.cpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/compiler/compilerOracle.cpp Fri Jul 13 13:29:49 2012 -0700 @@ -550,10 +550,12 @@ } } +static const char* default_cc_file = ".hotspot_compiler"; + static const char* cc_file() { #ifdef ASSERT if (CompileCommandFile == NULL) { - return ".hotspot_compiler"; + return default_cc_file; } #endif return CompileCommandFile; @@ -637,10 +639,17 @@ CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only); if (CompilerOracle::has_command_file()) { CompilerOracle::parse_from_file(); + } else { + struct stat buf; + if (os::stat(default_cc_file, &buf) == 0) { + warning("%s file is present but has been ignored. " + "Run with -XX:CompileCommandFile=%s to load the file.", + default_cc_file, default_cc_file); + } } if (lists[PrintCommand] != NULL) { if (PrintAssembly) { - warning("CompileCommand and/or .hotspot_compiler file contains 'print' commands, but PrintAssembly is also enabled"); + warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file); } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) { warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output"); DebugNonSafepoints = true;
--- a/src/share/vm/runtime/arguments.cpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/runtime/arguments.cpp Fri Jul 13 13:29:49 2012 -0700 @@ -2955,7 +2955,10 @@ const char* tail; // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. + const char* hotspotrc = ".hotspotrc"; bool settings_file_specified = false; + bool needs_hotspotrc_warning = false; + const char* flags_file; int index; for (index = 0; index < args->nOptions; index++) { @@ -2999,16 +3002,19 @@ if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) { return JNI_EINVAL; } - } - + } else { #ifdef ASSERT - // Parse default .hotspotrc settings file - if (!settings_file_specified) { + // Parse default .hotspotrc settings file if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) { return JNI_EINVAL; } +#else + struct stat buf; + if (os::stat(hotspotrc, &buf) == 0) { + needs_hotspotrc_warning = true; + } +#endif } -#endif if (PrintVMOptions) { for (index = 0; index < args->nOptions; index++) { @@ -3025,6 +3031,14 @@ return result; } + // Delay warning until here so that we've had a chance to process + // the -XX:-PrintWarnings flag + if (needs_hotspotrc_warning) { + warning("%s file is present but has been ignored. " + "Run with -XX:Flags=%s to load the file.", + hotspotrc, hotspotrc); + } + #if (defined JAVASE_EMBEDDED || defined ARM) UNSUPPORTED_OPTION(UseG1GC, "G1 GC"); #endif
--- a/src/share/vm/utilities/hashtable.cpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/utilities/hashtable.cpp Fri Jul 13 13:29:49 2012 -0700 @@ -23,6 +23,8 @@ */ #include "precompiled.hpp" +#include "classfile/altHashing.hpp" +#include "classfile/javaClasses.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" #include "memory/resourceArea.hpp" @@ -103,12 +105,33 @@ return false; } +template <class T> jint Hashtable<T>::_seed = 0; + +template <class T> unsigned int Hashtable<T>::new_hash(Symbol* sym) { + ResourceMark rm; + // Use alternate hashing algorithm on this symbol. + return AltHashing::murmur3_32(seed(), (const jbyte*)sym->as_C_string(), sym->utf8_length()); +} + +template <class T> unsigned int Hashtable<T>::new_hash(oop string) { + ResourceMark rm; + int length; + jchar* chars = java_lang_String::as_unicode_string(string, length); + // Use alternate hashing algorithm on the string + return AltHashing::murmur3_32(seed(), chars, length); +} + // Create a new table and using alternate hash code, populate the new table // with the existing elements. This can be used to change the hash code // and could in the future change the size of the table. template <class T> void Hashtable<T>::move_to(Hashtable<T>* new_table) { - int saved_entry_count = number_of_entries(); + + // Initialize the global seed for hashing. + _seed = AltHashing::compute_seed(); + assert(seed() != 0, "shouldn't be zero"); + + int saved_entry_count = this->number_of_entries(); // Iterate through the table and create a new entry for the new table for (int i = 0; i < new_table->table_size(); ++i) {
--- a/src/share/vm/utilities/hashtable.hpp Wed Jul 11 11:22:49 2012 -0700 +++ b/src/share/vm/utilities/hashtable.hpp Fri Jul 13 13:29:49 2012 -0700 @@ -278,7 +278,14 @@ // Function to move these elements into the new table. void move_to(Hashtable<T>* new_table); - virtual unsigned int new_hash(T) { ShouldNotReachHere(); return 0; } // should be overridden + static bool use_alternate_hashcode() { return _seed != 0; } + static jint seed() { return _seed; } + + private: + static jint _seed; + + unsigned int new_hash(Symbol* s); + unsigned int new_hash(oop string); };