diff src/share/vm/opto/type.cpp @ 1009:03b336640699

6885584: A particular class structure causes large allocation spike for jit Reviewed-by: kvn
author never
date Wed, 07 Oct 2009 15:38:37 -0700
parents 6a8ccac44f41
children 97125851f396 ae4032fb0a5b
line wrap: on
line diff
--- a/src/share/vm/opto/type.cpp	Wed Oct 07 12:43:50 2009 -0700
+++ b/src/share/vm/opto/type.cpp	Wed Oct 07 15:38:37 2009 -0700
@@ -1115,7 +1115,7 @@
 
 //------------------------------widen------------------------------------------
 // Only happens for optimistic top-down optimizations.
-const Type *TypeInt::widen( const Type *old ) const {
+const Type *TypeInt::widen( const Type *old, const Type* limit ) const {
   // Coming from TOP or such; no widening
   if( old->base() != Int ) return this;
   const TypeInt *ot = old->is_int();
@@ -1134,15 +1134,21 @@
     // Now widen new guy.
     // Check for widening too far
     if (_widen == WidenMax) {
-      if (min_jint < _lo && _hi < max_jint) {
+      int max = max_jint;
+      int min = min_jint;
+      if (limit->isa_int()) {
+        max = limit->is_int()->_hi;
+        min = limit->is_int()->_lo;
+      }
+      if (min < _lo && _hi < max) {
         // If neither endpoint is extremal yet, push out the endpoint
         // which is closer to its respective limit.
         if (_lo >= 0 ||                 // easy common case
-            (juint)(_lo - min_jint) >= (juint)(max_jint - _hi)) {
+            (juint)(_lo - min) >= (juint)(max - _hi)) {
           // Try to widen to an unsigned range type of 31 bits:
-          return make(_lo, max_jint, WidenMax);
+          return make(_lo, max, WidenMax);
         } else {
-          return make(min_jint, _hi, WidenMax);
+          return make(min, _hi, WidenMax);
         }
       }
       return TypeInt::INT;
@@ -1357,7 +1363,7 @@
 
 //------------------------------widen------------------------------------------
 // Only happens for optimistic top-down optimizations.
-const Type *TypeLong::widen( const Type *old ) const {
+const Type *TypeLong::widen( const Type *old, const Type* limit ) const {
   // Coming from TOP or such; no widening
   if( old->base() != Long ) return this;
   const TypeLong *ot = old->is_long();
@@ -1376,18 +1382,24 @@
     // Now widen new guy.
     // Check for widening too far
     if (_widen == WidenMax) {
-      if (min_jlong < _lo && _hi < max_jlong) {
+      jlong max = max_jlong;
+      jlong min = min_jlong;
+      if (limit->isa_long()) {
+        max = limit->is_long()->_hi;
+        min = limit->is_long()->_lo;
+      }
+      if (min < _lo && _hi < max) {
         // If neither endpoint is extremal yet, push out the endpoint
         // which is closer to its respective limit.
         if (_lo >= 0 ||                 // easy common case
-            (julong)(_lo - min_jlong) >= (julong)(max_jlong - _hi)) {
+            (julong)(_lo - min) >= (julong)(max - _hi)) {
           // Try to widen to an unsigned range type of 32/63 bits:
-          if (_hi < max_juint)
+          if (max >= max_juint && _hi < max_juint)
             return make(_lo, max_juint, WidenMax);
           else
-            return make(_lo, max_jlong, WidenMax);
+            return make(_lo, max, WidenMax);
         } else {
-          return make(min_jlong, _hi, WidenMax);
+          return make(min, _hi, WidenMax);
         }
       }
       return TypeLong::LONG;