duplicate structured records with different canonical field type representation
Categories
(Webtools :: Searchfox, enhancement)
Tracking
(firefox129 fixed)
| Tracking | Status | |
|---|---|---|
| firefox129 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 file)
https://searchfox.org/mozilla-central/query/default?q=field-layout%3A%27js%3A%3Agc%3A%3AGCRuntime%27
This shows that there are 2 types for systemZone field:
class js::ProtectedDataNoCheckArgs<class js::CheckMainThread<js::AllowedHelperThread::None>, class JS::Zone *>class js::ProtectedDataNoCheckArgs<class js::CheckMainThread<enum AllowedHelperThread::None>, class JS::Zone *>
The difference is the AllowedHelperThread::None part, whether it has js:: prefix or enum prefix.
When I look into the GCRuntime.h analysis file before merge, there are 2 structured records for all platform except for android-armv7,
where the first one has enum prefix and the second one has js:: prefix.
| Assignee | ||
Comment 1•1 year ago
|
||
when compiling the code with mozsearch-plugin, in most case, the class GCRuntime declaration generates field type with js:: prefix for AllowedHelperThread::None, but if the compilation unit contains js/src/threading/ProtectedData.cpp, especially the following template instantiation, the class GCRuntime generates field type with enum prefix.
template class CheckMainThread<AllowedHelperThread::None>;
So I guess this is an issue around how clang generate the canonical type string representation, depending on whether the instantiation exists in the compilation unit or not.
Comment 2•1 year ago
|
||
Thanks for digging into the cause of the over-proliferation of structured representation variants[1]! cc'ing :botond in case he might have some thoughts/awareness on this.
1: Restating: Our clang plugin de-duplicates records based on string equivalence, so if the structured info emission does not always produce the exact same output, the merger logic which uses the hash of the string representation of the structured JSON records to figure out our variants will end up with a bunch of extra variants. (In general I was assuming this could not happen during initial implementation for simplicity, but I think this was obviously false by the time the structured representation stuff landed from my fancy-branch field-layout prototype. Just it was less bad then.)
| Assignee | ||
Comment 3•1 year ago
•
|
||
Looks like we can control it by PrintingPolicy parameter of QualType::getAsString.
std::string QualType::getAsString() const {
return getAsString(split(), LangOptions());
}
std::string QualType::getAsString(const PrintingPolicy &Policy) const {
std::string S;
getAsStringInternal(S, Policy);
return S;
}
the policy is eventually consumed by the following:
if (auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
const TemplateParameterList *TParams =
S->getSpecializedTemplate()->getTemplateParameters();
const ASTTemplateArgumentListInfo *TArgAsWritten =
S->getTemplateArgsAsWritten();
IncludeStrongLifetimeRAII Strong(Policy);
if (TArgAsWritten && !Policy.PrintCanonicalTypes)
printTemplateArgumentList(OS, TArgAsWritten->arguments(), Policy,
TParams);
else
printTemplateArgumentList(OS, S->getTemplateArgs().asArray(), Policy,
TParams);
and I do see the difference in the following, when the compilation unit contains the template instantiation.
CanonicalFieldType.getAsString(); // generates with `enum ` prefix
PrintingPolicy Policy((LangOptions()));
Policy.PrintCanonicalTypes = true;
CanonicalFieldType.getAsString(Policy); // generates with `js::`
I'll apply the workaround for all callsites the field type (apparently other cases are not related to merge).
| Assignee | ||
Comment 4•1 year ago
|
||
Comment 6•1 year ago
|
||
| bugherder | ||
Description
•