Commit 55fc5c0c authored by titzer's avatar titzer Committed by Commit bot

[wasm] Rename wasm::LocalType to wasm::ValueType and kAst* to kWasm*

This is more renaming work to comply with the naming in the public
design repository. E.g. types are called "value types" and we no longer
refer to ASTs.

R=clemensh@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2594993002
Cr-Commit-Position: refs/heads/master@{#41891}
parent bc981e61
This diff is collapsed.
......@@ -251,18 +251,18 @@ class WasmTrapHelper : public ZoneObject {
}
}
Node* GetTrapValue(wasm::LocalType type) {
Node* GetTrapValue(wasm::ValueType type) {
switch (type) {
case wasm::kAstI32:
case wasm::kWasmI32:
return jsgraph()->Int32Constant(0xdeadbeef);
case wasm::kAstI64:
case wasm::kWasmI64:
return jsgraph()->Int64Constant(0xdeadbeefdeadbeef);
case wasm::kAstF32:
case wasm::kWasmF32:
return jsgraph()->Float32Constant(bit_cast<float>(0xdeadbeef));
case wasm::kAstF64:
case wasm::kWasmF64:
return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef));
break;
case wasm::kAstS128:
case wasm::kWasmS128:
return builder_->CreateS128Value(0xdeadbeef);
break;
default:
......@@ -353,10 +353,10 @@ WasmGraphBuilder::WasmGraphBuilder(
sig_(sig),
source_position_table_(source_position_table) {
for (size_t i = 0; i < sig->parameter_count(); i++) {
if (sig->GetParam(i) == wasm::kAstS128) has_simd_ = true;
if (sig->GetParam(i) == wasm::kWasmS128) has_simd_ = true;
}
for (size_t i = 0; i < sig->return_count(); i++) {
if (sig->GetReturn(i) == wasm::kAstS128) has_simd_ = true;
if (sig->GetReturn(i) == wasm::kWasmS128) has_simd_ = true;
}
DCHECK_NOT_NULL(jsgraph_);
}
......@@ -427,7 +427,7 @@ Node* WasmGraphBuilder::Merge(unsigned count, Node** controls) {
return graph()->NewNode(jsgraph()->common()->Merge(count), count, controls);
}
Node* WasmGraphBuilder::Phi(wasm::LocalType type, unsigned count, Node** vals,
Node* WasmGraphBuilder::Phi(wasm::ValueType type, unsigned count, Node** vals,
Node* control) {
DCHECK(IrOpcode::IsMergeOpcode(control->opcode()));
Node** buf = Realloc(vals, count, count + 1);
......@@ -1168,7 +1168,7 @@ static bool ReverseBytesSupported(MachineOperatorBuilder* m,
}
Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
wasm::LocalType wasmtype) {
wasm::ValueType wasmtype) {
Node* result;
Node* value = node;
MachineOperatorBuilder* m = jsgraph()->machine();
......@@ -1284,7 +1284,7 @@ Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
// Perform sign extension using following trick
// result = (x << machine_width - type_width) >> (machine_width -
// type_width)
if (wasmtype == wasm::kAstI64) {
if (wasmtype == wasm::kWasmI64) {
shiftBitCount = jsgraph()->Int32Constant(64 - valueSizeInBits);
result = graph()->NewNode(
m->Word64Sar(),
......@@ -1292,7 +1292,7 @@ Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
graph()->NewNode(m->ChangeInt32ToInt64(), result),
shiftBitCount),
shiftBitCount);
} else if (wasmtype == wasm::kAstI32) {
} else if (wasmtype == wasm::kWasmI32) {
shiftBitCount = jsgraph()->Int32Constant(32 - valueSizeInBits);
result = graph()->NewNode(
m->Word32Sar(),
......@@ -2469,24 +2469,24 @@ Node* WasmGraphBuilder::BuildChangeFloat64ToTagged(Node* value) {
return value;
}
Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) {
Node* WasmGraphBuilder::ToJS(Node* node, wasm::ValueType type) {
switch (type) {
case wasm::kAstI32:
case wasm::kWasmI32:
return BuildChangeInt32ToTagged(node);
case wasm::kAstS128:
case wasm::kAstI64:
case wasm::kWasmS128:
case wasm::kWasmI64:
// Throw a TypeError. The native context is good enough here because we
// only throw a TypeError.
return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
jsgraph()->isolate()->native_context(), nullptr,
0, effect_, *control_);
case wasm::kAstF32:
case wasm::kWasmF32:
node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(),
node);
return BuildChangeFloat64ToTagged(node);
case wasm::kAstF64:
case wasm::kWasmF64:
return BuildChangeFloat64ToTagged(node);
case wasm::kAstStmt:
case wasm::kWasmStmt:
return jsgraph()->UndefinedConstant();
default:
UNREACHABLE();
......@@ -2623,8 +2623,8 @@ Node* WasmGraphBuilder::BuildChangeTaggedToFloat64(Node* value) {
}
Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
wasm::LocalType type) {
DCHECK_NE(wasm::kAstStmt, type);
wasm::ValueType type) {
DCHECK_NE(wasm::kWasmStmt, type);
// Do a JavaScript ToNumber.
Node* num = BuildJavaScriptToNumber(node, context);
......@@ -2634,23 +2634,23 @@ Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
num = BuildChangeTaggedToFloat64(num);
switch (type) {
case wasm::kAstI32: {
case wasm::kWasmI32: {
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToWord32(),
num);
break;
}
case wasm::kAstS128:
case wasm::kAstI64:
case wasm::kWasmS128:
case wasm::kWasmI64:
// Throw a TypeError. The native context is good enough here because we
// only throw a TypeError.
return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
jsgraph()->isolate()->native_context(), nullptr,
0, effect_, *control_);
case wasm::kAstF32:
case wasm::kWasmF32:
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(),
num);
break;
case wasm::kAstF64:
case wasm::kWasmF64:
break;
default:
UNREACHABLE();
......@@ -2770,7 +2770,7 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
Node* param = Param(i + 1);
Node* wasm_param = FromJS(param, context, sig->GetParam(i));
args[pos++] = wasm_param;
if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kAstI64) {
if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64) {
// We make up the high word with SAR to get the proper sign extension.
args[pos++] = graph()->NewNode(jsgraph()->machine()->Word32Sar(),
wasm_param, jsgraph()->Int32Constant(31));
......@@ -2790,13 +2790,13 @@ void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
*effect_ = call;
Node* retval = call;
if (jsgraph()->machine()->Is32() && sig->return_count() > 0 &&
sig->GetReturn(0) == wasm::kAstI64) {
sig->GetReturn(0) == wasm::kWasmI64) {
// The return values comes as two values, we pick the low word.
retval = graph()->NewNode(jsgraph()->common()->Projection(0), retval,
graph()->start());
}
Node* jsval = ToJS(
retval, sig->return_count() == 0 ? wasm::kAstStmt : sig->GetReturn());
retval, sig->return_count() == 0 ? wasm::kWasmStmt : sig->GetReturn());
Return(jsval);
}
......@@ -2807,7 +2807,7 @@ int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count,
for (int i = 0; i < param_count; ++i) {
Node* param = Param(param_index++);
args[pos++] = ToJS(param, sig->GetParam(i));
if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kAstI64) {
if (jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64) {
// On 32 bit platforms we have to skip the high word of int64
// parameters.
param_index++;
......@@ -3061,8 +3061,7 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
}
Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
Node* index, uint32_t offset,
uint32_t alignment,
wasm::WasmCodePosition position) {
......@@ -3101,7 +3100,7 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
load = BuildChangeEndianness(load, memtype, type);
#endif
if (type == wasm::kAstI64 &&
if (type == wasm::kWasmI64 &&
ElementSizeLog2Of(memtype.representation()) < 3) {
// TODO(titzer): TF zeroes the upper bits of 64-bit loads for subword sizes.
if (memtype.IsSigned()) {
......
......@@ -131,7 +131,7 @@ class WasmGraphBuilder {
Node* Loop(Node* entry);
Node* Terminate(Node* effect, Node* control);
Node* Merge(unsigned count, Node** controls);
Node* Phi(wasm::LocalType type, unsigned count, Node** vals, Node* control);
Node* Phi(wasm::ValueType type, unsigned count, Node** vals, Node* control);
Node* EffectPhi(unsigned count, Node** effects, Node* control);
Node* NumberConstant(int32_t value);
Node* Uint32Constant(uint32_t value);
......@@ -183,8 +183,8 @@ class WasmGraphBuilder {
void BuildJSToWasmWrapper(Handle<Code> wasm_code, wasm::FunctionSig* sig);
void BuildWasmToJSWrapper(Handle<JSReceiver> target, wasm::FunctionSig* sig);
Node* ToJS(Node* node, wasm::LocalType type);
Node* FromJS(Node* node, Node* context, wasm::LocalType type);
Node* ToJS(Node* node, wasm::ValueType type);
Node* FromJS(Node* node, Node* context, wasm::ValueType type);
Node* Invert(Node* node);
void EnsureFunctionTableNodes();
......@@ -194,7 +194,7 @@ class WasmGraphBuilder {
Node* CurrentMemoryPages();
Node* GetGlobal(uint32_t index);
Node* SetGlobal(uint32_t index, Node* val);
Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index,
Node* LoadMem(wasm::ValueType type, MachineType memtype, Node* index,
uint32_t offset, uint32_t alignment,
wasm::WasmCodePosition position);
Node* StoreMem(MachineType type, Node* index, uint32_t offset,
......@@ -264,7 +264,7 @@ class WasmGraphBuilder {
wasm::WasmCodePosition position);
Node* BuildChangeEndianness(Node* node, MachineType type,
wasm::LocalType wasmtype = wasm::kAstStmt);
wasm::ValueType wasmtype = wasm::kWasmStmt);
Node* MaskShiftCount32(Node* node);
Node* MaskShiftCount64(Node* node);
......
......@@ -24,17 +24,17 @@ using compiler::LinkageLocation;
namespace {
MachineType MachineTypeFor(LocalType type) {
MachineType MachineTypeFor(ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
return MachineType::Int32();
case kAstI64:
case kWasmI64:
return MachineType::Int64();
case kAstF64:
case kWasmF64:
return MachineType::Float64();
case kAstF32:
case kWasmF32:
return MachineType::Float32();
case kAstS128:
case kWasmS128:
return MachineType::Simd128();
default:
UNREACHABLE();
......@@ -173,7 +173,7 @@ struct Allocator {
int stack_offset;
LinkageLocation Next(LocalType type) {
LinkageLocation Next(ValueType type) {
if (IsFloatingPoint(type)) {
// Allocate a floating point register/stack location.
if (fp_offset < fp_count) {
......@@ -182,7 +182,7 @@ struct Allocator {
// Allocate floats using a double register, but modify the code to
// reflect how ARM FP registers alias.
// TODO(bbudge) Modify wasm linkage to allow use of all float regs.
if (type == kAstF32) {
if (type == kWasmF32) {
int float_reg_code = reg.code() * 2;
DCHECK(float_reg_code < RegisterConfiguration::kMaxFPRegisters);
return regloc(DoubleRegister::from_code(float_reg_code),
......@@ -206,11 +206,11 @@ struct Allocator {
}
}
}
bool IsFloatingPoint(LocalType type) {
return type == kAstF32 || type == kAstF64;
bool IsFloatingPoint(ValueType type) {
return type == kWasmF32 || type == kWasmF64;
}
int Words(LocalType type) {
if (kPointerSize < 8 && (type == kAstI64 || type == kAstF64)) {
int Words(ValueType type) {
if (kPointerSize < 8 && (type == kWasmI64 || type == kWasmF64)) {
return 2;
}
return 1;
......@@ -285,7 +285,7 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone,
// Add return location(s).
const int return_count = static_cast<int>(locations.return_count_);
for (int i = 0; i < return_count; i++) {
LocalType ret = fsig->GetReturn(i);
ValueType ret = fsig->GetReturn(i);
locations.AddReturn(rets.Next(ret));
}
......@@ -294,7 +294,7 @@ CallDescriptor* ModuleEnv::GetWasmCallDescriptor(Zone* zone,
// Add register and/or stack parameter(s).
const int parameter_count = static_cast<int>(fsig->parameter_count());
for (int i = 0; i < parameter_count; i++) {
LocalType param = fsig->GetParam(i);
ValueType param = fsig->GetParam(i);
locations.AddParam(params.Next(param));
}
......
This diff is collapsed.
......@@ -32,12 +32,12 @@ struct WasmGlobal;
// Helpers for decoding different kinds of operands which follow bytecodes.
struct LocalIndexOperand {
uint32_t index;
LocalType type;
ValueType type;
unsigned length;
inline LocalIndexOperand(Decoder* decoder, const byte* pc) {
index = decoder->checked_read_u32v(pc, 1, &length, "local index");
type = kAstStmt;
type = kWasmStmt;
}
};
......@@ -86,14 +86,14 @@ struct ImmF64Operand {
struct GlobalIndexOperand {
uint32_t index;
LocalType type;
ValueType type;
const WasmGlobal* global;
unsigned length;
inline GlobalIndexOperand(Decoder* decoder, const byte* pc) {
index = decoder->checked_read_u32v(pc, 1, &length, "global index");
global = nullptr;
type = kAstStmt;
type = kWasmStmt;
}
};
......@@ -104,12 +104,12 @@ struct BlockTypeOperand {
inline BlockTypeOperand(Decoder* decoder, const byte* pc) {
uint8_t val = decoder->checked_read_u8(pc, 1, "block type");
LocalType type = kAstStmt;
ValueType type = kWasmStmt;
length = 1;
arity = 0;
types = nullptr;
if (decode_local_type(val, &type)) {
arity = type == kAstStmt ? 0 : 1;
arity = type == kWasmStmt ? 0 : 1;
types = pc + 1;
} else {
// Handle multi-value blocks.
......@@ -135,7 +135,7 @@ struct BlockTypeOperand {
uint32_t offset = 1 + 1 + len + i;
val = decoder->checked_read_u8(pc, offset, "block type");
decode_local_type(val, &type);
if (type == kAstStmt) {
if (type == kWasmStmt) {
decoder->error(pc, pc + offset, "invalid block type");
return;
}
......@@ -144,34 +144,34 @@ struct BlockTypeOperand {
}
// Decode a byte representing a local type. Return {false} if the encoded
// byte was invalid or {kMultivalBlock}.
bool decode_local_type(uint8_t val, LocalType* result) {
switch (static_cast<LocalTypeCode>(val)) {
bool decode_local_type(uint8_t val, ValueType* result) {
switch (static_cast<ValueTypeCode>(val)) {
case kLocalVoid:
*result = kAstStmt;
*result = kWasmStmt;
return true;
case kLocalI32:
*result = kAstI32;
*result = kWasmI32;
return true;
case kLocalI64:
*result = kAstI64;
*result = kWasmI64;
return true;
case kLocalF32:
*result = kAstF32;
*result = kWasmF32;
return true;
case kLocalF64:
*result = kAstF64;
*result = kWasmF64;
return true;
case kLocalS128:
*result = kAstS128;
*result = kWasmS128;
return true;
default:
*result = kAstStmt;
*result = kWasmStmt;
return false;
}
}
LocalType read_entry(unsigned index) {
ValueType read_entry(unsigned index) {
DCHECK_LT(index, arity);
LocalType result;
ValueType result;
CHECK(decode_local_type(types[index], &result));
return result;
}
......@@ -366,7 +366,7 @@ struct BodyLocalDecls {
uint32_t total_local_count;
// List of {local type, count} pairs.
ZoneVector<std::pair<LocalType, uint32_t>> local_types;
ZoneVector<std::pair<ValueType, uint32_t>> local_types;
// Constructor initializes the vector.
explicit BodyLocalDecls(Zone* zone)
......
......@@ -32,25 +32,25 @@ namespace {
const char* kNameString = "name";
const size_t kNameStringLength = 4;
LocalType TypeOf(const WasmModule* module, const WasmInitExpr& expr) {
ValueType TypeOf(const WasmModule* module, const WasmInitExpr& expr) {
switch (expr.kind) {
case WasmInitExpr::kNone:
return kAstStmt;
return kWasmStmt;
case WasmInitExpr::kGlobalIndex:
return expr.val.global_index < module->globals.size()
? module->globals[expr.val.global_index].type
: kAstStmt;
: kWasmStmt;
case WasmInitExpr::kI32Const:
return kAstI32;
return kWasmI32;
case WasmInitExpr::kI64Const:
return kAstI64;
return kWasmI64;
case WasmInitExpr::kF32Const:
return kAstF32;
return kWasmF32;
case WasmInitExpr::kF64Const:
return kAstF64;
return kWasmF64;
default:
UNREACHABLE();
return kAstStmt;
return kWasmStmt;
}
}
......@@ -331,7 +331,7 @@ class ModuleDecoder : public Decoder {
// ===== Imported global =========================================
import->index = static_cast<uint32_t>(module->globals.size());
module->globals.push_back(
{kAstStmt, false, WasmInitExpr(), 0, true, false});
{kWasmStmt, false, WasmInitExpr(), 0, true, false});
WasmGlobal* global = &module->globals.back();
global->type = consume_value_type();
global->mutability = consume_u8("mutability") != 0;
......@@ -414,7 +414,7 @@ class ModuleDecoder : public Decoder {
static_cast<int>(pc_ - start_));
// Add an uninitialized global and pass a pointer to it.
module->globals.push_back(
{kAstStmt, false, WasmInitExpr(), 0, false, false});
{kWasmStmt, false, WasmInitExpr(), 0, false, false});
WasmGlobal* global = &module->globals.back();
DecodeGlobalInModule(module, i + imported_globals, global);
}
......@@ -536,7 +536,7 @@ class ModuleDecoder : public Decoder {
} else {
table = &module->function_tables[table_index];
}
WasmInitExpr offset = consume_init_expr(module, kAstI32);
WasmInitExpr offset = consume_init_expr(module, kWasmI32);
uint32_t num_elem =
consume_count("number of elements", kV8MaxWasmTableEntries);
std::vector<uint32_t> vector;
......@@ -670,7 +670,7 @@ class ModuleDecoder : public Decoder {
WasmInitExpr DecodeInitExpr(const byte* start) {
pc_ = start;
return consume_init_expr(nullptr, kAstStmt);
return consume_init_expr(nullptr, kWasmStmt);
}
private:
......@@ -686,7 +686,7 @@ class ModuleDecoder : public Decoder {
global->type = consume_value_type();
global->mutability = consume_u8("mutability") != 0;
const byte* pos = pc();
global->init = consume_init_expr(module, kAstStmt);
global->init = consume_init_expr(module, kWasmStmt);
switch (global->init.kind) {
case WasmInitExpr::kGlobalIndex: {
uint32_t other_index = global->init.val.global_index;
......@@ -724,7 +724,7 @@ class ModuleDecoder : public Decoder {
void DecodeDataSegmentInModule(WasmModule* module, WasmDataSegment* segment) {
const byte* start = pc_;
expect_u8("linear memory index", 0);
segment->dest_addr = consume_init_expr(module, kAstI32);
segment->dest_addr = consume_init_expr(module, kWasmI32);
segment->source_size = consume_u32v("source size");
segment->source_offset = static_cast<uint32_t>(pc_ - start_);
......@@ -900,7 +900,7 @@ class ModuleDecoder : public Decoder {
return true;
}
WasmInitExpr consume_init_expr(WasmModule* module, LocalType expected) {
WasmInitExpr consume_init_expr(WasmModule* module, ValueType expected) {
const byte* pos = pc();
uint8_t opcode = consume_u8("opcode");
WasmInitExpr expr;
......@@ -966,7 +966,7 @@ class ModuleDecoder : public Decoder {
if (!expect_u8("end opcode", kExprEnd)) {
expr.kind = WasmInitExpr::kNone;
}
if (expected != kAstStmt && TypeOf(module, expr) != kAstI32) {
if (expected != kWasmStmt && TypeOf(module, expr) != kWasmI32) {
error(pos, pos, "type error in init expression, expected %s, got %s",
WasmOpcodes::TypeName(expected),
WasmOpcodes::TypeName(TypeOf(module, expr)));
......@@ -975,28 +975,28 @@ class ModuleDecoder : public Decoder {
}
// Reads a single 8-bit integer, interpreting it as a local type.
LocalType consume_value_type() {
ValueType consume_value_type() {
byte val = consume_u8("value type");
LocalTypeCode t = static_cast<LocalTypeCode>(val);
ValueTypeCode t = static_cast<ValueTypeCode>(val);
switch (t) {
case kLocalI32:
return kAstI32;
return kWasmI32;
case kLocalI64:
return kAstI64;
return kWasmI64;
case kLocalF32:
return kAstF32;
return kWasmF32;
case kLocalF64:
return kAstF64;
return kWasmF64;
case kLocalS128:
if (origin_ != kAsmJsOrigin && FLAG_wasm_simd_prototype) {
return kAstS128;
return kWasmS128;
} else {
error(pc_ - 1, "invalid local type");
return kAstStmt;
return kWasmStmt;
}
default:
error(pc_ - 1, "invalid local type");
return kAstStmt;
return kWasmStmt;
}
}
......@@ -1007,9 +1007,9 @@ class ModuleDecoder : public Decoder {
uint32_t param_count =
consume_count("param count", kV8MaxWasmFunctionParams);
if (failed()) return nullptr;
std::vector<LocalType> params;
std::vector<ValueType> params;
for (uint32_t i = 0; ok() && i < param_count; ++i) {
LocalType param = consume_value_type();
ValueType param = consume_value_type();
params.push_back(param);
}
......@@ -1019,17 +1019,17 @@ class ModuleDecoder : public Decoder {
: kV8MaxWasmFunctionReturns;
uint32_t return_count = consume_count("return count", max_return_count);
if (failed()) return nullptr;
std::vector<LocalType> returns;
std::vector<ValueType> returns;
for (uint32_t i = 0; ok() && i < return_count; ++i) {
LocalType ret = consume_value_type();
ValueType ret = consume_value_type();
returns.push_back(ret);
}
if (failed()) return nullptr;
// FunctionSig stores the return types first.
LocalType* buffer =
module_zone->NewArray<LocalType>(param_count + return_count);
ValueType* buffer =
module_zone->NewArray<ValueType>(param_count + return_count);
uint32_t b = 0;
for (uint32_t i = 0; i < return_count; ++i) buffer[b++] = returns[i];
for (uint32_t i = 0; i < param_count; ++i) buffer[b++] = params[i];
......
......@@ -1122,16 +1122,16 @@ class ThreadImpl : public WasmInterpreter::Thread {
for (auto p : code->locals.local_types) {
WasmVal val;
switch (p.first) {
case kAstI32:
case kWasmI32:
val = WasmVal(static_cast<int32_t>(0));
break;
case kAstI64:
case kWasmI64:
val = WasmVal(static_cast<int64_t>(0));
break;
case kAstF32:
case kWasmF32:
val = WasmVal(static_cast<float>(0));
break;
case kAstF64:
case kWasmF64:
val = WasmVal(static_cast<double>(0));
break;
default:
......@@ -1448,15 +1448,15 @@ class ThreadImpl : public WasmInterpreter::Thread {
GlobalIndexOperand operand(&decoder, code->at(pc));
const WasmGlobal* global = &module()->globals[operand.index];
byte* ptr = instance()->globals_start + global->offset;
LocalType type = global->type;
ValueType type = global->type;
WasmVal val;
if (type == kAstI32) {
if (type == kWasmI32) {
val = WasmVal(*reinterpret_cast<int32_t*>(ptr));
} else if (type == kAstI64) {
} else if (type == kWasmI64) {
val = WasmVal(*reinterpret_cast<int64_t*>(ptr));
} else if (type == kAstF32) {
} else if (type == kWasmF32) {
val = WasmVal(*reinterpret_cast<float*>(ptr));
} else if (type == kAstF64) {
} else if (type == kWasmF64) {
val = WasmVal(*reinterpret_cast<double*>(ptr));
} else {
UNREACHABLE();
......@@ -1469,15 +1469,15 @@ class ThreadImpl : public WasmInterpreter::Thread {
GlobalIndexOperand operand(&decoder, code->at(pc));
const WasmGlobal* global = &module()->globals[operand.index];
byte* ptr = instance()->globals_start + global->offset;
LocalType type = global->type;
ValueType type = global->type;
WasmVal val = Pop();
if (type == kAstI32) {
if (type == kWasmI32) {
*reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>();
} else if (type == kAstI64) {
} else if (type == kWasmI64) {
*reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>();
} else if (type == kAstF32) {
} else if (type == kWasmF32) {
*reinterpret_cast<float*>(ptr) = val.to<float>();
} else if (type == kAstF64) {
} else if (type == kWasmF64) {
*reinterpret_cast<double*>(ptr) = val.to<double>();
} else {
UNREACHABLE();
......@@ -1702,7 +1702,7 @@ class ThreadImpl : public WasmInterpreter::Thread {
void Push(pc_t pc, WasmVal val) {
// TODO(titzer): store PC as well?
if (val.type != kAstStmt) stack_.push_back(val);
if (val.type != kWasmStmt) stack_.push_back(val);
}
void TraceStack(const char* phase, pc_t pc) {
......@@ -1728,19 +1728,19 @@ class ThreadImpl : public WasmInterpreter::Thread {
PrintF(" s%zu:", i);
WasmVal val = stack_[i];
switch (val.type) {
case kAstI32:
case kWasmI32:
PrintF("i32:%d", val.to<int32_t>());
break;
case kAstI64:
case kWasmI64:
PrintF("i64:%" PRId64 "", val.to<int64_t>());
break;
case kAstF32:
case kWasmF32:
PrintF("f32:%f", val.to<float>());
break;
case kAstF64:
case kWasmF64:
PrintF("f64:%lf", val.to<double>());
break;
case kAstStmt:
case kWasmStmt:
PrintF("void");
break;
default:
......@@ -1844,14 +1844,14 @@ WasmVal WasmInterpreter::GetLocalVal(const WasmFrame* frame, int index) {
CHECK_GE(index, 0);
UNIMPLEMENTED();
WasmVal none;
none.type = kAstStmt;
none.type = kWasmStmt;
return none;
}
WasmVal WasmInterpreter::GetExprVal(const WasmFrame* frame, int pc) {
UNIMPLEMENTED();
WasmVal none;
none.type = kAstStmt;
none.type = kWasmStmt;
return none;
}
......
......@@ -32,23 +32,23 @@ typedef ZoneMap<pc_t, pcdiff_t> ControlTransferMap;
// Macro for defining union members.
#define FOREACH_UNION_MEMBER(V) \
V(i32, kAstI32, int32_t) \
V(u32, kAstI32, uint32_t) \
V(i64, kAstI64, int64_t) \
V(u64, kAstI64, uint64_t) \
V(f32, kAstF32, float) \
V(f64, kAstF64, double)
V(i32, kWasmI32, int32_t) \
V(u32, kWasmI32, uint32_t) \
V(i64, kWasmI64, int64_t) \
V(u64, kWasmI64, uint64_t) \
V(f32, kWasmF32, float) \
V(f64, kWasmF64, double)
// Representation of values within the interpreter.
struct WasmVal {
LocalType type;
ValueType type;
union {
#define DECLARE_FIELD(field, localtype, ctype) ctype field;
FOREACH_UNION_MEMBER(DECLARE_FIELD)
#undef DECLARE_FIELD
} val;
WasmVal() : type(kAstStmt) {}
WasmVal() : type(kWasmStmt) {}
#define DECLARE_CONSTRUCTOR(field, localtype, ctype) \
explicit WasmVal(ctype v) : type(localtype) { val.field = v; }
......@@ -72,7 +72,7 @@ FOREACH_UNION_MEMBER(DECLARE_CAST)
template <>
inline void WasmVal::to() {
CHECK_EQ(kAstStmt, type);
CHECK_EQ(kWasmStmt, type);
}
// Representation of frames within the interpreter.
......
......@@ -71,13 +71,13 @@
#define WASM_BLOCK(...) kExprBlock, kLocalVoid, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_T(t, ...) \
kExprBlock, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t)), \
kExprBlock, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t)), \
__VA_ARGS__, kExprEnd
#define WASM_BLOCK_TT(t1, t2, ...) \
kExprBlock, kMultivalBlock, 0, \
static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t1)), \
static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t2)), __VA_ARGS__, \
static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t1)), \
static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t2)), __VA_ARGS__, \
kExprEnd
#define WASM_BLOCK_I(...) kExprBlock, kLocalI32, __VA_ARGS__, kExprEnd
......@@ -99,13 +99,13 @@
cond, kExprIf, kLocalVoid, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_T(t, cond, tstmt, fstmt) \
cond, kExprIf, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t)), tstmt, \
cond, kExprIf, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t)), tstmt, \
kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_TT(t1, t2, cond, tstmt, fstmt) \
cond, kExprIf, kMultivalBlock, 0, \
static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t1)), \
static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(t2)), tstmt, kExprElse, \
static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t1)), \
static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(t2)), tstmt, kExprElse, \
fstmt, kExprEnd
#define WASM_IF_ELSE_I(cond, tstmt, fstmt) \
......@@ -195,7 +195,7 @@ class LocalDeclEncoder {
pos = WriteUint32v(buffer, pos, static_cast<uint32_t>(local_decls.size()));
for (size_t i = 0; i < local_decls.size(); ++i) {
pos = WriteUint32v(buffer, pos, local_decls[i].first);
buffer[pos++] = WasmOpcodes::LocalTypeCodeFor(local_decls[i].second);
buffer[pos++] = WasmOpcodes::ValueTypeCodeFor(local_decls[i].second);
}
DCHECK_EQ(Size(), pos);
return pos;
......@@ -203,7 +203,7 @@ class LocalDeclEncoder {
// Add locals declarations to this helper. Return the index of the newly added
// local(s), with an optional adjustment for the parameters.
uint32_t AddLocals(uint32_t count, LocalType type) {
uint32_t AddLocals(uint32_t count, ValueType type) {
uint32_t result =
static_cast<uint32_t>(total + (sig ? sig->parameter_count() : 0));
total += count;
......@@ -211,7 +211,7 @@ class LocalDeclEncoder {
count += local_decls.back().first;
local_decls.pop_back();
}
local_decls.push_back(std::pair<uint32_t, LocalType>(count, type));
local_decls.push_back(std::pair<uint32_t, ValueType>(count, type));
return result;
}
......@@ -227,7 +227,7 @@ class LocalDeclEncoder {
private:
FunctionSig* sig;
ZoneVector<std::pair<uint32_t, LocalType>> local_decls;
ZoneVector<std::pair<uint32_t, ValueType>> local_decls;
size_t total;
size_t SizeofUint32v(uint32_t val) const {
......
......@@ -76,7 +76,7 @@ void WasmFunctionBuilder::SetSignature(FunctionSig* sig) {
signature_index_ = builder_->AddSignature(sig);
}
uint32_t WasmFunctionBuilder::AddLocal(LocalType type) {
uint32_t WasmFunctionBuilder::AddLocal(ValueType type) {
DCHECK(locals_.has_sig());
return locals_.AddLocals(1, type);
}
......@@ -289,7 +289,7 @@ void WasmModuleBuilder::MarkStartFunction(WasmFunctionBuilder* function) {
start_function_index_ = function->func_index();
}
uint32_t WasmModuleBuilder::AddGlobal(LocalType type, bool exported,
uint32_t WasmModuleBuilder::AddGlobal(ValueType type, bool exported,
bool mutability,
const WasmInitExpr& init) {
globals_.push_back({type, exported, mutability, init});
......@@ -313,11 +313,11 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
buffer.write_u8(kWasmFunctionTypeForm);
buffer.write_size(sig->parameter_count());
for (size_t j = 0; j < sig->parameter_count(); j++) {
buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(sig->GetParam(j)));
buffer.write_u8(WasmOpcodes::ValueTypeCodeFor(sig->GetParam(j)));
}
buffer.write_size(sig->return_count());
for (size_t j = 0; j < sig->return_count(); j++) {
buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(sig->GetReturn(j)));
buffer.write_u8(WasmOpcodes::ValueTypeCodeFor(sig->GetReturn(j)));
}
}
FixupSection(buffer, start);
......@@ -378,29 +378,29 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
buffer.write_size(globals_.size());
for (auto global : globals_) {
buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(global.type));
buffer.write_u8(WasmOpcodes::ValueTypeCodeFor(global.type));
buffer.write_u8(global.mutability ? 1 : 0);
switch (global.init.kind) {
case WasmInitExpr::kI32Const: {
DCHECK_EQ(kAstI32, global.type);
DCHECK_EQ(kWasmI32, global.type);
const byte code[] = {WASM_I32V_5(global.init.val.i32_const)};
buffer.write(code, sizeof(code));
break;
}
case WasmInitExpr::kI64Const: {
DCHECK_EQ(kAstI64, global.type);
DCHECK_EQ(kWasmI64, global.type);
const byte code[] = {WASM_I64V_10(global.init.val.i64_const)};
buffer.write(code, sizeof(code));
break;
}
case WasmInitExpr::kF32Const: {
DCHECK_EQ(kAstF32, global.type);
DCHECK_EQ(kWasmF32, global.type);
const byte code[] = {WASM_F32(global.init.val.f32_const)};
buffer.write(code, sizeof(code));
break;
}
case WasmInitExpr::kF64Const: {
DCHECK_EQ(kAstF64, global.type);
DCHECK_EQ(kWasmF64, global.type);
const byte code[] = {WASM_F64(global.init.val.f64_const)};
buffer.write(code, sizeof(code));
break;
......@@ -414,22 +414,22 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
default: {
// No initializer, emit a default value.
switch (global.type) {
case kAstI32: {
case kWasmI32: {
const byte code[] = {WASM_I32V_1(0)};
buffer.write(code, sizeof(code));
break;
}
case kAstI64: {
case kWasmI64: {
const byte code[] = {WASM_I64V_1(0)};
buffer.write(code, sizeof(code));
break;
}
case kAstF32: {
case kWasmF32: {
const byte code[] = {WASM_F32(0.0)};
buffer.write(code, sizeof(code));
break;
}
case kAstF64: {
case kWasmF64: {
const byte code[] = {WASM_F64(0.0)};
buffer.write(code, sizeof(code));
break;
......
......@@ -120,7 +120,7 @@ class V8_EXPORT_PRIVATE WasmFunctionBuilder : public ZoneObject {
public:
// Building methods.
void SetSignature(FunctionSig* sig);
uint32_t AddLocal(LocalType type);
uint32_t AddLocal(ValueType type);
void EmitVarInt(uint32_t val);
void EmitCode(const byte* code, uint32_t code_size);
void Emit(WasmOpcode opcode);
......@@ -175,18 +175,18 @@ class V8_EXPORT_PRIVATE WasmFunctionBuilder : public ZoneObject {
class WasmTemporary {
public:
WasmTemporary(WasmFunctionBuilder* builder, LocalType type) {
WasmTemporary(WasmFunctionBuilder* builder, ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
temporary_ = &builder->i32_temps_;
break;
case kAstI64:
case kWasmI64:
temporary_ = &builder->i64_temps_;
break;
case kAstF32:
case kWasmF32:
temporary_ = &builder->f32_temps_;
break;
case kAstF64:
case kWasmF64:
temporary_ = &builder->f64_temps_;
break;
default:
......@@ -223,7 +223,7 @@ class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
imports_[index].name_length = name_length;
}
WasmFunctionBuilder* AddFunction(FunctionSig* sig = nullptr);
uint32_t AddGlobal(LocalType type, bool exported, bool mutability = true,
uint32_t AddGlobal(ValueType type, bool exported, bool mutability = true,
const WasmInitExpr& init = WasmInitExpr());
void AddDataSegment(const byte* data, uint32_t size, uint32_t dest);
uint32_t AddSignature(FunctionSig* sig);
......@@ -254,7 +254,7 @@ class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
};
struct WasmGlobal {
LocalType type;
ValueType type;
bool exported;
bool mutability;
WasmInitExpr init;
......
......@@ -1526,17 +1526,17 @@ class WasmInstanceBuilder {
TRACE("init [globals+%u] = %lf, type = %s\n", global.offset, num,
WasmOpcodes::TypeName(global.type));
switch (global.type) {
case kAstI32:
case kWasmI32:
*GetRawGlobalPtr<int32_t>(global) = static_cast<int32_t>(num);
break;
case kAstI64:
case kWasmI64:
// TODO(titzer): initialization of imported i64 globals.
UNREACHABLE();
break;
case kAstF32:
case kWasmF32:
*GetRawGlobalPtr<float>(global) = static_cast<float>(num);
break;
case kAstF64:
case kWasmF64:
*GetRawGlobalPtr<double>(global) = static_cast<double>(num);
break;
default:
......@@ -1707,7 +1707,7 @@ class WasmInstanceBuilder {
module_->globals[global.init.val.global_index].offset;
TRACE("init [globals+%u] = [globals+%d]\n", global.offset,
old_offset);
size_t size = (global.type == kAstI64 || global.type == kAstF64)
size_t size = (global.type == kWasmI64 || global.type == kWasmF64)
? sizeof(double)
: sizeof(int32_t);
memcpy(raw_buffer_ptr(globals_, new_offset),
......@@ -1858,13 +1858,13 @@ class WasmInstanceBuilder {
WasmGlobal& global = module_->globals[exp.index];
double num = 0;
switch (global.type) {
case kAstI32:
case kWasmI32:
num = *GetRawGlobalPtr<int32_t>(global);
break;
case kAstF32:
case kWasmF32:
num = *GetRawGlobalPtr<float>(global);
break;
case kAstF64:
case kWasmF64:
num = *GetRawGlobalPtr<double>(global);
break;
default:
......
......@@ -116,7 +116,7 @@ struct WasmFunction {
// Static representation of a wasm global variable.
struct WasmGlobal {
LocalType type; // type of the global.
ValueType type; // type of the global.
bool mutability; // {true} if mutable.
WasmInitExpr init; // the initialization expression of the global.
uint32_t offset; // offset into global memory.
......@@ -320,7 +320,7 @@ struct V8_EXPORT_PRIVATE ModuleEnv {
bool IsValidTable(uint32_t index) const {
return module && index < module->function_tables.size();
}
LocalType GetGlobalType(uint32_t index) {
ValueType GetGlobalType(uint32_t index) {
DCHECK(IsValidGlobal(index));
return module->globals[index].type;
}
......
......@@ -11,7 +11,7 @@ namespace v8 {
namespace internal {
namespace wasm {
typedef Signature<LocalType> FunctionSig;
typedef Signature<ValueType> FunctionSig;
const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
switch (opcode) {
......@@ -70,7 +70,7 @@ enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) };
// TODO(titzer): not static-initializer safe. Wrap in LazyInstance.
#define DECLARE_SIG(name, ...) \
static LocalType kTypes_##name[] = {__VA_ARGS__}; \
static ValueType kTypes_##name[] = {__VA_ARGS__}; \
static const FunctionSig kSig_##name( \
1, static_cast<int>(arraysize(kTypes_##name)) - 1, kTypes_##name);
......
......@@ -15,7 +15,7 @@ namespace internal {
namespace wasm {
// Binary encoding of local types.
enum LocalTypeCode {
enum ValueTypeCode {
kLocalVoid = 0x40,
kLocalI32 = 0x7f,
kLocalI64 = 0x7e,
......@@ -29,17 +29,17 @@ static const uint8_t kMultivalBlock = 0x41;
// We reuse the internal machine type to represent WebAssembly types.
// A typedef improves readability without adding a whole new type system.
typedef MachineRepresentation LocalType;
const LocalType kAstStmt = MachineRepresentation::kNone;
const LocalType kAstI32 = MachineRepresentation::kWord32;
const LocalType kAstI64 = MachineRepresentation::kWord64;
const LocalType kAstF32 = MachineRepresentation::kFloat32;
const LocalType kAstF64 = MachineRepresentation::kFloat64;
const LocalType kAstS128 = MachineRepresentation::kSimd128;
// We use kTagged here because kNone is already used by kAstStmt.
const LocalType kAstEnd = MachineRepresentation::kTagged;
typedef Signature<LocalType> FunctionSig;
typedef MachineRepresentation ValueType;
const ValueType kWasmStmt = MachineRepresentation::kNone;
const ValueType kWasmI32 = MachineRepresentation::kWord32;
const ValueType kWasmI64 = MachineRepresentation::kWord64;
const ValueType kWasmF32 = MachineRepresentation::kFloat32;
const ValueType kWasmF64 = MachineRepresentation::kFloat64;
const ValueType kWasmS128 = MachineRepresentation::kSimd128;
// We use kTagged here because kNone is already used by kWasmStmt.
const ValueType kWasmEnd = MachineRepresentation::kTagged;
typedef Signature<ValueType> FunctionSig;
std::ostream& operator<<(std::ostream& os, const FunctionSig& function);
typedef Vector<const char> WasmName;
......@@ -454,41 +454,41 @@ const WasmCodePosition kNoCodePosition = -1;
// All signatures.
#define FOREACH_SIGNATURE(V) \
FOREACH_SIMD_SIGNATURE(V) \
V(i_ii, kAstI32, kAstI32, kAstI32) \
V(i_i, kAstI32, kAstI32) \
V(i_v, kAstI32) \
V(i_ff, kAstI32, kAstF32, kAstF32) \
V(i_f, kAstI32, kAstF32) \
V(i_dd, kAstI32, kAstF64, kAstF64) \
V(i_d, kAstI32, kAstF64) \
V(i_l, kAstI32, kAstI64) \
V(l_ll, kAstI64, kAstI64, kAstI64) \
V(i_ll, kAstI32, kAstI64, kAstI64) \
V(l_l, kAstI64, kAstI64) \
V(l_i, kAstI64, kAstI32) \
V(l_f, kAstI64, kAstF32) \
V(l_d, kAstI64, kAstF64) \
V(f_ff, kAstF32, kAstF32, kAstF32) \
V(f_f, kAstF32, kAstF32) \
V(f_d, kAstF32, kAstF64) \
V(f_i, kAstF32, kAstI32) \
V(f_l, kAstF32, kAstI64) \
V(d_dd, kAstF64, kAstF64, kAstF64) \
V(d_d, kAstF64, kAstF64) \
V(d_f, kAstF64, kAstF32) \
V(d_i, kAstF64, kAstI32) \
V(d_l, kAstF64, kAstI64) \
V(d_id, kAstF64, kAstI32, kAstF64) \
V(f_if, kAstF32, kAstI32, kAstF32) \
V(l_il, kAstI64, kAstI32, kAstI64)
V(i_ii, kWasmI32, kWasmI32, kWasmI32) \
V(i_i, kWasmI32, kWasmI32) \
V(i_v, kWasmI32) \
V(i_ff, kWasmI32, kWasmF32, kWasmF32) \
V(i_f, kWasmI32, kWasmF32) \
V(i_dd, kWasmI32, kWasmF64, kWasmF64) \
V(i_d, kWasmI32, kWasmF64) \
V(i_l, kWasmI32, kWasmI64) \
V(l_ll, kWasmI64, kWasmI64, kWasmI64) \
V(i_ll, kWasmI32, kWasmI64, kWasmI64) \
V(l_l, kWasmI64, kWasmI64) \
V(l_i, kWasmI64, kWasmI32) \
V(l_f, kWasmI64, kWasmF32) \
V(l_d, kWasmI64, kWasmF64) \
V(f_ff, kWasmF32, kWasmF32, kWasmF32) \
V(f_f, kWasmF32, kWasmF32) \
V(f_d, kWasmF32, kWasmF64) \
V(f_i, kWasmF32, kWasmI32) \
V(f_l, kWasmF32, kWasmI64) \
V(d_dd, kWasmF64, kWasmF64, kWasmF64) \
V(d_d, kWasmF64, kWasmF64) \
V(d_f, kWasmF64, kWasmF32) \
V(d_i, kWasmF64, kWasmI32) \
V(d_l, kWasmF64, kWasmI64) \
V(d_id, kWasmF64, kWasmI32, kWasmF64) \
V(f_if, kWasmF32, kWasmI32, kWasmF32) \
V(l_il, kWasmI64, kWasmI32, kWasmI64)
#define FOREACH_SIMD_SIGNATURE(V) \
V(s_s, kAstS128, kAstS128) \
V(s_f, kAstS128, kAstF32) \
V(s_ss, kAstS128, kAstS128, kAstS128) \
V(s_sss, kAstS128, kAstS128, kAstS128, kAstS128) \
V(s_i, kAstS128, kAstI32) \
V(s_si, kAstS128, kAstS128, kAstI32)
V(s_s, kWasmS128, kWasmS128) \
V(s_f, kWasmS128, kWasmF32) \
V(s_ss, kWasmS128, kWasmS128, kWasmS128) \
V(s_sss, kWasmS128, kWasmS128, kWasmS128, kWasmS128) \
V(s_i, kWasmS128, kWasmI32) \
V(s_si, kWasmS128, kWasmS128, kWasmI32)
#define FOREACH_PREFIX(V) \
V(Simd, 0xe5) \
......@@ -539,21 +539,21 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
return 1 << ElementSizeLog2Of(type.representation());
}
static byte MemSize(LocalType type) { return 1 << ElementSizeLog2Of(type); }
static byte MemSize(ValueType type) { return 1 << ElementSizeLog2Of(type); }
static LocalTypeCode LocalTypeCodeFor(LocalType type) {
static ValueTypeCode ValueTypeCodeFor(ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
return kLocalI32;
case kAstI64:
case kWasmI64:
return kLocalI64;
case kAstF32:
case kWasmF32:
return kLocalF32;
case kAstF64:
case kWasmF64:
return kLocalF64;
case kAstS128:
case kWasmS128:
return kLocalS128;
case kAstStmt:
case kWasmStmt:
return kLocalVoid;
default:
UNREACHABLE();
......@@ -561,19 +561,19 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
}
}
static MachineType MachineTypeFor(LocalType type) {
static MachineType MachineTypeFor(ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
return MachineType::Int32();
case kAstI64:
case kWasmI64:
return MachineType::Int64();
case kAstF32:
case kWasmF32:
return MachineType::Float32();
case kAstF64:
case kWasmF64:
return MachineType::Float64();
case kAstS128:
case kWasmS128:
return MachineType::Simd128();
case kAstStmt:
case kWasmStmt:
return MachineType::None();
default:
UNREACHABLE();
......@@ -581,32 +581,32 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
}
}
static LocalType LocalTypeFor(MachineType type) {
static ValueType ValueTypeFor(MachineType type) {
if (type == MachineType::Int8()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Uint8()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Int16()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Uint16()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Int32()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Uint32()) {
return kAstI32;
return kWasmI32;
} else if (type == MachineType::Int64()) {
return kAstI64;
return kWasmI64;
} else if (type == MachineType::Uint64()) {
return kAstI64;
return kWasmI64;
} else if (type == MachineType::Float32()) {
return kAstF32;
return kWasmF32;
} else if (type == MachineType::Float64()) {
return kAstF64;
return kWasmF64;
} else if (type == MachineType::Simd128()) {
return kAstS128;
return kWasmS128;
} else {
UNREACHABLE();
return kAstI32;
return kWasmI32;
}
}
......@@ -637,21 +637,21 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
}
}
static char ShortNameOf(LocalType type) {
static char ShortNameOf(ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
return 'i';
case kAstI64:
case kWasmI64:
return 'l';
case kAstF32:
case kWasmF32:
return 'f';
case kAstF64:
case kWasmF64:
return 'd';
case kAstS128:
case kWasmS128:
return 's';
case kAstStmt:
case kWasmStmt:
return 'v';
case kAstEnd:
case kWasmEnd:
return 'x';
default:
UNREACHABLE();
......@@ -659,21 +659,21 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
}
}
static const char* TypeName(LocalType type) {
static const char* TypeName(ValueType type) {
switch (type) {
case kAstI32:
case kWasmI32:
return "i32";
case kAstI64:
case kWasmI64:
return "i64";
case kAstF32:
case kWasmF32:
return "f32";
case kAstF64:
case kWasmF64:
return "f64";
case kAstS128:
case kWasmS128:
return "s128";
case kAstStmt:
case kWasmStmt:
return "<stmt>";
case kAstEnd:
case kWasmEnd:
return "<end>";
default:
return "<unknown>";
......
......@@ -869,10 +869,10 @@ WASM_EXEC_TEST_WITH_TRAP(I64UConvertF64a) {
}
WASM_EXEC_TEST(CallI64Parameter) {
LocalType param_types[20];
for (int i = 0; i < 20; i++) param_types[i] = kAstI64;
param_types[3] = kAstI32;
param_types[4] = kAstI32;
ValueType param_types[20];
for (int i = 0; i < 20; i++) param_types[i] = kWasmI64;
param_types[3] = kWasmI32;
param_types[4] = kWasmI32;
FunctionSig sig(1, 19, param_types);
for (int i = 0; i < 19; i++) {
if (i == 2 || i == 3) continue;
......@@ -1357,7 +1357,7 @@ WASM_EXEC_TEST(MemI64_Sum) {
const int kNumElems = 20;
WasmRunner<uint64_t, int32_t> r(execution_mode);
uint64_t* memory = r.module().AddMemoryElems<uint64_t>(kNumElems);
const byte kSum = r.AllocateLocal(kAstI64);
const byte kSum = r.AllocateLocal(kWasmI64);
BUILD(
r,
......@@ -1492,13 +1492,13 @@ WASM_EXEC_TEST_WITH_TRAP(StoreMem_offset_oob_i64) {
for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
} while (false)
static void CompileCallIndirectMany(LocalType param) {
static void CompileCallIndirectMany(ValueType param) {
// Make sure we don't run out of registers when compiling indirect calls
// with many many parameters.
TestSignatures sigs;
for (byte num_params = 0; num_params < 40; num_params++) {
WasmRunner<void> r(kExecuteCompiled);
FunctionSig* sig = sigs.many(r.zone(), kAstStmt, param, num_params);
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
r.module().AddSignature(sig);
r.module().AddSignature(sig);
......@@ -1517,7 +1517,7 @@ static void CompileCallIndirectMany(LocalType param) {
}
}
TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kWasmI64); }
static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
const int kExpected = 6333;
......@@ -1544,9 +1544,9 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
// Build the selector function.
// =========================================================================
FunctionSig::Builder b(&zone, 1, num_params);
b.AddReturn(WasmOpcodes::LocalTypeFor(result));
b.AddReturn(WasmOpcodes::ValueTypeFor(result));
for (int i = 0; i < num_params; i++) {
b.AddParam(WasmOpcodes::LocalTypeFor(memtypes[i]));
b.AddParam(WasmOpcodes::ValueTypeFor(memtypes[i]));
}
WasmFunctionCompiler& t = r.NewFunction(b.Build());
BUILD(t, WASM_GET_LOCAL(which));
......
......@@ -150,8 +150,8 @@ TEST(Run_CallJS_Add_jswrapped) {
void RunJSSelectTest(int which) {
const int kMaxParams = 8;
PredictableInputValues inputs(0x100);
LocalType type = kAstF64;
LocalType types[kMaxParams + 1] = {type, type, type, type, type,
ValueType type = kWasmF64;
ValueType types[kMaxParams + 1] = {type, type, type, type, type,
type, type, type, type};
for (int num_params = which + 1; num_params < kMaxParams; num_params++) {
HandleScope scope(CcTest::InitIsolateOnce());
......@@ -226,8 +226,8 @@ void RunWASMSelectTest(int which) {
Isolate* isolate = CcTest::InitIsolateOnce();
const int kMaxParams = 8;
for (int num_params = which + 1; num_params < kMaxParams; num_params++) {
LocalType type = kAstF64;
LocalType types[kMaxParams + 1] = {type, type, type, type, type,
ValueType type = kWasmF64;
ValueType types[kMaxParams + 1] = {type, type, type, type, type,
type, type, type, type};
FunctionSig sig(1, num_params, types);
......@@ -297,8 +297,8 @@ void RunWASMSelectAlignTest(int num_args, int num_params) {
Isolate* isolate = CcTest::InitIsolateOnce();
const int kMaxParams = 10;
DCHECK_LE(num_args, kMaxParams);
LocalType type = kAstF64;
LocalType types[kMaxParams + 1] = {type, type, type, type, type, type,
ValueType type = kWasmF64;
ValueType types[kMaxParams + 1] = {type, type, type, type, type, type,
type, type, type, type, type};
FunctionSig sig(1, num_params, types);
......@@ -393,8 +393,8 @@ void RunJSSelectAlignTest(int num_args, int num_params) {
const int kMaxParams = 10;
CHECK_LE(num_args, kMaxParams);
CHECK_LE(num_params, kMaxParams);
LocalType type = kAstF64;
LocalType types[kMaxParams + 1] = {type, type, type, type, type, type,
ValueType type = kWasmF64;
ValueType types[kMaxParams + 1] = {type, type, type, type, type, type,
type, type, type, type, type};
FunctionSig sig(1, num_params, types);
i::AccountingAllocator allocator;
......
......@@ -139,7 +139,7 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
uint16_t localIndex = f->AddLocal(kAstI32);
uint16_t localIndex = f->AddLocal(kWasmI32);
ExportAsMain(f);
byte code[] = {WASM_BLOCK_I(
WASM_WHILE(
......@@ -163,7 +163,7 @@ TEST(Run_WasmModule_CallMain_recursive) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
uint16_t localIndex = f->AddLocal(kAstI32);
uint16_t localIndex = f->AddLocal(kWasmI32);
ExportAsMain(f);
byte code[] = {
WASM_SET_LOCAL(localIndex,
......@@ -186,8 +186,8 @@ TEST(Run_WasmModule_Global) {
TestSignatures sigs;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
uint32_t global1 = builder->AddGlobal(kAstI32, 0);
uint32_t global2 = builder->AddGlobal(kAstI32, 0);
uint32_t global1 = builder->AddGlobal(kWasmI32, 0);
uint32_t global2 = builder->AddGlobal(kWasmI32, 0);
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code1[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
......@@ -716,9 +716,9 @@ TEST(Run_WasmModule_Global_init) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
uint32_t global1 =
builder->AddGlobal(kAstI32, false, false, WasmInitExpr(777777));
builder->AddGlobal(kWasmI32, false, false, WasmInitExpr(777777));
uint32_t global2 =
builder->AddGlobal(kAstI32, false, false, WasmInitExpr(222222));
builder->AddGlobal(kWasmI32, false, false, WasmInitExpr(222222));
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
......@@ -730,13 +730,13 @@ TEST(Run_WasmModule_Global_init) {
}
template <typename CType>
static void RunWasmModuleGlobalInitTest(LocalType type, CType expected) {
static void RunWasmModuleGlobalInitTest(ValueType type, CType expected) {
{
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
TestSignatures sigs;
LocalType types[] = {type};
ValueType types[] = {type};
FunctionSig sig(1, 0, types);
for (int padding = 0; padding < 5; padding++) {
......@@ -744,12 +744,12 @@ static void RunWasmModuleGlobalInitTest(LocalType type, CType expected) {
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
for (int i = 0; i < padding; i++) { // pad global before
builder->AddGlobal(kAstI32, false, false, WasmInitExpr(i + 20000));
builder->AddGlobal(kWasmI32, false, false, WasmInitExpr(i + 20000));
}
uint32_t global =
builder->AddGlobal(type, false, false, WasmInitExpr(expected));
for (int i = 0; i < padding; i++) { // pad global after
builder->AddGlobal(kAstI32, false, false, WasmInitExpr(i + 30000));
builder->AddGlobal(kWasmI32, false, false, WasmInitExpr(i + 30000));
}
WasmFunctionBuilder* f1 = builder->AddFunction(&sig);
......@@ -763,18 +763,18 @@ static void RunWasmModuleGlobalInitTest(LocalType type, CType expected) {
}
TEST(Run_WasmModule_Global_i32) {
RunWasmModuleGlobalInitTest<int32_t>(kAstI32, -983489);
RunWasmModuleGlobalInitTest<int32_t>(kAstI32, 11223344);
RunWasmModuleGlobalInitTest<int32_t>(kWasmI32, -983489);
RunWasmModuleGlobalInitTest<int32_t>(kWasmI32, 11223344);
}
TEST(Run_WasmModule_Global_f32) {
RunWasmModuleGlobalInitTest<float>(kAstF32, -983.9f);
RunWasmModuleGlobalInitTest<float>(kAstF32, 1122.99f);
RunWasmModuleGlobalInitTest<float>(kWasmF32, -983.9f);
RunWasmModuleGlobalInitTest<float>(kWasmF32, 1122.99f);
}
TEST(Run_WasmModule_Global_f64) {
RunWasmModuleGlobalInitTest<double>(kAstF64, -833.9);
RunWasmModuleGlobalInitTest<double>(kAstF64, 86374.25);
RunWasmModuleGlobalInitTest<double>(kWasmF64, -833.9);
RunWasmModuleGlobalInitTest<double>(kWasmF64, 86374.25);
}
TEST(InitDataAtTheUpperLimit) {
......
......@@ -98,7 +98,7 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Add_With_F32x4) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
WASM_RETURN1(
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0)))));
......@@ -108,7 +108,7 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Local) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmS128);
BUILD(r,
WASM_BLOCK(
WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
......@@ -121,8 +121,8 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Replace_Lane) {
WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstF32);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmF32);
r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(23.5))),
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(
......@@ -138,8 +138,8 @@ WASM_EXEC_COMPILED_TEST(Simd_F32x4_Replace_Lane) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
BUILD(r,
WASM_BLOCK(
WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE(
......@@ -152,12 +152,12 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Splat_From_Extract) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kAstS128);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
*(global) = 0;
*(global + 1) = 1;
*(global + 2) = 2;
*(global + 3) = 3;
r.AllocateLocal(kAstI32);
r.AllocateLocal(kWasmI32);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(1, WASM_I32V(1)),
WASM_IF(WASM_I32_NE(WASM_I32V(0), WASM_SIMD_I32x4_EXTRACT_LANE(
......@@ -179,7 +179,7 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Get_Global) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
int32_t* global = r.module().AddGlobal<int32_t>(kAstS128);
int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(
......@@ -199,12 +199,12 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_Set_Global) {
WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kAstS128);
float* global = r.module().AddGlobal<float>(kWasmS128);
*(global) = 0.0;
*(global + 1) = 1.5;
*(global + 2) = 2.25;
*(global + 3) = 3.5;
r.AllocateLocal(kAstI32);
r.AllocateLocal(kWasmI32);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(1, WASM_I32V(1)),
WASM_IF(WASM_F32_NE(WASM_F32(0.0), WASM_SIMD_F32x4_EXTRACT_LANE(
......@@ -226,7 +226,7 @@ WASM_EXEC_COMPILED_TEST(Simd_F32x4_Get_Global) {
WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
float* global = r.module().AddGlobal<float>(kAstS128);
float* global = r.module().AddGlobal<float>(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(
......@@ -246,8 +246,8 @@ WASM_EXEC_COMPILED_TEST(Simd_F32x4_Set_Global) {
WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
BUILD(
r,
WASM_BLOCK(
......@@ -286,8 +286,8 @@ WASM_EXEC_COMPILED_TEST(Simd_I32x4_For) {
WASM_EXEC_COMPILED_TEST(Simd_F32x4_For) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t> r(kExecuteCompiled);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstS128);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))),
WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(
......
......@@ -96,7 +96,7 @@ WASM_EXEC_TEST(F32x4Splat) {
WasmRunner<int32_t, float> r(kExecuteCompiled);
byte lane_val = 0;
byte simd = r.AllocateLocal(kAstS128);
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(
WASM_GET_LOCAL(lane_val))),
WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, lane_val),
......@@ -110,7 +110,7 @@ WASM_EXEC_TEST(F32x4ReplaceLane) {
WasmRunner<int32_t, float, float> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
byte simd = r.AllocateLocal(kAstS128);
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd,
WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(old_val))),
......@@ -145,9 +145,9 @@ WASM_EXEC_TEST(F32x4FromInt32x4) {
byte a = 0;
byte expected_signed = 1;
byte expected_unsigned = 2;
byte simd0 = r.AllocateLocal(kAstS128);
byte simd1 = r.AllocateLocal(kAstS128);
byte simd2 = r.AllocateLocal(kAstS128);
byte simd0 = r.AllocateLocal(kWasmS128);
byte simd1 = r.AllocateLocal(kWasmS128);
byte simd2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(
......@@ -169,9 +169,9 @@ WASM_EXEC_TEST(S32x4Select) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte val1 = 0;
byte val2 = 1;
byte mask = r.AllocateLocal(kAstS128);
byte src1 = r.AllocateLocal(kAstS128);
byte src2 = r.AllocateLocal(kAstS128);
byte mask = r.AllocateLocal(kWasmS128);
byte src1 = r.AllocateLocal(kWasmS128);
byte src2 = r.AllocateLocal(kWasmS128);
BUILD(r,
WASM_BLOCK(
WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_SPLAT(WASM_ZERO)),
......@@ -198,7 +198,7 @@ void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) {
WasmRunner<int32_t, float, float> r(kExecuteCompiled);
byte a = 0;
byte expected = 1;
byte simd = r.AllocateLocal(kAstS128);
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(
......@@ -221,8 +221,8 @@ void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) {
byte a = 0;
byte b = 1;
byte expected = 2;
byte simd0 = r.AllocateLocal(kAstS128);
byte simd1 = r.AllocateLocal(kAstS128);
byte simd0 = r.AllocateLocal(kWasmS128);
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
......@@ -250,8 +250,8 @@ void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
byte a = 0;
byte b = 1;
byte expected = 2;
byte simd0 = r.AllocateLocal(kAstS128);
byte simd1 = r.AllocateLocal(kAstS128);
byte simd0 = r.AllocateLocal(kWasmS128);
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
......@@ -289,7 +289,7 @@ WASM_EXEC_TEST(I32x4Splat) {
// return 1
WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
byte lane_val = 0;
byte simd = r.AllocateLocal(kAstS128);
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(
WASM_GET_LOCAL(lane_val))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val),
......@@ -303,7 +303,7 @@ WASM_EXEC_TEST(I32x4ReplaceLane) {
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
byte old_val = 0;
byte new_val = 1;
byte simd = r.AllocateLocal(kAstS128);
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd,
WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(old_val))),
......@@ -380,9 +380,9 @@ WASM_EXEC_TEST(I32x4FromFloat32x4) {
byte a = 0;
byte expected_signed = 1;
byte expected_unsigned = 2;
byte simd0 = r.AllocateLocal(kAstS128);
byte simd1 = r.AllocateLocal(kAstS128);
byte simd2 = r.AllocateLocal(kAstS128);
byte simd0 = r.AllocateLocal(kWasmS128);
byte simd1 = r.AllocateLocal(kWasmS128);
byte simd2 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(
......@@ -407,8 +407,8 @@ void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
byte a = 0;
byte b = 1;
byte expected = 2;
byte simd0 = r.AllocateLocal(kAstS128);
byte simd1 = r.AllocateLocal(kAstS128);
byte simd0 = r.AllocateLocal(kWasmS128);
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_BLOCK(
WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
......
......@@ -152,7 +152,7 @@ WASM_EXEC_TEST(Int32Add_P2) {
WASM_EXEC_TEST(Int32Add_block1) {
FLAG_wasm_mv_prototype = true;
static const byte code[] = {
WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
kExprI32Add};
RunInt32AddTest(execution_mode, code, sizeof(code));
}
......@@ -160,7 +160,7 @@ WASM_EXEC_TEST(Int32Add_block1) {
WASM_EXEC_TEST(Int32Add_block2) {
FLAG_wasm_mv_prototype = true;
static const byte code[] = {
WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
kExprBr, DEPTH_0),
kExprI32Add};
RunInt32AddTest(execution_mode, code, sizeof(code));
......@@ -169,7 +169,7 @@ WASM_EXEC_TEST(Int32Add_block2) {
WASM_EXEC_TEST(Int32Add_multi_if) {
FLAG_wasm_mv_prototype = true;
static const byte code[] = {
WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
WASM_IF_ELSE_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
WASM_SEQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
WASM_SEQ(WASM_GET_LOCAL(1), WASM_GET_LOCAL(0))),
kExprI32Add};
......@@ -835,8 +835,8 @@ WASM_EXEC_TEST(Select_strict1) {
WASM_EXEC_TEST(Select_strict2) {
WasmRunner<int32_t, int32_t> r(execution_mode);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmI32);
// select(b=5, c=6, a)
BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I8(5)),
WASM_TEE_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0)));
......@@ -848,8 +848,8 @@ WASM_EXEC_TEST(Select_strict2) {
WASM_EXEC_TEST(Select_strict3) {
WasmRunner<int32_t, int32_t> r(execution_mode);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kAstI32);
r.AllocateLocal(kWasmI32);
r.AllocateLocal(kWasmI32);
// select(b=5, c=6, a=b)
BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I8(5)),
WASM_TEE_LOCAL(2, WASM_I8(6)),
......@@ -1666,7 +1666,7 @@ WASM_EXEC_TEST(MemI32_Sum) {
const int kNumElems = 20;
WasmRunner<uint32_t, int32_t> r(execution_mode);
uint32_t* memory = r.module().AddMemoryElems<uint32_t>(kNumElems);
const byte kSum = r.AllocateLocal(kAstI32);
const byte kSum = r.AllocateLocal(kWasmI32);
BUILD(
r,
......@@ -1730,7 +1730,7 @@ WASM_EXEC_TEST(MemF32_Sum) {
r.module().WriteMemory(&buffer[2], -77.25f);
r.module().WriteMemory(&buffer[3], 66666.25f);
r.module().WriteMemory(&buffer[4], 5555.25f);
const byte kSum = r.AllocateLocal(kAstF32);
const byte kSum = r.AllocateLocal(kWasmF32);
BUILD(
r,
......@@ -1752,7 +1752,7 @@ WASM_EXEC_TEST(MemF32_Sum) {
template <typename T>
T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop,
T* buffer, uint32_t size, LocalType astType,
T* buffer, uint32_t size, ValueType astType,
MachineType memType) {
WasmRunner<int32_t, int32_t> r(execution_mode);
T* memory = r.module().AddMemoryElems<T>(size);
......@@ -1781,7 +1781,7 @@ WASM_EXEC_TEST(MemF64_Mul) {
double buffer[kSize] = {1, 2, 2, 2, 2, 2};
double result =
GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize,
kAstF64, MachineType::Float64());
kWasmF64, MachineType::Float64());
CHECK_EQ(32, result);
}
......@@ -2094,8 +2094,8 @@ WASM_EXEC_TEST(CallF32StackParameter) {
WasmRunner<float> r(execution_mode);
// Build the target function.
LocalType param_types[20];
for (int i = 0; i < 20; ++i) param_types[i] = kAstF32;
ValueType param_types[20];
for (int i = 0; i < 20; ++i) param_types[i] = kWasmF32;
FunctionSig sig(1, 19, param_types);
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_GET_LOCAL(17));
......@@ -2117,8 +2117,8 @@ WASM_EXEC_TEST(CallF64StackParameter) {
WasmRunner<double> r(execution_mode);
// Build the target function.
LocalType param_types[20];
for (int i = 0; i < 20; ++i) param_types[i] = kAstF64;
ValueType param_types[20];
for (int i = 0; i < 20; ++i) param_types[i] = kWasmF64;
FunctionSig sig(1, 19, param_types);
WasmFunctionCompiler& t = r.NewFunction(&sig);
BUILD(t, WASM_GET_LOCAL(17));
......@@ -2254,9 +2254,9 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
// Build the selector function.
// =========================================================================
FunctionSig::Builder b(&zone, 1, num_params);
b.AddReturn(WasmOpcodes::LocalTypeFor(result));
b.AddReturn(WasmOpcodes::ValueTypeFor(result));
for (int i = 0; i < num_params; ++i) {
b.AddParam(WasmOpcodes::LocalTypeFor(memtypes[i]));
b.AddParam(WasmOpcodes::ValueTypeFor(memtypes[i]));
}
WasmFunctionCompiler& t = r.NewFunction(b.Build());
BUILD(t, WASM_GET_LOCAL(which));
......@@ -2314,7 +2314,7 @@ WASM_EXEC_TEST(AddCall) {
WasmFunctionCompiler& t1 = r.NewFunction<int32_t, int32_t, int32_t>();
BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
byte local = r.AllocateLocal(kAstI32);
byte local = r.AllocateLocal(kWasmI32);
BUILD(r, WASM_SET_LOCAL(local, WASM_I8(99)),
WASM_I32_ADD(WASM_CALL_FUNCTION(t1.function_index(), WASM_GET_LOCAL(0),
WASM_GET_LOCAL(0)),
......@@ -2330,7 +2330,7 @@ WASM_EXEC_TEST(MultiReturnSub) {
FLAG_wasm_mv_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
LocalType storage[] = {kAstI32, kAstI32, kAstI32, kAstI32};
ValueType storage[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32};
FunctionSig sig_ii_ii(2, 2, storage);
WasmFunctionCompiler& t1 = r.NewFunction(&sig_ii_ii);
BUILD(t1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(0));
......@@ -2350,8 +2350,8 @@ WASM_EXEC_TEST(MultiReturnSub) {
template <typename T>
void RunMultiReturnSelect(WasmExecutionMode execution_mode, const T* inputs) {
FLAG_wasm_mv_prototype = true;
LocalType type = WasmOpcodes::LocalTypeFor(MachineTypeForC<T>());
LocalType storage[] = {type, type, type, type, type, type};
ValueType type = WasmOpcodes::ValueTypeFor(MachineTypeForC<T>());
ValueType storage[] = {type, type, type, type, type, type};
const size_t kNumReturns = 2;
const size_t kNumParams = arraysize(storage) - kNumReturns;
FunctionSig sig(kNumReturns, kNumParams, storage);
......@@ -2851,13 +2851,13 @@ WASM_EXEC_TEST(F32CopySign) {
}
}
static void CompileCallIndirectMany(LocalType param) {
static void CompileCallIndirectMany(ValueType param) {
// Make sure we don't run out of registers when compiling indirect calls
// with many many parameters.
TestSignatures sigs;
for (byte num_params = 0; num_params < 40; ++num_params) {
WasmRunner<void> r(kExecuteCompiled);
FunctionSig* sig = sigs.many(r.zone(), kAstStmt, param, num_params);
FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params);
r.module().AddSignature(sig);
r.module().AddSignature(sig);
......@@ -2876,11 +2876,11 @@ static void CompileCallIndirectMany(LocalType param) {
}
}
TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); }
TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kWasmI32); }
TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kWasmF32); }
TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kWasmF64); }
WASM_EXEC_TEST_WITH_TRAP(Int32RemS_dead) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_mode);
......
......@@ -121,7 +121,7 @@ class TestingModule : public ModuleEnv {
template <typename T>
T* AddGlobal(
LocalType type = WasmOpcodes::LocalTypeFor(MachineTypeForC<T>())) {
ValueType type = WasmOpcodes::ValueTypeFor(MachineTypeForC<T>())) {
const WasmGlobal* global = AddGlobal(type);
return reinterpret_cast<T*>(instance->globals_start + global->offset);
}
......@@ -297,7 +297,7 @@ class TestingModule : public ModuleEnv {
WasmInterpreter* interpreter_;
Handle<WasmInstanceObject> instance_object_;
const WasmGlobal* AddGlobal(LocalType type) {
const WasmGlobal* AddGlobal(ValueType type) {
byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type));
global_offset = (global_offset + size - 1) & ~(size - 1); // align
module_.globals.push_back(
......@@ -524,7 +524,7 @@ class WasmFunctionCompiler : private GraphAndBuilders {
testing_module_->SetFunctionCode(function_index(), code);
}
byte AllocateLocal(LocalType type) {
byte AllocateLocal(ValueType type) {
uint32_t index = local_decls.AddLocals(1, type);
byte result = static_cast<byte>(index);
DCHECK_EQ(index, result);
......@@ -636,7 +636,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
return *functions_.back();
}
byte AllocateLocal(LocalType type) {
byte AllocateLocal(ValueType type) {
return functions_[0]->AllocateLocal(type);
}
......@@ -663,16 +663,16 @@ class WasmRunnerBase : public HandleAndZoneScope {
int param_count = param_types.length();
// Allocate storage array in zone.
LocalType* sig_types =
zone_.NewArray<LocalType>(return_count + param_count);
ValueType* sig_types =
zone_.NewArray<ValueType>(return_count + param_count);
// Convert machine types to local types, and check that there are no
// MachineType::None()'s in the parameters.
int idx = 0;
if (return_count) sig_types[idx++] = WasmOpcodes::LocalTypeFor(return_type);
if (return_count) sig_types[idx++] = WasmOpcodes::ValueTypeFor(return_type);
for (MachineType param : param_types) {
CHECK_NE(MachineType::None(), param);
sig_types[idx++] = WasmOpcodes::LocalTypeFor(param);
sig_types[idx++] = WasmOpcodes::ValueTypeFor(param);
}
return new (&zone_) FunctionSig(return_count, param_count, sig_types);
}
......
......@@ -12,7 +12,7 @@ namespace v8 {
namespace internal {
namespace wasm {
typedef Signature<LocalType> FunctionSig;
typedef Signature<ValueType> FunctionSig;
// A helper class with many useful signatures in order to simplify tests.
class TestSignatures {
......@@ -40,18 +40,18 @@ class TestSignatures {
sig_v_iii(0, 3, kIntTypes4),
sig_s_i(1, 1, kSimd128IntTypes4) {
// I used C++ and you won't believe what happened next....
for (int i = 0; i < 4; i++) kIntTypes4[i] = kAstI32;
for (int i = 0; i < 4; i++) kLongTypes4[i] = kAstI64;
for (int i = 0; i < 4; i++) kFloatTypes4[i] = kAstF32;
for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kAstF64;
for (int i = 0; i < 4; i++) kIntLongTypes4[i] = kAstI64;
for (int i = 0; i < 4; i++) kIntFloatTypes4[i] = kAstF32;
for (int i = 0; i < 4; i++) kIntDoubleTypes4[i] = kAstF64;
for (int i = 0; i < 4; i++) kSimd128IntTypes4[i] = kAstS128;
kIntLongTypes4[0] = kAstI32;
kIntFloatTypes4[0] = kAstI32;
kIntDoubleTypes4[0] = kAstI32;
kSimd128IntTypes4[1] = kAstI32;
for (int i = 0; i < 4; i++) kIntTypes4[i] = kWasmI32;
for (int i = 0; i < 4; i++) kLongTypes4[i] = kWasmI64;
for (int i = 0; i < 4; i++) kFloatTypes4[i] = kWasmF32;
for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kWasmF64;
for (int i = 0; i < 4; i++) kIntLongTypes4[i] = kWasmI64;
for (int i = 0; i < 4; i++) kIntFloatTypes4[i] = kWasmF32;
for (int i = 0; i < 4; i++) kIntDoubleTypes4[i] = kWasmF64;
for (int i = 0; i < 4; i++) kSimd128IntTypes4[i] = kWasmS128;
kIntLongTypes4[0] = kWasmI32;
kIntFloatTypes4[0] = kWasmI32;
kIntDoubleTypes4[0] = kWasmI32;
kSimd128IntTypes4[1] = kWasmI32;
}
FunctionSig* i_v() { return &sig_i_v; }
......@@ -80,9 +80,9 @@ class TestSignatures {
FunctionSig* v_iii() { return &sig_v_iii; }
FunctionSig* s_i() { return &sig_s_i; }
FunctionSig* many(Zone* zone, LocalType ret, LocalType param, int count) {
FunctionSig::Builder builder(zone, ret == kAstStmt ? 0 : 1, count);
if (ret != kAstStmt) builder.AddReturn(ret);
FunctionSig* many(Zone* zone, ValueType ret, ValueType param, int count) {
FunctionSig::Builder builder(zone, ret == kWasmStmt ? 0 : 1, count);
if (ret != kWasmStmt) builder.AddReturn(ret);
for (int i = 0; i < count; i++) {
builder.AddParam(param);
}
......@@ -90,14 +90,14 @@ class TestSignatures {
}
private:
LocalType kIntTypes4[4];
LocalType kLongTypes4[4];
LocalType kFloatTypes4[4];
LocalType kDoubleTypes4[4];
LocalType kIntLongTypes4[4];
LocalType kIntFloatTypes4[4];
LocalType kIntDoubleTypes4[4];
LocalType kSimd128IntTypes4[4];
ValueType kIntTypes4[4];
ValueType kLongTypes4[4];
ValueType kFloatTypes4[4];
ValueType kDoubleTypes4[4];
ValueType kIntLongTypes4[4];
ValueType kIntFloatTypes4[4];
ValueType kIntDoubleTypes4[4];
ValueType kSimd128IntTypes4[4];
FunctionSig sig_i_v;
FunctionSig sig_i_i;
......
......@@ -35,25 +35,25 @@ static inline V read_value(const uint8_t** data, size_t* size, bool* ok) {
}
static void add_argument(
v8::internal::Isolate* isolate, LocalType type, WasmVal* interpreter_args,
v8::internal::Isolate* isolate, ValueType type, WasmVal* interpreter_args,
v8::internal::Handle<v8::internal::Object>* compiled_args, int* argc,
const uint8_t** data, size_t* size, bool* ok) {
if (!(*ok)) return;
switch (type) {
case kAstF32: {
case kWasmF32: {
float value = read_value<float>(data, size, ok);
interpreter_args[*argc] = WasmVal(value);
compiled_args[*argc] =
isolate->factory()->NewNumber(static_cast<double>(value));
break;
}
case kAstF64: {
case kWasmF64: {
double value = read_value<double>(data, size, ok);
interpreter_args[*argc] = WasmVal(value);
compiled_args[*argc] = isolate->factory()->NewNumber(value);
break;
}
case kAstI32: {
case kWasmI32: {
int32_t value = read_value<int32_t>(data, size, ok);
interpreter_args[*argc] = WasmVal(value);
compiled_args[*argc] =
......@@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
uint8_t num_functions =
(read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_FUNCTIONS) + 1;
LocalType types[] = {kAstF32, kAstF64, kAstI32, kAstI64};
ValueType types[] = {kWasmF32, kWasmF64, kWasmI32, kWasmI64};
WasmVal interpreter_args[3];
v8::internal::Handle<v8::internal::Object> compiled_args[3];
int argc = 0;
......@@ -99,10 +99,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
size_t num_params = static_cast<size_t>(
(read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_PARAMS) + 1);
FunctionSig::Builder sig_builder(&zone, 1, num_params);
sig_builder.AddReturn(kAstI32);
sig_builder.AddReturn(kWasmI32);
for (size_t param = 0; param < num_params; param++) {
// The main function cannot handle int64 parameters.
LocalType param_type = types[(read_value<uint8_t>(&data, &size, &ok) %
ValueType param_type = types[(read_value<uint8_t>(&data, &size, &ok) %
(arraysize(types) - (fun == 0 ? 1 : 0)))];
sig_builder.AddParam(param_type);
if (fun == 0) {
......
......@@ -12,7 +12,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]);
builder.addFunction('main', kSig_v_v)
.addBody([kExprBlock, kAstStmt, kExprI32Const, 2, kExprDrop, kExprEnd])
.addBody([kExprBlock, kWasmStmt, kExprI32Const, 2, kExprDrop, kExprEnd])
.exportAs('main');
var module_bytes = builder.toArray();
......
......@@ -19,7 +19,7 @@ var sig_index = builder.addType(kSig_v_v);
builder.addFunction('main', kSig_v_v)
.addBody([
kExprBlock, kAstStmt, kExprI32Const, 0, kExprCallIndirect, sig_index,
kExprBlock, kWasmStmt, kExprI32Const, 0, kExprCallIndirect, sig_index,
kTableZero, kExprEnd
])
.exportAs('main');
......
......@@ -18,7 +18,7 @@ var call_imported_idx = builder.addFunction('call_func', kSig_v_v)
// Open a block in order to make the positions more interesting...
builder.addFunction('main', kSig_v_v)
.addBody(
[kExprBlock, kAstStmt, kExprCallFunction, call_imported_idx, kExprEnd])
[kExprBlock, kWasmStmt, kExprCallFunction, call_imported_idx, kExprEnd])
.exportAs('main');
var module_bytes = builder.toArray();
......
......@@ -18,9 +18,9 @@ function makeSelect(type, args, which) {
return function() {
var val = +arguments[which];
print(" " + val);
if (type == kAstI32) return val | 0;
if (type == kAstF32) return Math.fround(val);
if (type == kAstF64) return val;
if (type == kWasmI32) return val | 0;
if (type == kWasmF32) return Math.fround(val);
if (type == kWasmF64) return val;
return undefined;
}
}
......@@ -42,7 +42,7 @@ const inputs = [
(function TestInt1() {
print("i32 1(0)...");
var C = function(v) { return v | 0; }
var select1 = makeSelect(kAstI32, 1, 0);
var select1 = makeSelect(kWasmI32, 1, 0);
for (val of inputs) {
assertEquals(C(val), select1(val));
......@@ -58,7 +58,7 @@ const inputs = [
(function TestInt2() {
print("i32 2(0)...");
var C = function(v) { return v | 0; }
var select = makeSelect(kAstI32, 2, 0);
var select = makeSelect(kWasmI32, 2, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1));
......@@ -72,7 +72,7 @@ const inputs = [
}
print("i32 2(1)...");
var select = makeSelect(kAstI32, 2, 1);
var select = makeSelect(kWasmI32, 2, 1);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, val));
......@@ -90,7 +90,7 @@ const inputs = [
(function TestInt3() {
print("i32 3(0)...");
var C = function(v) { return v | 0; }
var select = makeSelect(kAstI32, 3, 0);
var select = makeSelect(kWasmI32, 3, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1, WRONG2));
......@@ -104,7 +104,7 @@ const inputs = [
}
print("i32 3(1)...");
var select = makeSelect(kAstI32, 3, 1);
var select = makeSelect(kWasmI32, 3, 1);
for (val of inputs) {
assertEquals(val | 0, select(WRONG1, val, WRONG2));
......@@ -118,7 +118,7 @@ const inputs = [
}
print("i32 3(2)...");
var select = makeSelect(kAstI32, 3, 2);
var select = makeSelect(kWasmI32, 3, 2);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, WRONG2, val));
......@@ -135,7 +135,7 @@ const inputs = [
(function TestFloat32_1() {
print("f32 1(0)...");
var C = function(v) { return Math.fround(v); }
var select1 = makeSelect(kAstF32, 1, 0);
var select1 = makeSelect(kWasmF32, 1, 0);
for (val of inputs) {
assertEquals(C(val), select1(val));
......@@ -151,7 +151,7 @@ const inputs = [
(function TestFloat32_2() {
print("f32 2(0)...");
var C = function(v) { return Math.fround(v); }
var select = makeSelect(kAstF32, 2, 0);
var select = makeSelect(kWasmF32, 2, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1));
......@@ -165,7 +165,7 @@ const inputs = [
}
print("f32 2(1)...");
var select = makeSelect(kAstF32, 2, 1);
var select = makeSelect(kWasmF32, 2, 1);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, val));
......@@ -183,7 +183,7 @@ const inputs = [
(function TestFloat32_2() {
print("f32 3(0)...");
var C = function(v) { return Math.fround(v); }
var select = makeSelect(kAstF32, 3, 0);
var select = makeSelect(kWasmF32, 3, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1, WRONG2));
......@@ -197,7 +197,7 @@ const inputs = [
}
print("f32 3(1)...");
var select = makeSelect(kAstF32, 3, 1);
var select = makeSelect(kWasmF32, 3, 1);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, val, WRONG2));
......@@ -211,7 +211,7 @@ const inputs = [
}
print("f32 3(2)...");
var select = makeSelect(kAstF32, 3, 2);
var select = makeSelect(kWasmF32, 3, 2);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, WRONG2, val));
......@@ -229,7 +229,7 @@ const inputs = [
(function TestFloat64_1() {
print("f64 1(0)...");
var C = function(v) { return +v; }
var select1 = makeSelect(kAstF64, 1, 0);
var select1 = makeSelect(kWasmF64, 1, 0);
for (val of inputs) {
assertEquals(C(val), select1(val));
......@@ -245,7 +245,7 @@ const inputs = [
(function TestFloat64_2() {
print("f64 2(0)...");
var C = function(v) { return +v; }
var select = makeSelect(kAstF64, 2, 0);
var select = makeSelect(kWasmF64, 2, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1));
......@@ -259,7 +259,7 @@ const inputs = [
}
print("f64 2(1)...");
var select = makeSelect(kAstF64, 2, 1);
var select = makeSelect(kWasmF64, 2, 1);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, val));
......@@ -277,7 +277,7 @@ const inputs = [
(function TestFloat64_2() {
print("f64 3(0)...");
var C = function(v) { return +v; }
var select = makeSelect(kAstF64, 3, 0);
var select = makeSelect(kWasmF64, 3, 0);
for (val of inputs) {
assertEquals(C(val), select(val, WRONG1, WRONG2));
......@@ -291,7 +291,7 @@ const inputs = [
}
print("f64 3(1)...");
var select = makeSelect(kAstF64, 3, 1);
var select = makeSelect(kWasmF64, 3, 1);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, val, WRONG2));
......@@ -305,7 +305,7 @@ const inputs = [
}
print("f64 3(2)...");
var select = makeSelect(kAstF64, 3, 2);
var select = makeSelect(kWasmF64, 3, 2);
for (val of inputs) {
assertEquals(C(val), select(WRONG1, WRONG2, val));
......
......@@ -10,7 +10,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function SerializeAndDeserializeModule() {
var builder = new WasmModuleBuilder();
builder.addMemory(1,1, true);
var kSig_v_i = makeSig([kAstI32], []);
var kSig_v_i = makeSig([kWasmI32], []);
var signature = builder.addType(kSig_v_i);
builder.addImport("", "some_value", kSig_i_v);
builder.addImport("", "writer", signature);
......
......@@ -37,11 +37,11 @@ function GlobalImportedInitTest(pad) {
var builder = new WasmModuleBuilder();
builder.addMemory(1, 1, false);
while (pad-- > 0) builder.addGlobal(kAstI32); // pad
while (pad-- > 0) builder.addGlobal(kWasmI32); // pad
var g = builder.addImportedGlobal("mod", "offset", kAstI32);
var g = builder.addImportedGlobal("mod", "offset", kWasmI32);
while (pad-- > 0) builder.addGlobal(kAstI32); // pad
while (pad-- > 0) builder.addGlobal(kWasmI32); // pad
builder.addFunction("load", kSig_i_i)
.addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0])
......
......@@ -81,16 +81,16 @@ function assertConversionError(bytes, imports = {}) {
assertLinkError(b.toBuffer(), {foo: {bar: 9}});
b = builder();
b.addImportedGlobal("foo", "bar", kAstI32);
b.addImportedGlobal("foo", "bar", kWasmI32);
assertTypeError(b.toBuffer(), {});
b = builder();
b.addImportedGlobal("foo", "bar", kAstI32);
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {foo: {}});
b = builder();
b.addImportedGlobal("foo", "bar", kAstI32);
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {foo: {bar: ""}});
b = builder();
b.addImportedGlobal("foo", "bar", kAstI32);
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {foo: {bar: () => 9}});
b = builder();
......
......@@ -16,7 +16,7 @@ var test_throw = (function () {
kExprGetLocal, 0,
kExprI32Const, 0,
kExprI32Ne,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprGetLocal, 0,
kExprThrow,
kExprEnd,
......@@ -119,11 +119,11 @@ var test_catch = (function () {
// happen in case of inlining, for example.
builder.addFunction("same_scope", kSig_i_i)
.addBody([
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprI32Const, 0,
kExprI32Ne,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprGetLocal, 0,
kExprThrow,
kExprUnreachable,
......@@ -139,7 +139,7 @@ var test_catch = (function () {
builder.addFunction("same_scope_ignore", kSig_i_i)
.addBody([
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprThrow,
kExprUnreachable,
......@@ -184,13 +184,13 @@ var test_catch = (function () {
// p == 3 -> path == 338
// else -> path == 146
.addBody([
kExprTry, kAstI32,
kExprTry, kAstI32,
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprTry, kWasmI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprI32Const, 1,
kExprI32Eq,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprI32Const, 1,
kExprThrow,
kExprUnreachable,
......@@ -207,7 +207,7 @@ var test_catch = (function () {
kExprGetLocal, 0,
kExprI32Const, 2,
kExprI32Eq,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprGetLocal, 2,
kExprI32Const, 8,
kExprI32Ior,
......@@ -227,7 +227,7 @@ var test_catch = (function () {
kExprGetLocal, 0,
kExprI32Const, 3,
kExprI32Eq,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprGetLocal, 2,
kExprI32Const, /*64=*/ 192, 0,
kExprI32Ior,
......@@ -249,7 +249,7 @@ var test_catch = (function () {
var kFromDirectCallee =
builder.addFunction("from_direct_callee", kSig_i_i)
.addBody([
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprCallFunction, kWasmThrowFunction,
kExprI32Const, /*-1=*/ 127,
......@@ -268,7 +268,7 @@ var test_catch = (function () {
kExprGetLocal, 0,
kExprI32Const, 0,
kExprI32GtS,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprGetLocal, 0,
kExprI32Const, 1,
kExprI32Sub,
......@@ -283,7 +283,7 @@ var test_catch = (function () {
builder.addFunction("from_indirect_callee", kSig_i_i)
.addBody([
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprI32Const, 0,
kExprCallFunction, kFromIndirectCalleeHelper,
......@@ -298,7 +298,7 @@ var test_catch = (function () {
// Scenario 4: Catches an exception raised in JS.
builder.addFunction("from_js", kSig_i_i)
.addBody([
kExprTry, kAstI32,
kExprTry, kWasmI32,
kExprGetLocal, 0,
kExprCallFunction, kJSThrowI,
kExprI32Const, /*-1=*/ 127,
......
......@@ -242,7 +242,7 @@ function testCallBinopVoid(type, func, check) {
var builder = new WasmModuleBuilder();
builder.addImport("", "func", makeSig_v_xx(type));
builder.addFunction("main", makeSig_r_xx(kAstI32, type))
builder.addFunction("main", makeSig_r_xx(kWasmI32, type))
.addBody([
kExprGetLocal, 0, // --
kExprGetLocal, 1, // --
......@@ -262,17 +262,17 @@ function testCallBinopVoid(type, func, check) {
assertEquals(2, passed_length);
var expected_a, expected_b;
switch (type) {
case kAstI32: {
case kWasmI32: {
expected_a = a | 0;
expected_b = b | 0;
break;
}
case kAstF32: {
case kWasmF32: {
expected_a = Math.fround(a);
expected_b = Math.fround(b);
break;
}
case kAstF64: {
case kWasmF64: {
expected_a = a;
expected_b = b;
break;
......@@ -287,17 +287,17 @@ function testCallBinopVoid(type, func, check) {
}
testCallBinopVoid(kAstI32);
// TODO testCallBinopVoid(kAstI64);
testCallBinopVoid(kAstF32);
testCallBinopVoid(kAstF64);
testCallBinopVoid(kWasmI32);
// TODO testCallBinopVoid(kWasmI64);
testCallBinopVoid(kWasmF32);
testCallBinopVoid(kWasmF64);
(function testCallPrint() {
var builder = new WasmModuleBuilder();
builder.addImport("", "print", makeSig_v_x(kAstI32));
builder.addImport("", "print", makeSig_v_x(kAstF64));
builder.addFunction("main", makeSig_v_x(kAstF64))
builder.addImport("", "print", makeSig_v_x(kWasmI32));
builder.addImport("", "print", makeSig_v_x(kWasmF64));
builder.addFunction("main", makeSig_v_x(kWasmF64))
.addBody([
kExprI8Const, 97, // --
kExprCallFunction, 0, // --
......
......@@ -54,21 +54,21 @@ function print10(a, b, c, d, e, f, g, h, i) {
}
(function I32Test() {
var main = makeFFI(print10, kAstI32);
var main = makeFFI(print10, kWasmI32);
for (var i = 1; i < 0xFFFFFFF; i <<= 2) {
main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8);
}
})();
(function F32Test() {
var main = makeFFI(print10, kAstF32);
var main = makeFFI(print10, kWasmF32);
for (var i = 1; i < 2e+30; i *= -157) {
main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8);
}
})();
(function F64Test() {
var main = makeFFI(print10, kAstF64);
var main = makeFFI(print10, kWasmF64);
for (var i = 1; i < 2e+80; i *= -1137) {
main(i - 1, i, i + 2, i + 3, i + 4, i + 5, i + 6, i + 7, i + 8);
}
......
......@@ -15,34 +15,34 @@ function TestImported(type, val, expected) {
builder.addFunction("main", sig)
.addBody([kExprGetGlobal, g.index])
.exportAs("main");
builder.addGlobal(kAstI32); // pad
builder.addGlobal(kWasmI32); // pad
var instance = builder.instantiate({uuu: {foo: val}});
assertEquals(expected, instance.exports.main());
}
TestImported(kAstI32, 300.1, 300);
TestImported(kAstF32, 87234.87238, Math.fround(87234.87238));
TestImported(kAstF64, 77777.88888, 77777.88888);
TestImported(kWasmI32, 300.1, 300);
TestImported(kWasmF32, 87234.87238, Math.fround(87234.87238));
TestImported(kWasmF64, 77777.88888, 77777.88888);
function TestExported(type, val, expected) {
print("TestExported " + type + "(" + val +")" + " = " + expected);
var builder = new WasmModuleBuilder();
var sig = makeSig([type], []);
builder.addGlobal(kAstI32); // pad
builder.addGlobal(kWasmI32); // pad
var g = builder.addGlobal(type, false)
.exportAs("foo");
g.init = val;
builder.addGlobal(kAstI32); // pad
builder.addGlobal(kWasmI32); // pad
var instance = builder.instantiate();
assertEquals(expected, instance.exports.foo);
}
TestExported(kAstI32, 455.5, 455);
TestExported(kAstF32, -999.34343, Math.fround(-999.34343));
TestExported(kAstF64, 87347.66666, 87347.66666);
TestExported(kWasmI32, 455.5, 455);
TestExported(kWasmF32, -999.34343, Math.fround(-999.34343));
TestExported(kWasmF64, 87347.66666, 87347.66666);
function TestImportedExported(type, val, expected) {
......@@ -50,19 +50,19 @@ function TestImportedExported(type, val, expected) {
var builder = new WasmModuleBuilder();
var sig = makeSig([type], []);
var i = builder.addImportedGlobal("ttt", "foo", type);
builder.addGlobal(kAstI32); // pad
builder.addGlobal(kWasmI32); // pad
var o = builder.addGlobal(type, false)
.exportAs("bar");
o.init_index = i;
builder.addGlobal(kAstI32); // pad
builder.addGlobal(kWasmI32); // pad
var instance = builder.instantiate({ttt: {foo: val}});
assertEquals(expected, instance.exports.bar);
}
TestImportedExported(kAstI32, 415.5, 415);
TestImportedExported(kAstF32, -979.34343, Math.fround(-979.34343));
TestImportedExported(kAstF64, 81347.66666, 81347.66666);
TestImportedExported(kWasmI32, 415.5, 415);
TestImportedExported(kWasmF32, -979.34343, Math.fround(-979.34343));
TestImportedExported(kWasmF64, 81347.66666, 81347.66666);
function TestGlobalIndexSpace(type, val) {
print("TestGlobalIndexSpace(" + val + ") = " + val);
......@@ -82,6 +82,6 @@ function TestGlobalIndexSpace(type, val) {
assertEquals(val, instance.exports.main());
}
TestGlobalIndexSpace(kAstI32, 123);
TestGlobalIndexSpace(kAstF32, 54321.125);
TestGlobalIndexSpace(kAstF64, 12345.678);
TestGlobalIndexSpace(kWasmI32, 123);
TestGlobalIndexSpace(kWasmF32, 54321.125);
TestGlobalIndexSpace(kWasmF64, 12345.678);
......@@ -185,7 +185,7 @@ function testCallBinopVoid(type, func, check) {
var builder = new WasmModuleBuilder();
builder.addImport("q", "func", makeSig_v_xx(type));
builder.addFunction("main", makeSig_r_xx(kAstI32, type))
builder.addFunction("main", makeSig_r_xx(kWasmI32, type))
.addBody([
kExprGetLocal, 0, // --
kExprGetLocal, 1, // --
......@@ -205,17 +205,17 @@ function testCallBinopVoid(type, func, check) {
assertEquals(2, passed_length);
var expected_a, expected_b;
switch (type) {
case kAstI32: {
case kWasmI32: {
expected_a = a | 0;
expected_b = b | 0;
break;
}
case kAstF32: {
case kWasmF32: {
expected_a = Math.fround(a);
expected_b = Math.fround(b);
break;
}
case kAstF64: {
case kWasmF64: {
expected_a = a;
expected_b = b;
break;
......@@ -230,18 +230,18 @@ function testCallBinopVoid(type, func, check) {
}
testCallBinopVoid(kAstI32);
// TODO testCallBinopVoid(kAstI64);
testCallBinopVoid(kAstF32);
testCallBinopVoid(kAstF64);
testCallBinopVoid(kWasmI32);
// TODO testCallBinopVoid(kWasmI64);
testCallBinopVoid(kWasmF32);
testCallBinopVoid(kWasmF64);
function testCallPrint() {
var builder = new WasmModuleBuilder();
builder.addImport("q", "print", makeSig_v_x(kAstI32));
builder.addImport("q", "print", makeSig_r_x(kAstF64, kAstF64));
builder.addFunction("main", makeSig_r_x(kAstF64, kAstF64))
builder.addImport("q", "print", makeSig_v_x(kWasmI32));
builder.addImport("q", "print", makeSig_r_x(kWasmF64, kWasmF64));
builder.addFunction("main", makeSig_r_x(kWasmF64, kWasmF64))
.addBody([
kExprI8Const, 97, // --
kExprCallFunction, 0, // --
......
......@@ -185,7 +185,7 @@ assertTraps(kTrapFuncInvalid, "module.exports.main(12, 3)");
.exportAs("main");
builder.setFunctionTableLength(10);
var g = builder.addImportedGlobal("fff", "base", kAstI32);
var g = builder.addImportedGlobal("fff", "base", kWasmI32);
builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index, f.sub.index]);
var module = new WebAssembly.Module(builder.toBuffer());
......
......@@ -50,7 +50,7 @@ function js_div(a, b) { return (a / b) | 0; }
f.add.exportAs("blarg");
builder.setFunctionTableLength(10);
let g = builder.addImportedGlobal("q", "base", kAstI32);
let g = builder.addImportedGlobal("q", "base", kWasmI32);
builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index,
f.sub.index,
d]);
......@@ -110,7 +110,7 @@ function js_div(a, b) { return (a / b) | 0; }
let d = builder.addImport("q", "js_div", kSig_i_ii);
let f = AddFunctions(builder);
builder.setFunctionTableLength(kTableSize);
let g = builder.addImportedGlobal("q", "base", kAstI32);
let g = builder.addImportedGlobal("q", "base", kWasmI32);
builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index,
f.sub.index,
d]);
......@@ -180,7 +180,7 @@ function js_div(a, b) { return (a / b) | 0; }
let d = builder.addImport("q", "js_div", kSig_i_ii);
builder.addImportedTable("q", "table", kTableSize, kTableSize);
let g = builder.addImportedGlobal("q", "base", kAstI32);
let g = builder.addImportedGlobal("q", "base", kWasmI32);
let f = AddFunctions(builder);
builder.addFunctionTableInit(g, true, [f.mul.index, f.add.index,
f.sub.index,
......@@ -247,7 +247,7 @@ function js_div(a, b) { return (a / b) | 0; }
var builder = new WasmModuleBuilder();
builder.addImportedTable("x", "table", kTableSize, kTableSize);
let g = builder.addImportedGlobal("x", "base", kAstI32);
let g = builder.addImportedGlobal("x", "base", kWasmI32);
let sig_index = builder.addType(kSig_i_v);
builder.addFunction("g", sig_index)
.addBody([
......
......@@ -118,7 +118,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
print("InstancesAreIsolatedFromEachother...");
var builder = new WasmModuleBuilder();
builder.addMemory(1,1, true);
var kSig_v_i = makeSig([kAstI32], []);
var kSig_v_i = makeSig([kWasmI32], []);
var signature = builder.addType(kSig_v_i);
builder.addImport("m", "some_value", kSig_i_v);
builder.addImport("m", "writer", signature);
......@@ -172,7 +172,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
(function GlobalsArePrivateToTheInstance() {
print("GlobalsArePrivateToTheInstance...");
var builder = new WasmModuleBuilder();
builder.addGlobal(kAstI32, true);
builder.addGlobal(kWasmI32, true);
builder.addFunction("read", kSig_i_v)
.addBody([
kExprGetGlobal, 0])
......
......@@ -17,12 +17,12 @@ function genModule(memory) {
.addBody([
// main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0;
// TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc
/**/ kExprLoop, kAstStmt, // --
/**/ kExprLoop, kWasmStmt, // --
/* */ kExprGetLocal, 0, // --
/* */ kExprIf, kAstStmt, // --
/* */ kExprIf, kWasmStmt, // --
/* */ kExprGetLocal, 0, // --
/* */ kExprI32LoadMem, 0, 0, // --
/* */ kExprIf, kAstStmt, // --
/* */ kExprIf, kWasmStmt, // --
/* */ kExprI8Const, 255, // --
/* */ kExprReturn, // --
/* */ kExprEnd, // --
......
......@@ -26,7 +26,7 @@ function testSelect2(type) {
runSelect2(select, which, 99, 97);
runSelect2(select, which, -99, -97);
if (type != kAstF32) {
if (type != kWasmF32) {
runSelect2(select, which, 0x80000000 | 0, 0x7fffffff | 0);
runSelect2(select, which, 0x80000001 | 0, 0x7ffffffe | 0);
runSelect2(select, which, 0xffffffff | 0, 0xfffffffe | 0);
......@@ -35,7 +35,7 @@ function testSelect2(type) {
runSelect2(select, which, -2147483648, 2147483647);
}
if (type != kAstI32 && type != kAstI64) {
if (type != kWasmI32 && type != kWasmI64) {
runSelect2(select, which, -1.25, 5.25);
runSelect2(select, which, Infinity, -Infinity);
}
......@@ -43,9 +43,9 @@ function testSelect2(type) {
}
testSelect2(kAstI32);
testSelect2(kAstF32);
testSelect2(kAstF64);
testSelect2(kWasmI32);
testSelect2(kWasmF32);
testSelect2(kWasmF64);
function runSelect10(select, which, a, b) {
......@@ -89,7 +89,7 @@ function testSelect10(t) {
runSelect10(select, which, 99, 97);
runSelect10(select, which, -99, -97);
if (t != kAstF32) {
if (t != kWasmF32) {
runSelect10(select, which, 0x80000000 | 0, 0x7fffffff | 0);
runSelect10(select, which, 0x80000001 | 0, 0x7ffffffe | 0);
runSelect10(select, which, 0xffffffff | 0, 0xfffffffe | 0);
......@@ -98,7 +98,7 @@ function testSelect10(t) {
runSelect10(select, which, -2147483648, 2147483647);
}
if (t != kAstI32 && t != kAstI64) {
if (t != kWasmI32 && t != kWasmI64) {
runSelect10(select, which, -1.25, 5.25);
runSelect10(select, which, Infinity, -Infinity);
}
......@@ -106,6 +106,6 @@ function testSelect10(t) {
}
testSelect10(kAstI32);
testSelect10(kAstF32);
testSelect10(kAstF64);
testSelect10(kWasmI32);
testSelect10(kWasmF32);
testSelect10(kWasmF64);
......@@ -27,7 +27,7 @@ function instantiate(buffer, ffi) {
(function ImportTest() {
let builder = new WasmModuleBuilder();
var index = builder.addImport("", "print", makeSig_v_x(kAstI32));
var index = builder.addImport("", "print", makeSig_v_x(kWasmI32));
builder.addFunction("foo", kSig_v_v)
.addBody([kExprI8Const, 13, kExprCallFunction, index])
.exportAs("main");
......@@ -54,10 +54,10 @@ function instantiate(buffer, ffi) {
(function LocalsTest2() {
// TODO(titzer): i64 only works on 64-bit platforms.
var types = [
{locals: {i32_count: 1}, type: kAstI32},
// {locals: {i64_count: 1}, type: kAstI64},
{locals: {f32_count: 1}, type: kAstF32},
{locals: {f64_count: 1}, type: kAstF64},
{locals: {i32_count: 1}, type: kWasmI32},
// {locals: {i64_count: 1}, type: kWasmI64},
{locals: {f32_count: 1}, type: kWasmF32},
{locals: {f64_count: 1}, type: kWasmF64},
];
for (p of types) {
......@@ -145,7 +145,7 @@ function instantiate(buffer, ffi) {
(function ImportTestTwoLevel() {
let builder = new WasmModuleBuilder();
var index = builder.addImport("mod", "print", makeSig_v_x(kAstI32));
var index = builder.addImport("mod", "print", makeSig_v_x(kWasmI32));
builder.addFunction("foo", kSig_v_v)
.addBody([kExprI8Const, 19, kExprCallFunction, index])
.exportAs("main");
......
......@@ -30,11 +30,11 @@ var sig_index = builder.addType(kSig_i_v)
builder.addFunction("main", kSig_i_i)
.addBody([
// offset 1
kExprBlock, kAstI32,
kExprBlock, kWasmI32,
kExprGetLocal, 0,
kExprI32Const, 2,
kExprI32LtU,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
// offset 9
kExprI32Const, 0x7e /* -2 */,
kExprGetLocal, 0,
......@@ -47,7 +47,7 @@ builder.addFunction("main", kSig_i_i)
kExprGetLocal, 0,
kExprI32Const, 2,
kExprI32Eq,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprUnreachable,
kExprEnd,
// offset 30
......
......@@ -30,11 +30,11 @@ var sig_index = builder.addType(kSig_i_v)
builder.addFunction("main", kSig_i_i)
.addBody([
// offset 1
kExprBlock, kAstI32,
kExprBlock, kWasmI32,
kExprGetLocal, 0,
kExprI32Const, 2,
kExprI32LtU,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
// offset 9
kExprI32Const, 0x7e /* -2 */,
kExprGetLocal, 0,
......@@ -47,7 +47,7 @@ builder.addFunction("main", kSig_i_i)
kExprGetLocal, 0,
kExprI32Const, 2,
kExprI32Eq,
kExprIf, kAstStmt,
kExprIf, kWasmStmt,
kExprUnreachable,
kExprEnd,
// offset 30
......
......@@ -77,12 +77,12 @@ let kDeclFunctionLocals = 0x04;
let kDeclFunctionExport = 0x08;
// Local types
let kAstStmt = 0x40;
let kAstI32 = 0x7f;
let kAstI64 = 0x7e;
let kAstF32 = 0x7d;
let kAstF64 = 0x7c;
let kAstS128 = 0x7b;
let kWasmStmt = 0x40;
let kWasmI32 = 0x7f;
let kWasmI64 = 0x7e;
let kWasmF32 = 0x7d;
let kWasmF64 = 0x7c;
let kWasmS128 = 0x7b;
let kExternalFunction = 0;
let kExternalTable = 1;
......@@ -93,27 +93,27 @@ let kTableZero = 0;
let kMemoryZero = 0;
// Useful signatures
let kSig_i_i = makeSig([kAstI32], [kAstI32]);
let kSig_l_l = makeSig([kAstI64], [kAstI64]);
let kSig_i_l = makeSig([kAstI64], [kAstI32]);
let kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]);
let kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]);
let kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]);
let kSig_l_ll = makeSig([kAstI64, kAstI64], [kAstI64]);
let kSig_i_dd = makeSig([kAstF64, kAstF64], [kAstI32]);
let kSig_i_i = makeSig([kWasmI32], [kWasmI32]);
let kSig_l_l = makeSig([kWasmI64], [kWasmI64]);
let kSig_i_l = makeSig([kWasmI64], [kWasmI32]);
let kSig_i_ii = makeSig([kWasmI32, kWasmI32], [kWasmI32]);
let kSig_i_iii = makeSig([kWasmI32, kWasmI32, kWasmI32], [kWasmI32]);
let kSig_d_dd = makeSig([kWasmF64, kWasmF64], [kWasmF64]);
let kSig_l_ll = makeSig([kWasmI64, kWasmI64], [kWasmI64]);
let kSig_i_dd = makeSig([kWasmF64, kWasmF64], [kWasmI32]);
let kSig_v_v = makeSig([], []);
let kSig_i_v = makeSig([], [kAstI32]);
let kSig_l_v = makeSig([], [kAstI64]);
let kSig_f_v = makeSig([], [kAstF64]);
let kSig_d_v = makeSig([], [kAstF64]);
let kSig_v_i = makeSig([kAstI32], []);
let kSig_v_ii = makeSig([kAstI32, kAstI32], []);
let kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []);
let kSig_v_l = makeSig([kAstI64], []);
let kSig_v_d = makeSig([kAstF64], []);
let kSig_v_dd = makeSig([kAstF64, kAstF64], []);
let kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []);
let kSig_s_v = makeSig([], [kAstS128]);
let kSig_i_v = makeSig([], [kWasmI32]);
let kSig_l_v = makeSig([], [kWasmI64]);
let kSig_f_v = makeSig([], [kWasmF64]);
let kSig_d_v = makeSig([], [kWasmF64]);
let kSig_v_i = makeSig([kWasmI32], []);
let kSig_v_ii = makeSig([kWasmI32, kWasmI32], []);
let kSig_v_iii = makeSig([kWasmI32, kWasmI32, kWasmI32], []);
let kSig_v_l = makeSig([kWasmI64], []);
let kSig_v_d = makeSig([kWasmF64], []);
let kSig_v_dd = makeSig([kWasmF64, kWasmF64], []);
let kSig_v_ddi = makeSig([kWasmF64, kWasmF64, kWasmI32], []);
let kSig_s_v = makeSig([], [kWasmS128]);
function makeSig(params, results) {
return {params: params, results: results};
......
......@@ -353,15 +353,15 @@ class WasmModuleBuilder {
if ((typeof global.init_index) == "undefined") {
// Emit a constant initializer.
switch (global.type) {
case kAstI32:
case kWasmI32:
section.emit_u8(kExprI32Const);
section.emit_u32v(global.init);
break;
case kAstI64:
case kWasmI64:
section.emit_u8(kExprI64Const);
section.emit_u8(global.init);
break;
case kAstF32:
case kWasmF32:
section.emit_u8(kExprF32Const);
f32_view[0] = global.init;
section.emit_u8(byte_view[0]);
......@@ -369,7 +369,7 @@ class WasmModuleBuilder {
section.emit_u8(byte_view[2]);
section.emit_u8(byte_view[3]);
break;
case kAstF64:
case kWasmF64:
section.emit_u8(kExprF64Const);
f64_view[0] = global.init;
section.emit_u8(byte_view[0]);
......@@ -457,16 +457,16 @@ class WasmModuleBuilder {
if (l != undefined) {
let local_decls_count = 0;
if (l.i32_count > 0) {
local_decls.push({count: l.i32_count, type: kAstI32});
local_decls.push({count: l.i32_count, type: kWasmI32});
}
if (l.i64_count > 0) {
local_decls.push({count: l.i64_count, type: kAstI64});
local_decls.push({count: l.i64_count, type: kWasmI64});
}
if (l.f32_count > 0) {
local_decls.push({count: l.f32_count, type: kAstF32});
local_decls.push({count: l.f32_count, type: kWasmF32});
}
if (l.f64_count > 0) {
local_decls.push({count: l.f64_count, type: kAstF64});
local_decls.push({count: l.f64_count, type: kWasmF64});
}
}
......
......@@ -126,13 +126,13 @@ static size_t SizeOfVarInt(size_t value) {
return size;
}
struct LocalTypePair {
struct ValueTypePair {
uint8_t code;
LocalType type;
} kLocalTypes[] = {{kLocalI32, kAstI32},
{kLocalI64, kAstI64},
{kLocalF32, kAstF32},
{kLocalF64, kAstF64}};
ValueType type;
} kValueTypes[] = {{kLocalI32, kWasmI32},
{kLocalI64, kWasmI64},
{kLocalF32, kWasmF32},
{kLocalF64, kWasmF64}};
class WasmModuleVerifyTest : public TestWithIsolateAndZone {
public:
......@@ -199,7 +199,7 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) {
const WasmGlobal* global = &result.val->globals.back();
EXPECT_EQ(kAstI32, global->type);
EXPECT_EQ(kWasmI32, global->type);
EXPECT_EQ(0u, global->offset);
EXPECT_FALSE(global->mutability);
EXPECT_EQ(WasmInitExpr::kI32Const, global->init.kind);
......@@ -360,14 +360,14 @@ TEST_F(WasmModuleVerifyTest, TwoGlobals) {
const WasmGlobal* g0 = &result.val->globals[0];
EXPECT_EQ(kAstF32, g0->type);
EXPECT_EQ(kWasmF32, g0->type);
EXPECT_EQ(0u, g0->offset);
EXPECT_FALSE(g0->mutability);
EXPECT_EQ(WasmInitExpr::kF32Const, g0->init.kind);
const WasmGlobal* g1 = &result.val->globals[1];
EXPECT_EQ(kAstF64, g1->type);
EXPECT_EQ(kWasmF64, g1->type);
EXPECT_EQ(8u, g1->offset);
EXPECT_TRUE(g1->mutability);
EXPECT_EQ(WasmInitExpr::kF64Const, g1->init.kind);
......@@ -784,8 +784,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_v) {
}
TEST_F(WasmSignatureDecodeTest, Ok_t_v) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalTypePair ret_type = kLocalTypes[i];
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair ret_type = kValueTypes[i];
const byte data[] = {SIG_ENTRY_x(ret_type.code)};
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
......@@ -798,8 +798,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_v) {
}
TEST_F(WasmSignatureDecodeTest, Ok_v_t) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalTypePair param_type = kLocalTypes[i];
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair param_type = kValueTypes[i];
const byte data[] = {SIG_ENTRY_v_x(param_type.code)};
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
......@@ -812,10 +812,10 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_t) {
}
TEST_F(WasmSignatureDecodeTest, Ok_t_t) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalTypePair ret_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalTypePair param_type = kLocalTypes[j];
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair ret_type = kValueTypes[i];
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
ValueTypePair param_type = kValueTypes[j];
const byte data[] = {SIG_ENTRY_x_x(ret_type.code, param_type.code)};
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
......@@ -830,10 +830,10 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_t) {
}
TEST_F(WasmSignatureDecodeTest, Ok_i_tt) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalTypePair p0_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalTypePair p1_type = kLocalTypes[j];
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair p0_type = kValueTypes[i];
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
ValueTypePair p1_type = kValueTypes[j];
const byte data[] = {
SIG_ENTRY_x_xx(kLocalI32, p0_type.code, p1_type.code)};
FunctionSig* sig =
......@@ -1054,7 +1054,7 @@ TEST_F(WasmModuleVerifyTest, UnknownSectionSkipped) {
const WasmGlobal* global = &result.val->globals.back();
EXPECT_EQ(kAstI32, global->type);
EXPECT_EQ(kWasmI32, global->type);
EXPECT_EQ(0u, global->offset);
if (result.val) delete result.val;
......
......@@ -17,7 +17,7 @@ namespace wasm {
class WasmModuleBuilderTest : public TestWithZone {
protected:
void AddLocal(WasmFunctionBuilder* f, LocalType type) {
void AddLocal(WasmFunctionBuilder* f, ValueType type) {
uint16_t index = f->AddLocal(type);
f->EmitGetLocal(index);
}
......
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