Revert of [wasm] Update {i32,i64}.const to use signed leb128 (patchset #3 id:40001 of https://codereview.chromium.org/1765673002/ )
Reason for revert: [Sheriff] Breaks chromium win compile: https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Win/builds/3844/steps/compile/logs/stdio Original issue's description: > [wasm] Update {i32,i64}.const to use signed leb128 > > R=titzer@chromium.org > R=bradnelson@chromium.org > LOG=n > > Committed: https://crrev.com/4b613a67e0aa4e073946f5f0dd95ee9366c8ca86 > Cr-Commit-Position: refs/heads/master@{#34471} TBR=bradnelson@chromium.org,titzer@chromium.org,binji@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1760363003 Cr-Commit-Position: refs/heads/master@{#34482}
This commit is contained in:
parent
53e5563ff0
commit
ec0f451b64
@ -237,8 +237,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
void SetLocalTo(uint16_t index, int value) {
|
||||
current_function_builder_->Emit(kExprSetLocal);
|
||||
AddLeb128(index, true);
|
||||
// TODO(bradnelson): variable size
|
||||
byte code[] = {WASM_I32V(value)};
|
||||
byte code[] = {WASM_I32(value)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
block_size_++;
|
||||
}
|
||||
@ -466,8 +465,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
switch (type) {
|
||||
case kAstI32: {
|
||||
int val = static_cast<int>(expr->raw_value()->AsNumber());
|
||||
// TODO(bradnelson): variable size
|
||||
byte code[] = {WASM_I32V(val)};
|
||||
byte code[] = {WASM_I32(val)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
break;
|
||||
}
|
||||
@ -744,8 +742,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
Handle<Object> nvalue = maybe_nvalue.ToHandleChecked();
|
||||
if (nvalue->IsNumber()) {
|
||||
int32_t val = static_cast<int32_t>(nvalue->Number());
|
||||
// TODO(bradnelson): variable size
|
||||
byte code[] = {WASM_I32V(val)};
|
||||
byte code[] = {WASM_I32(val)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
return;
|
||||
}
|
||||
@ -757,7 +754,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
byte code[] = {WASM_F64(std::numeric_limits<double>::quiet_NaN())};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
} else {
|
||||
byte code[] = {WASM_I32V_1(0)};
|
||||
byte code[] = {WASM_I32(0)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
}
|
||||
}
|
||||
@ -815,8 +812,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
DCHECK(value->raw_value()->IsNumber());
|
||||
DCHECK_EQ(kAstI32, TypeOf(value));
|
||||
int val = static_cast<int>(value->raw_value()->AsNumber());
|
||||
// TODO(bradnelson): variable size
|
||||
byte code[] = {WASM_I32V(val * size)};
|
||||
byte code[] = {WASM_I32(val * size)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
return;
|
||||
}
|
||||
@ -1061,8 +1057,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
current_function_builder_->EmitWithU8(kExprCallIndirect,
|
||||
indices->signature_index);
|
||||
current_function_builder_->Emit(kExprI32Add);
|
||||
// TODO(bradnelson): variable size
|
||||
byte code[] = {WASM_I32V(indices->start_index)};
|
||||
byte code[] = {WASM_I32(indices->start_index)};
|
||||
current_function_builder_->EmitCode(code, sizeof(code));
|
||||
RECURSE(Visit(p->key()));
|
||||
break;
|
||||
|
@ -46,8 +46,8 @@ struct ImmI32Operand {
|
||||
int32_t value;
|
||||
int length;
|
||||
inline ImmI32Operand(Decoder* decoder, const byte* pc) {
|
||||
value =
|
||||
bit_cast<int32_t>(decoder->checked_read_i32v(pc, 1, &length, "immi32"));
|
||||
value = bit_cast<int32_t>(decoder->checked_read_u32(pc, 1, "immi32"));
|
||||
length = 4;
|
||||
}
|
||||
};
|
||||
|
||||
@ -55,8 +55,8 @@ struct ImmI64Operand {
|
||||
int64_t value;
|
||||
int length;
|
||||
inline ImmI64Operand(Decoder* decoder, const byte* pc) {
|
||||
value =
|
||||
bit_cast<int64_t>(decoder->checked_read_i64v(pc, 1, &length, "immi64"));
|
||||
value = bit_cast<int64_t>(decoder->checked_read_u64(pc, 1, "immi64"));
|
||||
length = 8;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -80,14 +80,13 @@ class Decoder {
|
||||
// Reads a variable-length unsigned integer (little endian).
|
||||
uint32_t checked_read_u32v(const byte* base, int offset, int* length,
|
||||
const char* msg = "expected LEB32") {
|
||||
return checked_read_leb<uint32_t, false>(base, offset, length, msg);
|
||||
return checked_read_leb<uint32_t>(base, offset, length, msg);
|
||||
}
|
||||
|
||||
// Reads a variable-length signed integer (little endian).
|
||||
int32_t checked_read_i32v(const byte* base, int offset, int* length,
|
||||
const char* msg = "expected SLEB32") {
|
||||
uint32_t result =
|
||||
checked_read_leb<uint32_t, true>(base, offset, length, msg);
|
||||
uint32_t result = checked_read_u32v(base, offset, length, msg);
|
||||
if (*length == 5) return bit_cast<int32_t>(result);
|
||||
if (*length > 0) {
|
||||
int shift = 32 - 7 * *length;
|
||||
@ -100,14 +99,13 @@ class Decoder {
|
||||
// Reads a variable-length unsigned integer (little endian).
|
||||
uint64_t checked_read_u64v(const byte* base, int offset, int* length,
|
||||
const char* msg = "expected LEB64") {
|
||||
return checked_read_leb<uint64_t, false>(base, offset, length, msg);
|
||||
return checked_read_leb<uint64_t>(base, offset, length, msg);
|
||||
}
|
||||
|
||||
// Reads a variable-length signed integer (little endian).
|
||||
int64_t checked_read_i64v(const byte* base, int offset, int* length,
|
||||
const char* msg = "expected SLEB64") {
|
||||
uint64_t result =
|
||||
checked_read_leb<uint64_t, true>(base, offset, length, msg);
|
||||
uint64_t result = checked_read_u64v(base, offset, length, msg);
|
||||
if (*length == 10) return bit_cast<int64_t>(result);
|
||||
if (*length > 0) {
|
||||
int shift = 64 - 7 * *length;
|
||||
@ -341,7 +339,7 @@ class Decoder {
|
||||
base::SmartArrayPointer<char> error_msg_;
|
||||
|
||||
private:
|
||||
template <typename IntType, bool is_signed>
|
||||
template <typename IntType>
|
||||
IntType checked_read_leb(const byte* base, int offset, int* length,
|
||||
const char* msg) {
|
||||
if (!check(base, offset, 1, msg)) {
|
||||
@ -367,21 +365,9 @@ class Decoder {
|
||||
if (ptr == end) {
|
||||
// Check there are no bits set beyond the bitwidth of {IntType}.
|
||||
const int kExtraBits = (1 + kMaxLength * 7) - (sizeof(IntType) * 8);
|
||||
const byte kExtraBitsMask = static_cast<byte>(0xFF << (8 - kExtraBits));
|
||||
int extra_bits_value;
|
||||
if (is_signed) {
|
||||
// A signed-LEB128 must sign-extend the final byte, excluding its
|
||||
// most-signifcant bit. e.g. for a 32-bit LEB128:
|
||||
// kExtraBits = 4
|
||||
// kExtraBitsMask = 0xf0
|
||||
// If b is 0x0f, the value is negative, so extra_bits_value is 0x70.
|
||||
// If b is 0x03, the value is positive, so extra_bits_value is 0x00.
|
||||
extra_bits_value = (static_cast<int8_t>(b << kExtraBits) >> 8) &
|
||||
kExtraBitsMask & ~0x80;
|
||||
} else {
|
||||
extra_bits_value = 0;
|
||||
}
|
||||
if (*length == kMaxLength && (b & kExtraBitsMask) != extra_bits_value) {
|
||||
const byte kExtraBitsMask =
|
||||
static_cast<byte>((0xFF << (8 - kExtraBits)) & 0xFF);
|
||||
if (*length == kMaxLength && (b & kExtraBitsMask) != 0) {
|
||||
error(base, ptr, "extra bits in varint");
|
||||
return 0;
|
||||
}
|
||||
|
@ -52,155 +52,18 @@
|
||||
#define WASM_ZERO kExprI8Const, 0
|
||||
#define WASM_ONE kExprI8Const, 1
|
||||
#define WASM_I8(val) kExprI8Const, static_cast<byte>(val)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Int32 Const operations
|
||||
//------------------------------------------------------------------------------
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
#define I32V_MIN(length) -(1 << (6 + (7 * ((length) - 1))))
|
||||
#define I32V_MAX(length) ((1 << (6 + (7 * ((length) - 1)))) - 1)
|
||||
|
||||
#define I32V_IN_RANGE(value, length) \
|
||||
((value) >= I32V_MIN(length) && (value) <= I32V_MAX(length))
|
||||
|
||||
inline void CheckI32v(int32_t value, int length) {
|
||||
DCHECK(length >= 1 && length <= 5);
|
||||
DCHECK(length == 5 || I32V_IN_RANGE(value, length));
|
||||
DCHECK(length == 1 || !I32V_IN_RANGE(value, length - 1));
|
||||
}
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#define WASM_I32V(val) kExprI32Const, U32V_5(val)
|
||||
|
||||
#define WASM_I32V_1(val) \
|
||||
static_cast<byte>(CheckI32v((val), 1), kExprI32Const), U32V_1(val)
|
||||
#define WASM_I32V_2(val) \
|
||||
static_cast<byte>(CheckI32v((val), 2), kExprI32Const), U32V_2(val)
|
||||
#define WASM_I32V_3(val) \
|
||||
static_cast<byte>(CheckI32v((val), 3), kExprI32Const), U32V_3(val)
|
||||
#define WASM_I32V_4(val) \
|
||||
static_cast<byte>(CheckI32v((val), 4), kExprI32Const), U32V_4(val)
|
||||
#define WASM_I32V_5(val) \
|
||||
static_cast<byte>(CheckI32v((val), 5), kExprI32Const), U32V_5(val)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Int64 Const operations
|
||||
//------------------------------------------------------------------------------
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
#define I64V_MIN(length) -(1LL << (6 + (7 * ((length)-1))))
|
||||
#define I64V_MAX(length) ((1LL << (6 + 7 * ((length)-1))) - 1)
|
||||
|
||||
#define I64V_IN_RANGE(value, length) \
|
||||
((value) >= I64V_MIN(length) && (value) <= I64V_MAX(length))
|
||||
|
||||
inline void CheckI64v(int64_t value, int length) {
|
||||
DCHECK(length >= 1 && length <= 10);
|
||||
DCHECK(length == 10 || I64V_IN_RANGE(value, length));
|
||||
DCHECK(length == 1 || !I64V_IN_RANGE(value, length - 1));
|
||||
}
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#define WASM_I64V(val) \
|
||||
kExprI64Const, \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 56) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 63) & MASK_7)
|
||||
|
||||
#define WASM_I64V_1(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 1), kExprI64Const), \
|
||||
static_cast<byte>(static_cast<int64_t>(val) & MASK_7)
|
||||
#define WASM_I64V_2(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 2), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 7) & MASK_7)
|
||||
#define WASM_I64V_3(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 3), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 14) & MASK_7)
|
||||
#define WASM_I64V_4(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 4), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 21) & MASK_7)
|
||||
#define WASM_I64V_5(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 5), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 28) & MASK_7)
|
||||
#define WASM_I64V_6(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 6), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 35) & MASK_7)
|
||||
#define WASM_I64V_7(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 7), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 42) & MASK_7)
|
||||
#define WASM_I64V_8(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 8), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 49) & MASK_7)
|
||||
#define WASM_I64V_9(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 9), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 56) & MASK_7)
|
||||
#define WASM_I64V_10(val) \
|
||||
static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 10), kExprI64Const), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((static_cast<int64_t>(val) >> 56) & MASK_7) | 0x80), \
|
||||
static_cast<byte>((static_cast<int64_t>(val) >> 63) & MASK_7)
|
||||
|
||||
#define WASM_I32(val) \
|
||||
kExprI32Const, static_cast<byte>(val), static_cast<byte>(val >> 8), \
|
||||
static_cast<byte>(val >> 16), static_cast<byte>(val >> 24)
|
||||
#define WASM_I64(val) \
|
||||
kExprI64Const, static_cast<byte>(static_cast<uint64_t>(val)), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 8), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 16), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 24), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 32), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 40), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 48), \
|
||||
static_cast<byte>(static_cast<uint64_t>(val) >> 56)
|
||||
#define WASM_F32(val) \
|
||||
kExprF32Const, \
|
||||
static_cast<byte>(bit_cast<int32_t>(static_cast<float>(val))), \
|
||||
@ -440,6 +303,6 @@ inline void CheckI64v(int64_t value, int length) {
|
||||
static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((x >> 14) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((x >> 21) & MASK_7) | 0x80), \
|
||||
static_cast<byte>(((x >> 28) & MASK_7))
|
||||
static_cast<byte>((x >> 28) & 0xF)
|
||||
|
||||
#endif // V8_WASM_MACRO_GEN_H_
|
||||
|
@ -132,7 +132,7 @@ TEST(Run_WasmI64GeU) {
|
||||
TEST(Run_WasmI32ConvertI64) {
|
||||
FOR_INT64_INPUTS(i) {
|
||||
WasmRunner<int32_t> r;
|
||||
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(*i)));
|
||||
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64(*i)));
|
||||
CHECK_EQ(static_cast<int32_t>(*i), r.Call());
|
||||
}
|
||||
}
|
||||
@ -175,20 +175,18 @@ TEST(Run_WasmCallI64Parameter) {
|
||||
// Build the calling function.
|
||||
WasmRunner<int32_t> r;
|
||||
r.env()->module = &module;
|
||||
BUILD(
|
||||
r,
|
||||
WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION(
|
||||
index, WASM_I64V_9(0xbcd12340000000b),
|
||||
WASM_I64V_9(0xbcd12340000000c), WASM_I32V_1(0xd),
|
||||
WASM_I32_CONVERT_I64(WASM_I64V_9(0xbcd12340000000e)),
|
||||
WASM_I64V_9(0xbcd12340000000f), WASM_I64V_10(0xbcd1234000000010),
|
||||
WASM_I64V_10(0xbcd1234000000011), WASM_I64V_10(0xbcd1234000000012),
|
||||
WASM_I64V_10(0xbcd1234000000013), WASM_I64V_10(0xbcd1234000000014),
|
||||
WASM_I64V_10(0xbcd1234000000015), WASM_I64V_10(0xbcd1234000000016),
|
||||
WASM_I64V_10(0xbcd1234000000017), WASM_I64V_10(0xbcd1234000000018),
|
||||
WASM_I64V_10(0xbcd1234000000019), WASM_I64V_10(0xbcd123400000001a),
|
||||
WASM_I64V_10(0xbcd123400000001b), WASM_I64V_10(0xbcd123400000001c),
|
||||
WASM_I64V_10(0xbcd123400000001d))));
|
||||
BUILD(r,
|
||||
WASM_I32_CONVERT_I64(WASM_CALL_FUNCTION(
|
||||
index, WASM_I64(0xbcd12340000000b), WASM_I64(0xbcd12340000000c),
|
||||
WASM_I32(0xd), WASM_I32_CONVERT_I64(WASM_I64(0xbcd12340000000e)),
|
||||
WASM_I64(0xbcd12340000000f), WASM_I64(0xbcd1234000000010),
|
||||
WASM_I64(0xbcd1234000000011), WASM_I64(0xbcd1234000000012),
|
||||
WASM_I64(0xbcd1234000000013), WASM_I64(0xbcd1234000000014),
|
||||
WASM_I64(0xbcd1234000000015), WASM_I64(0xbcd1234000000016),
|
||||
WASM_I64(0xbcd1234000000017), WASM_I64(0xbcd1234000000018),
|
||||
WASM_I64(0xbcd1234000000019), WASM_I64(0xbcd123400000001a),
|
||||
WASM_I64(0xbcd123400000001b), WASM_I64(0xbcd123400000001c),
|
||||
WASM_I64(0xbcd123400000001d))));
|
||||
|
||||
CHECK_EQ(i + 0xb, r.Call());
|
||||
}
|
||||
|
@ -141,12 +141,12 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
|
||||
byte code[] = {WASM_BLOCK(
|
||||
2,
|
||||
WASM_WHILE(
|
||||
WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32V_3(kCheckSize)),
|
||||
WASM_I32_LTS(WASM_GET_LOCAL(localIndex), WASM_I32(kCheckSize)),
|
||||
WASM_IF_ELSE(
|
||||
WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(localIndex)),
|
||||
WASM_BRV(2, WASM_I8(-1)), WASM_INC_LOCAL_BY(localIndex, 4))),
|
||||
WASM_I8(11))};
|
||||
uint32_t local_indices[] = {7, 18, 24, 27};
|
||||
uint32_t local_indices[] = {7, 19, 25, 28};
|
||||
f->EmitCode(code, sizeof(code), local_indices, sizeof(local_indices) / 4);
|
||||
WasmModuleWriter* writer = builder->Build(&zone);
|
||||
TestModule(writer->WriteTo(&zone), 11);
|
||||
@ -197,8 +197,8 @@ TEST(Run_WasmModule_Global) {
|
||||
f = builder->FunctionAt(f2_index);
|
||||
f->ReturnType(kAstI32);
|
||||
f->Exported(1);
|
||||
byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)),
|
||||
WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)),
|
||||
byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32(56)),
|
||||
WASM_STORE_GLOBAL(global2, WASM_I32(41)),
|
||||
WASM_RETURN(WASM_CALL_FUNCTION0(f1_index))};
|
||||
f->EmitCode(code2, sizeof(code2));
|
||||
WasmModuleWriter* writer = builder->Build(&zone);
|
||||
|
@ -60,7 +60,7 @@ TEST(Run_WasmInt32Const) {
|
||||
WasmRunner<int32_t> r;
|
||||
const int32_t kExpectedValue = 0x11223344;
|
||||
// return(kExpectedValue)
|
||||
BUILD(r, WASM_I32V_5(kExpectedValue));
|
||||
BUILD(r, WASM_I32(kExpectedValue));
|
||||
CHECK_EQ(kExpectedValue, r.Call());
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ TEST(Run_WasmInt32Const_many) {
|
||||
WasmRunner<int32_t> r;
|
||||
const int32_t kExpectedValue = *i;
|
||||
// return(kExpectedValue)
|
||||
BUILD(r, WASM_I32V(kExpectedValue));
|
||||
BUILD(r, WASM_I32(kExpectedValue));
|
||||
CHECK_EQ(kExpectedValue, r.Call());
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ TEST(Run_WasmInt64Const) {
|
||||
WasmRunner<int64_t> r;
|
||||
const int64_t kExpectedValue = 0x1122334455667788LL;
|
||||
// return(kExpectedValue)
|
||||
BUILD(r, WASM_I64V_9(kExpectedValue));
|
||||
BUILD(r, WASM_I64(kExpectedValue));
|
||||
CHECK_EQ(kExpectedValue, r.Call());
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ TEST(Run_WasmInt64Const_many) {
|
||||
WasmRunner<int64_t> r;
|
||||
const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr;
|
||||
// return(kExpectedValue)
|
||||
BUILD(r, WASM_I64V(kExpectedValue));
|
||||
BUILD(r, WASM_I64(kExpectedValue));
|
||||
CHECK_EQ(kExpectedValue, r.Call());
|
||||
cntr++;
|
||||
}
|
||||
@ -192,7 +192,7 @@ void TestInt32Binop(WasmOpcode opcode, int32_t expected, int32_t a, int32_t b) {
|
||||
{
|
||||
WasmRunner<int32_t> r;
|
||||
// K op K
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I32V(a), WASM_I32V(b)));
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I32(a), WASM_I32(b)));
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
{
|
||||
@ -240,7 +240,7 @@ void TestInt32Unop(WasmOpcode opcode, int32_t expected, int32_t a) {
|
||||
{
|
||||
WasmRunner<int32_t> r;
|
||||
// return op K
|
||||
BUILD(r, WASM_UNOP(opcode, WASM_I32V(a)));
|
||||
BUILD(r, WASM_UNOP(opcode, WASM_I32(a)));
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
{
|
||||
@ -341,7 +341,7 @@ void TestInt64Binop(WasmOpcode opcode, int64_t expected, int64_t a, int64_t b) {
|
||||
{
|
||||
WasmRunner<int64_t> r;
|
||||
// return K op K
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b)));
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I64(a), WASM_I64(b)));
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
{
|
||||
@ -358,7 +358,7 @@ void TestInt64Cmp(WasmOpcode opcode, int64_t expected, int64_t a, int64_t b) {
|
||||
{
|
||||
WasmRunner<int32_t> r;
|
||||
// return K op K
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b)));
|
||||
BUILD(r, WASM_BINOP(opcode, WASM_I64(a), WASM_I64(b)));
|
||||
CHECK_EQ(expected, r.Call());
|
||||
}
|
||||
{
|
||||
@ -574,7 +574,7 @@ TEST(Run_WASM_Int32DivS_byzero_const) {
|
||||
TEST(Run_WASM_Int32DivU_byzero_const) {
|
||||
for (uint32_t denom = 0xfffffffe; denom < 8; denom++) {
|
||||
WasmRunner<uint32_t> r(MachineType::Uint32());
|
||||
BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
|
||||
BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_I32(denom)));
|
||||
|
||||
for (uint32_t val = 0xfffffff0; val < 8; val++) {
|
||||
if (denom == 0) {
|
||||
@ -657,7 +657,7 @@ TEST(Run_WASM_Int64RemU_trap) {
|
||||
TEST(Run_WASM_Int64DivS_byzero_const) {
|
||||
for (int8_t denom = -2; denom < 8; denom++) {
|
||||
WasmRunner<int64_t> r(MachineType::Int64());
|
||||
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom)));
|
||||
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64(denom)));
|
||||
for (int64_t val = -7; val < 8; val++) {
|
||||
if (denom == 0) {
|
||||
CHECK_TRAP64(r.Call(val));
|
||||
@ -672,7 +672,7 @@ TEST(Run_WASM_Int64DivS_byzero_const) {
|
||||
TEST(Run_WASM_Int64DivU_byzero_const) {
|
||||
for (uint64_t denom = 0xfffffffffffffffe; denom < 8; denom++) {
|
||||
WasmRunner<uint64_t> r(MachineType::Uint64());
|
||||
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom)));
|
||||
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64(denom)));
|
||||
|
||||
for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) {
|
||||
if (denom == 0) {
|
||||
@ -1268,7 +1268,7 @@ TEST(Run_Wasm_VoidReturn1) {
|
||||
// Build the calling function.
|
||||
WasmRunner<int32_t> r;
|
||||
r.env()->module = &module;
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32(kExpected)));
|
||||
|
||||
int32_t result = r.Call();
|
||||
CHECK_EQ(kExpected, result);
|
||||
@ -1288,7 +1288,7 @@ TEST(Run_Wasm_VoidReturn2) {
|
||||
// Build the calling function.
|
||||
WasmRunner<int32_t> r;
|
||||
r.env()->module = &module;
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
|
||||
BUILD(r, WASM_BLOCK(2, WASM_CALL_FUNCTION0(index), WASM_I32(kExpected)));
|
||||
|
||||
int32_t result = r.Call();
|
||||
CHECK_EQ(kExpected, result);
|
||||
@ -1649,7 +1649,7 @@ TEST(Run_Wasm_StoreMemI32_offset) {
|
||||
const int32_t kWritten = 0xaabbccdd;
|
||||
|
||||
BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0),
|
||||
WASM_I32V_5(kWritten)));
|
||||
WASM_I32(kWritten)));
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
module.RandomizeMemory(1111);
|
||||
@ -2304,7 +2304,7 @@ TEST(Run_TestI64WasmRunner) {
|
||||
{
|
||||
FOR_INT64_INPUTS(i) {
|
||||
WasmRunner<int64_t> r;
|
||||
BUILD(r, WASM_I64V(*i));
|
||||
BUILD(r, WASM_I64(*i));
|
||||
CHECK_EQ(*i, r.Call());
|
||||
}
|
||||
}
|
||||
@ -2359,7 +2359,7 @@ TEST(Run_WasmCallEmpty) {
|
||||
TestSignatures sigs;
|
||||
TestingModule module;
|
||||
WasmFunctionCompiler t(sigs.i_v(), &module);
|
||||
BUILD(t, WASM_I32V_3(kExpected));
|
||||
BUILD(t, WASM_I32(kExpected));
|
||||
uint32_t index = t.CompileAndAdd();
|
||||
|
||||
// Build the calling function.
|
||||
@ -2431,7 +2431,7 @@ TEST(Run_WasmCallVoid) {
|
||||
module.RandomizeMemory();
|
||||
WasmFunctionCompiler t(sigs.v_v(), &module);
|
||||
BUILD(t, WASM_STORE_MEM(MachineType::Int32(), WASM_I8(kMemOffset),
|
||||
WASM_I32V_3(kExpected)));
|
||||
WASM_I32(kExpected)));
|
||||
uint32_t index = t.CompileAndAdd();
|
||||
|
||||
// Build the calling function.
|
||||
@ -2611,7 +2611,7 @@ static void Run_WasmMixedCall_N(int start) {
|
||||
ADD_CODE(code, WASM_LOAD_MEM(memtypes[i], WASM_I8(offset)));
|
||||
}
|
||||
|
||||
ADD_CODE(code, WASM_I32V_2(kExpected));
|
||||
ADD_CODE(code, WASM_I32(kExpected));
|
||||
size_t end = code.size();
|
||||
code.push_back(0);
|
||||
r.Build(&code[0], &code[end]);
|
||||
|
@ -219,23 +219,26 @@ TEST_F(AstDecoderTest, Int8Const_fallthru) {
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, Int32Const) {
|
||||
byte code[] = {kExprI32Const, 0, 0, 0, 0};
|
||||
int32_t* ptr = reinterpret_cast<int32_t*>(code + 1);
|
||||
const int kInc = 4498211;
|
||||
for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
|
||||
// TODO(binji): expand test for other sized int32s; 1 through 5 bytes.
|
||||
byte code[] = {WASM_I32V(i)};
|
||||
*ptr = i;
|
||||
EXPECT_VERIFIES(&env_i_i, code);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, Int8Const_fallthru2) {
|
||||
byte code[] = {WASM_I8(0), WASM_I32V_4(0x1122334)};
|
||||
byte code[] = {kExprI8Const, 0, kExprI32Const, 1, 2, 3, 4};
|
||||
EXPECT_VERIFIES(&env_i_i, code);
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, Int64Const) {
|
||||
byte code[] = {kExprI64Const, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
int64_t* ptr = reinterpret_cast<int64_t*>(code + 1);
|
||||
const int kInc = 4498211;
|
||||
for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
|
||||
byte code[] = {WASM_I64V((static_cast<int64_t>(i) << 32) | i)};
|
||||
*ptr = (static_cast<int64_t>(i) << 32) | i;
|
||||
EXPECT_VERIFIES(&env_l_l, code);
|
||||
}
|
||||
}
|
||||
@ -780,7 +783,7 @@ TEST_F(AstDecoderTest, TypeConversions) {
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, MacrosStmt) {
|
||||
VERIFY(WASM_SET_LOCAL(0, WASM_I32V_3(87348)));
|
||||
VERIFY(WASM_SET_LOCAL(0, WASM_I32(87348)));
|
||||
VERIFY(WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40)));
|
||||
VERIFY(WASM_IF(WASM_GET_LOCAL(0), WASM_NOP));
|
||||
VERIFY(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP));
|
||||
@ -795,8 +798,7 @@ TEST_F(AstDecoderTest, MacrosBreak) {
|
||||
EXPECT_VERIFIES_INLINE(&env_v_v, WASM_LOOP(1, WASM_BREAK(0)));
|
||||
|
||||
EXPECT_VERIFIES_INLINE(&env_i_i, WASM_LOOP(1, WASM_BREAKV(0, WASM_ZERO)));
|
||||
EXPECT_VERIFIES_INLINE(&env_l_l,
|
||||
WASM_LOOP(1, WASM_BREAKV(0, WASM_I64V_1(0))));
|
||||
EXPECT_VERIFIES_INLINE(&env_l_l, WASM_LOOP(1, WASM_BREAKV(0, WASM_I64(0))));
|
||||
EXPECT_VERIFIES_INLINE(&env_f_ff,
|
||||
WASM_LOOP(1, WASM_BREAKV(0, WASM_F32(0.0))));
|
||||
EXPECT_VERIFIES_INLINE(&env_d_dd,
|
||||
@ -893,35 +895,35 @@ TEST_F(AstDecoderTest, MacrosInt64) {
|
||||
#define VERIFY_L_LL(...) EXPECT_VERIFIES_INLINE(&env_l_ll, __VA_ARGS__)
|
||||
#define VERIFY_I_LL(...) EXPECT_VERIFIES_INLINE(&env_i_ll, __VA_ARGS__)
|
||||
|
||||
VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64V_1(12)));
|
||||
VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64V_1(13)));
|
||||
VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64V_1(14)));
|
||||
VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(15)));
|
||||
VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(16)));
|
||||
VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64V_1(17)));
|
||||
VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64V_1(18)));
|
||||
VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64V_1(19)));
|
||||
VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64V_1(20)));
|
||||
VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64V_1(21)));
|
||||
VERIFY_L_LL(WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64(12)));
|
||||
VERIFY_L_LL(WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64(13)));
|
||||
VERIFY_L_LL(WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64(14)));
|
||||
VERIFY_L_LL(WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64(15)));
|
||||
VERIFY_L_LL(WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64(16)));
|
||||
VERIFY_L_LL(WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_I64(17)));
|
||||
VERIFY_L_LL(WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_I64(18)));
|
||||
VERIFY_L_LL(WASM_I64_AND(WASM_GET_LOCAL(0), WASM_I64(19)));
|
||||
VERIFY_L_LL(WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_I64(20)));
|
||||
VERIFY_L_LL(WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64(21)));
|
||||
|
||||
VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(22)));
|
||||
VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(23)));
|
||||
VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(24)));
|
||||
VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64V_1(24)));
|
||||
VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64V_1(24)));
|
||||
VERIFY_L_LL(WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64(22)));
|
||||
VERIFY_L_LL(WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64(23)));
|
||||
VERIFY_L_LL(WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64(24)));
|
||||
VERIFY_L_LL(WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_I64(24)));
|
||||
VERIFY_L_LL(WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_I64(24)));
|
||||
|
||||
VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64V_1(26)));
|
||||
VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64V_1(27)));
|
||||
VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64V_1(28)));
|
||||
VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64V_1(29)));
|
||||
VERIFY_I_LL(WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_I64(26)));
|
||||
VERIFY_I_LL(WASM_I64_LES(WASM_GET_LOCAL(0), WASM_I64(27)));
|
||||
VERIFY_I_LL(WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_I64(28)));
|
||||
VERIFY_I_LL(WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_I64(29)));
|
||||
|
||||
VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64V_1(26)));
|
||||
VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64V_1(27)));
|
||||
VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64V_1(28)));
|
||||
VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64V_1(29)));
|
||||
VERIFY_I_LL(WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_I64(26)));
|
||||
VERIFY_I_LL(WASM_I64_GES(WASM_GET_LOCAL(0), WASM_I64(27)));
|
||||
VERIFY_I_LL(WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_I64(28)));
|
||||
VERIFY_I_LL(WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_I64(29)));
|
||||
|
||||
VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64V_1(25)));
|
||||
VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64V_1(25)));
|
||||
VERIFY_I_LL(WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_I64(25)));
|
||||
VERIFY_I_LL(WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64(25)));
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, AllSimpleExpressions) {
|
||||
@ -1194,7 +1196,7 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) {
|
||||
|
||||
module_env.AddFunction(sigs.i_i());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(17)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(17)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F32(17.1)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(17.1)));
|
||||
}
|
||||
@ -1207,13 +1209,13 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) {
|
||||
module_env.AddFunction(sigs.i_f());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I8(17)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64V_1(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_I64(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(0, WASM_F64(37.2)));
|
||||
|
||||
module_env.AddFunction(sigs.i_d());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I8(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64V_1(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_I64(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_FUNCTION(1, WASM_F32(17.6)));
|
||||
}
|
||||
|
||||
@ -1256,19 +1258,17 @@ TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) {
|
||||
byte f0 = module_env.AddFunction(sigs.i_f());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I8(17)));
|
||||
EXPECT_FAILURE_INLINE(env,
|
||||
WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64V_1(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_I64(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f0, WASM_ZERO, WASM_F64(37.2)));
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I8(17)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64V_1(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_I64(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT0(f0, WASM_F64(37.2)));
|
||||
|
||||
byte f1 = module_env.AddFunction(sigs.i_d());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I8(16)));
|
||||
EXPECT_FAILURE_INLINE(env,
|
||||
WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I64V_1(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_I64(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_INDIRECT(f1, WASM_ZERO, WASM_F32(17.6)));
|
||||
}
|
||||
|
||||
@ -1295,14 +1295,14 @@ TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) {
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f0));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I8(17)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I64V_1(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_I64(27)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f0, WASM_F64(37.2)));
|
||||
|
||||
byte f1 = module_env.AddImport(sigs.i_d());
|
||||
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT0(f1));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I8(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I64V_1(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_I64(16)));
|
||||
EXPECT_FAILURE_INLINE(env, WASM_CALL_IMPORT(f1, WASM_F32(17.6)));
|
||||
}
|
||||
|
||||
@ -1811,8 +1811,8 @@ TEST_F(AstDecoderTest, Select) {
|
||||
WASM_SELECT(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO));
|
||||
EXPECT_VERIFIES_INLINE(&env_d_dd,
|
||||
WASM_SELECT(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO));
|
||||
EXPECT_VERIFIES_INLINE(
|
||||
&env_l_l, WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO));
|
||||
EXPECT_VERIFIES_INLINE(&env_l_l,
|
||||
WASM_SELECT(WASM_I64(0), WASM_I64(0), WASM_ZERO));
|
||||
}
|
||||
|
||||
TEST_F(AstDecoderTest, Select_fail1) {
|
||||
@ -1861,7 +1861,7 @@ TEST_F(AstDecoderTest, Select_TypeCheck) {
|
||||
WASM_GET_LOCAL(0)));
|
||||
|
||||
EXPECT_FAILURE_INLINE(
|
||||
&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64V_1(0)));
|
||||
&env_i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64(0)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -428,26 +428,6 @@ TEST_F(DecoderTest, ReadU32v_extra_bits) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DecoderTest, ReadI32v_extra_bits_negative) {
|
||||
// OK for negative signed values to have extra ones.
|
||||
int length = 0;
|
||||
byte data[] = {0xff, 0xff, 0xff, 0xff, 0x7f};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(5, length);
|
||||
EXPECT_TRUE(decoder.ok());
|
||||
}
|
||||
|
||||
TEST_F(DecoderTest, ReadI32v_extra_bits_positive) {
|
||||
// Not OK for positive signed values to have extra ones.
|
||||
int length = 0;
|
||||
byte data[] = {0x80, 0x80, 0x80, 0x80, 0x77};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(5, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
|
||||
TEST_F(DecoderTest, ReadU32v_Bits) {
|
||||
// A more exhaustive test.
|
||||
const int kMaxSize = 5;
|
||||
@ -607,7 +587,8 @@ TEST_F(DecoderTest, ReadI64v_Bits) {
|
||||
|
||||
int length = 1 + i / 7;
|
||||
for (int j = 0; j < kMaxSize; j++) {
|
||||
data[j] = static_cast<byte>((val >> (7 * j)) & MASK_7);
|
||||
const uint64_t uval = bit_cast<uint64_t>(val);
|
||||
data[j] = static_cast<byte>((uval >> (7 * j)) & MASK_7);
|
||||
}
|
||||
for (int j = 0; j < length - 1; j++) {
|
||||
data[j] |= 0x80;
|
||||
@ -642,26 +623,6 @@ TEST_F(DecoderTest, ReadU64v_extra_bits) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DecoderTest, ReadI64v_extra_bits_negative) {
|
||||
// OK for negative signed values to have extra ones.
|
||||
int length = 0;
|
||||
byte data[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i64v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(10, length);
|
||||
EXPECT_TRUE(decoder.ok());
|
||||
}
|
||||
|
||||
TEST_F(DecoderTest, ReadI64v_extra_bits_positive) {
|
||||
// Not OK for positive signed values to have extra ones.
|
||||
int length = 0;
|
||||
byte data[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x77};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i64v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(10, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -26,14 +26,14 @@ TEST_F(WasmMacroGenTest, Constants) {
|
||||
EXPECT_SIZE(2, WASM_I8(122));
|
||||
EXPECT_SIZE(2, WASM_I8(254));
|
||||
|
||||
EXPECT_SIZE(2, WASM_I32V_1(1));
|
||||
EXPECT_SIZE(4, WASM_I32V_3(10000));
|
||||
EXPECT_SIZE(5, WASM_I32V_4(-9828934));
|
||||
EXPECT_SIZE(5, WASM_I32(1));
|
||||
EXPECT_SIZE(5, WASM_I32(10000));
|
||||
EXPECT_SIZE(5, WASM_I32(-9828934));
|
||||
|
||||
EXPECT_SIZE(2, WASM_I64V_1(1));
|
||||
EXPECT_SIZE(4, WASM_I64V_3(10000));
|
||||
EXPECT_SIZE(5, WASM_I64V_4(-9828934));
|
||||
EXPECT_SIZE(10, WASM_I64V_9(0x123456789abcdef0ULL));
|
||||
EXPECT_SIZE(9, WASM_I64(1));
|
||||
EXPECT_SIZE(9, WASM_I64(10000));
|
||||
EXPECT_SIZE(9, WASM_I64(-9828934));
|
||||
EXPECT_SIZE(9, WASM_I64(0x123456789abcdef0ULL));
|
||||
|
||||
EXPECT_SIZE(5, WASM_F32(1.0f));
|
||||
EXPECT_SIZE(5, WASM_F32(10000.0f));
|
||||
|
Loading…
Reference in New Issue
Block a user