Skip to content

Commit 87f4210

Browse files
committed
Cache 'instantiateSignature' as a query
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
1 parent b681fe3 commit 87f4210

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

frontend/include/chpl/resolution/resolution-types.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ class CallInfo {
561561
public:
562562
using CallInfoActualIterable = Iterable<std::vector<CallInfoActual>>;
563563

564+
/** default constructor for the query system */
565+
CallInfo() : name_(), calledType_() {}
566+
564567
/** Construct a CallInfo that contains QualifiedTypes for actuals */
565568
CallInfo(UniqueString name, types::QualifiedType calledType,
566569
bool isMethodCall,
@@ -732,6 +735,20 @@ class CallInfo {
732735
hasQuestionArg_, isParenless_,
733736
actuals_);
734737
}
738+
static bool update(CallInfo& keep,
739+
CallInfo& addin) {
740+
return defaultUpdate(keep, addin);
741+
}
742+
743+
void swap(CallInfo& other) {
744+
std::swap(name_, other.name_);
745+
std::swap(calledType_, other.calledType_);
746+
std::swap(isMethodCall_, other.isMethodCall_);
747+
std::swap(isOpCall_, other.isOpCall_);
748+
std::swap(hasQuestionArg_, other.hasQuestionArg_);
749+
std::swap(isParenless_, other.isParenless_);
750+
actuals_.swap(other.actuals_);
751+
}
735752

736753
void stringify(std::ostream& ss, chpl::StringifyKind stringKind) const;
737754

frontend/lib/resolution/resolution-queries.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,10 +2160,11 @@ static bool instantiateAcrossManagerRecordConversion(Context* context,
21602160

21612161
// TODO: We could remove the 'ResolutionContext' argument if we figure out
21622162
// a different way/decide not to resolve initializer bodies down below.
2163-
ApplicabilityResult instantiateSignature(ResolutionContext* rc,
2164-
const TypedFnSignature* sig,
2165-
const CallInfo& call,
2166-
const PoiScope* poiScope) {
2163+
static ApplicabilityResult
2164+
instantiateSignatureImpl(ResolutionContext* rc,
2165+
const TypedFnSignature* sig,
2166+
const CallInfo& call,
2167+
const PoiScope* poiScope) {
21672168
// Performance: Should this query use a similar approach to
21682169
// resolveFunctionByInfoQuery, where the PoiInfo and visibility
21692170
// are consulted?
@@ -2636,6 +2637,23 @@ ApplicabilityResult instantiateSignature(ResolutionContext* rc,
26362637
return ApplicabilityResult::success(result);
26372638
}
26382639

2640+
static ApplicabilityResult const&
2641+
instantiateSignatureQuery(ResolutionContext* rc,
2642+
const TypedFnSignature* sig,
2643+
const CallInfo& call,
2644+
const PoiScope* poiScope) {
2645+
CHPL_RESOLUTION_QUERY_BEGIN(instantiateSignatureQuery, rc, sig, call, poiScope);
2646+
auto ret = instantiateSignatureImpl(rc, sig, call, poiScope);
2647+
return CHPL_RESOLUTION_QUERY_END(ret);
2648+
}
2649+
2650+
ApplicabilityResult instantiateSignature(ResolutionContext* rc,
2651+
const TypedFnSignature* sig,
2652+
const CallInfo& call,
2653+
const PoiScope* poiScope) {
2654+
return instantiateSignatureQuery(rc, sig, call, poiScope);
2655+
}
2656+
26392657
// This implements the body of 'resolveFunctionByInfo'. It returns a new
26402658
// 'ResolvedFunction' and does not directly set any queries.
26412659
//

0 commit comments

Comments
 (0)