-
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
New version of execution_result #219
Conversation
Benchmarking before cepairing landing does not make sense then. |
Hm? It is in the |
49d3278
to
401c213
Compare
Rebased so we can run another set of benchmark comparison post 0.1.0. |
Codecov Report
@@ Coverage Diff @@
## master #219 +/- ##
==========================================
+ Coverage 99.17% 99.28% +0.11%
==========================================
Files 49 49
Lines 13237 13227 -10
==========================================
+ Hits 13128 13133 +5
+ Misses 109 94 -15 |
I think this can be revived in a simplified way (e.g. only affected "public api") once the span changes are pushed. |
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.
There is a problem with struct layout of bool
+ std::optional<uint64_t>
. In whatever order you put these the end struct size will be 24 bytes. Therefore it cannot be returned by registers from a function.
We should not use std::optional<uint64_t>
, just make flat struct as
struct execution_result
{
bool trapped;
bool has_value;
uint64_t value;
};
Would an enum make sense?
|
Yes, performance wise this should be the same. Although, you will probably need additional helpers like |
Also there is
|
f87078e
to
ae85c67
Compare
7401072
to
f7ac7d1
Compare
test/spectests/spectests.cpp
Outdated
pass(); | ||
else | ||
fail("Unexpected returned value."); | ||
continue; | ||
} | ||
|
||
if (result->stack.size() != 1) | ||
if (!result->has_value) |
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.
wrong.
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.
Bummer, actually should have removed this part of the code with #398.
Benchmarks without "Simplify trap handling".
The "Simplify trap handling" does not change the results. |
b9b0245
to
6a4386e
Compare
test/unittests/instantiate_test.cpp
Outdated
@@ -18,7 +18,7 @@ uint64_t call_table_func(Instance& instance, size_t idx) | |||
{ | |||
const auto& elem = (*instance.table)[idx]; | |||
const auto res = elem->function(instance, {}, 0); | |||
// ASSERT_TRUE(res.result.has_value()); | |||
assert(res.has_value); |
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 keeping ASSERT_TRUE
? (I'm not sure why it was disabled in this PR in the first.)
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.
Apparently the ASSERT_TRUE
only works inside TEST
as it use return
for early exit.
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.
Changed to EXPECT_TRUE
.
aa8eca4
to
5fce948
Compare
test/unittests/instantiate_test.cpp
Outdated
auto host_foo2 = [](Instance&, span<const uint64_t>, int) -> execution_result { | ||
return {true, {}}; | ||
}; | ||
auto host_foo1 = [](Instance&, span<const uint64_t>, int) -> execution_result { return Void; }; |
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.
These are not executed, but foo1
import returns a result (foo2
is void)
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.
But both were also traps in the same time. You cannot have trap + value now.
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.
Before: both were trapping, but foo1
supposed to return a result and foo2
not
After: foo1
does not trap and returns nothing, foo2
traps
@gumb0 is this the correct intended behaviour?
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 implementation doesn't matter, I would just make them both trap.
Looks good to merge apart form that single question. And the header with |
constexpr execution_result(uint64_t _value) noexcept : has_value{true}, value{_value} {} | ||
|
||
constexpr explicit execution_result(trapped_tag) noexcept : trapped{true} {} | ||
constexpr explicit execution_result(bool success) noexcept : trapped{!success} {} |
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 constructor should not be used by users. We can also add default value bool success = true
to allow {}
as previously. But rather single way of doing things in internal code is better.
This re-implements the execution_result struct. Now it has three valid states: value, void and trap. The struct is simplified, close to POD type, std::vector is not used any more. Co-authored-by: Paweł Bylica <chfast@gmail.com>
This re-implements the execution_result struct. Now it has three valid
states: value, void and trap. The struct is simplified, close to POD
type, std::vector is not used any more.
In benchmarks for certain cases (such as ecpairing) deleting an
std::vector
took quite a big chunk of time. I thought perhaps the moved stack for the return value could be the culprit, hence did this change. However my local benchmarks are inconclusive.