# HG changeset patch # User simonis # Date 1457626243 -3600 # Thu Mar 10 17:10:43 2016 +0100 # Node ID 09eb6fc48c4bc71f06b96cea58dfcec71f27abd5 # Parent 7d5870c06812d2cdef2ba32a7b4904a10fc03206 8151593: Cleanup definition/usage of INLINE/NOINLINE macros and add xlC support Contributed-by: matthias.baesken@sap.com diff --git a/src/os/linux/vm/os_linux.cpp b/src/os/linux/vm/os_linux.cpp --- a/src/os/linux/vm/os_linux.cpp +++ b/src/os/linux/vm/os_linux.cpp @@ -593,15 +593,7 @@ // _expand_stack_to() assumes its frame size is less than page size, which // should always be true if the function is not inlined. -#if __GNUC__ < 3 // gcc 2.x does not support noinline attribute - #define NOINLINE -#else - #define NOINLINE __attribute__ ((noinline)) -#endif - -static void _expand_stack_to(address bottom) NOINLINE; - -static void _expand_stack_to(address bottom) { +static void NOINLINE _expand_stack_to(address bottom) { address sp; size_t size; volatile char *p; diff --git a/src/share/vm/oops/instanceKlass.inline.hpp b/src/share/vm/oops/instanceKlass.inline.hpp --- a/src/share/vm/oops/instanceKlass.inline.hpp +++ b/src/share/vm/oops/instanceKlass.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -36,16 +36,9 @@ // The iteration over the oops in objects is a hot path in the GC code. // By force inlining the following functions, we get similar GC performance // as the previous macro based implementation. -#ifdef TARGET_COMPILER_visCPP -#define INLINE __forceinline -#elif defined(TARGET_COMPILER_sparcWorks) -#define INLINE __attribute__((always_inline)) -#else -#define INLINE inline -#endif template -INLINE void InstanceKlass::oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure) { T* p = (T*)obj->obj_field_addr(map->offset()); T* const end = p + map->count(); @@ -56,7 +49,7 @@ #if INCLUDE_ALL_GCS template -INLINE void InstanceKlass::oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure) { T* const start = (T*)obj->obj_field_addr(map->offset()); T* p = start + map->count(); @@ -68,7 +61,7 @@ #endif template -INLINE void InstanceKlass::oop_oop_iterate_oop_map_bounded(OopMapBlock* map, oop obj, OopClosureType* closure, MemRegion mr) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_map_bounded(OopMapBlock* map, oop obj, OopClosureType* closure, MemRegion mr) { T* p = (T*)obj->obj_field_addr(map->offset()); T* end = p + map->count(); @@ -91,7 +84,7 @@ } template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized(oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized(oop obj, OopClosureType* closure) { OopMapBlock* map = start_of_nonstatic_oop_maps(); OopMapBlock* const end_map = map + nonstatic_oop_map_count(); @@ -102,7 +95,7 @@ #if INCLUDE_ALL_GCS template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized_reverse(oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized_reverse(oop obj, OopClosureType* closure) { OopMapBlock* const start_map = start_of_nonstatic_oop_maps(); OopMapBlock* map = start_map + nonstatic_oop_map_count(); @@ -114,7 +107,7 @@ #endif template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized_bounded(oop obj, OopClosureType* closure, MemRegion mr) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_specialized_bounded(oop obj, OopClosureType* closure, MemRegion mr) { OopMapBlock* map = start_of_nonstatic_oop_maps(); OopMapBlock* const end_map = map + nonstatic_oop_map_count(); @@ -124,7 +117,7 @@ } template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure) { if (UseCompressedOops) { oop_oop_iterate_oop_maps_specialized(obj, closure); } else { @@ -134,7 +127,7 @@ #if INCLUDE_ALL_GCS template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure) { if (UseCompressedOops) { oop_oop_iterate_oop_maps_specialized_reverse(obj, closure); } else { @@ -144,7 +137,7 @@ #endif template -INLINE void InstanceKlass::oop_oop_iterate_oop_maps_bounded(oop obj, OopClosureType* closure, MemRegion mr) { +ALWAYSINLINE void InstanceKlass::oop_oop_iterate_oop_maps_bounded(oop obj, OopClosureType* closure, MemRegion mr) { if (UseCompressedOops) { oop_oop_iterate_oop_maps_specialized_bounded(obj, closure, mr); } else { @@ -153,7 +146,7 @@ } template -INLINE int InstanceKlass::oop_oop_iterate(oop obj, OopClosureType* closure) { +ALWAYSINLINE int InstanceKlass::oop_oop_iterate(oop obj, OopClosureType* closure) { if (Devirtualizer::do_metadata(closure)) { Devirtualizer::do_klass(closure, this); } @@ -165,7 +158,7 @@ #if INCLUDE_ALL_GCS template -INLINE int InstanceKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) { +ALWAYSINLINE int InstanceKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) { assert(!Devirtualizer::do_metadata(closure), "Code to handle metadata is not implemented"); @@ -176,7 +169,7 @@ #endif template -INLINE int InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) { +ALWAYSINLINE int InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) { if (Devirtualizer::do_metadata(closure)) { if (mr.contains(obj)) { Devirtualizer::do_klass(closure, this); @@ -188,8 +181,6 @@ return size_helper(); } -#undef INLINE - #define ALL_INSTANCE_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ OOP_OOP_ITERATE_DEFN( InstanceKlass, OopClosureType, nv_suffix) \ OOP_OOP_ITERATE_DEFN_BOUNDED( InstanceKlass, OopClosureType, nv_suffix) \ diff --git a/src/share/vm/runtime/objectMonitor.cpp b/src/share/vm/runtime/objectMonitor.cpp --- a/src/share/vm/runtime/objectMonitor.cpp +++ b/src/share/vm/runtime/objectMonitor.cpp @@ -44,14 +44,6 @@ #include "utilities/macros.hpp" #include "utilities/preserveException.hpp" -#if defined(__GNUC__) && !defined(IA64) && !defined(PPC64) -// Need to inhibit inlining for older versions of GCC to avoid build-time failures - #define NOINLINE __attribute__((noinline)) -#else - #define NOINLINE -#endif - - #ifdef DTRACE_ENABLED // Only bother with this argument setup if dtrace is available @@ -254,7 +246,7 @@ // ----------------------------------------------------------------------------- // Enter support -void NOINLINE ObjectMonitor::enter(TRAPS) { +void ObjectMonitor::enter(TRAPS) { // The following code is ordered to check the most common cases first // and to reduce RTS->RTO cache line upgrades on SPARC and IA32 processors. Thread * const Self = THREAD; @@ -431,7 +423,7 @@ #define MAX_RECHECK_INTERVAL 1000 -void NOINLINE ObjectMonitor::EnterI(TRAPS) { +void ObjectMonitor::EnterI(TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "invariant"); assert(((JavaThread *) Self)->thread_state() == _thread_blocked, "invariant"); @@ -681,7 +673,7 @@ // Knob_Reset and Knob_SpinAfterFutile support and restructuring the // loop accordingly. -void NOINLINE ObjectMonitor::ReenterI(Thread * Self, ObjectWaiter * SelfNode) { +void ObjectMonitor::ReenterI(Thread * Self, ObjectWaiter * SelfNode) { assert(Self != NULL, "invariant"); assert(SelfNode != NULL, "invariant"); assert(SelfNode->_thread == Self, "invariant"); @@ -894,7 +886,7 @@ // structured the code so the windows are short and the frequency // of such futile wakups is low. -void NOINLINE ObjectMonitor::exit(bool not_suspended, TRAPS) { +void ObjectMonitor::exit(bool not_suspended, TRAPS) { Thread * const Self = THREAD; if (THREAD != _owner) { if (THREAD->is_lock_owned((address) _owner)) { diff --git a/src/share/vm/runtime/synchronizer.cpp b/src/share/vm/runtime/synchronizer.cpp --- a/src/share/vm/runtime/synchronizer.cpp +++ b/src/share/vm/runtime/synchronizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -48,13 +48,6 @@ #include "utilities/events.hpp" #include "utilities/preserveException.hpp" -#if defined(__GNUC__) && !defined(PPC64) -// Need to inhibit inlining for older versions of GCC to avoid build-time failures - #define NOINLINE __attribute__((noinline)) -#else - #define NOINLINE -#endif - // The "core" versions of monitor enter and exit reside in this file. // The interpreter and compilers contain specialized transliterated // variants of the enter-exit fast-path operations. See i486.ad fast_lock(), @@ -1038,7 +1031,7 @@ assert(free_tally == Self->omFreeCount, "free count off"); } -ObjectMonitor * NOINLINE ObjectSynchronizer::omAlloc(Thread * Self) { +ObjectMonitor* ObjectSynchronizer::omAlloc(Thread * Self) { // A large MAXPRIVATE value reduces both list lock contention // and list coherency traffic, but also tends to increase the // number of objectMonitors in circulation as well as the STW @@ -1313,7 +1306,7 @@ inflate_cause_vm_internal); } -ObjectMonitor * NOINLINE ObjectSynchronizer::inflate(Thread * Self, +ObjectMonitor* ObjectSynchronizer::inflate(Thread * Self, oop object, const InflateCause cause) { diff --git a/src/share/vm/utilities/globalDefinitions.hpp b/src/share/vm/utilities/globalDefinitions.hpp --- a/src/share/vm/utilities/globalDefinitions.hpp +++ b/src/share/vm/utilities/globalDefinitions.hpp @@ -42,6 +42,12 @@ # include "utilities/globalDefinitions_xlc.hpp" #endif +#ifndef NOINLINE +#define NOINLINE +#endif +#ifndef ALWAYSINLINE +#define ALWAYSINLINE inline +#endif #ifndef PRAGMA_DIAG_PUSH #define PRAGMA_DIAG_PUSH #endif diff --git a/src/share/vm/utilities/globalDefinitions_gcc.hpp b/src/share/vm/utilities/globalDefinitions_gcc.hpp --- a/src/share/vm/utilities/globalDefinitions_gcc.hpp +++ b/src/share/vm/utilities/globalDefinitions_gcc.hpp @@ -322,4 +322,8 @@ #define THREAD_LOCAL_DECL __thread #endif +// Inlining support +#define NOINLINE __attribute__ ((noinline)) +#define ALWAYSINLINE __attribute__ ((always_inline)) + #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp b/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp --- a/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp +++ b/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -277,4 +277,8 @@ #define THREAD_LOCAL_DECL __thread #endif +// Inlining support +#define NOINLINE +#define ALWAYSINLINE __attribute__((always_inline)) + #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_SPARCWORKS_HPP diff --git a/src/share/vm/utilities/globalDefinitions_visCPP.hpp b/src/share/vm/utilities/globalDefinitions_visCPP.hpp --- a/src/share/vm/utilities/globalDefinitions_visCPP.hpp +++ b/src/share/vm/utilities/globalDefinitions_visCPP.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -240,4 +240,9 @@ #define THREAD_LOCAL_DECL __declspec( thread ) #endif +// Inlining support +// MSVC has '__declspec(noinline)' but it only applies to member functions +#define NOINLINE +#define ALWAYSINLINE __forceinline + #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP diff --git a/src/share/vm/utilities/globalDefinitions_xlc.hpp b/src/share/vm/utilities/globalDefinitions_xlc.hpp --- a/src/share/vm/utilities/globalDefinitions_xlc.hpp +++ b/src/share/vm/utilities/globalDefinitions_xlc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2013 SAP SE. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016 SAP SE. 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 @@ -184,4 +184,8 @@ #define THREAD_LOCAL_DECL __thread #endif +// Inlining support +#define NOINLINE +#define ALWAYSINLINE __attribute__((always_inline)) + #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP diff --git a/src/share/vm/utilities/stack.inline.hpp b/src/share/vm/utilities/stack.inline.hpp --- a/src/share/vm/utilities/stack.inline.hpp +++ b/src/share/vm/utilities/stack.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ -27,17 +27,6 @@ #include "utilities/stack.hpp" -// Stack is used by the GC code and in some hot paths a lot of the Stack -// code gets inlined. This is generally good, but when too much code has -// been inlined, no further inlining is allowed by GCC. Therefore we need -// to prevent parts of the slow path in Stack to be inlined to allow other -// code to be. -#if defined(TARGET_COMPILER_gcc) -#define NOINLINE __attribute__((noinline)) -#else -#define NOINLINE -#endif - template StackBase::StackBase(size_t segment_size, size_t max_cache_size, size_t max_size): _seg_size(segment_size), @@ -151,6 +140,11 @@ FREE_C_HEAP_ARRAY(char, (char*) addr); } +// Stack is used by the GC code and in some hot paths a lot of the Stack +// code gets inlined. This is generally good, but when too much code has +// been inlined, no further inlining is allowed by GCC. Therefore we need +// to prevent parts of the slow path in Stack to be inlined to allow other +// code to be. template NOINLINE void Stack::push_segment() { @@ -280,6 +274,4 @@ return _cur_seg + --_cur_seg_size; } -#undef NOINLINE - #endif // SHARE_VM_UTILITIES_STACK_INLINE_HPP