14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 27 #include "gc/shared/memset_with_concurrent_readers.hpp" 28 #include "runtime/prefetch.inline.hpp" 29 #include "utilities/align.hpp" 30 #include "utilities/debug.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 #include "utilities/macros.hpp" 33 34 #if INCLUDE_ALL_GCS 35 36 // An implementation of memset, for use when there may be concurrent 37 // readers of the region being stored into. 38 // 39 // We can't use the standard library memset if it is implemented using 40 // block initializing stores. Doing so can result in concurrent readers 41 // seeing spurious zeros. 42 // 43 // We can't use the obvious C/C++ for-loop, because the compiler may 44 // recognize the idiomatic loop and optimize it into a call to the 45 // standard library memset; we've seen exactly this happen with, for 46 // example, Solaris Studio 12.3. Hence the use of inline assembly 47 // code, hiding loops from the compiler's optimizer. 48 // 49 // We don't attempt to use the standard library memset when it is safe 50 // to do so. We could conservatively do so by detecting the presence 51 // of block initializing stores (VM_Version::has_blk_init()), but the 52 // implementation provided here should be sufficient. 53 54 inline void fill_subword(void* start, void* end, int value) { 55 STATIC_ASSERT(BytesPerWord == 8); 139 // DISPATCH: no direct reference, but without it the store block may be elided. 140 "3:\n\t" 141 " stx %[xvalue], [%[aend]-56]\n\t" // aligned_end[-7] = xvalue 142 " stx %[xvalue], [%[aend]-48]\n\t" 143 " stx %[xvalue], [%[aend]-40]\n\t" 144 " stx %[xvalue], [%[aend]-32]\n\t" 145 " stx %[xvalue], [%[aend]-24]\n\t" 146 " stx %[xvalue], [%[aend]-16]\n\t" 147 " stx %[xvalue], [%[aend]-8]\n\t" // aligned_end[-1] = xvalue 148 : /* only temporaries/overwritten outputs */ 149 [temp] "=&r" (temp), 150 [ato] "+&r" (aligned_to) 151 : [aend] "r" (aligned_end), 152 [xvalue] "r" (xvalue) 153 : "cc", "memory"); 154 to = aligned_end; // setup for suffix 155 } 156 // Fill any partial word suffix. Also the prefix if size < BytesPerWord. 157 fill_subword(to, end, value); 158 } 159 160 #endif // INCLUDE_ALL_GCS | 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 27 #include "gc/shared/memset_with_concurrent_readers.hpp" 28 #include "runtime/prefetch.inline.hpp" 29 #include "utilities/align.hpp" 30 #include "utilities/debug.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 #include "utilities/macros.hpp" 33 34 // An implementation of memset, for use when there may be concurrent 35 // readers of the region being stored into. 36 // 37 // We can't use the standard library memset if it is implemented using 38 // block initializing stores. Doing so can result in concurrent readers 39 // seeing spurious zeros. 40 // 41 // We can't use the obvious C/C++ for-loop, because the compiler may 42 // recognize the idiomatic loop and optimize it into a call to the 43 // standard library memset; we've seen exactly this happen with, for 44 // example, Solaris Studio 12.3. Hence the use of inline assembly 45 // code, hiding loops from the compiler's optimizer. 46 // 47 // We don't attempt to use the standard library memset when it is safe 48 // to do so. We could conservatively do so by detecting the presence 49 // of block initializing stores (VM_Version::has_blk_init()), but the 50 // implementation provided here should be sufficient. 51 52 inline void fill_subword(void* start, void* end, int value) { 53 STATIC_ASSERT(BytesPerWord == 8); 137 // DISPATCH: no direct reference, but without it the store block may be elided. 138 "3:\n\t" 139 " stx %[xvalue], [%[aend]-56]\n\t" // aligned_end[-7] = xvalue 140 " stx %[xvalue], [%[aend]-48]\n\t" 141 " stx %[xvalue], [%[aend]-40]\n\t" 142 " stx %[xvalue], [%[aend]-32]\n\t" 143 " stx %[xvalue], [%[aend]-24]\n\t" 144 " stx %[xvalue], [%[aend]-16]\n\t" 145 " stx %[xvalue], [%[aend]-8]\n\t" // aligned_end[-1] = xvalue 146 : /* only temporaries/overwritten outputs */ 147 [temp] "=&r" (temp), 148 [ato] "+&r" (aligned_to) 149 : [aend] "r" (aligned_end), 150 [xvalue] "r" (xvalue) 151 : "cc", "memory"); 152 to = aligned_end; // setup for suffix 153 } 154 // Fill any partial word suffix. Also the prefix if size < BytesPerWord. 155 fill_subword(to, end, value); 156 } |