MCPcopy Create free account
hub / github.com/argumentcomputer/ix / apply_sharing_with_stats

Function apply_sharing_with_stats

crates/compile/src/compile.rs:1608–1665  ·  view source on GitHub ↗

Apply sharing analysis to a set of expressions. Returns the rewritten expressions, sharing vector, and hash-consed size. Hash-consed size tracking is controlled by the global `TRACK_HASH_CONSED_SIZE` flag.

(
  exprs: Vec<Arc<Expr>>,
  block_name: Option<&str>,
)

Source from the content-addressed store, hash-verified

1606 cache.arena.alloc(ExprMetaData::App { children: [f_root, a_root] }),
1607 );
1608 },
1609
1610 Frame::BuildLam(name_addr, info) => {
1611 let body_root =
1612 cache.arena_roots.pop().expect("BuildLam missing body root");
1613 let ty_root =
1614 cache.arena_roots.pop().expect("BuildLam missing ty root");
1615 let body = results.pop().expect("BuildLam missing body");
1616 let ty = results.pop().expect("BuildLam missing ty");
1617 results.push(Expr::lam(ty, body));
1618 cache.arena_roots.push(cache.arena.alloc(ExprMetaData::Binder {
1619 name: name_addr,
1620 info,
1621 children: [ty_root, body_root],
1622 }));
1623 },
1624
1625 Frame::BuildAll(name_addr, info) => {
1626 let body_root =
1627 cache.arena_roots.pop().expect("BuildAll missing body root");
1628 let ty_root =
1629 cache.arena_roots.pop().expect("BuildAll missing ty root");
1630 let body = results.pop().expect("BuildAll missing body");
1631 let ty = results.pop().expect("BuildAll missing ty");
1632 results.push(Expr::all(ty, body));
1633 cache.arena_roots.push(cache.arena.alloc(ExprMetaData::Binder {
1634 name: name_addr,
1635 info,
1636 children: [ty_root, body_root],
1637 }));
1638 },
1639
1640 Frame::BuildLet(name_addr, non_dep) => {
1641 let body_root =
1642 cache.arena_roots.pop().expect("BuildLet missing body root");
1643 let val_root =
1644 cache.arena_roots.pop().expect("BuildLet missing val root");
1645 let ty_root =
1646 cache.arena_roots.pop().expect("BuildLet missing ty root");
1647 let body = results.pop().expect("BuildLet missing body");
1648 let val = results.pop().expect("BuildLet missing val");
1649 let ty = results.pop().expect("BuildLet missing ty");
1650 results.push(Expr::let_(non_dep, ty, val, body));
1651 cache.arena_roots.push(cache.arena.alloc(ExprMetaData::LetBinder {
1652 name: name_addr,
1653 children: [ty_root, val_root, body_root],
1654 }));
1655 },
1656
1657 Frame::BuildProj(type_ref_idx, field_idx, struct_name_addr) => {
1658 let child_root =
1659 cache.arena_roots.pop().expect("BuildProj missing child root");
1660 let struct_val = results.pop().expect("BuildProj missing struct_val");
1661 results.push(Expr::prj(type_ref_idx, field_idx, struct_val));
1662 cache.arena_roots.push(cache.arena.alloc(ExprMetaData::Prj {
1663 struct_name: struct_name_addr,
1664 child: child_root,
1665 }));

Calls 7

analyze_blockFunction · 0.85
compute_hash_consed_sizeFunction · 0.85
analyze_sharing_statsFunction · 0.85
decide_sharingFunction · 0.85
build_sharing_vecFunction · 0.85
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected