From b6f7f77aaea901b00354ed433440cc943e8cec9f Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 20 Mar 2022 20:12:20 +0100 Subject: [PATCH] Revert "inline subs operations more aggressively" This reverts commit f4cb2ec25462ea4cd03f9aaeadd165c6df19a29c. it'll be merged by a different PR --- compiler/types/src/subs.rs | 20 ++++++++---------- vendor/ena/src/unify/mod.rs | 42 +++++++++++++------------------------ 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index 966f51e834..13f96c991d 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -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; diff --git a/vendor/ena/src/unify/mod.rs b/vendor/ena/src/unify/mod.rs index cdcf08cfb7..00c120ff3d 100644 --- a/vendor/ena/src/unify/mod.rs +++ b/vendor/ena/src/unify/mod.rs @@ -298,35 +298,21 @@ impl UnificationTable { /// /// 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, { 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, { 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, { let id = id.into(); - let id = self.inlined_get_root_key(id); + let id = self.get_root_key(id); self.value_mut(id) }