|
29 | 29 |
|
30 | 30 | namespace wasm { |
31 | 31 |
|
32 | | -TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, |
33 | | - std::vector<char>&& input, |
34 | | - bool closedWorld) |
35 | | - : wasm(wasm), closedWorld(closedWorld), builder(wasm), |
36 | | - random(std::move(input), wasm.features), |
37 | | - publicTypeValidator(wasm.features) { |
38 | | - |
39 | | - atomicMemoryOrders = wasm.features.hasRelaxedAtomics() |
40 | | - ? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst} |
41 | | - : std::vector{MemoryOrder::SeqCst}; |
| 32 | +namespace { |
42 | 33 |
|
43 | | - haveInitialFunctions = !wasm.functions.empty(); |
44 | | - |
45 | | - loggableTypes = {Type::i32, Type::i64, Type::f32, Type::f64}; |
46 | | - if (wasm.features.hasSIMD()) { |
| 34 | +std::vector<Type> getLoggableTypes(const FeatureSet& features) { |
| 35 | + std::vector<Type> loggableTypes = { |
| 36 | + Type::i32, Type::i64, Type::f32, Type::f64}; |
| 37 | + if (features.hasSIMD()) { |
47 | 38 | loggableTypes.push_back(Type::v128); |
48 | 39 | } |
49 | | - if (wasm.features.hasReferenceTypes()) { |
50 | | - if (wasm.features.hasGC()) { |
| 40 | + if (features.hasReferenceTypes()) { |
| 41 | + if (features.hasGC()) { |
51 | 42 | loggableTypes.push_back(Type(HeapType::any, Nullable)); |
52 | 43 | loggableTypes.push_back(Type(HeapType::func, Nullable)); |
53 | 44 | loggableTypes.push_back(Type(HeapType::ext, Nullable)); |
54 | 45 | } |
55 | | - if (wasm.features.hasStackSwitching()) { |
| 46 | + if (features.hasStackSwitching()) { |
56 | 47 | loggableTypes.push_back(Type(HeapType::cont, Nullable)); |
57 | 48 | } |
58 | 49 | // Note: exnref traps on the JS boundary, so we cannot try to log it. |
59 | 50 | } |
60 | 51 |
|
| 52 | + return loggableTypes; |
| 53 | +} |
| 54 | + |
| 55 | +std::vector<MemoryOrder> getMemoryOrders(const FeatureSet& features) { |
| 56 | + return features.hasRelaxedAtomics() |
| 57 | + ? std::vector{MemoryOrder::AcqRel, MemoryOrder::SeqCst} |
| 58 | + : std::vector{MemoryOrder::SeqCst}; |
| 59 | +} |
| 60 | + |
| 61 | +} // namespace |
| 62 | + |
| 63 | +TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm, |
| 64 | + std::vector<char>&& input, |
| 65 | + bool closedWorld) |
| 66 | + : wasm(wasm), closedWorld(closedWorld), builder(wasm), |
| 67 | + random(std::move(input), wasm.features), |
| 68 | + loggableTypes(getLoggableTypes(wasm.features)), |
| 69 | + atomicMemoryOrders(getMemoryOrders(wasm.features)), |
| 70 | + |
| 71 | + publicTypeValidator(wasm.features) { |
| 72 | + |
| 73 | + haveInitialFunctions = !wasm.functions.empty(); |
| 74 | + |
61 | 75 | // Setup params. Start with the defaults. |
62 | 76 | globalParams = std::make_unique<FuzzParamsContext>(*this); |
63 | 77 |
|
|
0 commit comments