From aae2813bd76aea0718bc36b4e602aec70d074bb5 Mon Sep 17 00:00:00 2001 From: mchinnathamb Date: Mon, 23 Apr 2018 02:05:50 -0700 Subject: [PATCH] 8158012: Use SW prefetch instructions instead of BIS for allocation prefetches on SPARC Core C4 Reviewed-by: kvn, dholmes, poonam --- src/cpu/sparc/vm/vm_version_sparc.cpp | 22 +++++++++++++++++----- src/share/vm/opto/macro.cpp | 6 ++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/cpu/sparc/vm/vm_version_sparc.cpp b/src/cpu/sparc/vm/vm_version_sparc.cpp index 15e6f333d..c0cd16a18 100644 --- a/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, 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 @@ -140,10 +140,17 @@ void VM_Version::initialize() { if (is_niagara_plus()) { if (has_blk_init() && (cache_line_size > 0) && UseTLAB && FLAG_IS_DEFAULT(AllocatePrefetchInstr)) { - // Use BIS instruction for TLAB allocation prefetch. - FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1); - if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { - FLAG_SET_ERGO(intx, AllocatePrefetchStyle, 3); + if (!has_sparc5_instr()) { + // Use BIS instruction for TLAB allocation prefetch + // on Niagara plus processors other than those based on CoreS4. + FLAG_SET_DEFAULT(AllocatePrefetchInstr, 1); + } else { + // On CoreS4 processors use prefetch instruction + // to avoid partial RAW issue, also use prefetch style 3. + FLAG_SET_DEFAULT(AllocatePrefetchInstr, 0); + if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { + FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3); + } } if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { // Use smaller prefetch distance with BIS @@ -165,6 +172,11 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); } if (AllocatePrefetchInstr == 1) { + + // Use allocation prefetch style 3 because BIS instructions + // require aligned memory addresses. + FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3); + // Need a space at the end of TLAB for BIS since it // will fault when accessing memory outside of heap. diff --git a/src/share/vm/opto/macro.cpp b/src/share/vm/opto/macro.cpp index d1e1f3220..cf2ba77d5 100644 --- a/src/share/vm/opto/macro.cpp +++ b/src/share/vm/opto/macro.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, 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 @@ -1775,7 +1775,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, i_o = pf_phi_abio; } else if( UseTLAB && AllocatePrefetchStyle == 3 ) { // Insert a prefetch for each allocation. - // This code is used for Sparc with BIS. + // This code is used to generate 1 prefetch instruction per cache line. Node *pf_region = new (C) RegionNode(3); Node *pf_phi_rawmem = new (C) PhiNode( pf_region, Type::MEMORY, TypeRawPtr::BOTTOM ); @@ -1791,6 +1791,8 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, transform_later(cache_adr); cache_adr = new (C) CastP2XNode(needgc_false, cache_adr); transform_later(cache_adr); + // Address is aligned to execute prefetch to the beginning of cache line size + // (it is important when BIS instruction is used on SPARC as prefetch). Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1)); cache_adr = new (C) AndXNode(cache_adr, mask); transform_later(cache_adr); -- GitLab