Skip to content
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

MLton backend #156

Merged
merged 108 commits into from
Feb 15, 2023
Merged

MLton backend #156

merged 108 commits into from
Feb 15, 2023

Conversation

b-studios
Copy link
Collaborator

@b-studios b-studios commented Sep 27, 2022

This is a draft PR for discussion and tracking the changes on this branch :)

TODO

  • Non-sequential function scope (and mutual recursion) (requires analysis to maximize let-generalization)
  • Std lib things
  • mlton on ci
  • Suppress warnings

Limitations #185

@b-studios b-studios added the draft Draft PR, do not merge! label Sep 27, 2022
@b-studios
Copy link
Collaborator Author

@JonathanStarup Is there anything that you planned to do before we can merge this PR?

@JonathanStarup
Copy link
Contributor

Nothing except some cleaup, the changes to effekt.sh and the build should be reverted right?

@b-studios
Copy link
Collaborator Author

the changes to effekt.sh and the build should be reverted right?

I have to look into this, maybe for now. We still have the open ticket on how to support, unix, and macos at the same time with the same convenience.


def name(id: Symbol): MLName = MLName(uniqueName(id))

def name(id: Name): MLName = MLName(id.name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move those into a companion object on MLName? Then we do not need this file?

// lift inference infers two lifts here, which is not necessary!
// but how can we tell functions like `triple` apart from capabilities?
// what if a local function closes over some capabilities and receives a few others?
// what if that function is used under a handler?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still the case? Maybe we can describe this a bit more precisely in a ticket and drop the comment here?


def trace(pos: Point, dir: Vector, scene: Scene, depth: Int): ColorV = {

def surface(pos: Point, dir: Vector, scene: Scene, depth: Int, intersection: Intersection): ColorV = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to the original raytracer example in examples/pos I had to manually reorder (and partially re-nest) the function definitions in order to be sorted topologically. @JonathanStarup Could you maybe open up a ticket so that we remember implementing this as a preprocessing step before emitting ML?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 640x480, the example takes around 200ms on my machine:

Benchmark 1: ./out/raytracer 640 480
  Time (mean ± σ):     207.7 ms ±   0.8 ms    [User: 111.2 ms, System: 95.9 ms]
  Range (min … max):   205.9 ms … 209.8 ms    30 runs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also rewrite the List stdlib to use tailrecursive functions instead of local mutable state since we do not know how fast the latter is in ML at the moment.

Had to solve a lot of conflicts, so this merge commit contains semantic content!

Conflicts:
  effekt/shared/src/main/scala/effekt/generator/chez/ChezSchemeLift.scala
  effekt/shared/src/main/scala/effekt/lifted/LiftInference.scala
  examples/neg/scoped.effekt
@b-studios b-studios marked this pull request as ready for review February 14, 2023 17:30
@b-studios
Copy link
Collaborator Author

@JonathanStarup Can you tell me whether you can think of something that blocks the merge? I would like to click merge tomorrow, so that we can maintain the backend in all subsequent PRs :) It is not necessary that everything works; it is more important that all tests pass (which is the case) and no impediments for other backends or contributors are created.

@b-studios b-studios removed the draft Draft PR, do not merge! label Feb 15, 2023
@b-studios b-studios merged commit 3e4012d into master Feb 15, 2023
@b-studios b-studios deleted the feature/mlton branch February 15, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants