# HG changeset patch # User skuksenko # Date 1559245502 25200 # Node ID a0d4e61acb6b11c44c28b6d74c8161b53fe83af2 # Parent 6515a96809a19cbd013d520ca937555b614f7d58 8223504: Improve performance of forall loops by better inlining of "iterator()" methods Reviewed-by: vlivanov, shade diff -r 6515a96809a1 -r a0d4e61acb6b src/hotspot/share/classfile/systemDictionary.hpp --- a/src/hotspot/share/classfile/systemDictionary.hpp Thu May 30 10:29:55 2019 +0800 +++ b/src/hotspot/share/classfile/systemDictionary.hpp Thu May 30 12:45:02 2019 -0700 @@ -214,6 +214,9 @@ do_klass(Integer_klass, java_lang_Integer ) \ do_klass(Long_klass, java_lang_Long ) \ \ + /* force inline of iterators */ \ + do_klass(Iterator_klass, java_util_Iterator ) \ + \ /*end*/ diff -r 6515a96809a1 -r a0d4e61acb6b src/hotspot/share/classfile/vmSymbols.hpp --- a/src/hotspot/share/classfile/vmSymbols.hpp Thu May 30 10:29:55 2019 +0800 +++ b/src/hotspot/share/classfile/vmSymbols.hpp Thu May 30 12:45:02 2019 -0700 @@ -126,6 +126,7 @@ template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ template(jdk_internal_vm_PostVMInitHook, "jdk/internal/vm/PostVMInitHook") \ template(sun_net_www_ParseUtil, "sun/net/www/ParseUtil") \ + template(java_util_Iterator, "java/util/Iterator") \ \ template(jdk_internal_loader_ClassLoaders_AppClassLoader, "jdk/internal/loader/ClassLoaders$AppClassLoader") \ template(jdk_internal_loader_ClassLoaders_PlatformClassLoader, "jdk/internal/loader/ClassLoaders$PlatformClassLoader") \ diff -r 6515a96809a1 -r a0d4e61acb6b src/hotspot/share/opto/bytecodeInfo.cpp --- a/src/hotspot/share/opto/bytecodeInfo.cpp Thu May 30 10:29:55 2019 +0800 +++ b/src/hotspot/share/opto/bytecodeInfo.cpp Thu May 30 12:45:02 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2019, 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 @@ -77,6 +77,8 @@ * 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 methods returning Iterator (including Iterable::iterator()) + * that is essential for forall-loops performance. */ static bool is_init_with_ea(ciMethod* callee_method, ciMethod* caller_method, Compile* C) { @@ -94,6 +96,11 @@ if (C->eliminate_boxing() && callee_method->is_boxing_method()) { return true; } + ciType *retType = callee_method->signature()->return_type(); + ciKlass *iter = C->env()->Iterator_klass(); + if(retType->is_loaded() && iter->is_loaded() && retType->is_subtype_of(iter)) { + return true; + } return false; }