Caml1999I037b\#Tmc'rewriteh@&Lambda&lambda@@@&lambda@@@@@@.lambda/tmc.mliQ [ [Q [ y@@B@@@H#Tmc0vȽ PdŠ(Warnings0mJɒkgrs-Stdlib__Uchar056uf4[_+Stdlib__Sys0 -ռ鱦s5/.Stdlib__String0Vê>)Longident0s `7mɕc(Location0a7cK_H%9)Load_path0I@18 ~&Lambda0z1x]&ZT,Identifiable0 {d\FX'`%Ident0">WA+9*X*Format_doc0]mWϓ:Mݠ#Env0zV L{YWI)Debuginfo0PtJ=^w/*Data_types0I'Ue`wq]Ѡ*Cmi_format0c˯7͗ԩmݠ0CamlinternalLazy0&͂7 Pˆ8CamlinternalFormatBasics0%FU(Q/Tu5Build_path_prefix_map0z HkGs(Asttypes0>n{T8cئ@@@Caml1999T037(aC#Tmc*ocaml.text&_none_@@A w Tail-modulo-cons optimization. {b Warning:} this module is unstable and part of {{!Compiler_libs}compiler-libs}. .lambda/tmc.mliRVNP@@@@@@3@@@@@@#intA;@@@A@@@@@:@A@$charB;@@A@@@@@>@A@&stringQ;@@ A@@@@@B@@@%bytesC;@@ A@@@@@F@@@%floatD;@@A@@@@@J@@@$boolE;@@%falsec@@T@$trued@@Z@@@A@@@@@[@A@$unitF;@@"()e@@e@@@A@@@@@f@A@ #exnG;@@@A@@@@@j@@@#effH;@@O@A@A@@@@@@s@@@,continuationI;@@Q@@P@B@A@nY@@@@@@@@@%arrayJ;@@R@A@A@@@@@@@@@ $listK;@@S@A"[]f@@@"::g@@@T@@@ @@A@Y@@@@@@@@&optionL;@@V@A$Noneh@@@$Somei@@@@@A@Y@@@@@@@@)nativeintM;@@A@@@@@@@@%int32N;@@A@@@@@@@@%int64O;@@A@@@@@@@@&lazy_tP;@@X@AJA@Y@@@@@@@@5extension_constructorR;@@A@@@@@@@@*floatarrayS;@@A@@@@@@@@&iarrayT;@@Y@A[A@Y@@@@@@@@*atomic_locU;@@Z@AdA@@@@@@@@@.Assert_failure`#@@@@@J@@@@@@@@[@@A=ocaml.warn_on_literal_pattern @ @0Division_by_zero]#@@@A  @+End_of_file\#$@@@A@'FailureY#,@'@@A!$$@0Invalid_argumentX#5@0@@A*$-#-@-Match_failureV#>@@=@9@;@@a@@A;5>4>@)Not_foundZ#O@@@AC=F<F@-Out_of_memoryW#W@@@AKENDN@.Stack_overflow^#_@@@ASMVLV@.Sys_blocked_io_#g@@@A[U^T^@)Sys_error[#o@j@@Ad^g]g@:Undefined_recursive_modulea#x@@w@s@u@@h@@Auoxnx@:Continuation_already_takenb#@@@A}wv@&Stdlib@Ax  TMC (Tail Modulo Cons) is a code transformation that rewrites transformed functions in destination-passing-style, in such a way that certain calls that were not in tail position in the original program become tail-calls in the transformed program. As a classic example, the following program {| let[@tail_mod_cons] rec map f = function | [] -> [] | x :: xs -> let y = f x in y :: map f xs |} becomes (expressed in almost-source-form; the translation is in fact at the Lambda-level) {| let rec map f = function | [] -> [] | x :: xs -> let y = f x in let dst = y :: Placeholder in map_dps dst 1 f xs; dst and map_dps dst offset f = function | [] -> dst.offset <- [] | x :: xs -> let y = f x in let dst' = y :: Placeholder in dst.offset <- dst'; map_dps dst 1 f fx |} In this example, the expression (y :: map f xs) had a call in non-tail-position, and it gets rewritten into tail-calls. TMC handles all such cases where the continuation of the call (what needs to be done after the return) is a "construction", the creation of a (possibly nested) data block. The code transformation generates two versions of the input function, the "direct" version with the same type and behavior as the original one (here just [map]), and the "destination-passing-style" version (here [map_dps]). Any call to the original function from outside the let..rec declaration gets transformed into a call into the direct version, which will itself call the destination-passing-style versions on recursive calls that may benefit from it (they are in tail-position modulo constructors). Because of this inherent code duplication, the transformation may not always improve performance. In this implementation, TMC is opt-in, we only transform functions that the user has annotated with an attribute to request the transformation. XRRM J L@@@@@@ࠐ&Lambda&LambdaO N SO N Y@@A3@ @AO N N@@@'rewritegQ [ _Q [ f@б@г&lambdaQ [ iQ [ o@@ @@@ @@г*&lambdaQ [ sQ [ y@@ @@@ *@@@@@ -@@@Q [ [ @@B@@ @@3@,@@3@6. @A@ H************************************************************************A@@A@L@ H BMMBM@ H OCaml CC@ H DD3@ J Frédéric Bour E44E4@ H Gabriel Scherer, projet Partout, INRIA Saclay FF@ I Basile Clément, projet Cambium, INRIA Paris GG@ H HHj@ H Copyright 2020 Institut National de Recherche en Informatique et IkkIk@ H en Automatique. JJ@ H  KKQ@ H All rights reserved. This file is distributed under the terms of LRRLR@ H the GNU Lesser General Public License version 2.1, with the MM@ H special exception on linking described in the file LICENSE. N N8@ H %O99&O9@ H************************************************************************+P,P@ x* Tail-modulo-cons optimization. {b Warning:} this module is unstable and part of {{!Compiler_libs}compiler-libs}. 1 * TMC (Tail Modulo Cons) is a code transformation that rewrites transformed functions in destination-passing-style, in such a way that certain calls that were not in tail position in the original program become tail-calls in the transformed program. As a classic example, the following program {| let[@tail_mod_cons] rec map f = function | [] -> [] | x :: xs -> let y = f x in y :: map f xs |} becomes (expressed in almost-source-form; the translation is in fact at the Lambda-level) {| let rec map f = function | [] -> [] | x :: xs -> let y = f x in let dst = y :: Placeholder in map_dps dst 1 f xs; dst and map_dps dst offset f = function | [] -> dst.offset <- [] | x :: xs -> let y = f x in let dst' = y :: Placeholder in dst.offset <- dst'; map_dps dst 1 f fx |} In this example, the expression (y :: map f xs) had a call in non-tail-position, and it gets rewritten into tail-calls. TMC handles all such cases where the continuation of the call (what needs to be done after the return) is a "construction", the creation of a (possibly nested) data block. The code transformation generates two versions of the input function, the "direct" version with the same type and behavior as the original one (here just [map]), and the "destination-passing-style" version (here [map_dps]). Any call to the original function from outside the let..rec declaration gets transformed into a call into the direct version, which will itself call the destination-passing-style versions on recursive calls that may benefit from it (they are in tail-position modulo constructors). Because of this inherent code duplication, the transformation may not always improve performance. In this implementation, TMC is opt-in, we only transform functions that the user has annotated with an attribute to request the transformation. @-./boot/ocamlc)-nostdlib"-I&./boot*-use-prims2runtime/primitives"-g0-strict-sequence*-principal(-absname"-w8+a-4-9-40-41-42-44-45-48+-warn-error"+a*-bin-annot/-strict-formats"-I&lambda"-I%utils"-I'parsing"-I&typing"-I(bytecomp"-I,file_formats"-I&lambda"-I*middle_end"-I2middle_end/closure"-I2middle_end/flambda"-I=middle_end/flambda/base_types"-I'asmcomp"-I&driver"-I(toplevel"-I%tools"-I'runtime"-I1otherlibs/dynlink"-I-otherlibs/str"-I4otherlibs/systhreads"-I.otherlibs/unix"-I8otherlibs/runtime_events"-cno =/builds/workspace/precheck/flambda/false/label/ocaml-linux-32 >10/.-,+*)('&%$#"! @@0ZRgLfC*3@@@(Asttypes0>n{T8cئ5Build_path_prefix_map0z HkGs8CamlinternalFormatBasics0%FU(Q/Tu0CamlinternalLazy0&͂7 Pˆ*Cmi_format0c˯7͗ԩmݠ*Data_types0I'Ue`wq]Ѡ)Debuginfo0PtJ=^w/#Env0zV L{YWI*Format_doc0]mWϓ:Mݠ%Ident0">WA+9*X,Identifiable0 {d\FX'`40z1x]&ZT)Load_path0I@18 ~(Location0a7cK_H%9)Longident0s `7mɕc$Misc0ob]6>Vê>+Outcometree0kX%d5Q/+)Parsetree0T鿁ۘ7Qu$Path0Y2kf֯J._Ϡ)Primitive0²~$xzT෠%Shape0oNՄBH&Stdlib0Lku]8_٠.Stdlib__Buffer08APF< t..Stdlib__Digest0l!LHgErζ .Stdlib__Domain0:M;׉<O$Ġ.Stdlib__Either0Vy`u~c à.Stdlib__Format0ܚ#G7m|/Stdlib__Hashtbl0ѱN][/!,Stdlib__Lazy0* -S$.)"0D.Stdlib__Lexing0e<.V +Stdlib__Map0L5xE|O0~,J-.Stdlib__Result06 ]/J+Stdlib__Seq0nwzG&amg+Stdlib__Set0\$;7 .Stdlib__String0sb0vȽ PdŠ.Type_immediacy0A^abOhՠ%Types0^Y~# )Unit_info0ڀh%((Warnings0mJɒkgr