-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRMC, reloaded #9760
TRMC, reloaded #9760
Commits on Nov 2, 2021
-
Configuration menu - View commit details
-
Copy full SHA for a84b25b - Browse repository at this point
Copy the full SHA a84b25bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 35dff8c - Browse repository at this point
Copy the full SHA 35dff8cView commit details -
TMC: product representation of choices
Before this commit the representation of choices was type choice = | Return of lambda | Set of { direct: lambda; dps: Dps.t } the idea being that Return means that only the direct-style form is useful (there are no TMC calls, so never a need for a specific DPS implementation). The new representation has the same information encoded as a product rather than a sum: type choice = { direct: lambda; dps: dps.t; has_tmc_calls: bool; } When `has_tmc_calls` is false, this is the same as `Return`, otherwise it is a `Set`. This new representation makes some of the code easier (more homogeneous, no need for case distinctions), and it avoids some bugs we had when considering how to mix Return and Set values together.
Configuration menu - View commit details
-
Copy full SHA for e0df0a1 - Browse repository at this point
Copy the full SHA e0df0a1View commit details -
These tests are less robust than the other TMC tests, but they test more varied aspect of the transformation, and will be useful to assess the impact of upcoming code changes during the code review period, and further improvements to the TMC transformation.
Configuration menu - View commit details
-
Copy full SHA for 90dd724 - Browse repository at this point
Copy the full SHA 90dd724View commit details -
Configuration menu - View commit details
-
Copy full SHA for e9397f6 - Browse repository at this point
Copy the full SHA e9397f6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d2d0b0 - Browse repository at this point
Copy the full SHA 4d2d0b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for e30d162 - Browse repository at this point
Copy the full SHA e30d162View commit details -
TMC: Constructor composition in direct style: [benefits_from_dps : bo…
…ol]. The direct-style version of the tailmap3 function let[@tail_mod_cons] rec tailmap3 = fun f li -> match li with | [] -> [] | x :: xs -> f 0 x :: f 1 x :: f 2 x :: tailmap3 f xs looked as follows before this PR: (tailmap3/109 (function f/110 li/111 tail_mod_cons (if li/111 (let (xs/113 =a (field 1 li/111) x/112 =a (field 0 li/111)) (let (block/115 = (makemutable 0 (apply f/110 0 x/112) 0)) (seq (let (arg1/116 = (apply f/110 1 x/112) block/117 = (makemutable 0 (apply f/110 2 x/112) 0)) (seq (setfield_ptr(heap-init)_computed block/115 1 (makeblock 0 arg1/116 block/117)) (apply tailmap3_dps/114 block/117 1 f/110 xs/113))) block/115))) 0a)) It now looks as follows: (tailmap3/109 (function f/110 li/111 trmc (if li/111 (let (xs/113 =a (field 1 li/111) x/112 =a (field 0 li/111)) (makeblock 0 (apply f/110 0 x/112) (makeblock 0 (apply f/110 1 x/112) (let (block/115 = (makemutable 0 (apply f/110 2 x/112) 0)) (seq (apply tailmap3_dps/114 block/115 1 f/110 xs/113) block/115))))) The idea is that the deeply nested constructor (f 2 x :: ...) needs to be turned into a location for the tailmap3 call to go to the DPS version, but the code around this constructor itself does not need to be put in DPS form (as the constructor is already providing a location). Advertising that it "does not benefit from DPS" let us generate the much nicer version below, by not trying to create new locations on each constructor above it.
Configuration menu - View commit details
-
Copy full SHA for 10d756b - Browse repository at this point
Copy the full SHA 10d756bView commit details -
TMC: error if several different calls could be optimized
One reason to error in these ambiguous situations, instead of making a choice for the user, is that the TMC transformation changes the evaluation order, delaying the call that is made tailrec to after the evaluation of all other arguments. Example: ``` type 'a tree = | Leaf of 'a | Node of 'a tree * 'a tree let[@tail_mod_cons] rec correct_map f = function | Leaf v -> Leaf (f v) | Node (left, right) -> Node (correct_map f left, (correct_map[@tailcall]) f right) let[@tail_mod_cons] rec incorrect_map f = function | Leaf v -> Leaf (f v) | Node (left, right) -> Node (incorrect_map f left, incorrect_map f right) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error: [@tail_mod_cons]: this constructor application may be optimized in several different ways, please disambiguate by adding a [@tailcall] attribute to the call that should be made tail-recursive. ```
Configuration menu - View commit details
-
Copy full SHA for 7dc0d86 - Browse repository at this point
Copy the full SHA 7dc0d86View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e04aa1 - Browse repository at this point
Copy the full SHA 0e04aa1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b8771e - Browse repository at this point
Copy the full SHA 1b8771eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 640f246 - Browse repository at this point
Copy the full SHA 640f246View commit details -
Configuration menu - View commit details
-
Copy full SHA for 41b9afc - Browse repository at this point
Copy the full SHA 41b9afcView commit details -
[refactoring] move Simplif.exact_application to Lambda
We need to use this logic in lambda/tmc.ml to support tupled functions.
Configuration menu - View commit details
-
Copy full SHA for 1daea33 - Browse repository at this point
Copy the full SHA 1daea33View commit details -
TMC: support Tupled functions and partial applications
Partial applications are obviously not considered TMC calls, but this is also the case for direct calls to Tupled functions that do not take a direct tuple literal, but another tuple value.
Configuration menu - View commit details
-
Copy full SHA for 9242408 - Browse repository at this point
Copy the full SHA 9242408View commit details -
Configuration menu - View commit details
-
Copy full SHA for f881fc4 - Browse repository at this point
Copy the full SHA f881fc4View commit details -
[review] TMC: rename 'return' to 'lambda'
There is a naming conflict between using 'return v' to mean - "build a piece of code that returns the same result as `v`", and - the `return` function of the applicative functor (Note that the first operation is not polymorphic: it has type lambda -> lambda t and not 'a -> 'a t ) To avoid this ambiguity we rename our 'return' functions into 'lambda'. (Issue spotted by Pierre Chambart during review.)
Configuration menu - View commit details
-
Copy full SHA for 7c17ea6 - Browse repository at this point
Copy the full SHA 7c17ea6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c99520 - Browse repository at this point
Copy the full SHA 9c99520View commit details -
[review] tmc: use a placeholder value that is better for debugging
(suggestion from Konstantin Romanov) After discussion with Pierre Chambart, we convinced ourselves that the tagged forms is what users will see in their debugger, and went for 0xBBBB / 2, which gets tagged as 0xBBBB. Co-Authored-By: Pierre Chambart
Configuration menu - View commit details
-
Copy full SHA for d92ef98 - Browse repository at this point
Copy the full SHA d92ef98View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9306f65 - Browse repository at this point
Copy the full SHA 9306f65View commit details -
Configuration menu - View commit details
-
Copy full SHA for 333806b - Browse repository at this point
Copy the full SHA 333806bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 67251d9 - Browse repository at this point
Copy the full SHA 67251d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9725d90 - Browse repository at this point
Copy the full SHA 9725d90View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2dcd818 - Browse repository at this point
Copy the full SHA 2dcd818View commit details -
Configuration menu - View commit details
-
Copy full SHA for 955528b - Browse repository at this point
Copy the full SHA 955528bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d2a2dc9 - Browse repository at this point
Copy the full SHA d2a2dc9View commit details -
Configuration menu - View commit details
-
Copy full SHA for e6fbcc8 - Browse repository at this point
Copy the full SHA e6fbcc8View commit details -
TMC: much thinking about which @tailcall annotations to preserve where
Co-Authored-By: Pierre Chambart
Configuration menu - View commit details
-
Copy full SHA for 1b10dd9 - Browse repository at this point
Copy the full SHA 1b10dd9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4a338a8 - Browse repository at this point
Copy the full SHA 4a338a8View commit details -
Configuration menu - View commit details
-
Copy full SHA for a862307 - Browse repository at this point
Copy the full SHA a862307View commit details -
[minor] complete the renaming of 'TRMC' into 'TMC'
(suggestion from Konstantin Romanov)
Configuration menu - View commit details
-
Copy full SHA for 0d80ae3 - Browse repository at this point
Copy the full SHA 0d80ae3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0891d8e - Browse repository at this point
Copy the full SHA 0891d8eView commit details