Commit 29e1b281 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Fix compile time regressions in SIMD tests

Avoid templates, just encode all wasm opcodes as 2-byte LEB instead.

R=zhin@chromium.org

Bug: v8:10258
Change-Id: I3bfd5235b235a5d9366e0007e915a2c02a09b0d4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2182638Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67625}
parent 7215211e
This diff is collapsed.
......@@ -18,40 +18,6 @@ namespace v8 {
namespace internal {
namespace wasm {
template <>
void AppendSingle(std::vector<byte>* code, WasmOpcode op) {
// We do not yet have opcodes that take up more than 2 byte (decoded). But if
// that changes, this will need to be updated.
DCHECK_EQ(0, op >> 16);
byte prefix = (op >> 8) & 0xff;
byte opcode = op & 0xff;
if (!prefix) {
code->push_back(opcode);
return;
}
// Ensure the prefix is really one of the supported prefixed opcodes.
DCHECK(WasmOpcodes::IsPrefixOpcode(static_cast<WasmOpcode>(prefix)));
code->push_back(prefix);
// Decoded opcodes fit in a byte (0x00-0xff).
DCHECK_LE(LEBHelper::sizeof_u32v(opcode), 2);
// Therefore, the encoding needs max 2 bytes.
uint8_t encoded[2];
uint8_t* d = encoded;
// d is updated to after the last uint8_t written.
LEBHelper::write_u32v(&d, opcode);
for (uint8_t* p = encoded; p < d; p++) {
code->push_back(*p);
}
}
template <>
void AppendSingle(std::vector<byte>* code, ValueTypeCode op) {
code->push_back(op);
}
TestingModuleBuilder::TestingModuleBuilder(
Zone* zone, ManuallyImportedJSFunction* maybe_import, ExecutionTier tier,
RuntimeExceptionSupport exception_support, LowerSimd lower_simd)
......
......@@ -75,46 +75,6 @@ using compiler::Node;
r.Build(code, code + arraysize(code)); \
} while (false)
template <typename T>
void AppendSingle(std::vector<byte>* code, T t) {
static_assert(std::is_integral<T>::value,
"Special types need specializations");
code->push_back(t);
}
// Specialized for WasmOpcode.
template <>
void AppendSingle<WasmOpcode>(std::vector<byte>* code, WasmOpcode op);
// Specialized for ValueTypeCode.
template <>
void AppendSingle<ValueTypeCode>(std::vector<byte>* code, ValueTypeCode op);
template <typename... T>
void Append(std::vector<byte>* code, T... ts) {
static_assert(sizeof...(ts) == 0, "Base case for appending bytes to code.");
}
template <typename First, typename... Rest>
void Append(std::vector<byte>* code, First first, Rest... rest) {
AppendSingle(code, first);
Append(code, rest...);
}
// Like BUILD but pushes code bytes into a std::vector instead of an array
// initializer. This is useful for opcodes (like SIMD), that are LEB128
// (variable-sized). We use recursive template instantiations with variadic
// template arguments, so that the Append calls can handle either bytes or
// opcodes. AppendSingle is specialized for WasmOpcode, and appends multiple
// bytes. This allows existing callers to swap out the BUILD macro for BUILD_V
// macro without changes. Also see https://crbug.com/v8/10258.
#define BUILD_V(r, ...) \
do { \
std::vector<byte> code; \
Append(&code, __VA_ARGS__); \
r.Build(code.data(), code.data() + code.size()); \
} while (false)
// For tests that must manually import a JSFunction with source code.
struct ManuallyImportedJSFunction {
const FunctionSig* sig;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment