--- a/hotspot/src/share/vm/classfile/symbolTable.hpp Mon Nov 12 16:15:05 2012 -0500
+++ b/hotspot/src/share/vm/classfile/symbolTable.hpp Tue Nov 13 15:14:27 2012 -0500
@@ -262,19 +262,14 @@
// The string table
static StringTable* the_table() { return _the_table; }
+ // Size of one bucket in the string table. Used when checking for rollover.
+ static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
+
static void create_table() {
assert(_the_table == NULL, "One string table allowed.");
_the_table = new StringTable();
}
- static void create_table(HashtableBucket<mtSymbol>* t, int length,
- int number_of_entries) {
- assert(_the_table == NULL, "One string table allowed.");
- assert((size_t)length == StringTableSize * sizeof(HashtableBucket<mtSymbol>),
- "bad shared string size.");
- _the_table = new StringTable(t, number_of_entries);
- }
-
// GC support
// Delete pointers to otherwise-unreachable objects.
static void unlink(BoolObjectClosure* cl);
--- a/hotspot/src/share/vm/runtime/arguments.cpp Mon Nov 12 16:15:05 2012 -0500
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Tue Nov 13 15:14:27 2012 -0500
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "classfile/javaAssertions.hpp"
+#include "classfile/symbolTable.hpp"
#include "compiler/compilerOracle.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/cardTableRS.hpp"
@@ -1844,6 +1845,11 @@
status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
+ // Divide by bucket size to prevent a large size from causing rollover when
+ // calculating amount of memory needed to be allocated for the String table.
+ status = status && verify_interval(StringTableSize, defaultStringTableSize,
+ (max_uintx / StringTable::bucket_size()), "StringTable size");
+
if (MinHeapFreeRatio > MaxHeapFreeRatio) {
jio_fprintf(defaultStream::error_stream(),
"MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
--- a/hotspot/src/share/vm/runtime/globals.hpp Mon Nov 12 16:15:05 2012 -0500
+++ b/hotspot/src/share/vm/runtime/globals.hpp Tue Nov 13 15:14:27 2012 -0500
@@ -3593,7 +3593,7 @@
diagnostic(bool, PrintDTraceDOF, false, \
"Print the DTrace DOF passed to the system for JSDT probes") \
\
- product(uintx, StringTableSize, 1009, \
+ product(uintx, StringTableSize, defaultStringTableSize, \
"Number of buckets in the interned String table") \
\
develop(bool, TraceDefaultMethods, false, \
--- a/hotspot/src/share/vm/runtime/os.cpp Mon Nov 12 16:15:05 2012 -0500
+++ b/hotspot/src/share/vm/runtime/os.cpp Tue Nov 13 15:14:27 2012 -0500
@@ -576,7 +576,9 @@
// if NULL is returned the calling functions assume out of memory.
size = 1;
}
-
+ if (size > size + space_before + space_after) { // Check for rollover.
+ return NULL;
+ }
NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap());
u_char* ptr = (u_char*)::malloc(size + space_before + space_after);
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp Mon Nov 12 16:15:05 2012 -0500
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp Tue Nov 13 15:14:27 2012 -0500
@@ -328,6 +328,12 @@
//----------------------------------------------------------------------------------------------------
+// Minimum StringTableSize value
+
+const int defaultStringTableSize=1009;
+
+
+//----------------------------------------------------------------------------------------------------
// HotSwap - for JVMTI aka Class File Replacement and PopFrame
//
// Determines whether on-the-fly class replacement and frame popping are enabled.