[libSyntax] Remove incremental JSON transfer option

We were only keeping track of `RawSyntax` node IDs to incrementally transfer a syntax tree via JSON. However, AFAICT the incremental JSON transfer option has been superceeded by `SyntaxParseActions`, which are more efficient.

So, let’s clean up and remove the `RawSyntax` node ID and JSON incremental transfer option.

In places that still need a notion of `RawSyntax` identity (like determining the reused syntax regions), use the `RawSyntax`’s pointer instead of the manually created ID.

In `incr_transfer_round_trip.py` always use the code path that uses the `SyntaxParseActions` and remove the transitional code that was still using the incremental JSON transfer but was never called.
This commit is contained in:
Alex Hoppen
2021-03-12 09:56:59 +01:00
parent fd8e34913a
commit 294977534c
26 changed files with 98 additions and 912 deletions

View File

@@ -150,12 +150,6 @@ OmitNodeIds("omit-node-ids",
llvm::cl::desc("If specified, the serialized syntax tree will not "
"include the IDs of the serialized nodes."));
static llvm::cl::opt<bool>
IncrementalSerialization("incremental-serialization",
llvm::cl::desc("If specified, the serialized syntax "
"tree will omit nodes that have not "
"changed since the last parse."));
static llvm::cl::opt<std::string>
OutputFilename("output-filename",
llvm::cl::desc("Path to the output file"));
@@ -725,35 +719,20 @@ int doSerializeRawTree(const char *MainExecutablePath,
return parseFile(MainExecutablePath, InputFile,
[](ParseInfo info) -> int {
auto SF = info.SF;
auto SyntaxCache = info.SyntaxCache;
auto Root = SF->getSyntaxRoot().getRaw();
std::unordered_set<unsigned> ReusedNodeIds;
if (options::IncrementalSerialization && SyntaxCache) {
ReusedNodeIds = SyntaxCache->getReusedNodeIds();
}
auto SerializeTree = [&ReusedNodeIds](llvm::raw_ostream &os,
const RawSyntax *Root,
SyntaxParsingCache *SyntaxCache) {
swift::json::Output::UserInfoMap JsonUserInfo;
JsonUserInfo[swift::json::OmitNodesUserInfoKey] = &ReusedNodeIds;
if (options::OmitNodeIds) {
JsonUserInfo[swift::json::DontSerializeNodeIdsUserInfoKey] =
(void *)true;
}
swift::json::Output out(os, JsonUserInfo);
out << *Root;
os << "\n";
};
if (!options::OutputFilename.empty()) {
std::error_code errorCode;
llvm::raw_fd_ostream os(options::OutputFilename, errorCode,
llvm::sys::fs::F_None);
assert(!errorCode && "Couldn't open output file");
SerializeTree(os, Root, SyntaxCache);
swift::json::Output out(os);
out << *Root;
os << "\n";
} else {
SerializeTree(llvm::outs(), Root, SyntaxCache);
swift::json::Output out(llvm::outs());
out << *Root;
llvm::outs() << "\n";
}
if (!options::DiagsOutputFilename.empty()) {