[Chapel Merge] POI-aware caching of generic instantiations of met

Branch: refs/heads/master
Revision: 24e4b19
Author: vasslitvinov
Log Message:

Merge pull request #16450 from vasslitvinov/poi-caching-methods

POI-aware caching of generic instantiations of methods

This is the counterpart of #16261 for methods.
It implements #15923 for “normal” methods, i.e.
except for “type helpers”, see typeHelperNames and
cachedInstantiationIsAlwaysApplicable().

IMPLEMENTATION DETAILS

The main changes are to getVisibleMethods() and surrounding code,
they parallel the changes in #16261 to getVisibleFunctions().
I also did minor reorg of these functions to make the code for “functions”
and for “methods” to be very similar.

A major challenge has been the need to provide access to some of this
functionality from outside of findVisibleFunctions. Specifically:

  • initializerResolution.cpp / resolveInitCall()
    calls findVisibleFunctionsAllPOIs()
    calls findVisibleFunctions() with visInfo==visited==NULL
    calls getVisibleMethodsImpl() with visInfo==NULL

  • preFold.cpp / createFunctionAsValue()
    called for PRIM_CAPTURE_FN_FOR_CHPL, PRIM_CAPTURE_FN_FOR_C, PRIM_GATHER_TESTS
    calls getVisibleFunctions()
    calls getVisibleFunctionsImpl() with visInfo==NULL

  • caches.cpp / visitMorePOIs()
    calls getMoreVisibleFunctionsOrMethods()
    calls getVisibleFunctionsVI() or getVisibleMethodsVI()
    mostly the same way as for a “normal” invocation of findVisibleFunctions()
    i.e. from resolveNormalCall() / findVisibleFunctionsAndCandidates()
    // visInfo.visitedScopes is incomplete in this case

The change that “turns on” this code for methods is in
cachedInstantiationIsAlwaysApplicable().

TEST CHANGES

I replaced the tests:
test/functions/generic/poi/check-gc-reuse-warns.chpl
test/functions/generic/poi/check-gc-reuse-writes.chpl
with
test/functions/generic/poi/check-gc-reuse.chpl
which combines the former and adds calls to/from methods.

I also added
test/functions/generic/poi/ApplicationB.methods.chpl
which is a simpler functions->methods conversion of
test/functions/ferguson/hijacking/ApplicationB.chpl

I am observing a 1-2% compilation time improvement with this change
compiling hello and ssca2 with --no-codegen. I am unsure of the reason.

r: @mppf

Modified Files:
A test/functions/generic/poi/ApplicationB.methods.chpl
A test/functions/generic/poi/ApplicationB.methods.good
A test/functions/generic/poi/check-gc-reuse.chpl
A test/functions/generic/poi/check-gc-reuse.good
R test/functions/generic/poi/check-gc-reuse-warns.chpl
R test/functions/generic/poi/check-gc-reuse-warns.good
R test/functions/generic/poi/check-gc-reuse-writes.chpl
R test/functions/generic/poi/check-gc-reuse-writes.good
M compiler/include/visibleFunctions.h
M compiler/resolution/caches.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/initializerResolution.cpp
M compiler/resolution/visibleFunctions.cpp

Compare: https://github.com/chapel-lang/chapel/compare/ff63799929bc...24e4b19ef69b