-
Notifications
You must be signed in to change notification settings - Fork 205
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
Use DeBruijn levels in SExpr0. #11987
Conversation
76a7b7f
to
46c5063
Compare
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.
LGTM
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.
Thanks!
…des both index and level, and performs a runtime check. changelog_begin changelog_end add runtime check in freeVars: determination that a variable is-free using levels instead of indexes remove DB-indexes and runtime check; simplify freeVars computation in closure-conversion
d051ead
to
1783596
Compare
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.
LGTM. Thanks.
def decrement1(x: SExpr): SExpr = SEApp(SEBuiltin(SBSubInt64), List(x, SEValue(SInt64(1)))) | ||
val decrement = SEAbs(1, decrement1(SEVar(1))) | ||
val decrement = SEAbs(1, decrement1(mkVar(0))) | ||
|
||
def subtract2(x: SExpr, y: SExpr): SExpr = SEApp(SEBuiltin(SBSubInt64), List(x, y)) | ||
val subtract = SEAbs(2, subtract2(SEVar(2), SEVar(1))) | ||
val subtract = SEAbs(2, subtract2(mkVar(0), mkVar(1))) | ||
|
||
def twice2(f: SExpr, x: SExpr): SExpr = SEApp(f, List(SEApp(f, List(x)))) | ||
val twice = SEAbs(2, twice2(SEVar(2), SEVar(1))) | ||
val twice = SEAbs(2, twice2(mkVar(3), mkVar(4))) | ||
|
||
def thrice2(f: SExpr, x: SExpr): SExpr = SEApp(f, List(SEApp(f, List(SEApp(f, List(x)))))) | ||
val thrice = SEAbs(2, thrice2(SEVar(2), SEVar(1))) | ||
val thrice = SEAbs(2, thrice2(mkVar(0), mkVar(1))) |
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.
Not very important, but I do not really like the use of global index in this class.
How are they calculated ? ...
I assume the level is somehow global, and those expression should be use in a very specific place.
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.
I agree.
Actually, I think there is very little value in this class. I should delete it.
It's left over form my very first explorations into speedy.
mapping.get(v) match { | ||
case Some(loc) => loc | ||
case None => | ||
throw sys.error(s"lookup($abs),in:$mapping") | ||
case None => sys.error(s"lookup($v),in:$mapping") |
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.
why not using getOrElse
?
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.
🤷♂️
…des both index and level, and performs a runtime check. (#11987) changelog_begin changelog_end add runtime check in freeVars: determination that a variable is-free using levels instead of indexes remove DB-indexes and runtime check; simplify freeVars computation in closure-conversion
Move to using DB-levels (not DB-indexes) in
SExpr0
.ClosureConversion
code to computefreeVars
is much simpler.Compiler.scala
(During the dev for this change, I ran with both index and level numbers, and ensure behaviour is unchanged.)
This PR is waiting for the fix in: #12047
This PR is part of work to cleanup the speedy compiler: #11669