From 4f6de03d0f58e8969fa88490378b949619fbe6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=B7=D0=B4=D0=B0=D0=B9=D1=89=D0=B8=D0=BA?= <a.v.konovalov87@mail.ru> Date: Sat, 5 Dec 2020 15:11:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3:=20=D0=B7=D0=B0=D0=BC=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=BC=D0=BE=D0=B3=D1=83=D1=82=20?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D1=82=D1=8C=20=D0=BF=D1=80=D0=B8=D1=87=D0=B8?= =?UTF-8?q?=D0=BD=D1=83=20=D0=B7=D0=B0=D0=BC=D0=BE=D1=80=D0=BE=D0=B7=D0=BA?= =?UTF-8?q?=D0=B8=20(#228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/Log-AST.ref | 12 ++++++++---- src/compiler/OptTree-Drive.ref | 10 +++++++--- src/compiler/OptTree-Spec.ref | 22 +++------------------- src/compiler/OptTree.ref | 18 ++++++++++++++++-- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/compiler/Log-AST.ref b/src/compiler/Log-AST.ref index 0d60961e..b623a193 100644 --- a/src/compiler/Log-AST.ref +++ b/src/compiler/Log-AST.ref @@ -25,8 +25,8 @@ UndoubleEmtpyLines { Element { (Function s.Scope (e.Name) e.Body) = <Function (e.Name) s.Scope e.Body>; - (ColdFunction s.Scope (e.Name) e.Body) - = <ColdFunction (e.Name) s.Scope e.Body>; + (ColdFunction s.ColdBy s.Scope (e.Name) e.Body) + = <ColdFunction s.ColdBy (e.Name) s.Scope e.Body>; (Swap GN-Entry e.Name) = ('$ESWAP ' <DisplayName e.Name> ';'); (Swap GN-Local e.Name) = ('$SWAP ' <DisplayName e.Name> ';'); @@ -71,8 +71,12 @@ Function { } ColdFunction { - (e.Name) s.Scope e.Body - = <Function-Aux ('* ' <DisplayName e.Name> ' *') s.Scope e.Body>; + s.ColdBy (e.Name) s.Scope e.Body + = <Function-Aux ('* ' <DisplayName e.Name> ' *') s.Scope e.Body> + : () e.FunctionLines + = () + ('/* Cold by ' <Explode s.ColdBy> ' */') + e.FunctionLines; } Function-Aux { diff --git a/src/compiler/OptTree-Drive.ref b/src/compiler/OptTree-Drive.ref index a4f4d5c3..d866f958 100644 --- a/src/compiler/OptTree-Drive.ref +++ b/src/compiler/OptTree-Drive.ref @@ -348,10 +348,14 @@ DriveInlineOptimizerTick { = <MapAccum { (e.News-B (Function s.ScopeClass (e.Name) e._) e.News-E) - (s.Function s.ScopeClass (e.Name) e.Body) - , <OneOf s.Function Function ColdFunction> : True + (Function s.ScopeClass (e.Name) e.Body) + = (e.News-B e.News-E) + (Function s.ScopeClass (e.Name) e.Body); + + (e.News-B (Function s.ScopeClass (e.Name) e._) e.News-E) + (ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body) = (e.News-B e.News-E) - (s.Function s.ScopeClass (e.Name) e.Body); + (ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body); (e.NewFunctions^) t.Other = (e.NewFunctions) t.Other; } diff --git a/src/compiler/OptTree-Spec.ref b/src/compiler/OptTree-Spec.ref index 500c5f0d..fafc5ce2 100644 --- a/src/compiler/OptTree-Spec.ref +++ b/src/compiler/OptTree-Spec.ref @@ -221,7 +221,7 @@ ColdAll { = <Map { (Function s.ScopeClass (e.Name) e.Body) - = (ColdFunction s.ScopeClass (e.Name) e.Body); + = (ColdFunction SPEC s.ScopeClass (e.Name) e.Body); t.OtherItem = t.OtherItem; } @@ -274,7 +274,7 @@ SpecUnit { > : (e.SpecInfo^ (e.Histories) (e.History^) (e.NewFunctions^)) e.Sentences^ = (e.SpecInfo (e.Histories) (e.NewFunctions)) - (ColdFunction s.ScopeClass t.Name Sentences e.Sentences); + (ColdFunction SPEC s.ScopeClass t.Name Sentences e.Sentences); (e.SpecInfo (e.Histories) (e.NewFunctions)) (Function s.ScopeClass t.Name Sentences e.Sentences) @@ -286,7 +286,7 @@ SpecUnit { : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Sentences^ = (e.SpecInfo (e.Histories) (e.NewFunctions)) - (ColdFunction s.ScopeClass t.Name Sentences e.Sentences); + (ColdFunction SPEC s.ScopeClass t.Name Sentences e.Sentences); (e.SpecInfo (e.Histories) (e.NewFunctions)) t.Other = (e.SpecInfo (e.Histories) (e.NewFunctions)) t.Other; @@ -1082,22 +1082,6 @@ PrepareSpecConditions { > } -/** - <OptTree-Spec-CleanupColdFunctions e.AST> == e.AST^ -*/ -$ENTRY OptTree-Spec-CleanupColdFunctions { - e.AST - = <Map - { - (ColdFunction s.ScopeClass (e.Name) e.Body) - = (Function s.ScopeClass (e.Name) e.Body); - - t.OtherItem = t.OtherItem; - } - e.AST - >; -} - /* Вспомогательные функции модуля */ diff --git a/src/compiler/OptTree.ref b/src/compiler/OptTree.ref index 8fb79d4f..43127afe 100644 --- a/src/compiler/OptTree.ref +++ b/src/compiler/OptTree.ref @@ -15,7 +15,7 @@ $EXTERN OptTree-AutoMarkup-Drive, OptTree-AutoMarkup-CureDrives, $EXTERN OptTree-Drive-Prepare, OptTree-Drive, OptTree-Drive-CleanupColdCalls; *$FROM OptTree-Spec -$EXTERN OptTree-Spec-Prepare, OptTree-Spec, OptTree-Spec-CleanupColdFunctions; +$EXTERN OptTree-Spec-Prepare, OptTree-Spec; *$FROM Log $EXTERN Log-AST; @@ -70,7 +70,7 @@ $ENTRY OptTree { (pass (trace 'before Spec') (call &OptTree-Spec s.OptSpec))) - (call &OptTree-Spec-CleanupColdFunctions)) + (call &WarmColdFunctions SPEC)) (begin (call &OptTree-Drive-Prepare t.OptDrive) (DriveLoop)))) @@ -115,6 +115,20 @@ $ENTRY OptTree-CleanupMarkup { } +WarmColdFunctions { + s.ColdBy e.AST + = <Map + { + (ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body) + = (Function s.ScopeClass (e.Name) e.Body); + + t.OtherItem = t.OtherItem; + } + e.AST + >; +} + + ExpandClosures { e.AST = <Map