Skip to content

Commit

Permalink
Принудительные обобщения в куче мест для борьбы с распуханием № 4 (#359)
Browse files Browse the repository at this point in the history
По-нормальному, нужно каждый случай обобщения описать, сделать выводы
и решить проблему в общем случае в рамках #332. А пока я анализировал
лог и подсекал наиболее явные точки распухания.

В Log-AST.ref был интересный случай квадратичного распухания,
а в остальных местах — типичная специализация по аккумулятору.
  • Loading branch information
Mazdaywik committed Aug 1, 2021
1 parent 7e50e6c commit 8844890
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/compiler/HighLevelRASL-GenResult-Simple.ref
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,17 @@ GenResult {
>;
}

gen_e__ { e.arg = e.arg }

DoGenResult {
(e.Vars) (e.AllocCommands) (e.Commands) s.Counter e.Result
= <DoGenResult-GEN
(e.Vars) (<gen_e__ e.AllocCommands>) (<gen_e__ e.Commands>)
s.Counter e.Result
>;
}

DoGenResult-GEN {
(e.Vars) (e.AllocCommands) (e.Commands)
s.Counter (TkOpenCallCond s.Offset) e.Result =
<DoGenResult
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/Log-AST.ref
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Function-Aux {
('* metatable function')
<Map
{
(t.Ident t.Name)
= (' ' <InlineTerm t.Ident> ' :: ' <InlineTerm t.Name>);
((Symbol Identifier e.Ident) (Symbol Name e.Name^))
= (' ' <Symbol Identifier e.Ident> ' :: ' <Symbol Name e.Name>);
}
e.Metatable
>
Expand Down
9 changes: 9 additions & 0 deletions src/compiler/LowLevelRASL.ref
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ Canonize {
}

CalcDigest {
t.Hashes t.Element
= <CalcDigest-Aux t.Hashes t.Element> : t.Hashes^ t.Element^
= t.Hashes <gen_t__ t.Element>;
}

gen_t__ { e.arg = <gen_e__ e.arg> }
gen_e__ { e.arg = e.arg }

CalcDigest-Aux {
(s.Hash1 s.Hash2) (UnitName e.SrcName) =
(<HashLittle2-Chars s.Hash1 s.Hash2 e.SrcName>)
(UnitName e.SrcName);
Expand Down
7 changes: 7 additions & 0 deletions src/compiler/R5-Parser.ref
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ TokenChain {
gen_e__ { e.arg = e.arg }

DoTokenChain {
s.Mode s.Kind t.ErrorList (e.Collected) e.Tokens
= <DoTokenChain-GEN
s.Mode s.Kind t.ErrorList (<gen_e__ e.Collected>) e.Tokens
>
}

DoTokenChain-GEN {
s.Mode s.Kind t.ErrorList (e.Collected) t.NextToken e.Tokens
= t.NextToken
: {
Expand Down
14 changes: 14 additions & 0 deletions src/compiler/SR-Parser.sref
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,13 @@ ParsePattern {
gen_e__ { e.arg = e.arg; }

DoParsePattern {
t.ErrorList (e.MultiBracket) (e.Scanned) e.Tokens
= <DoParsePattern-GEN
t.ErrorList (<gen_e__ e.MultiBracket>) (<gen_e__ e.Scanned>) e.Tokens
>;
}

DoParsePattern-GEN {
// Обработка литералов атомов

t.ErrorList (e.MultiBrackets) (e.Scanned) (#TkChar s.LnNum s.Char) e.Tail =
Expand Down Expand Up @@ -638,6 +645,13 @@ ParseBlocks {
<DoParseResult t.ErrorList (e.MultiBracket) (e.Scanned) e.Tail>
*/
DoParseResult {
t.ErrorList (e.MultiBracket) (e.Scanned) e.Tokens
= <DoParseResult-GEN
t.ErrorList (<gen_e__ e.MultiBracket>) (<gen_e__ e.Scanned>) e.Tokens
>;
}

DoParseResult-GEN {
// Обработка литералов атомов

t.ErrorList (e.MultiBracket) (e.Scanned) (#TkChar s.LnNum s.Char) e.Tail =
Expand Down

0 comments on commit 8844890

Please sign in to comment.