-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
CS: cptypes friendly unbox #4211
base: master
Are you sure you want to change the base?
Conversation
racket/src/ChezScheme/mats/hash.ms
Outdated
@@ -1662,7 +1662,7 @@ | |||
[(4) (gensym)] | |||
[(5) (open-output-string)] | |||
[(6) (fxvector 15 55)] | |||
[(7) (lambda () x)] | |||
[(7) (let ([g (gensym)]) (lambda () (lisy x g)))] |
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.
[(7) (let ([g (gensym)]) (lambda () (lisy x g)))] | |
[(7) (let ([g (gensym)]) (lambda () (list x g)))] |
I think this is just a typo.
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! Fixed.
For my edification, what patterns in Schemify output get helped by this? |
Sure. I'll use fake prefixes Currently there is a macro
Where My proposal is to make
Now Currently The current version is enough to make similar reductions with things that can't be impersonated, like
But to reduce
it's necessary to to make Also, to reduce
it's necessary to to make |
I uncommented the relevant test in optimize.rktl |
I worry about an implementation approach that involves changing the inlining heuristic. The test failure illustrates one kind of pitfall, although that sort of thing mostly happens to tests, which often depend on assumptions about the implementation. But there's also likely to be slowdowns or increased memory use for real programs. If the goal is to get inlining to happen always, maybe implementing |
With the new implementation, cptypes can collect more information that may be useful for reductions in the following code.
About the test: I classify this as a bug in the test, it depends too much in the implementation details. Anyway, messing with the optimization heuristic is a problem because I don't understand how they affect the tradeoff. (Note: I'm not sure if it's necessary to increase it form 20 to 40, perhaps 21 is enough. I didn't made a very exhaustive test because 21 may be enough for I made another version, that uses a macro to force expanding An alternative is to rename my I've seen both approaches in other parts of |
Defining For |
Do you mean this? racket/racket/src/cs/rumble/impersonator.ss Lines 315 to 316 in 10a34f3
IIUC this can be a huge problem for my proposed change. I'll try to add some test that are broken by my current version, and take some time to think about it. It's easy to fix this so Perhaps the only solution is to make |
That's what I had in mind, but maybe it doesn't apply to boxes, after all. The |
I think it does not apply to boxes, but adding Another possibility is to delete |
I think you may be right that |
This is a just a initial short draft to make
schemify
morecptypes
-friendly and makecptypes
moreschemify
-friendly.My idea is instead of using a macro to force
unbox
to be inlined, modify it socp0
can inline it. This version expose the checks for theimpersonator
andchaperone
, socptypes
can understand that it's arecord
and call a helper function to handle the difficult case once the type is confirmed.In particular this enable some reductions like
The first problem is that the new version is too big to be inlined, so I had to modify
cp0
increasingscore-limit
to40
. This change causes a weird error inhash.ms
because an auxiliary function gets inlined and a closure is transformed into a normal function.About the main part of the change, there are a few method to check the if it's a
impersonator
andchaperone
. I think it's better to usebox-impersonator?
andbox-chaperone?
. It's enough to mark it as a record incptypes
, but stillcptypes
can only track one kind of record, so I hope to increase that to two independent records in the future. Other possibility is to makebox-chaperone
a subrecord ofbox-impersonator
but this alternative needs more changes in the code outsidecptypes
. A third possibility is to addlens
tocptypes
, but I'm not sure how long it will take.I also modified the code in the helper function that deals with
impersonator
andchaperone
, in the case when the content of theimpersonator
andchaperone
is not abox
because I don't expect it to be other kind ofimpersonator
, but it may be a mistake.I'm still not sure if it's better to keep the macro version of
unbox
to force it to be inlined always, and modifyunbox
so it's inlined in the more unusual cases.