Skip to content

Commit

Permalink
Merge branch 'main' into chai-multilocale-inf-tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremiah Corrado <jeremiah.corrado@hpe.com>
  • Loading branch information
jeremiah-corrado committed Oct 14, 2024
2 parents 099b570 + 55f5489 commit 98f12d0
Show file tree
Hide file tree
Showing 83 changed files with 1,858 additions and 654 deletions.
2 changes: 1 addition & 1 deletion compiler/resolution/expandVarArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ static void expandVarArgsBody(FnSymbol* fn,
}

if (formal->intent == INTENT_CONST || formal->intent == INTENT_CONST_IN ||
formal->intent == INTENT_BLANK) {
formal->intent == INTENT_CONST_REF || formal->intent == INTENT_BLANK) {
// TODO: Note that this will be overly strict for arrays, syncs, and
// atomics, since their default is "pass-by-ref". However, we think this is
// okay for now, in part due to thinking it's unlikely to be relied upon and
Expand Down
1 change: 1 addition & 0 deletions compiler/resolution/functionResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9599,6 +9599,7 @@ static void resolveMoveForRhsCallExpr(CallExpr* call, Type* rhsType) {

static void moveSetConstFlagsAndCheck(CallExpr* call, CallExpr* rhs) {
if (rhs->isPrimitive(PRIM_GET_MEMBER) ||
(rhs->isPrimitive(PRIM_GET_MEMBER_VALUE) && rhs->qualType().isRef()) ||
rhs->isPrimitive(PRIM_ADDR_OF))
{
if (SymExpr* rhsBase = toSymExpr(rhs->get(1))) {
Expand Down
18 changes: 17 additions & 1 deletion compiler/util/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,23 @@ static void addPath(const char* pathVar, std::vector<const char*>* pathvec) {
colon++; // and advance to the next
}

pathvec->push_back(astr(dirString));
// FIXME (Maybe?)
// Following the precedent of $PATH on Unix, we should
// treat empty strings between colons like :: or trailing/leading
// colons as meaning to add the current directory to the path.
// If we don't include the current directory in the CHPL_LIB_PATH by
// default, this behavior below is incorrect, and instead of ignoring
// empty strings, it should figure out the current directory and add
// that to the path.
// Alternatively, we can alter the compiler to throw -L . when
// CHPL_LIB_PATH has empty strings in between colons.
// However, if we do include the current directory in CHPL_LIB_PATH
// by default, then this doesn't need fixing, delete this FIXME.

// ignore empty strings
if (dirString && strlen(dirString) > 0) {
pathvec->push_back(astr(dirString));
}

dirString = colon; // advance dirString
} while (colon != NULL);
Expand Down
26 changes: 21 additions & 5 deletions frontend/include/chpl/framework/Context-detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,20 @@ class QueryMapResultBase {
// lastChanged indicates the last revision in which the query result
// has changed
mutable RevisionNumber lastChanged = -1;

mutable QueryDependencyVec dependencies;
// This field exists to support isQueryRunning. When traversingg the dependencies
// of a query, we may re-run dependency queries to see if their results change.
// Sometimes, these queries will check isQueryRunning. At this time, the
// actual query (this) is not running, but we want to return 'true' to hide
// the details of the query system from the query author. This field is set to
// 'true' when the query is being tested for re-computation, so that
// we can return 'true' when isQueryRunning is called in that case.
//
// Note (Daniel 10/08/2024): there may be a way to combine this field with
// lastChanged somehow, since that's what we use for isQueryRunning while
// the query really is running. However, the semantics of that are nontrivial,
// and that field is used for a lot of things, so for the time being, the
// extra boolean is fine.
mutable bool beingTestedForReuse = false;

// Whether or not errors from this query result have been shown to the
// user (they may not have been if some query checked for errors).
Expand All @@ -273,13 +285,16 @@ class QueryMapResultBase {
// This is not too strongly connected to emittedErrors (which tracks whether
// errors --- if any --- were shown to the user for this query result only)
mutable bool errorsPresentInSelfOrDependencies = false;

mutable QueryDependencyVec dependencies;
mutable std::set<const QueryMapResultBase*> recursionErrors;
mutable QueryErrorVec errors;

QueryMapBase* parentQueryMap;

QueryMapResultBase(RevisionNumber lastChecked,
RevisionNumber lastChanged,
bool beingTestedForReuse,
bool emittedErrors,
bool errorsPresentInSelfOrDependencies,
std::set<const QueryMapResultBase*> recursionErrors,
Expand All @@ -302,20 +317,21 @@ class QueryMapResult final : public QueryMapResultBase {
// * a default-constructed result
QueryMapResult(QueryMap<ResultType, ArgTs...>* parentQueryMap,
std::tuple<ArgTs...> tupleOfArgs)
: QueryMapResultBase(-1, -1, false, false, {}, parentQueryMap),
: QueryMapResultBase(-1, -1, false, false, false, {}, parentQueryMap),
tupleOfArgs(std::move(tupleOfArgs)),
result() {
}
QueryMapResult(RevisionNumber lastChecked,
RevisionNumber lastChanged,
bool beingTestedForReuse,
bool emittedErrors,
bool errorsPresentInSelfOrDependencies,
std::set<const QueryMapResultBase*> recursionErrors,
QueryMap<ResultType, ArgTs...>* parentQueryMap,
std::tuple<ArgTs...> tupleOfArgs,
ResultType result)
: QueryMapResultBase(lastChecked, lastChanged, emittedErrors,
errorsPresentInSelfOrDependencies,
: QueryMapResultBase(lastChecked, lastChanged, beingTestedForReuse,
emittedErrors, errorsPresentInSelfOrDependencies,
std::move(recursionErrors), parentQueryMap),
tupleOfArgs(std::move(tupleOfArgs)),
result(std::move(result)) {
Expand Down
4 changes: 4 additions & 0 deletions frontend/include/chpl/framework/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ class Context {
context_ = nullptr;
}

bool isCleared() {
return context_ == nullptr;
}

~RecomputeMarker() {
restore();
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/include/chpl/framework/query-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ Context::getResult(QueryMap<ResultType, ArgTs...>* queryMap,
// printf("Found result %p %s\n", savedElement, queryMap->queryName);
}

if (newElementWasAdded == false && savedElement->lastChecked == -1) {
if (newElementWasAdded == false &&
(savedElement->lastChecked == -1 ||
savedElement->beingTestedForReuse)) {
// A recursion error was encountered. We will try to gracefully handle
// this error by adding it to the set of recursion errors on this
// result.
Expand Down Expand Up @@ -560,7 +562,7 @@ Context::isQueryRunning(
return false;
}

return search2->lastChecked == -1;
return search2->lastChecked == -1 || search2->beingTestedForReuse;
}

template<typename ResultType,
Expand Down
6 changes: 6 additions & 0 deletions frontend/include/chpl/resolution/ResolutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,14 @@ class ResolutionContext::GlobalQuery {
}

// Otherwise we are computing, so set the recompute marker.
// We don't want it to go out of scope now (since that undoes the mark),
// but this is just the 'begin' function; we do want it to go out of scope
// when the query is done (when 'end' is called). So, marker it in a field.
const bool isRecomputing = false;
auto activeRecomputeMarker = context_->markRecomputing(isRecomputing);

// We better not be saving another marker, since we only have room to save one.
CHPL_ASSERT(recomputeMarker_.isCleared());
std::swap(recomputeMarker_, activeRecomputeMarker);

// Set the stopwatch if it is compile-time enabled.
Expand Down
8 changes: 7 additions & 1 deletion frontend/lib/framework/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ void Context::recomputeIfNeeded(const QueryMapResultBase* resultEntry) {
// changed since the last revision in which we computed this?
// If so, compute it again.
bool useSaved = true;
resultEntry->beingTestedForReuse = true;
for (auto& dependency : resultEntry->dependencies) {
const QueryMapResultBase* dependencyQuery = dependency.query;
if (dependencyQuery->lastChanged > resultEntry->lastChanged) {
Expand All @@ -1042,6 +1043,7 @@ void Context::recomputeIfNeeded(const QueryMapResultBase* resultEntry) {
}
}
}
resultEntry->beingTestedForReuse = false;

if (useSaved == false) {
auto marker = markRecomputing(true);
Expand Down Expand Up @@ -1124,6 +1126,7 @@ bool Context::queryCanUseSavedResult(
useSaved = false;
} else {
useSaved = true;
resultEntry->beingTestedForReuse = true;
for (auto& dependency: resultEntry->dependencies) {
const QueryMapResultBase* dependencyQuery = dependency.query;

Expand All @@ -1142,6 +1145,7 @@ bool Context::queryCanUseSavedResult(
break;
}
}
resultEntry->beingTestedForReuse = false;
if (useSaved == true) {
updateForReuse(resultEntry);
}
Expand Down Expand Up @@ -1339,15 +1343,17 @@ void queryArgsPrintSep(std::ostream& s) {

QueryMapResultBase::QueryMapResultBase(RevisionNumber lastChecked,
RevisionNumber lastChanged,
bool beingTestedForReuse,
bool emittedErrors,
bool errorsPresentInSelfOrDependencies,
std::set<const QueryMapResultBase*> recursionErrors,
QueryMapBase* parentQueryMap)
: lastChecked(lastChecked),
lastChanged(lastChanged),
dependencies(),
beingTestedForReuse(beingTestedForReuse),
emittedErrors(emittedErrors),
errorsPresentInSelfOrDependencies(errorsPresentInSelfOrDependencies),
dependencies(),
recursionErrors(std::move(recursionErrors)),
errors(),
parentQueryMap(parentQueryMap) {
Expand Down
13 changes: 7 additions & 6 deletions frontend/lib/resolution/InitResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,15 @@ bool InitResolver::handleCallToSuperInit(const FnCall* node,
}

void InitResolver::updateSuperType(const CallResolutionResult* c) {
auto& msc = c->mostSpecific().only();
auto superThis = msc.formalActualMap().byFormalIdx(0).formalType().type();
if (auto& msc = c->mostSpecific().only()) {
auto superThis = msc.formalActualMap().byFormalIdx(0).formalType().type();

this->superType_ = superThis->getCompositeType()->toBasicClassType();
this->superType_ = superThis->getCompositeType()->toBasicClassType();

// Only update the current receiver if the parent was generic.
if (superType_->instantiatedFromCompositeType() != nullptr) {
updateResolverVisibleReceiverType();
// Only update the current receiver if the parent was generic.
if (superType_->instantiatedFromCompositeType() != nullptr) {
updateResolverVisibleReceiverType();
}
}

phase_ = PHASE_NEED_COMPLETE;
Expand Down
26 changes: 12 additions & 14 deletions frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,17 +2571,13 @@ QualifiedType Resolver::typeForId(const ID& id, bool localGenericToUnknown) {
// that we are working with a nested method
if (auto rt = methodReceiverType().type()) {
// get the new class type if the receiver is a class
auto nct = rt->toClassType();
// get the manager record using ClassType method managerRecordType()
if (auto mr = checkIfReceiverIsManagerRecord(context, nct, parentId)) {
ct = mr;
auto fieldName = parsing::fieldIdToName(context, id);
// TODO: shared has additional fields that are not generic
CHPL_ASSERT(fieldName == "chpl_t" || fieldName == "chpl_p");
auto intent = fieldName == "chpl_t" ? QualifiedType::TYPE : QualifiedType::VAR;
auto borrowed = nct->withDecorator(context, nct->decorator().toBorrowed());
return QualifiedType(intent, borrowed);
} else if (auto comprt = rt->getCompositeType()) {
if (auto ct = rt->toClassType()) {
if (auto mr = ct->managerRecordType(context)) {
rt = mr;
}
}

if (auto comprt = rt->getCompositeType()) {
if (comprt->id() == parentId) {
ct = comprt; // handle record, class with field
} else if (auto bct = comprt->toBasicClassType()) {
Expand Down Expand Up @@ -3971,9 +3967,11 @@ static const Type* getGenericType(Context* context, const Type* recv) {
gen = cur->instantiatedFromCompositeType();
if (gen == nullptr) gen = cur;
} else if (auto bct = recv->toBasicClassType()) {
if (bct->parentClassType()->instantiatedFromCompositeType()) {
auto pt = getGenericType(context, bct->parentClassType())->toBasicClassType();
bct = BasicClassType::get(context, bct->id(), bct->name(), pt, bct->instantiatedFrom(), bct->substitutions());
if (auto pct = bct->parentClassType()) {
if (pct->instantiatedFromCompositeType()) {
auto pt = getGenericType(context, pct)->toBasicClassType();
bct = BasicClassType::get(context, bct->id(), bct->name(), pt, bct->instantiatedFrom(), bct->substitutions());
}
}

gen = bct->instantiatedFromCompositeType();
Expand Down
Loading

0 comments on commit 98f12d0

Please sign in to comment.