Revert "inline subs operations more aggressively"

This reverts commit f4cb2ec254.

it'll be merged by a different PR
This commit is contained in:
Folkert 2022-03-20 20:12:20 +01:00
parent ba13ad71a6
commit b6f7f77aae
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 23 additions and 39 deletions

View file

@ -1602,8 +1602,8 @@ impl Subs {
/// Unions two keys without the possibility of failure.
pub fn union(&mut self, left: Variable, right: Variable, desc: Descriptor) {
let l_root = self.utable.inlined_get_root_key(left);
let r_root = self.utable.inlined_get_root_key(right);
let l_root = self.utable.get_root_key(left);
let r_root = self.utable.get_root_key(right);
// NOTE this swapping is intentional! most of our unifying commands are based on the elm
// source, but unify_roots is from `ena`, not the elm source. Turns out that they have
@ -1647,25 +1647,23 @@ impl Subs {
&self.utable.probe_value_ref(key).value.content
}
#[inline(always)]
pub fn get_root_key(&mut self, key: Variable) -> Variable {
self.utable.inlined_get_root_key(key)
self.utable.get_root_key(key)
}
#[inline(always)]
pub fn get_root_key_without_compacting(&self, key: Variable) -> Variable {
self.utable.get_root_key_without_compacting(key)
}
#[inline(always)]
pub fn set(&mut self, key: Variable, r_value: Descriptor) {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
self.utable.update_value(l_key, |node| node.value = r_value);
}
pub fn set_rank(&mut self, key: Variable, rank: Rank) {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
self.utable.update_value(l_key, |node| {
node.value.rank = rank;
@ -1673,7 +1671,7 @@ impl Subs {
}
pub fn set_mark(&mut self, key: Variable, mark: Mark) {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
self.utable.update_value(l_key, |node| {
node.value.mark = mark;
@ -1681,7 +1679,7 @@ impl Subs {
}
pub fn set_rank_mark(&mut self, key: Variable, rank: Rank, mark: Mark) {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
self.utable.update_value(l_key, |node| {
node.value.rank = rank;
@ -1690,7 +1688,7 @@ impl Subs {
}
pub fn set_content(&mut self, key: Variable, content: Content) {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
self.utable.update_value(l_key, |node| {
node.value.content = content;
@ -1706,7 +1704,7 @@ impl Subs {
#[inline(always)]
pub fn get_rank_set_mark(&mut self, key: Variable, mark: Mark) -> Rank {
let l_key = self.utable.inlined_get_root_key(key);
let l_key = self.utable.get_root_key(key);
let mut rank = Rank::NONE;

View file

@ -298,35 +298,21 @@ impl<S: UnificationStore> UnificationTable<S> {
///
/// NB. This is a building-block operation and you would probably
/// prefer to call `probe` below.
///
/// This is an always-inlined version of this function for the hot
/// callsites. `uninlined_get_root_key` is the never-inlined version.
#[inline(always)]
pub fn inlined_get_root_key(&mut self, vid: S::Key) -> S::Key {
let redirect = {
match self.value(vid).parent(vid) {
None => return vid,
Some(redirect) => redirect,
pub fn get_root_key(&mut self, vid: S::Key) -> S::Key {
match self.value(vid).parent(vid) {
None => vid,
Some(redirect) => {
let root_key: S::Key = self.get_root_key(redirect);
if root_key != redirect {
// Path compression
self.update_value(vid, |value| value.parent = root_key);
}
root_key
}
};
let root_key: S::Key = self.uninlined_get_root_key(redirect);
if root_key != redirect {
// Path compression
self.update_value(vid, |value| value.parent = root_key);
}
root_key
}
// This is a never-inlined version of this function for cold callsites.
// 'inlined_get_root_key` is the always-inlined version.
#[inline(never)]
fn uninlined_get_root_key(&mut self, vid: S::Key) -> S::Key {
self.inlined_get_root_key(vid)
}
#[inline(always)]
pub fn get_root_key_without_compacting(&self, mut vid: S::Key) -> S::Key {
while let Some(redirect) = self.value(vid).parent(vid) {
vid = redirect;
@ -449,7 +435,7 @@ where
K1: Into<K>,
{
let id = id.into();
self.inlined_get_root_key(id)
self.get_root_key(id)
}
/// Returns the current value for the given key. If the key has
@ -460,7 +446,7 @@ where
K1: Into<K>,
{
let id = id.into();
let id = self.inlined_get_root_key(id);
let id = self.get_root_key(id);
self.value(id).value.clone()
}
@ -484,7 +470,7 @@ where
K1: Into<K>,
{
let id = id.into();
let id = self.inlined_get_root_key(id);
let id = self.get_root_key(id);
self.value_mut(id)
}