-
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
Introduce Value type for operands #419
Conversation
791cbee
to
f3ae080
Compare
Codecov Report
@@ Coverage Diff @@
## master #419 +/- ##
==========================================
- Coverage 99.55% 99.54% -0.02%
==========================================
Files 49 51 +2
Lines 14604 14632 +28
==========================================
+ Hits 14539 14565 +26
- Misses 65 67 +2 |
e0c084e
to
5ae0db3
Compare
@@ -611,7 +611,7 @@ execution_result execute(Instance& instance, FuncIdx func_idx, span<const uint64 | |||
const auto& code = instance.module.codesec[code_idx]; | |||
auto* const memory = instance.memory.get(); | |||
|
|||
std::vector<uint64_t> locals(args.size() + code.local_count, 0); | |||
std::vector<Value> locals(args.size() + code.local_count); |
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.
Doesn't this leave them uninitialized, because Value
default constructor doesn't initialize it?
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.
No.
- Vector is using value initialization and then copy to init elements.
- For unions, value initialization is zero initialization, i.e.
-
If T is a union type, the first non-static named data member is zero-initialized and all padding is initialized to zero bits.
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.
It looks the spec for it has changed in C++11, but the result is the same. But having/not-having default constructor that initializes with zero affects GCC code generation (looks like a bug rather) and the version without zeroing default constructor is faster as it fills locals by a loop instead of a memset
call.
I'm not sure what is going on here. Can someone recheck?
|
fcdb355
to
df0ceb4
Compare
I'm getting different looking results
|
The
Value
is an union for now containing onlyi64
value. Later to be extended withf32
,f64
and maybei32
.I added implicit conversions from/to
uint64_t
to limit the number of required changes.The conversion from
std::initializer_list<uint64_t>
not possible in a type safe manner. I guess we will need something liketemplate<typename T...> TypedArgs
to construct a container ofValue
s. This will also handle usage of different value types in execution invocation.All will get more complicated if we want constructor from other types (e.g.
float
,unsigned int
) as we will get ambiguities (e.g.0
is of typeint
and will not know where to go).