Skip to content

Commit

Permalink
Performance fix to decoration site tree resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
krame505 committed Sep 27, 2024
1 parent 34ffe53 commit 70fec54
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions grammars/silver/compiler/definition/flow/env/DecSites.sv
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ DecSiteTree ::= prodName::String vt::VertexType seen::[(String, VertexType)] flo

-- Flatten a resolved decision tree, to determine the minimal places where an
-- equation is needed.
strategy attribute reduceDecSite = innermost( -- TODO: Avoid forcing the entire tree if the first dec site is supplied?
partial strategy attribute reduceDecSiteStep =
rule on DecSiteTree of
| altDec(alwaysDec(), d) -> alwaysDec()
| altDec(d, alwaysDec()) -> alwaysDec()
Expand All @@ -101,8 +101,7 @@ strategy attribute reduceDecSite = innermost( -- TODO: Avoid forcing the entire
| transAttrDec(attrName, neverDec()) -> neverDec()
-- This is assuming the we have already resolved for some inh-on-a-trans-attr that matches attrName.
| transAttrDec(attrName, alwaysDec()) -> alwaysDec()
end
) occurs on DecSiteTree;
end occurs on DecSiteTree;

inherited attribute attrToResolve::String occurs on DecSiteTree;
propagate attrToResolve on DecSiteTree excluding transAttrDec;
Expand All @@ -116,7 +115,7 @@ attribute flowEnv occurs on DecSiteTree;

-- Resolve the decision tree for a particular attribute, replacing decoration
-- sites known to be supplied with alwaysDec().
strategy attribute resolveDecSite = allTopDown(
partial strategy attribute resolveDecSiteStep =
rule on top::DecSiteTree of
| directDec(prodName, vt)
when vertexHasInhEq(prodName, vt, top.attrToResolve, top.flowEnv) ->
Expand All @@ -139,11 +138,17 @@ strategy attribute resolveDecSite = allTopDown(
| just((transAttr, inhAttr)) -> transAttr != attrName
| _ -> true
end -> neverDec()
end
) <* reduceDecSite
occurs on DecSiteTree;
end occurs on DecSiteTree;

propagate flowEnv, reduceDecSite, resolveDecSite on DecSiteTree;
strategy attribute resolveDecSite =
repeat(
{-rule on DecSiteTree of
| ds -> unsafeTracePrint(^ds, prettyDecSites(^ds) ++ "\n\n")
end <*-}
onceTopDown(resolveDecSiteStep <+ reduceDecSiteStep))
occurs on DecSiteTree;

propagate flowEnv, reduceDecSiteStep, resolveDecSiteStep, resolveDecSite on DecSiteTree;

{--
- Determine if some decoration site has some inherited attribute supplied.
Expand Down

0 comments on commit 70fec54

Please sign in to comment.