-
Notifications
You must be signed in to change notification settings - Fork 34
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
Stack optimization #247
Stack optimization #247
Conversation
Codecov Report
|
0e2b53b
to
d9f57d0
Compare
|
d9f57d0
to
62cee4f
Compare
Not easy with of the casts present there. |
62cee4f
to
b4b9965
Compare
b1360c6
to
2cc5a6f
Compare
2cc5a6f
to
2e2ff43
Compare
663ba86
to
00c0404
Compare
d9fb91a
to
d2ac5a9
Compare
lib/fizzy/parser_expr.cpp
Outdated
|
||
// Update code's max_stack_height using frame.stack_height of the previous instruction. | ||
// The frame.stack_height may have been updated by call instruction and it is fine | ||
// to omit value for end instruction. |
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'm not sure what do you mean by "it is fine to omit value for end instruction."? Is it about final end instruction?
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.
The each end
ending a frame. I will update the comment to
The frame.stack_height may have been updated by call instruction. This also omits every
end
andelse
instructions as they pop/reset the frame object.
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.
Still not sure I understand the second part. Do you mean that there's no need to update max_stack_height
on end
and else
? But it's kinda not related to why we update max_stack_height
according to previous instruction...
I would say we don't update max_stack_height
on end
and else
, because frame.stack_heigh
doesn't grow there anyway. Maybe here I'd just remove the second sentence.
But also wouldn't it be more straightforward to update here after frame.stack_height
growth (for current instruction) + in one other place - update_caller_frame
. No need for complicated comment here then. But you would need to pass code
there...
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 try to explain why the last update frame.stack_height += metrics.stack_height_change
is ignored for code.max_stack_height
.
I was considering changing update_caller_frame
that way, but decided to try having the update in single place (and this is result of it).
So removing last sentence is good enough resolution? Or maybe move it to frame.stack_height += metrics.stack_height_change
?
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 we keep the update here, I'd change the comment to something like
// Update code's max_stack_height using frame.stack_height of the previous instruction.
// At this point `frame.stack_height` includes additional changes to the stack if previous instruction was a call.
// This way this update is skipped for the end/else instruction (becaue their frame is already popped/reset), but it doesn't matter because they don't grow stack anyway.
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.
Comment updated.
cd49419
to
2f3aa84
Compare
2f3aa84
to
5508b62
Compare
330034c
to
c4d0ccb
Compare
c4d0ccb
to
4734f4d
Compare
c85b327
to
992b512
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.
looks good, just one minor typo
992b512
to
998fab6
Compare
Execution comparison
Parsing comparison