8146478: Node limit exceeded with -XX:AllocateInstancePrefetchLines=1073741823
authorzmajo
Thu, 28 Jan 2016 08:33:45 +0100
changeset 35751 6a057f120b11
parent 35605 34daf4d92515
child 35752 16265e7c7a53
8146478: Node limit exceeded with -XX:AllocateInstancePrefetchLines=1073741823 Summary: Constrain the set of accepted values for the Allocate{PrefetchLines, InstancePrefetchLines, PrefetchStepSize, PrefetchDistance} flags. Increase macro node expansion budget. Reviewed-by: kvn
hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
hotspot/src/cpu/x86/vm/vm_version_x86.cpp
hotspot/src/share/vm/opto/macro.cpp
hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp
hotspot/src/share/vm/runtime/globals.hpp
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Tue Jan 26 14:04:01 2016 +0000
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Jan 28 08:33:45 2016 +0100
@@ -45,13 +45,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Tue Jan 26 14:04:01 2016 +0000
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Thu Jan 28 08:33:45 2016 +0100
@@ -1163,13 +1163,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
@@ -1183,7 +1176,9 @@
     }
     if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus
       AllocatePrefetchDistance = 192;
-      AllocatePrefetchLines = 4;
+      if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
+        FLAG_SET_DEFAULT(AllocatePrefetchLines, 4);
+      }
     }
 #ifdef COMPILER2
     if (supports_sse4_2()) {
--- a/hotspot/src/share/vm/opto/macro.cpp	Tue Jan 26 14:04:01 2016 +0000
+++ b/hotspot/src/share/vm/opto/macro.cpp	Thu Jan 28 08:33:45 2016 +0100
@@ -2654,9 +2654,9 @@
   eliminate_macro_nodes();
 
   // Make sure expansion will not cause node limit to be exceeded.
-  // Worst case is a macro node gets expanded into about 50 nodes.
+  // Worst case is a macro node gets expanded into about 200 nodes.
   // Allow 50% more for optimization.
-  if (C->check_node_count(C->macro_count() * 75, "out of nodes before macro expansion" ) )
+  if (C->check_node_count(C->macro_count() * 300, "out of nodes before macro expansion" ) )
     return true;
 
   // Eliminate Opaque and LoopLimit nodes. Do it after all loop optimizations.
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Tue Jan 26 14:04:01 2016 +0000
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Thu Jan 28 08:33:45 2016 +0100
@@ -118,27 +118,46 @@
 }
 
 Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) {
-  if (value < 1 || value > max_jint) {
+  intx max_value = 512;
+  if (value < 1 || value > max_value) {
     CommandLineError::print(verbose,
                             "AllocatePrefetchStepSize (" INTX_FORMAT ") "
                             "must be between 1 and %d\n",
                             AllocatePrefetchStepSize,
-                            max_jint);
+                            max_value);
     return Flag::VIOLATES_CONSTRAINT;
   }
 
   if (AllocatePrefetchDistance % AllocatePrefetchStepSize != 0) {
-     CommandLineError::print(verbose,
-                             "AllocatePrefetchDistance (" INTX_FORMAT ") "
-                             "%% AllocatePrefetchStepSize (" INTX_FORMAT ") "
-                             "= " INTX_FORMAT " "
-                             "must be 0\n",
-                             AllocatePrefetchDistance, AllocatePrefetchStepSize,
-                             AllocatePrefetchDistance % AllocatePrefetchStepSize);
-     return Flag::VIOLATES_CONSTRAINT;
-   }
+    CommandLineError::print(verbose,
+                            "AllocatePrefetchDistance (" INTX_FORMAT ") "
+                            "%% AllocatePrefetchStepSize (" INTX_FORMAT ") "
+                            "= " INTX_FORMAT " "
+                            "must be 0\n",
+                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
+                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
+    return Flag::VIOLATES_CONSTRAINT;
+  }
 
-   return Flag::SUCCESS;
+  /* The limit of 64 for the quotient of AllocatePrefetchDistance and AllocatePrefetchSize
+   * originates from the limit of 64 for AllocatePrefetchLines/AllocateInstancePrefetchLines.
+   * If AllocatePrefetchStyle == 2, the quotient from above is used in PhaseMacroExpand::prefetch_allocation()
+   * to determine the number of lines to prefetch. For other values of AllocatePrefetchStyle,
+   * AllocatePrefetchDistance and AllocatePrefetchSize is used. For consistency, all these
+   * quantities must have the same limit (64 in this case).
+   */
+  if (AllocatePrefetchDistance / AllocatePrefetchStepSize > 64) {
+    CommandLineError::print(verbose,
+                            "AllocatePrefetchDistance (" INTX_FORMAT ") too large or "
+                            "AllocatePrefetchStepSize (" INTX_FORMAT ") too small; "
+                            "try decreasing/increasing values so that "
+                            "AllocatePrefetchDistance / AllocatePrefetchStepSize <= 64\n",
+                            AllocatePrefetchDistance, AllocatePrefetchStepSize,
+                            AllocatePrefetchDistance % AllocatePrefetchStepSize);
+    return Flag::VIOLATES_CONSTRAINT;
+  }
+
+  return Flag::SUCCESS;
 }
 
 Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) {
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Jan 26 14:04:01 2016 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Thu Jan 28 08:33:45 2016 +0100
@@ -2964,16 +2964,16 @@
                                                                             \
   product(intx,  AllocatePrefetchLines, 3,                                  \
           "Number of lines to prefetch ahead of array allocation pointer")  \
-          range(1, max_jint / 2)                                            \
+          range(1, 64)                                                      \
                                                                             \
   product(intx,  AllocateInstancePrefetchLines, 1,                          \
           "Number of lines to prefetch ahead of instance allocation "       \
           "pointer")                                                        \
-          range(1, max_jint / 2)                                            \
+          range(1, 64)                                                      \
                                                                             \
   product(intx,  AllocatePrefetchStepSize, 16,                              \
           "Step size in bytes of sequential prefetch instructions")         \
-          range(1, max_jint)                                                \
+          range(1, 512)                                                     \
           constraint(AllocatePrefetchStepSizeConstraintFunc,AfterMemoryInit)\
                                                                             \
   product(intx,  AllocatePrefetchInstr, 0,                                  \