mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Revert "inline subs operations more aggressively"
This reverts commit f4cb2ec254
.
it'll be merged by a different PR
This commit is contained in:
parent
ba13ad71a6
commit
b6f7f77aae
2 changed files with 23 additions and 39 deletions
|
@ -1602,8 +1602,8 @@ impl Subs {
|
||||||
|
|
||||||
/// Unions two keys without the possibility of failure.
|
/// Unions two keys without the possibility of failure.
|
||||||
pub fn union(&mut self, left: Variable, right: Variable, desc: Descriptor) {
|
pub fn union(&mut self, left: Variable, right: Variable, desc: Descriptor) {
|
||||||
let l_root = self.utable.inlined_get_root_key(left);
|
let l_root = self.utable.get_root_key(left);
|
||||||
let r_root = self.utable.inlined_get_root_key(right);
|
let r_root = self.utable.get_root_key(right);
|
||||||
|
|
||||||
// NOTE this swapping is intentional! most of our unifying commands are based on the elm
|
// 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
|
// 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
|
&self.utable.probe_value_ref(key).value.content
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn get_root_key(&mut self, key: Variable) -> Variable {
|
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 {
|
pub fn get_root_key_without_compacting(&self, key: Variable) -> Variable {
|
||||||
self.utable.get_root_key_without_compacting(key)
|
self.utable.get_root_key_without_compacting(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn set(&mut self, key: Variable, r_value: Descriptor) {
|
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);
|
self.utable.update_value(l_key, |node| node.value = r_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_rank(&mut self, key: Variable, rank: Rank) {
|
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| {
|
self.utable.update_value(l_key, |node| {
|
||||||
node.value.rank = rank;
|
node.value.rank = rank;
|
||||||
|
@ -1673,7 +1671,7 @@ impl Subs {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_mark(&mut self, key: Variable, mark: Mark) {
|
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| {
|
self.utable.update_value(l_key, |node| {
|
||||||
node.value.mark = mark;
|
node.value.mark = mark;
|
||||||
|
@ -1681,7 +1679,7 @@ impl Subs {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_rank_mark(&mut self, key: Variable, rank: Rank, mark: Mark) {
|
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| {
|
self.utable.update_value(l_key, |node| {
|
||||||
node.value.rank = rank;
|
node.value.rank = rank;
|
||||||
|
@ -1690,7 +1688,7 @@ impl Subs {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_content(&mut self, key: Variable, content: Content) {
|
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| {
|
self.utable.update_value(l_key, |node| {
|
||||||
node.value.content = content;
|
node.value.content = content;
|
||||||
|
@ -1706,7 +1704,7 @@ impl Subs {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn get_rank_set_mark(&mut self, key: Variable, mark: Mark) -> Rank {
|
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;
|
let mut rank = Rank::NONE;
|
||||||
|
|
||||||
|
|
42
vendor/ena/src/unify/mod.rs
vendored
42
vendor/ena/src/unify/mod.rs
vendored
|
@ -298,35 +298,21 @@ impl<S: UnificationStore> UnificationTable<S> {
|
||||||
///
|
///
|
||||||
/// NB. This is a building-block operation and you would probably
|
/// NB. This is a building-block operation and you would probably
|
||||||
/// prefer to call `probe` below.
|
/// prefer to call `probe` below.
|
||||||
///
|
pub fn get_root_key(&mut self, vid: S::Key) -> S::Key {
|
||||||
/// This is an always-inlined version of this function for the hot
|
match self.value(vid).parent(vid) {
|
||||||
/// callsites. `uninlined_get_root_key` is the never-inlined version.
|
None => vid,
|
||||||
#[inline(always)]
|
Some(redirect) => {
|
||||||
pub fn inlined_get_root_key(&mut self, vid: S::Key) -> S::Key {
|
let root_key: S::Key = self.get_root_key(redirect);
|
||||||
let redirect = {
|
if root_key != redirect {
|
||||||
match self.value(vid).parent(vid) {
|
// Path compression
|
||||||
None => return vid,
|
self.update_value(vid, |value| value.parent = root_key);
|
||||||
Some(redirect) => redirect,
|
}
|
||||||
|
|
||||||
|
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 {
|
pub fn get_root_key_without_compacting(&self, mut vid: S::Key) -> S::Key {
|
||||||
while let Some(redirect) = self.value(vid).parent(vid) {
|
while let Some(redirect) = self.value(vid).parent(vid) {
|
||||||
vid = redirect;
|
vid = redirect;
|
||||||
|
@ -449,7 +435,7 @@ where
|
||||||
K1: Into<K>,
|
K1: Into<K>,
|
||||||
{
|
{
|
||||||
let id = id.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
|
/// Returns the current value for the given key. If the key has
|
||||||
|
@ -460,7 +446,7 @@ where
|
||||||
K1: Into<K>,
|
K1: Into<K>,
|
||||||
{
|
{
|
||||||
let id = id.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()
|
self.value(id).value.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +470,7 @@ where
|
||||||
K1: Into<K>,
|
K1: Into<K>,
|
||||||
{
|
{
|
||||||
let id = id.into();
|
let id = id.into();
|
||||||
let id = self.inlined_get_root_key(id);
|
let id = self.get_root_key(id);
|
||||||
self.value_mut(id)
|
self.value_mut(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue