about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-06-06 12:44:05 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2018-06-06 20:08:34 +1000
commit5c36e01f35c1e0290afd654367c2ba1e2353ca36 (patch)
treec392eb6356414f0e3165bf8bf7e25615410a672e /src/rustllvm/RustWrapper.cpp
parent41affd03eb169830773cd1b11efda562ab81fad0 (diff)
downloadrust-5c36e01f35c1e0290afd654367c2ba1e2353ca36.tar.gz
rust-5c36e01f35c1e0290afd654367c2ba1e2353ca36.zip
Use scope tree depths to speed up `nearest_common_ancestor`.
This patch adds depth markings to all entries in the `ScopeTree`'s
`parent_map`. This change increases memory usage somewhat, but permits a
much faster algorithm to be used:

- If one scope has a greater depth than the other, the deeper scope is
  moved upward until they are at equal depths.

- Then we move the two scopes upward in lockstep until they match.

This avoids the need to keep track of which scopes have already been
seen, which was the major part of the cost of the old algorithm. It also
reduces the number of child-to-parent moves (which are hash table
lookups) when the scopes start at different levels, because it never
goes past the nearest common ancestor the way the old algorithm did.

Finally, the case where one of the scopes is the root is now handled in
advance, because that is moderately common and lets us skip everything.

This change speeds up runs of several rust-perf benchmarks, the best by
6%.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions