-
Notifications
You must be signed in to change notification settings - Fork 33
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
Allocate space for locals together with stack #382
Conversation
Codecov Report
@@ Coverage Diff @@
## master #382 +/- ##
=======================================
Coverage 98.73% 98.74%
=======================================
Files 58 58
Lines 8703 8765 +62
=======================================
+ Hits 8593 8655 +62
Misses 110 110 |
This seems to be very similar to #358. What is the story with this? |
cd4815e
to
c28b01f
Compare
I resurrected this one because I will need it in near future.
|
LTO builds looks a bit better:
|
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 overall, would be nice to add some tests with non-empty locals and args.
Does it make sense to try to increase |
I tried with 1K and 2K sizes. The performance is not much better, but it causes stack overflow in some infinite call tests. |
ab6bea2
to
e6917fa
Compare
We may consider renaming
In future it will probably be converted to RAII type and cooperate with "thread execution context" e.g. to bump call depth. Proposals:
|
ab79692
to
e6917fa
Compare
I also tried the small storage of 256 bytes, but I see no performance difference. So leaving it at 128. |
e6917fa
to
dc13f1d
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, it would be also nice to test rbegin() / rend()
for case with locals.
TEST(operand_stack, large) | ||
{ | ||
constexpr auto max_height = 33; | ||
OperandStack stack({}, 0, max_height); | ||
ASSERT_GT(address_diff(&stack, stack.rbegin()), 100) << "not allocated on the heap"; |
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 is this GT while the others LT? Ah I see heap in the message.
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 100
is arbitrary.
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.
Can you add a test where it tries to pop the stack to access the locals?
dc13f1d
to
a8717bc
Compare
@@ -61,37 +67,63 @@ class OperandStack | |||
/// in the constructor after the m_storage. | |||
Value* m_top; | |||
|
|||
Value* m_bottom; | |||
|
|||
Value* m_locals; |
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.
Would the order of these three manifest speed differences?
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 have corrected this. New version may be slightly faster, but hard to tell for sure as they are very close.
if (max_stack_height > small_storage_size) | ||
m_large_storage = std::make_unique<Value[]>(max_stack_height); | ||
m_top = bottom() - 1; | ||
const auto num_args = args.size(); |
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.
Perhaps this one could make sense to be typed as size_t
because then we can be sure storage_size_required
is size_t
? Though I guess size()
returns that anyhow.
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 fine now, but probably should be changed to uint32_t
at some point.
ffe7c0e
to
a506ea4
Compare
Extended existing tests to have this check. |
8a4e20d
to
e24521b
Compare
This move memory management of args and locals to OperandStack where space for all can be allocated in single go.
e24521b
to
642359f
Compare
This move memory management of args and locals to OperandStack where
space for all can be allocated in single go.