summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-04-23 16:42:01 -0700
committerGitHub <noreply@github.com>2024-04-23 16:42:01 -0700
commit42db73abe388c7c8ee990ef839a36fd74a0eaadd (patch)
tree7a4050dc1710c14bca24aa15e8f06c6f9a8b566d /src/wasm-interpreter.h
parent94ddae02e591adeb994ae2f798878e814f976bc1 (diff)
downloadbinaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.tar.gz
binaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.tar.bz2
binaryen-42db73abe388c7c8ee990ef839a36fd74a0eaadd.zip
[Strings] Fuzz and interpret all relevant StringNew methods (#6526)
This adds fuzzing for string.new_wtf16_array and string.from_code_point. The latter was also missing interpreter support, which this adds.
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 64c0bfb2d..0afbaba94 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -33,6 +33,7 @@
#include "support/bits.h"
#include "support/safe_integer.h"
#include "support/stdckdint.h"
+#include "support/string.h"
#include "wasm-builder.h"
#include "wasm-traversal.h"
#include "wasm.h"
@@ -1898,6 +1899,16 @@ public:
}
return makeGCData(contents, curr->type);
}
+ case StringNewFromCodePoint: {
+ uint32_t codePoint = ptr.getSingleValue().getUnsigned();
+ if (codePoint > 0x10FFFF) {
+ trap("invalid code point");
+ }
+ std::stringstream wtf16;
+ String::writeWTF16CodePoint(wtf16, codePoint);
+ std::string str = wtf16.str();
+ return Literal(str);
+ }
default:
// TODO: others
return Flow(NONCONSTANT_FLOW);