diff options
author | Alon Zakai <azakai@google.com> | 2020-10-09 10:40:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 10:40:01 -0700 |
commit | 9d50c1f4a7fb81ead03a2b8445655f157553fa1b (patch) | |
tree | b1cabe12156373474dccd5beec3fe1ee92836c9e /src | |
parent | 87fddcb0aa28f322c0781c08cca6ce2a756d8728 (diff) | |
download | binaryen-9d50c1f4a7fb81ead03a2b8445655f157553fa1b.tar.gz binaryen-9d50c1f4a7fb81ead03a2b8445655f157553fa1b.tar.bz2 binaryen-9d50c1f4a7fb81ead03a2b8445655f157553fa1b.zip |
Optimize getLoggableTypes in fuzzer, and add isLoggableType (#3208)
Previously getLoggableType would allocate a vector every time. This
caches it.
Also add isLoggableType which will need this caching as I will be
calling it quite a lot in a future patch to the fuzzer.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index ecc548e22..088aa3c96 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -2803,17 +2803,27 @@ private: // removed during optimization // - there's no point in logging externref or anyref because these are opaque // - don't bother logging tuples - std::vector<Type> getLoggableTypes() { - return items( - FeatureOptions<Type>() - .add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64) - .add(FeatureSet::SIMD, Type::v128) - .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, - Type::exnref)); + std::vector<Type> loggableTypes; + + const std::vector<Type>& getLoggableTypes() { + if (loggableTypes.empty()) { + loggableTypes = items( + FeatureOptions<Type>() + .add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64) + .add(FeatureSet::SIMD, Type::v128) + .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, + Type::exnref)); + } + return loggableTypes; } Type getLoggableType() { return pick(getLoggableTypes()); } + bool isLoggableType(Type type) { + const auto& types = getLoggableTypes(); + return std::find(types.begin(), types.end(), type) != types.end(); + } + // statistical distributions // 0 to the limit, logarithmic scale |