-
Notifications
You must be signed in to change notification settings - Fork 758
Implement GC basics #2607
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
base: main
Are you sure you want to change the base?
Implement GC basics #2607
Conversation
243ec44
to
68fe37e
Compare
struct TypeMut { | ||
Type type; | ||
bool mutable_; | ||
}; | ||
using TypeMutVector = std::vector<TypeMut>; | ||
|
||
// Garbage Collector specific type information |
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 a core part of the patch. It contains the (sub ...)
part of the type. It is declared as a structure, because it is not mandatory.
include/wabt/binary-reader.h
Outdated
virtual Result OnFuncType(Index index, | ||
GCTypeExtension* gc_ext, |
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 structure is passed as a second argument, because it is a header, but it could go to the last argument since it is an extra (and optional) information. Which one you prefer?
struct RecursiveRange { | ||
Index start_index; | ||
Index type_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.
This is another core structure to encode (rec ...)
constructs. It represents the range.
std::vector<FuncType> func_types; | ||
std::vector<StructType> struct_types; | ||
std::vector<ArrayType> array_types; | ||
std::vector<RecursiveRange> recursive_ranges; |
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 is stored in an ordered array. It cannot be stored as part of the types, because zero length (rec)
range is allowed for whatever reason.
e0ce7f8
to
adcbdf7
Compare
I have reworked the type validation system of the patch. Now it is capable of detecting the first type index for all equal types. This first type index is called canonical index. If I have two types ( |
75bdfe5
to
890a316
Compare
The |
It sounds like you are canonicalising wrt type indices. But type indices are meaningless in any program that consists of more than one module. Type canonicalisation must happen globally, across module boundaries, based on the types' structure. I suspect that is the reason for the link/run-time tests failing. |
The link tests are not failing, although the interpreter do a slow type comparison for import/exports. As far as I understand the interpreter here is just a demonstration, so this is probably ok. The runtime tests fail because the operations (such as The global type canonicalisation sounds like a very good idea! A high performance engine should do that! |
cc8e21f
to
097046d
Compare
@sbc100 there is a fuzzer issue in the code. The code is correct though. https://github.com/WebAssembly/wabt/blob/main/src/interp/binary-reader-interp.cc#L772 https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/fuzzer/FuzzerLoop.cpp What shall I do? |
We don't tend to have time to worry about fixing all the fuzz tests issues, unless they could conceivable show up in real world programs. i.e. we tend to assume trusted and save inputs, since we don't have the resources the harden wabt against other things. Having said that we obviously would be happy to accept fixes for such issues if folks come up with them. |
There is nothing to fix here, the code is correct (and not related to this patch). It is simply a limitation of the fuzzer, it assumes too much memory allocation is likely a bug. |
68c749c
to
b7fc45c
Compare
0af19a5
to
ffdf723
Compare
Is there a compile time define (or can be defined during build in some way) to detect that the fuzzer is active? Then I could guard out the failing |
47b24d4
to
c060ce0
Compare
Support named references for globals, locals, tables, elems Support named references for call_ref, ref_null Extend Var variables with an optional type field
f694b94
to
21a32fa
Compare
I have checked the type hashing system in the whole test system. It performs 45157 comparisons, and the hash/type_count is equal 513 times. From that, 467 times the types are really equal, and 46 times they are not. Overall the efficiency is 99.9%. I could not improve the hash by using more complex hashes. However, Edit: Now the efficiency is 100%. It does not mean it is perfect or anything. The missing cases were valid, worth improving the code. |
Parsing / reading / writing of core structures (rec/sub) is mostly completed, validation is far from over