< prev index next >

src/hotspot/share/opto/bytecodeInfo.cpp

Print this page
rev 54728 : force inline of iterator() methods for better scalar replacement of iterators

@@ -75,10 +75,11 @@
 
 /**
  *  Return true when EA is ON and a java constructor is called or
  *  a super constructor is called from an inlined java constructor.
  *  Also return true for boxing methods.
+ *  Also return true for Iterable::iterator() invocation that is essential for forall-loops performance.
  */
 static bool is_init_with_ea(ciMethod* callee_method,
                             ciMethod* caller_method, Compile* C) {
   if (!C->do_escape_analysis() || !EliminateAllocations) {
     return false; // EA is off

@@ -92,10 +93,16 @@
     return true; // super constructor is called from inlined constructor
   }
   if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
     return true;
   }
+  if (callee_method->name() == ciSymbol::iterator_name()) {
+    ciType *retType = callee_method->signature()->return_type();
+    if(retType->is_klass() && retType->as_klass()->is_subtype_of(C->env()->Iterator_klass())) {
+      return true;
+    }
+  }
   return false;
 }
 
 /**
  *  Force inlining unboxing accessor.
< prev index next >