-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor/replace environments by substitution #787
Refactor/replace environments by substitution #787
Conversation
Instead of const start_7 = (start_6 - (1)); const acc_10 = new Cons_0(tmp_32, acc_9); start_6 = start_7; acc_9 = acc_10; continue toList_worker_3; we now genereate const tmp_start_0 = start_0; const tmp_acc_0 = acc_0; start_0 = (tmp_start_0 - (1)); acc_0 = new Cons_0(tmp_2, tmp_acc_0); continue toList_worker_0; when translating tail calls.
|
||
case cps.Stmt.Resume(r, b, ks2, k2) => | ||
pure(js.Return(js.Call(RESUME, nameRef(r), toJS(b)(using nonrecursive(b)), toJS(ks2), toJS(k2)))) | ||
pure(js.Return(js.Call(RESUME, nameRef(r), toJS(b)(using nonrecursive(b)), toJS(ks2), requiringThunk { toJS(k2) }))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might slow down some benchmarks, but is necessary in the general case to avoid SOs
val a = Id("a") | ||
val ks = Id("ks") | ||
cps.Cont.ContLam(a, ks, cps.Hole()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be replaced by a specialized error continuation
@@ -21,6 +21,8 @@ object Optimizer extends Phase[CoreTransformed, CoreTransformed] { | |||
|
|||
def optimize(source: Source, mainSymbol: symbols.Symbol, core: ModuleDecl)(using Context): ModuleDecl = | |||
|
|||
val isLLVM = Context.config.backend().name == "llvm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is REALLY hacky. Another solution would be to first optimize and then do polymorphism boxing. However, this alternative currently (I didn't try to find out why) fails a lot of test.
patternMatches = 0, | ||
branches = 5, | ||
pushedFrames = 531467, | ||
poppedFrames = 531467, | ||
allocations = 0, | ||
closures = 265750, | ||
closures = 26, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is particularly significant...
case (tpe1, TTop) => true | ||
case (TBottom, tpe1) => true | ||
case _ => false // conservative :) | ||
// sys error s"Cannot compare ${tpe1} ${tpe2} in ${covariant}" // conservative :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you ever want to fix more bugs, comment this in again.
No description provided.