-
Notifications
You must be signed in to change notification settings - Fork 12
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
Don't translate all recursive definitions to LetRec #161
Comments
|
Later expressions won't get inside the Let class Refer to hkuplg#161
Say we have the following program:
The old translation of class L1 {
Object temp;
Closure x3;
Closure x4;
{
class Even {...}
x3 = ...;
class Odd {...}
x4 = ...;
class Id {...}
<some application statements using x3 and x4>
temp = ...;
}
}
L1 l1 = new L1();
return l1.temp; The new translation basically lift later expression out of the wrapping class like this class L1 {
Closure x3;
Closure x4;
{
class Even {...}
x3 = ...;
class Odd {...}
x4 = ...;
}
}
L1 l1 = new L1();
Closure x3 = l1.x3;
Closure x4 = l1.x4;
class Id {...}
<some application statements using x3 and x4> Now if later expressions contain This change also removes the need of having a standalone
It translates to class L1 {
Closure x2;
{
Closure Fact {...}
x2 = ...;
}
}
L1 x1 = new L1();
Closure x2 = x1.x2;
class Id {...}
<some application statements using x2>
|
One reason why we still had standalone fixpoints was performance. Translating a single-recursive function as a LetRec was not as efficient as translating a fixpoint. |
Are you referring to the performance of compiling a program or running the generated Jaca code? |
Running the generated code. |
yes, the only performance penalty is coming from having one more object creation, illustrated as below:
class L1 {
Closure x2;
{
Closure Fact {...}
x2 = ...;
}
}
L1 x1 = new L1(); -- can be eliminated if fixpoint
Closure x2 = x1.x2;
<statements using x2>
Closure Fact {...}
Closure x2 = ...;
<statements using x2> Anyway, i will leave |
In
Desugar.hs
The text was updated successfully, but these errors were encountered: