[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}
This commit is contained in:
parent
bc981e61de
commit
55fc5c0c32
@ -42,7 +42,7 @@ enum ValueFate { kDrop, kLeaveOnStack };
|
||||
struct ForeignVariable {
|
||||
Handle<Name> name;
|
||||
Variable* var;
|
||||
LocalType type;
|
||||
ValueType type;
|
||||
};
|
||||
|
||||
class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
@ -516,8 +516,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
// Add the parameters for the function.
|
||||
const auto& arguments = func_type->Arguments();
|
||||
for (int i = 0; i < expr->parameter_count(); ++i) {
|
||||
LocalType type = TypeFrom(arguments[i]);
|
||||
DCHECK_NE(kAstStmt, type);
|
||||
ValueType type = TypeFrom(arguments[i]);
|
||||
DCHECK_NE(kWasmStmt, type);
|
||||
InsertParameter(scope->parameter(i), type, i);
|
||||
}
|
||||
} else {
|
||||
@ -538,18 +538,18 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
RECURSE(Visit(expr->condition()));
|
||||
// WASM ifs come with implicit blocks for both arms.
|
||||
breakable_blocks_.push_back(std::make_pair(nullptr, false));
|
||||
LocalTypeCode type;
|
||||
ValueTypeCode type;
|
||||
switch (TypeOf(expr)) {
|
||||
case kAstI32:
|
||||
case kWasmI32:
|
||||
type = kLocalI32;
|
||||
break;
|
||||
case kAstI64:
|
||||
case kWasmI64:
|
||||
type = kLocalI64;
|
||||
break;
|
||||
case kAstF32:
|
||||
case kWasmF32:
|
||||
type = kLocalF32;
|
||||
break;
|
||||
case kAstF64:
|
||||
case kWasmF64:
|
||||
type = kLocalF64;
|
||||
break;
|
||||
default:
|
||||
@ -621,8 +621,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
if (VisitStdlibConstant(var)) {
|
||||
return;
|
||||
}
|
||||
LocalType var_type = TypeOf(expr);
|
||||
DCHECK_NE(kAstStmt, var_type);
|
||||
ValueType var_type = TypeOf(expr);
|
||||
DCHECK_NE(kWasmStmt, var_type);
|
||||
if (var->IsContextSlot()) {
|
||||
current_function_builder_->EmitWithVarInt(
|
||||
kExprGetGlobal, LookupOrInsertGlobal(var, var_type));
|
||||
@ -755,10 +755,10 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
auto* func_table_type = typer_->TypeOf(p->obj()->AsVariableProxy()->var())
|
||||
->AsFunctionTableType();
|
||||
const auto& arguments = func_type->Arguments();
|
||||
LocalType return_type = TypeFrom(func_type->ReturnType());
|
||||
FunctionSig::Builder sig(zone(), return_type == kAstStmt ? 0 : 1,
|
||||
ValueType return_type = TypeFrom(func_type->ReturnType());
|
||||
FunctionSig::Builder sig(zone(), return_type == kWasmStmt ? 0 : 1,
|
||||
arguments.size());
|
||||
if (return_type != kAstStmt) {
|
||||
if (return_type != kWasmStmt) {
|
||||
sig.AddReturn(return_type);
|
||||
}
|
||||
for (auto* arg : arguments) {
|
||||
@ -924,8 +924,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
if (target_var != nullptr) {
|
||||
// Left hand side is a local or a global variable.
|
||||
Variable* var = target_var->var();
|
||||
LocalType var_type = TypeOf(expr);
|
||||
DCHECK_NE(kAstStmt, var_type);
|
||||
ValueType var_type = TypeOf(expr);
|
||||
DCHECK_NE(kWasmStmt, var_type);
|
||||
if (var->IsContextSlot()) {
|
||||
uint32_t index = LookupOrInsertGlobal(var, var_type);
|
||||
current_function_builder_->EmitWithVarInt(kExprSetGlobal, index);
|
||||
@ -946,7 +946,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
Property* target_prop = expr->target()->AsProperty();
|
||||
if (target_prop != nullptr) {
|
||||
// Left hand side is a property access, i.e. the asm.js heap.
|
||||
if (TypeOf(expr->value()) == kAstF64 && expr->target()->IsProperty() &&
|
||||
if (TypeOf(expr->value()) == kWasmF64 && expr->target()->IsProperty() &&
|
||||
typer_->TypeOf(expr->target()->AsProperty()->obj())
|
||||
->IsA(AsmType::Float32Array())) {
|
||||
current_function_builder_->Emit(kExprF32ConvertF64);
|
||||
@ -1054,7 +1054,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
if (!key_literal->value().is_null()) {
|
||||
Handle<Name> name =
|
||||
Object::ToName(isolate_, key_literal->value()).ToHandleChecked();
|
||||
LocalType type = is_float ? kAstF64 : kAstI32;
|
||||
ValueType type = is_float ? kWasmF64 : kWasmI32;
|
||||
foreign_variables_.push_back({name, var, type});
|
||||
}
|
||||
}
|
||||
@ -1075,7 +1075,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
Literal* value = expr->key()->AsLiteral();
|
||||
if (value) {
|
||||
DCHECK(value->raw_value()->IsNumber());
|
||||
DCHECK_EQ(kAstI32, TypeOf(value));
|
||||
DCHECK_EQ(kWasmI32, TypeOf(value));
|
||||
int32_t val = static_cast<int32_t>(value->raw_value()->AsNumber());
|
||||
// TODO(titzer): handle overflow here.
|
||||
current_function_builder_->EmitI32Const(val * size);
|
||||
@ -1085,7 +1085,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
if (binop) {
|
||||
DCHECK_EQ(Token::SAR, binop->op());
|
||||
DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber());
|
||||
DCHECK(kAstI32 == TypeOf(binop->right()->AsLiteral()));
|
||||
DCHECK(kWasmI32 == TypeOf(binop->right()->AsLiteral()));
|
||||
DCHECK_EQ(size,
|
||||
1 << static_cast<int>(
|
||||
binop->right()->AsLiteral()->raw_value()->AsNumber()));
|
||||
@ -1131,7 +1131,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
AsmTyper::StandardMember standard_object =
|
||||
typer_->VariableAsStandardMember(var);
|
||||
ZoneList<Expression*>* args = call->arguments();
|
||||
LocalType call_type = TypeOf(call);
|
||||
ValueType call_type = TypeOf(call);
|
||||
|
||||
switch (standard_object) {
|
||||
case AsmTyper::kNone: {
|
||||
@ -1139,57 +1139,57 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathAcos: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Acos);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathAsin: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Asin);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathAtan: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Atan);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathCos: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Cos);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathSin: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Sin);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathTan: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Tan);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathExp: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Exp);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathLog: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Log);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathCeil: {
|
||||
VisitCallArgs(call);
|
||||
if (call_type == kAstF32) {
|
||||
if (call_type == kWasmF32) {
|
||||
current_function_builder_->Emit(kExprF32Ceil);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
current_function_builder_->Emit(kExprF64Ceil);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
@ -1198,9 +1198,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathFloor: {
|
||||
VisitCallArgs(call);
|
||||
if (call_type == kAstF32) {
|
||||
if (call_type == kWasmF32) {
|
||||
current_function_builder_->Emit(kExprF32Floor);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
current_function_builder_->Emit(kExprF64Floor);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
@ -1209,9 +1209,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathSqrt: {
|
||||
VisitCallArgs(call);
|
||||
if (call_type == kAstF32) {
|
||||
if (call_type == kWasmF32) {
|
||||
current_function_builder_->Emit(kExprF32Sqrt);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
current_function_builder_->Emit(kExprF64Sqrt);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
@ -1220,13 +1220,13 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathClz32: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK(call_type == kAstI32);
|
||||
DCHECK(call_type == kWasmI32);
|
||||
current_function_builder_->Emit(kExprI32Clz);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathAbs: {
|
||||
if (call_type == kAstI32) {
|
||||
WasmTemporary tmp(current_function_builder_, kAstI32);
|
||||
if (call_type == kWasmI32) {
|
||||
WasmTemporary tmp(current_function_builder_, kWasmI32);
|
||||
|
||||
// if set_local(tmp, x) < 0
|
||||
Visit(call->arguments()->at(0));
|
||||
@ -1247,10 +1247,10 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
// end
|
||||
current_function_builder_->Emit(kExprEnd);
|
||||
|
||||
} else if (call_type == kAstF32) {
|
||||
} else if (call_type == kWasmF32) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF32Abs);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF64Abs);
|
||||
} else {
|
||||
@ -1260,9 +1260,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathMin: {
|
||||
// TODO(bradnelson): Change wasm to match Math.min in asm.js mode.
|
||||
if (call_type == kAstI32) {
|
||||
WasmTemporary tmp_x(current_function_builder_, kAstI32);
|
||||
WasmTemporary tmp_y(current_function_builder_, kAstI32);
|
||||
if (call_type == kWasmI32) {
|
||||
WasmTemporary tmp_x(current_function_builder_, kWasmI32);
|
||||
WasmTemporary tmp_y(current_function_builder_, kWasmI32);
|
||||
|
||||
// if set_local(tmp_x, x) < set_local(tmp_y, y)
|
||||
Visit(call->arguments()->at(0));
|
||||
@ -1282,10 +1282,10 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
current_function_builder_->EmitGetLocal(tmp_y.index());
|
||||
current_function_builder_->Emit(kExprEnd);
|
||||
|
||||
} else if (call_type == kAstF32) {
|
||||
} else if (call_type == kWasmF32) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF32Min);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF64Min);
|
||||
} else {
|
||||
@ -1295,9 +1295,9 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathMax: {
|
||||
// TODO(bradnelson): Change wasm to match Math.max in asm.js mode.
|
||||
if (call_type == kAstI32) {
|
||||
WasmTemporary tmp_x(current_function_builder_, kAstI32);
|
||||
WasmTemporary tmp_y(current_function_builder_, kAstI32);
|
||||
if (call_type == kWasmI32) {
|
||||
WasmTemporary tmp_x(current_function_builder_, kWasmI32);
|
||||
WasmTemporary tmp_y(current_function_builder_, kWasmI32);
|
||||
|
||||
// if set_local(tmp_x, x) < set_local(tmp_y, y)
|
||||
Visit(call->arguments()->at(0));
|
||||
@ -1318,10 +1318,10 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
current_function_builder_->EmitGetLocal(tmp_x.index());
|
||||
current_function_builder_->Emit(kExprEnd);
|
||||
|
||||
} else if (call_type == kAstF32) {
|
||||
} else if (call_type == kWasmF32) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF32Max);
|
||||
} else if (call_type == kAstF64) {
|
||||
} else if (call_type == kWasmF64) {
|
||||
VisitCallArgs(call);
|
||||
current_function_builder_->Emit(kExprF64Max);
|
||||
} else {
|
||||
@ -1331,13 +1331,13 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
}
|
||||
case AsmTyper::kMathAtan2: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Atan2);
|
||||
break;
|
||||
}
|
||||
case AsmTyper::kMathPow: {
|
||||
VisitCallArgs(call);
|
||||
DCHECK_EQ(kAstF64, call_type);
|
||||
DCHECK_EQ(kWasmF64, call_type);
|
||||
current_function_builder_->Emit(kExprF64Pow);
|
||||
break;
|
||||
}
|
||||
@ -1418,11 +1418,11 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
VariableProxy* vp = expr->expression()->AsVariableProxy();
|
||||
DCHECK_NOT_NULL(vp);
|
||||
if (typer_->TypeOf(vp)->AsFFIType() != nullptr) {
|
||||
LocalType return_type = TypeOf(expr);
|
||||
ValueType return_type = TypeOf(expr);
|
||||
ZoneList<Expression*>* args = expr->arguments();
|
||||
FunctionSig::Builder sig(zone(), return_type == kAstStmt ? 0 : 1,
|
||||
FunctionSig::Builder sig(zone(), return_type == kWasmStmt ? 0 : 1,
|
||||
args->length());
|
||||
if (return_type != kAstStmt) {
|
||||
if (return_type != kWasmStmt) {
|
||||
sig.AddReturn(return_type);
|
||||
} else {
|
||||
returns_value = false;
|
||||
@ -1466,7 +1466,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
// We have to use a temporary for the correct order of evaluation.
|
||||
current_function_builder_->EmitI32Const(indices->start_index);
|
||||
current_function_builder_->Emit(kExprI32Add);
|
||||
WasmTemporary tmp(current_function_builder_, kAstI32);
|
||||
WasmTemporary tmp(current_function_builder_, kWasmI32);
|
||||
current_function_builder_->EmitSetLocal(tmp.index());
|
||||
|
||||
VisitCallArgs(expr);
|
||||
@ -1496,7 +1496,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
RECURSE(Visit(expr->expression()));
|
||||
switch (expr->op()) {
|
||||
case Token::NOT: {
|
||||
DCHECK_EQ(kAstI32, TypeOf(expr->expression()));
|
||||
DCHECK_EQ(kWasmI32, TypeOf(expr->expression()));
|
||||
current_function_builder_->Emit(kExprI32Eqz);
|
||||
break;
|
||||
}
|
||||
@ -1511,7 +1511,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
int32_t val) {
|
||||
DCHECK_NOT_NULL(expr->right());
|
||||
if (expr->op() == op && expr->right()->IsLiteral() &&
|
||||
TypeOf(expr) == kAstI32) {
|
||||
TypeOf(expr) == kWasmI32) {
|
||||
Literal* right = expr->right()->AsLiteral();
|
||||
if (right->raw_value()->IsNumber() &&
|
||||
static_cast<int32_t>(right->raw_value()->AsNumber()) == val) {
|
||||
@ -1525,7 +1525,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
double val) {
|
||||
DCHECK_NOT_NULL(expr->right());
|
||||
if (expr->op() == op && expr->right()->IsLiteral() &&
|
||||
TypeOf(expr) == kAstF64) {
|
||||
TypeOf(expr) == kWasmF64) {
|
||||
Literal* right = expr->right()->AsLiteral();
|
||||
DCHECK(right->raw_value()->IsNumber());
|
||||
if (right->raw_value()->AsNumber() == val) {
|
||||
@ -1539,7 +1539,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
|
||||
ConvertOperation MatchOr(BinaryOperation* expr) {
|
||||
if (MatchIntBinaryOperation(expr, Token::BIT_OR, 0) &&
|
||||
(TypeOf(expr->left()) == kAstI32)) {
|
||||
(TypeOf(expr->left()) == kWasmI32)) {
|
||||
return kAsIs;
|
||||
} else {
|
||||
return kNone;
|
||||
@ -1549,7 +1549,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
ConvertOperation MatchShr(BinaryOperation* expr) {
|
||||
if (MatchIntBinaryOperation(expr, Token::SHR, 0)) {
|
||||
// TODO(titzer): this probably needs to be kToUint
|
||||
return (TypeOf(expr->left()) == kAstI32) ? kAsIs : kToInt;
|
||||
return (TypeOf(expr->left()) == kWasmI32) ? kAsIs : kToInt;
|
||||
} else {
|
||||
return kNone;
|
||||
}
|
||||
@ -1557,13 +1557,13 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
|
||||
ConvertOperation MatchXor(BinaryOperation* expr) {
|
||||
if (MatchIntBinaryOperation(expr, Token::BIT_XOR, 0xffffffff)) {
|
||||
DCHECK_EQ(kAstI32, TypeOf(expr->left()));
|
||||
DCHECK_EQ(kAstI32, TypeOf(expr->right()));
|
||||
DCHECK_EQ(kWasmI32, TypeOf(expr->left()));
|
||||
DCHECK_EQ(kWasmI32, TypeOf(expr->right()));
|
||||
BinaryOperation* op = expr->left()->AsBinaryOperation();
|
||||
if (op != nullptr) {
|
||||
if (MatchIntBinaryOperation(op, Token::BIT_XOR, 0xffffffff)) {
|
||||
DCHECK_EQ(kAstI32, TypeOf(op->right()));
|
||||
if (TypeOf(op->left()) != kAstI32) {
|
||||
DCHECK_EQ(kWasmI32, TypeOf(op->right()));
|
||||
if (TypeOf(op->left()) != kWasmI32) {
|
||||
return kToInt;
|
||||
} else {
|
||||
return kAsIs;
|
||||
@ -1576,8 +1576,8 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
|
||||
ConvertOperation MatchMul(BinaryOperation* expr) {
|
||||
if (MatchDoubleBinaryOperation(expr, Token::MUL, 1.0)) {
|
||||
DCHECK_EQ(kAstF64, TypeOf(expr->right()));
|
||||
if (TypeOf(expr->left()) != kAstF64) {
|
||||
DCHECK_EQ(kWasmF64, TypeOf(expr->right()));
|
||||
if (TypeOf(expr->left()) != kWasmF64) {
|
||||
return kToDouble;
|
||||
} else {
|
||||
return kAsIs;
|
||||
@ -1836,7 +1836,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
uint32_t index;
|
||||
};
|
||||
|
||||
uint32_t LookupOrInsertLocal(Variable* v, LocalType type) {
|
||||
uint32_t LookupOrInsertLocal(Variable* v, ValueType type) {
|
||||
DCHECK_NOT_NULL(current_function_builder_);
|
||||
ZoneHashMap::Entry* entry =
|
||||
local_variables_.Lookup(v, ComputePointerHash(v));
|
||||
@ -1853,7 +1853,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
return (reinterpret_cast<IndexContainer*>(entry->value))->index;
|
||||
}
|
||||
|
||||
void InsertParameter(Variable* v, LocalType type, uint32_t index) {
|
||||
void InsertParameter(Variable* v, ValueType type, uint32_t index) {
|
||||
DCHECK(v->IsParameter());
|
||||
DCHECK_NOT_NULL(current_function_builder_);
|
||||
ZoneHashMap::Entry* entry =
|
||||
@ -1866,7 +1866,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
entry->value = container;
|
||||
}
|
||||
|
||||
uint32_t LookupOrInsertGlobal(Variable* v, LocalType type) {
|
||||
uint32_t LookupOrInsertGlobal(Variable* v, ValueType type) {
|
||||
ZoneHashMap::Entry* entry =
|
||||
global_variables_.Lookup(v, ComputePointerHash(v));
|
||||
if (entry == nullptr) {
|
||||
@ -1887,14 +1887,14 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
auto* func_type = typer_->TypeOf(v)->AsFunctionType();
|
||||
DCHECK_NOT_NULL(func_type);
|
||||
// Build the signature for the function.
|
||||
LocalType return_type = TypeFrom(func_type->ReturnType());
|
||||
ValueType return_type = TypeFrom(func_type->ReturnType());
|
||||
const auto& arguments = func_type->Arguments();
|
||||
FunctionSig::Builder b(zone(), return_type == kAstStmt ? 0 : 1,
|
||||
FunctionSig::Builder b(zone(), return_type == kWasmStmt ? 0 : 1,
|
||||
arguments.size());
|
||||
if (return_type != kAstStmt) b.AddReturn(return_type);
|
||||
if (return_type != kWasmStmt) b.AddReturn(return_type);
|
||||
for (int i = 0; i < static_cast<int>(arguments.size()); ++i) {
|
||||
LocalType type = TypeFrom(arguments[i]);
|
||||
DCHECK_NE(kAstStmt, type);
|
||||
ValueType type = TypeFrom(arguments[i]);
|
||||
DCHECK_NE(kWasmStmt, type);
|
||||
b.AddParam(type);
|
||||
}
|
||||
|
||||
@ -1909,22 +1909,22 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
|
||||
return (reinterpret_cast<WasmFunctionBuilder*>(entry->value));
|
||||
}
|
||||
|
||||
LocalType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); }
|
||||
ValueType TypeOf(Expression* expr) { return TypeFrom(typer_->TypeOf(expr)); }
|
||||
|
||||
LocalType TypeFrom(AsmType* type) {
|
||||
ValueType TypeFrom(AsmType* type) {
|
||||
if (type->IsA(AsmType::Intish())) {
|
||||
return kAstI32;
|
||||
return kWasmI32;
|
||||
}
|
||||
|
||||
if (type->IsA(AsmType::Floatish())) {
|
||||
return kAstF32;
|
||||
return kWasmF32;
|
||||
}
|
||||
|
||||
if (type->IsA(AsmType::DoubleQ())) {
|
||||
return kAstF64;
|
||||
return kWasmF64;
|
||||
}
|
||||
|
||||
return kAstStmt;
|
||||
return kWasmStmt;
|
||||
}
|
||||
|
||||
Zone* zone() { return zone_; }
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ struct SsaEnv {
|
||||
struct Value {
|
||||
const byte* pc;
|
||||
TFNode* node;
|
||||
LocalType type;
|
||||
ValueType type;
|
||||
};
|
||||
|
||||
struct TryInfo : public ZoneObject {
|
||||
@ -174,14 +174,14 @@ class WasmDecoder : public Decoder {
|
||||
ModuleEnv* module_;
|
||||
FunctionSig* sig_;
|
||||
size_t total_locals_;
|
||||
ZoneVector<LocalType>* local_types_;
|
||||
ZoneVector<ValueType>* local_types_;
|
||||
|
||||
inline bool Validate(const byte* pc, LocalIndexOperand& operand) {
|
||||
if (operand.index < total_locals_) {
|
||||
if (local_types_) {
|
||||
operand.type = local_types_->at(operand.index);
|
||||
} else {
|
||||
operand.type = kAstStmt;
|
||||
operand.type = kWasmStmt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -469,12 +469,12 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
decls.local_types.reserve(local_type_vec_.size());
|
||||
for (size_t pos = 0; pos < local_type_vec_.size();) {
|
||||
uint32_t count = 0;
|
||||
LocalType type = local_type_vec_[pos];
|
||||
ValueType type = local_type_vec_[pos];
|
||||
while (pos < local_type_vec_.size() && local_type_vec_[pos] == type) {
|
||||
pos++;
|
||||
count++;
|
||||
}
|
||||
decls.local_types.push_back(std::pair<LocalType, uint32_t>(type, count));
|
||||
decls.local_types.push_back(std::pair<ValueType, uint32_t>(type, count));
|
||||
}
|
||||
decls.total_local_count = static_cast<uint32_t>(local_type_vec_.size());
|
||||
return true;
|
||||
@ -486,7 +486,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
local_type_vec_.reserve(num_locals);
|
||||
if (num_locals > local_type_vec_.size()) {
|
||||
local_type_vec_.insert(local_type_vec_.end(),
|
||||
num_locals - local_type_vec_.size(), kAstI32);
|
||||
num_locals - local_type_vec_.size(), kWasmI32);
|
||||
}
|
||||
return AnalyzeLoopAssignment(pc);
|
||||
}
|
||||
@ -500,7 +500,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
|
||||
SsaEnv* ssa_env_;
|
||||
|
||||
ZoneVector<LocalType> local_type_vec_; // types of local variables.
|
||||
ZoneVector<ValueType> local_type_vec_; // types of local variables.
|
||||
ZoneVector<Value> stack_; // stack of values.
|
||||
ZoneVector<Control> control_; // stack of blocks, loops, and ifs.
|
||||
bool last_end_found_;
|
||||
@ -528,7 +528,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
index++;
|
||||
}
|
||||
while (index < local_type_vec_.size()) {
|
||||
LocalType type = local_type_vec_[index];
|
||||
ValueType type = local_type_vec_[index];
|
||||
TFNode* node = DefaultValue(type);
|
||||
while (index < local_type_vec_.size() &&
|
||||
local_type_vec_[index] == type) {
|
||||
@ -546,17 +546,17 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
TFNode* DefaultValue(LocalType type) {
|
||||
TFNode* DefaultValue(ValueType type) {
|
||||
switch (type) {
|
||||
case kAstI32:
|
||||
case kWasmI32:
|
||||
return builder_->Int32Constant(0);
|
||||
case kAstI64:
|
||||
case kWasmI64:
|
||||
return builder_->Int64Constant(0);
|
||||
case kAstF32:
|
||||
case kWasmF32:
|
||||
return builder_->Float32Constant(0);
|
||||
case kAstF64:
|
||||
case kWasmF64:
|
||||
return builder_->Float64Constant(0);
|
||||
case kAstS128:
|
||||
case kWasmS128:
|
||||
return builder_->CreateS128Value(0);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -595,22 +595,22 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
return;
|
||||
}
|
||||
byte code = consume_u8("local type");
|
||||
LocalType type;
|
||||
ValueType type;
|
||||
switch (code) {
|
||||
case kLocalI32:
|
||||
type = kAstI32;
|
||||
type = kWasmI32;
|
||||
break;
|
||||
case kLocalI64:
|
||||
type = kAstI64;
|
||||
type = kWasmI64;
|
||||
break;
|
||||
case kLocalF32:
|
||||
type = kAstF32;
|
||||
type = kWasmF32;
|
||||
break;
|
||||
case kLocalF64:
|
||||
type = kAstF64;
|
||||
type = kWasmF64;
|
||||
break;
|
||||
case kLocalS128:
|
||||
type = kAstS128;
|
||||
type = kWasmS128;
|
||||
break;
|
||||
default:
|
||||
error(pc_ - 1, "invalid local type");
|
||||
@ -676,7 +676,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
case kExprThrow: {
|
||||
CHECK_PROTOTYPE_OPCODE(wasm_eh_prototype);
|
||||
Value value = Pop(0, kAstI32);
|
||||
Value value = Pop(0, kWasmI32);
|
||||
BUILD(Throw, value.node);
|
||||
break;
|
||||
}
|
||||
@ -749,7 +749,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
case kExprIf: {
|
||||
// Condition on top of stack. Split environments for branches.
|
||||
BlockTypeOperand operand(this, pc_);
|
||||
Value cond = Pop(0, kAstI32);
|
||||
Value cond = Pop(0, kWasmI32);
|
||||
TFNode* if_true = nullptr;
|
||||
TFNode* if_false = nullptr;
|
||||
BUILD(BranchNoHint, cond.node, &if_true, &if_false);
|
||||
@ -857,19 +857,19 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
break;
|
||||
}
|
||||
case kExprSelect: {
|
||||
Value cond = Pop(2, kAstI32);
|
||||
Value cond = Pop(2, kWasmI32);
|
||||
Value fval = Pop();
|
||||
Value tval = Pop();
|
||||
if (tval.type == kAstStmt || tval.type != fval.type) {
|
||||
if (tval.type != kAstEnd && fval.type != kAstEnd) {
|
||||
if (tval.type == kWasmStmt || tval.type != fval.type) {
|
||||
if (tval.type != kWasmEnd && fval.type != kWasmEnd) {
|
||||
error("type mismatch in select");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (build()) {
|
||||
DCHECK(tval.type != kAstEnd);
|
||||
DCHECK(fval.type != kAstEnd);
|
||||
DCHECK(cond.type != kAstEnd);
|
||||
DCHECK(tval.type != kWasmEnd);
|
||||
DCHECK(fval.type != kWasmEnd);
|
||||
DCHECK(cond.type != kWasmEnd);
|
||||
TFNode* controls[2];
|
||||
builder_->BranchNoHint(cond.node, &controls[0], &controls[1]);
|
||||
TFNode* merge = builder_->Merge(2, controls);
|
||||
@ -893,7 +893,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
case kExprBrIf: {
|
||||
BreakDepthOperand operand(this, pc_);
|
||||
Value cond = Pop(0, kAstI32);
|
||||
Value cond = Pop(0, kWasmI32);
|
||||
if (ok() && Validate(pc_, operand, control_)) {
|
||||
SsaEnv* fenv = ssa_env_;
|
||||
SsaEnv* tenv = Split(fenv);
|
||||
@ -910,7 +910,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
BranchTableOperand operand(this, pc_);
|
||||
BranchTableIterator iterator(this, operand);
|
||||
if (Validate(pc_, operand, control_.size())) {
|
||||
Value key = Pop(0, kAstI32);
|
||||
Value key = Pop(0, kWasmI32);
|
||||
if (failed()) break;
|
||||
|
||||
SsaEnv* break_env = ssa_env_;
|
||||
@ -962,31 +962,31 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
case kExprI8Const: {
|
||||
ImmI8Operand operand(this, pc_);
|
||||
Push(kAstI32, BUILD(Int32Constant, operand.value));
|
||||
Push(kWasmI32, BUILD(Int32Constant, operand.value));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
case kExprI32Const: {
|
||||
ImmI32Operand operand(this, pc_);
|
||||
Push(kAstI32, BUILD(Int32Constant, operand.value));
|
||||
Push(kWasmI32, BUILD(Int32Constant, operand.value));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
case kExprI64Const: {
|
||||
ImmI64Operand operand(this, pc_);
|
||||
Push(kAstI64, BUILD(Int64Constant, operand.value));
|
||||
Push(kWasmI64, BUILD(Int64Constant, operand.value));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
case kExprF32Const: {
|
||||
ImmF32Operand operand(this, pc_);
|
||||
Push(kAstF32, BUILD(Float32Constant, operand.value));
|
||||
Push(kWasmF32, BUILD(Float32Constant, operand.value));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
case kExprF64Const: {
|
||||
ImmF64Operand operand(this, pc_);
|
||||
Push(kAstF64, BUILD(Float64Constant, operand.value));
|
||||
Push(kWasmF64, BUILD(Float64Constant, operand.value));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
@ -1048,79 +1048,79 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
break;
|
||||
}
|
||||
case kExprI32LoadMem8S:
|
||||
len = DecodeLoadMem(kAstI32, MachineType::Int8());
|
||||
len = DecodeLoadMem(kWasmI32, MachineType::Int8());
|
||||
break;
|
||||
case kExprI32LoadMem8U:
|
||||
len = DecodeLoadMem(kAstI32, MachineType::Uint8());
|
||||
len = DecodeLoadMem(kWasmI32, MachineType::Uint8());
|
||||
break;
|
||||
case kExprI32LoadMem16S:
|
||||
len = DecodeLoadMem(kAstI32, MachineType::Int16());
|
||||
len = DecodeLoadMem(kWasmI32, MachineType::Int16());
|
||||
break;
|
||||
case kExprI32LoadMem16U:
|
||||
len = DecodeLoadMem(kAstI32, MachineType::Uint16());
|
||||
len = DecodeLoadMem(kWasmI32, MachineType::Uint16());
|
||||
break;
|
||||
case kExprI32LoadMem:
|
||||
len = DecodeLoadMem(kAstI32, MachineType::Int32());
|
||||
len = DecodeLoadMem(kWasmI32, MachineType::Int32());
|
||||
break;
|
||||
case kExprI64LoadMem8S:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Int8());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Int8());
|
||||
break;
|
||||
case kExprI64LoadMem8U:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Uint8());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Uint8());
|
||||
break;
|
||||
case kExprI64LoadMem16S:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Int16());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Int16());
|
||||
break;
|
||||
case kExprI64LoadMem16U:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Uint16());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Uint16());
|
||||
break;
|
||||
case kExprI64LoadMem32S:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Int32());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Int32());
|
||||
break;
|
||||
case kExprI64LoadMem32U:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Uint32());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Uint32());
|
||||
break;
|
||||
case kExprI64LoadMem:
|
||||
len = DecodeLoadMem(kAstI64, MachineType::Int64());
|
||||
len = DecodeLoadMem(kWasmI64, MachineType::Int64());
|
||||
break;
|
||||
case kExprF32LoadMem:
|
||||
len = DecodeLoadMem(kAstF32, MachineType::Float32());
|
||||
len = DecodeLoadMem(kWasmF32, MachineType::Float32());
|
||||
break;
|
||||
case kExprF64LoadMem:
|
||||
len = DecodeLoadMem(kAstF64, MachineType::Float64());
|
||||
len = DecodeLoadMem(kWasmF64, MachineType::Float64());
|
||||
break;
|
||||
case kExprI32StoreMem8:
|
||||
len = DecodeStoreMem(kAstI32, MachineType::Int8());
|
||||
len = DecodeStoreMem(kWasmI32, MachineType::Int8());
|
||||
break;
|
||||
case kExprI32StoreMem16:
|
||||
len = DecodeStoreMem(kAstI32, MachineType::Int16());
|
||||
len = DecodeStoreMem(kWasmI32, MachineType::Int16());
|
||||
break;
|
||||
case kExprI32StoreMem:
|
||||
len = DecodeStoreMem(kAstI32, MachineType::Int32());
|
||||
len = DecodeStoreMem(kWasmI32, MachineType::Int32());
|
||||
break;
|
||||
case kExprI64StoreMem8:
|
||||
len = DecodeStoreMem(kAstI64, MachineType::Int8());
|
||||
len = DecodeStoreMem(kWasmI64, MachineType::Int8());
|
||||
break;
|
||||
case kExprI64StoreMem16:
|
||||
len = DecodeStoreMem(kAstI64, MachineType::Int16());
|
||||
len = DecodeStoreMem(kWasmI64, MachineType::Int16());
|
||||
break;
|
||||
case kExprI64StoreMem32:
|
||||
len = DecodeStoreMem(kAstI64, MachineType::Int32());
|
||||
len = DecodeStoreMem(kWasmI64, MachineType::Int32());
|
||||
break;
|
||||
case kExprI64StoreMem:
|
||||
len = DecodeStoreMem(kAstI64, MachineType::Int64());
|
||||
len = DecodeStoreMem(kWasmI64, MachineType::Int64());
|
||||
break;
|
||||
case kExprF32StoreMem:
|
||||
len = DecodeStoreMem(kAstF32, MachineType::Float32());
|
||||
len = DecodeStoreMem(kWasmF32, MachineType::Float32());
|
||||
break;
|
||||
case kExprF64StoreMem:
|
||||
len = DecodeStoreMem(kAstF64, MachineType::Float64());
|
||||
len = DecodeStoreMem(kWasmF64, MachineType::Float64());
|
||||
break;
|
||||
case kExprGrowMemory: {
|
||||
MemoryIndexOperand operand(this, pc_);
|
||||
if (module_->module->origin != kAsmJsOrigin) {
|
||||
Value val = Pop(0, kAstI32);
|
||||
Push(kAstI32, BUILD(GrowMemory, val.node));
|
||||
Value val = Pop(0, kWasmI32);
|
||||
Push(kWasmI32, BUILD(GrowMemory, val.node));
|
||||
} else {
|
||||
error("grow_memory is not supported for asmjs modules");
|
||||
}
|
||||
@ -1129,7 +1129,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
case kExprMemorySize: {
|
||||
MemoryIndexOperand operand(this, pc_);
|
||||
Push(kAstI32, BUILD(CurrentMemoryPages));
|
||||
Push(kWasmI32, BUILD(CurrentMemoryPages));
|
||||
len = 1 + operand.length;
|
||||
break;
|
||||
}
|
||||
@ -1147,7 +1147,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
case kExprCallIndirect: {
|
||||
CallIndirectOperand operand(this, pc_);
|
||||
if (Validate(pc_, operand)) {
|
||||
Value index = Pop(0, kAstI32);
|
||||
Value index = Pop(0, kWasmI32);
|
||||
TFNode** buffer = PopArgs(operand.sig);
|
||||
if (buffer) buffer[0] = index.node;
|
||||
TFNode** rets = nullptr;
|
||||
@ -1276,8 +1276,8 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
LocalType GetReturnType(FunctionSig* sig) {
|
||||
return sig->return_count() == 0 ? kAstStmt : sig->GetReturn();
|
||||
ValueType GetReturnType(FunctionSig* sig) {
|
||||
return sig->return_count() == 0 ? kWasmStmt : sig->GetReturn();
|
||||
}
|
||||
|
||||
void PushBlock(SsaEnv* end_env) {
|
||||
@ -1307,46 +1307,46 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
|
||||
void PopControl() { control_.pop_back(); }
|
||||
|
||||
int DecodeLoadMem(LocalType type, MachineType mem_type) {
|
||||
int DecodeLoadMem(ValueType type, MachineType mem_type) {
|
||||
MemoryAccessOperand operand(this, pc_,
|
||||
ElementSizeLog2Of(mem_type.representation()));
|
||||
|
||||
Value index = Pop(0, kAstI32);
|
||||
Value index = Pop(0, kWasmI32);
|
||||
TFNode* node = BUILD(LoadMem, type, mem_type, index.node, operand.offset,
|
||||
operand.alignment, position());
|
||||
Push(type, node);
|
||||
return 1 + operand.length;
|
||||
}
|
||||
|
||||
int DecodeStoreMem(LocalType type, MachineType mem_type) {
|
||||
int DecodeStoreMem(ValueType type, MachineType mem_type) {
|
||||
MemoryAccessOperand operand(this, pc_,
|
||||
ElementSizeLog2Of(mem_type.representation()));
|
||||
Value val = Pop(1, type);
|
||||
Value index = Pop(0, kAstI32);
|
||||
Value index = Pop(0, kWasmI32);
|
||||
BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment,
|
||||
val.node, position());
|
||||
return 1 + operand.length;
|
||||
}
|
||||
|
||||
unsigned ExtractLane(WasmOpcode opcode, LocalType type) {
|
||||
unsigned ExtractLane(WasmOpcode opcode, ValueType type) {
|
||||
LaneOperand operand(this, pc_);
|
||||
if (Validate(pc_, operand)) {
|
||||
compiler::NodeVector inputs(1, zone_);
|
||||
inputs[0] = Pop(0, LocalType::kSimd128).node;
|
||||
inputs[0] = Pop(0, ValueType::kSimd128).node;
|
||||
TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs);
|
||||
Push(type, node);
|
||||
}
|
||||
return operand.length;
|
||||
}
|
||||
|
||||
unsigned ReplaceLane(WasmOpcode opcode, LocalType type) {
|
||||
unsigned ReplaceLane(WasmOpcode opcode, ValueType type) {
|
||||
LaneOperand operand(this, pc_);
|
||||
if (Validate(pc_, operand)) {
|
||||
compiler::NodeVector inputs(2, zone_);
|
||||
inputs[1] = Pop(1, type).node;
|
||||
inputs[0] = Pop(0, LocalType::kSimd128).node;
|
||||
inputs[0] = Pop(0, ValueType::kSimd128).node;
|
||||
TFNode* node = BUILD(SimdLaneOp, opcode, operand.lane, inputs);
|
||||
Push(LocalType::kSimd128, node);
|
||||
Push(ValueType::kSimd128, node);
|
||||
}
|
||||
return operand.length;
|
||||
}
|
||||
@ -1355,19 +1355,19 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
unsigned len = 0;
|
||||
switch (opcode) {
|
||||
case kExprI32x4ExtractLane: {
|
||||
len = ExtractLane(opcode, LocalType::kWord32);
|
||||
len = ExtractLane(opcode, ValueType::kWord32);
|
||||
break;
|
||||
}
|
||||
case kExprF32x4ExtractLane: {
|
||||
len = ExtractLane(opcode, LocalType::kFloat32);
|
||||
len = ExtractLane(opcode, ValueType::kFloat32);
|
||||
break;
|
||||
}
|
||||
case kExprI32x4ReplaceLane: {
|
||||
len = ReplaceLane(opcode, LocalType::kWord32);
|
||||
len = ReplaceLane(opcode, ValueType::kWord32);
|
||||
break;
|
||||
}
|
||||
case kExprF32x4ReplaceLane: {
|
||||
len = ReplaceLane(opcode, LocalType::kFloat32);
|
||||
len = ReplaceLane(opcode, ValueType::kFloat32);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -1405,8 +1405,8 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
EndControl();
|
||||
}
|
||||
|
||||
void Push(LocalType type, TFNode* node) {
|
||||
if (type != kAstStmt && type != kAstEnd) {
|
||||
void Push(ValueType type, TFNode* node) {
|
||||
if (type != kWasmStmt && type != kWasmEnd) {
|
||||
stack_.push_back({pc_, node, type});
|
||||
}
|
||||
}
|
||||
@ -1423,14 +1423,14 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
return WasmOpcodes::ShortOpcodeName(static_cast<WasmOpcode>(*pc));
|
||||
}
|
||||
|
||||
Value Pop(int index, LocalType expected) {
|
||||
Value Pop(int index, ValueType expected) {
|
||||
if (!ssa_env_->go()) {
|
||||
// Unreachable code is essentially not typechecked.
|
||||
return {pc_, nullptr, expected};
|
||||
}
|
||||
Value val = Pop();
|
||||
if (val.type != expected) {
|
||||
if (val.type != kAstEnd) {
|
||||
if (val.type != kWasmEnd) {
|
||||
error(pc_, val.pc, "%s[%d] expected type %s, found %s of type %s",
|
||||
SafeOpcodeNameAt(pc_), index, WasmOpcodes::TypeName(expected),
|
||||
SafeOpcodeNameAt(val.pc), WasmOpcodes::TypeName(val.type));
|
||||
@ -1442,11 +1442,11 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
Value Pop() {
|
||||
if (!ssa_env_->go()) {
|
||||
// Unreachable code is essentially not typechecked.
|
||||
return {pc_, nullptr, kAstEnd};
|
||||
return {pc_, nullptr, kWasmEnd};
|
||||
}
|
||||
size_t limit = control_.empty() ? 0 : control_.back().stack_depth;
|
||||
if (stack_.size() <= limit) {
|
||||
Value val = {pc_, nullptr, kAstStmt};
|
||||
Value val = {pc_, nullptr, kWasmStmt};
|
||||
error(pc_, pc_, "%s found empty stack", SafeOpcodeNameAt(pc_));
|
||||
return val;
|
||||
}
|
||||
@ -1458,10 +1458,10 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
Value PopUpTo(int stack_depth) {
|
||||
if (!ssa_env_->go()) {
|
||||
// Unreachable code is essentially not typechecked.
|
||||
return {pc_, nullptr, kAstEnd};
|
||||
return {pc_, nullptr, kWasmEnd};
|
||||
}
|
||||
if (stack_depth == static_cast<int>(stack_.size())) {
|
||||
Value val = {pc_, nullptr, kAstStmt};
|
||||
Value val = {pc_, nullptr, kWasmStmt};
|
||||
return val;
|
||||
} else {
|
||||
DCHECK_LE(stack_depth, stack_.size());
|
||||
@ -1626,7 +1626,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
} else {
|
||||
DCHECK_EQ(SsaEnv::kMerged, try_info->catch_env->state);
|
||||
try_info->exception =
|
||||
CreateOrMergeIntoPhi(kAstI32, try_info->catch_env->control,
|
||||
CreateOrMergeIntoPhi(kWasmI32, try_info->catch_env->control,
|
||||
try_info->exception, if_exception);
|
||||
}
|
||||
|
||||
@ -1710,7 +1710,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
return from->Kill();
|
||||
}
|
||||
|
||||
TFNode* CreateOrMergeIntoPhi(LocalType type, TFNode* merge, TFNode* tnode,
|
||||
TFNode* CreateOrMergeIntoPhi(ValueType type, TFNode* merge, TFNode* tnode,
|
||||
TFNode* fnode) {
|
||||
DCHECK_NOT_NULL(builder_);
|
||||
if (builder_->IsPhiWithMerge(tnode, merge)) {
|
||||
@ -1955,7 +1955,7 @@ bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
|
||||
if (body.start != i.pc() && !FLAG_wasm_code_fuzzer_gen_test) {
|
||||
os << "// locals: ";
|
||||
for (auto p : decls.local_types) {
|
||||
LocalType type = p.first;
|
||||
ValueType type = p.first;
|
||||
uint32_t count = p.second;
|
||||
os << " " << count << " " << WasmOpcodes::TypeName(type);
|
||||
}
|
||||
|
@ -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 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<LocalType> FunctionSig;
|
||||
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});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ static const byte kCodeGetLocal1[] = {kExprGetLocal, 1};
|
||||
static const byte kCodeSetLocal0[] = {WASM_SET_LOCAL(0, WASM_ZERO)};
|
||||
static const byte kCodeTeeLocal0[] = {WASM_TEE_LOCAL(0, WASM_ZERO)};
|
||||
|
||||
static const LocalType kLocalTypes[] = {kAstI32, kAstI64, kAstF32, kAstF64};
|
||||
static const ValueType kValueTypes[] = {kWasmI32, kWasmI64, kWasmF32, kWasmF64};
|
||||
static const MachineType machineTypes[] = {
|
||||
MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
|
||||
MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
|
||||
@ -85,7 +85,7 @@ static bool old_eh_flag;
|
||||
|
||||
class FunctionBodyDecoderTest : public TestWithZone {
|
||||
public:
|
||||
typedef std::pair<uint32_t, LocalType> LocalsDecl;
|
||||
typedef std::pair<uint32_t, ValueType> LocalsDecl;
|
||||
|
||||
FunctionBodyDecoderTest() : module(nullptr), local_decls(zone()) {}
|
||||
|
||||
@ -100,7 +100,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
|
||||
ModuleEnv* module;
|
||||
LocalDeclEncoder local_decls;
|
||||
|
||||
void AddLocals(LocalType type, uint32_t count) {
|
||||
void AddLocals(ValueType type, uint32_t count) {
|
||||
local_decls.AddLocals(count, type);
|
||||
}
|
||||
|
||||
@ -139,10 +139,10 @@ class FunctionBodyDecoderTest : public TestWithZone {
|
||||
EXPECT_VERIFIES_SC(success, code);
|
||||
|
||||
// Try all combinations of return and parameter types.
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
for (size_t k = 0; k < arraysize(kLocalTypes); k++) {
|
||||
LocalType types[] = {kLocalTypes[i], kLocalTypes[j], kLocalTypes[k]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
for (size_t k = 0; k < arraysize(kValueTypes); k++) {
|
||||
ValueType types[] = {kValueTypes[i], kValueTypes[j], kValueTypes[k]};
|
||||
if (types[0] != success->GetReturn(0) ||
|
||||
types[1] != success->GetParam(0) ||
|
||||
types[2] != success->GetParam(1)) {
|
||||
@ -159,19 +159,19 @@ class FunctionBodyDecoderTest : public TestWithZone {
|
||||
TestUnop(opcode, success->GetReturn(), success->GetParam(0));
|
||||
}
|
||||
|
||||
void TestUnop(WasmOpcode opcode, LocalType ret_type, LocalType param_type) {
|
||||
void TestUnop(WasmOpcode opcode, ValueType ret_type, ValueType param_type) {
|
||||
// Return(op(local[0]))
|
||||
byte code[] = {WASM_UNOP(opcode, WASM_GET_LOCAL(0))};
|
||||
{
|
||||
LocalType types[] = {ret_type, param_type};
|
||||
ValueType types[] = {ret_type, param_type};
|
||||
FunctionSig sig(1, 1, types);
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
}
|
||||
|
||||
// Try all combinations of return and parameter types.
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType types[] = {kLocalTypes[i], kLocalTypes[j]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType types[] = {kValueTypes[i], kValueTypes[j]};
|
||||
if (types[0] != ret_type || types[1] != param_type) {
|
||||
// Test signature mismatch.
|
||||
FunctionSig sig(1, 1, types);
|
||||
@ -258,12 +258,12 @@ TEST_F(FunctionBodyDecoderTest, GetLocal0_param) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, GetLocal0_local) {
|
||||
AddLocals(kAstI32, 1);
|
||||
AddLocals(kWasmI32, 1);
|
||||
EXPECT_VERIFIES_C(i_v, kCodeGetLocal0);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, TooManyLocals) {
|
||||
AddLocals(kAstI32, 4034986500);
|
||||
AddLocals(kWasmI32, 4034986500);
|
||||
EXPECT_FAILURE_C(i_v, kCodeGetLocal0);
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ TEST_F(FunctionBodyDecoderTest, GetLocal0_param_n) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, GetLocalN_local) {
|
||||
for (byte i = 1; i < 8; i++) {
|
||||
AddLocals(kAstI32, 1);
|
||||
AddLocals(kWasmI32, 1);
|
||||
for (byte j = 0; j < i; j++) {
|
||||
byte code[] = {kExprGetLocal, j};
|
||||
EXPECT_VERIFIES_C(i_v, code);
|
||||
@ -299,23 +299,23 @@ TEST_F(FunctionBodyDecoderTest, GetLocal_off_end) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, NumLocalBelowLimit) {
|
||||
AddLocals(kAstI32, kMaxNumWasmLocals - 1);
|
||||
AddLocals(kWasmI32, kMaxNumWasmLocals - 1);
|
||||
EXPECT_VERIFIES(v_v, WASM_NOP);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, NumLocalAtLimit) {
|
||||
AddLocals(kAstI32, kMaxNumWasmLocals);
|
||||
AddLocals(kWasmI32, kMaxNumWasmLocals);
|
||||
EXPECT_VERIFIES(v_v, WASM_NOP);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, NumLocalAboveLimit) {
|
||||
AddLocals(kAstI32, kMaxNumWasmLocals + 1);
|
||||
AddLocals(kWasmI32, kMaxNumWasmLocals + 1);
|
||||
EXPECT_FAILURE(v_v, WASM_NOP);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, GetLocal_varint) {
|
||||
const int kMaxLocals = kMaxNumWasmLocals - 1;
|
||||
AddLocals(kAstI32, kMaxLocals);
|
||||
AddLocals(kWasmI32, kMaxLocals);
|
||||
|
||||
EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_1(66));
|
||||
EXPECT_VERIFIES(i_i, kExprGetLocal, U32V_2(7777));
|
||||
@ -335,8 +335,8 @@ TEST_F(FunctionBodyDecoderTest, GetLocal_varint) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, GetLocal_toomany) {
|
||||
AddLocals(kAstI32, kMaxNumWasmLocals - 100);
|
||||
AddLocals(kAstI32, 100);
|
||||
AddLocals(kWasmI32, kMaxNumWasmLocals - 100);
|
||||
AddLocals(kWasmI32, 100);
|
||||
|
||||
EXPECT_VERIFIES(i_v, kExprGetLocal, U32V_1(66));
|
||||
EXPECT_FAILURE(i_i, kExprGetLocal, U32V_1(66));
|
||||
@ -405,20 +405,20 @@ TEST_F(FunctionBodyDecoderTest, TeeLocal0_param) {
|
||||
TEST_F(FunctionBodyDecoderTest, SetLocal0_local) {
|
||||
EXPECT_FAILURE_C(i_v, kCodeSetLocal0);
|
||||
EXPECT_FAILURE_C(v_v, kCodeSetLocal0);
|
||||
AddLocals(kAstI32, 1);
|
||||
AddLocals(kWasmI32, 1);
|
||||
EXPECT_FAILURE_C(i_v, kCodeSetLocal0);
|
||||
EXPECT_VERIFIES_C(v_v, kCodeSetLocal0);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, TeeLocal0_local) {
|
||||
EXPECT_FAILURE_C(i_v, kCodeTeeLocal0);
|
||||
AddLocals(kAstI32, 1);
|
||||
AddLocals(kWasmI32, 1);
|
||||
EXPECT_VERIFIES_C(i_v, kCodeTeeLocal0);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, TeeLocalN_local) {
|
||||
for (byte i = 1; i < 8; i++) {
|
||||
AddLocals(kAstI32, 1);
|
||||
AddLocals(kWasmI32, 1);
|
||||
for (byte j = 0; j < i; j++) {
|
||||
EXPECT_FAILURE(v_v, WASM_TEE_LOCAL(j, WASM_I8(i)));
|
||||
EXPECT_VERIFIES(i_i, WASM_TEE_LOCAL(j, WASM_I8(i)));
|
||||
@ -678,11 +678,11 @@ TEST_F(FunctionBodyDecoderTest, IfElseUnreachable2) {
|
||||
static const byte code[] = {
|
||||
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_UNREACHABLE, WASM_GET_LOCAL(0))};
|
||||
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType types[] = {kAstI32, kLocalTypes[i]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType types[] = {kWasmI32, kValueTypes[i]};
|
||||
FunctionSig sig(1, 1, types);
|
||||
|
||||
if (kLocalTypes[i] == kAstI32) {
|
||||
if (kValueTypes[i] == kWasmI32) {
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code);
|
||||
@ -962,7 +962,7 @@ TEST_F(FunctionBodyDecoderTest, Int64Local_param) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Int64Locals) {
|
||||
for (byte i = 1; i < 8; i++) {
|
||||
AddLocals(kAstI64, 1);
|
||||
AddLocals(kWasmI64, 1);
|
||||
for (byte j = 0; j < i; j++) {
|
||||
EXPECT_VERIFIES(l_v, WASM_GET_LOCAL(j));
|
||||
}
|
||||
@ -1013,16 +1013,16 @@ TEST_F(FunctionBodyDecoderTest, FloatBinops) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, TypeConversions) {
|
||||
TestUnop(kExprI32SConvertF32, kAstI32, kAstF32);
|
||||
TestUnop(kExprI32SConvertF64, kAstI32, kAstF64);
|
||||
TestUnop(kExprI32UConvertF32, kAstI32, kAstF32);
|
||||
TestUnop(kExprI32UConvertF64, kAstI32, kAstF64);
|
||||
TestUnop(kExprF64SConvertI32, kAstF64, kAstI32);
|
||||
TestUnop(kExprF64UConvertI32, kAstF64, kAstI32);
|
||||
TestUnop(kExprF64ConvertF32, kAstF64, kAstF32);
|
||||
TestUnop(kExprF32SConvertI32, kAstF32, kAstI32);
|
||||
TestUnop(kExprF32UConvertI32, kAstF32, kAstI32);
|
||||
TestUnop(kExprF32ConvertF64, kAstF32, kAstF64);
|
||||
TestUnop(kExprI32SConvertF32, kWasmI32, kWasmF32);
|
||||
TestUnop(kExprI32SConvertF64, kWasmI32, kWasmF64);
|
||||
TestUnop(kExprI32UConvertF32, kWasmI32, kWasmF32);
|
||||
TestUnop(kExprI32UConvertF64, kWasmI32, kWasmF64);
|
||||
TestUnop(kExprF64SConvertI32, kWasmF64, kWasmI32);
|
||||
TestUnop(kExprF64UConvertI32, kWasmF64, kWasmI32);
|
||||
TestUnop(kExprF64ConvertF32, kWasmF64, kWasmF32);
|
||||
TestUnop(kExprF32SConvertI32, kWasmF32, kWasmI32);
|
||||
TestUnop(kExprF32UConvertI32, kWasmF32, kWasmI32);
|
||||
TestUnop(kExprF32ConvertF64, kWasmF32, kWasmF64);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MacrosStmt) {
|
||||
@ -1057,7 +1057,8 @@ TEST_F(FunctionBodyDecoderTest, MacrosNestedBlocks) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultipleReturn) {
|
||||
static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32};
|
||||
static ValueType kIntTypes5[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32,
|
||||
kWasmI32};
|
||||
FunctionSig sig_ii_v(2, 0, kIntTypes5);
|
||||
EXPECT_VERIFIES_S(&sig_ii_v, WASM_RETURNN(2, WASM_ZERO, WASM_ONE));
|
||||
EXPECT_FAILURE_S(&sig_ii_v, WASM_RETURNN(1, WASM_ZERO));
|
||||
@ -1069,7 +1070,8 @@ TEST_F(FunctionBodyDecoderTest, MultipleReturn) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultipleReturn_fallthru) {
|
||||
static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32};
|
||||
static ValueType kIntTypes5[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32,
|
||||
kWasmI32};
|
||||
FunctionSig sig_ii_v(2, 0, kIntTypes5);
|
||||
|
||||
EXPECT_VERIFIES_S(&sig_ii_v, WASM_ZERO, WASM_ONE);
|
||||
@ -1253,13 +1255,13 @@ TEST_F(FunctionBodyDecoderTest, StoreMemOffset_varint) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType local_type = kLocalTypes[i];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType local_type = kValueTypes[i];
|
||||
for (size_t j = 0; j < arraysize(machineTypes); j++) {
|
||||
MachineType mem_type = machineTypes[j];
|
||||
byte code[] = {WASM_LOAD_MEM(mem_type, WASM_ZERO)};
|
||||
FunctionSig sig(1, 0, &local_type);
|
||||
if (local_type == WasmOpcodes::LocalTypeFor(mem_type)) {
|
||||
if (local_type == WasmOpcodes::ValueTypeFor(mem_type)) {
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code);
|
||||
@ -1269,13 +1271,13 @@ TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AllStoreMemCombinations) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType local_type = kLocalTypes[i];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType local_type = kValueTypes[i];
|
||||
for (size_t j = 0; j < arraysize(machineTypes); j++) {
|
||||
MachineType mem_type = machineTypes[j];
|
||||
byte code[] = {WASM_STORE_MEM(mem_type, WASM_ZERO, WASM_GET_LOCAL(0))};
|
||||
FunctionSig sig(0, 1, &local_type);
|
||||
if (local_type == WasmOpcodes::LocalTypeFor(mem_type)) {
|
||||
if (local_type == WasmOpcodes::ValueTypeFor(mem_type)) {
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code);
|
||||
@ -1293,7 +1295,7 @@ class TestModuleEnv : public ModuleEnv {
|
||||
: ModuleEnv(&mod, nullptr) {
|
||||
mod.origin = origin;
|
||||
}
|
||||
byte AddGlobal(LocalType type, bool mutability = true) {
|
||||
byte AddGlobal(ValueType type, bool mutability = true) {
|
||||
mod.globals.push_back({type, mutability, WasmInitExpr(), 0, false, false});
|
||||
CHECK(mod.globals.size() <= 127);
|
||||
return static_cast<byte>(mod.globals.size() - 1);
|
||||
@ -1392,7 +1394,7 @@ TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs3) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultiReturn) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
LocalType storage[] = {kAstI32, kAstI32};
|
||||
ValueType storage[] = {kWasmI32, kWasmI32};
|
||||
FunctionSig sig_ii_v(2, 0, storage);
|
||||
FunctionSig sig_v_ii(0, 2, storage);
|
||||
TestModuleEnv module_env;
|
||||
@ -1408,13 +1410,13 @@ TEST_F(FunctionBodyDecoderTest, MultiReturn) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultiReturnType) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
for (size_t a = 0; a < arraysize(kLocalTypes); a++) {
|
||||
for (size_t b = 0; b < arraysize(kLocalTypes); b++) {
|
||||
for (size_t c = 0; c < arraysize(kLocalTypes); c++) {
|
||||
for (size_t d = 0; d < arraysize(kLocalTypes); d++) {
|
||||
LocalType storage_ab[] = {kLocalTypes[a], kLocalTypes[b]};
|
||||
for (size_t a = 0; a < arraysize(kValueTypes); a++) {
|
||||
for (size_t b = 0; b < arraysize(kValueTypes); b++) {
|
||||
for (size_t c = 0; c < arraysize(kValueTypes); c++) {
|
||||
for (size_t d = 0; d < arraysize(kValueTypes); d++) {
|
||||
ValueType storage_ab[] = {kValueTypes[a], kValueTypes[b]};
|
||||
FunctionSig sig_ab_v(2, 0, storage_ab);
|
||||
LocalType storage_cd[] = {kLocalTypes[c], kLocalTypes[d]};
|
||||
ValueType storage_cd[] = {kValueTypes[c], kValueTypes[d]};
|
||||
FunctionSig sig_cd_v(2, 0, storage_cd);
|
||||
|
||||
TestModuleEnv module_env;
|
||||
@ -1544,7 +1546,7 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
module_env.AddGlobal(kAstI32);
|
||||
module_env.AddGlobal(kWasmI32);
|
||||
|
||||
EXPECT_VERIFIES_S(sig, WASM_GET_GLOBAL(0));
|
||||
EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
|
||||
@ -1556,8 +1558,8 @@ TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
uint32_t g0 = module_env.AddGlobal(kAstI32, true);
|
||||
uint32_t g1 = module_env.AddGlobal(kAstI32, false);
|
||||
uint32_t g0 = module_env.AddGlobal(kWasmI32, true);
|
||||
uint32_t g1 = module_env.AddGlobal(kWasmI32, false);
|
||||
|
||||
EXPECT_VERIFIES_S(sig, WASM_SET_GLOBAL(g0, WASM_ZERO));
|
||||
EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(g1, WASM_ZERO));
|
||||
@ -1568,10 +1570,10 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
module_env.AddGlobal(kAstI64);
|
||||
module_env.AddGlobal(kAstI64);
|
||||
module_env.AddGlobal(kAstF32);
|
||||
module_env.AddGlobal(kAstF64);
|
||||
module_env.AddGlobal(kWasmI64);
|
||||
module_env.AddGlobal(kWasmI64);
|
||||
module_env.AddGlobal(kWasmF32);
|
||||
module_env.AddGlobal(kWasmF64);
|
||||
|
||||
EXPECT_FAILURE_S(sig, WASM_GET_GLOBAL(0));
|
||||
EXPECT_FAILURE_S(sig, WASM_GET_GLOBAL(1));
|
||||
@ -1589,8 +1591,8 @@ TEST_F(FunctionBodyDecoderTest, Int64Globals) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
module_env.AddGlobal(kAstI64);
|
||||
module_env.AddGlobal(kAstI64);
|
||||
module_env.AddGlobal(kWasmI64);
|
||||
module_env.AddGlobal(kWasmI64);
|
||||
|
||||
EXPECT_VERIFIES_S(sig, WASM_GET_GLOBAL(0));
|
||||
EXPECT_VERIFIES_S(sig, WASM_GET_GLOBAL(1));
|
||||
@ -1606,7 +1608,7 @@ TEST_F(FunctionBodyDecoderTest, Float32Globals) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
module_env.AddGlobal(kAstF32);
|
||||
module_env.AddGlobal(kWasmF32);
|
||||
|
||||
EXPECT_VERIFIES_S(sig, WASM_GET_GLOBAL(0));
|
||||
EXPECT_VERIFIES_S(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)),
|
||||
@ -1618,7 +1620,7 @@ TEST_F(FunctionBodyDecoderTest, Float64Globals) {
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
|
||||
module_env.AddGlobal(kAstF64);
|
||||
module_env.AddGlobal(kWasmF64);
|
||||
|
||||
EXPECT_VERIFIES_S(sig, WASM_GET_GLOBAL(0));
|
||||
EXPECT_VERIFIES_S(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)),
|
||||
@ -1626,10 +1628,10 @@ TEST_F(FunctionBodyDecoderTest, Float64Globals) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AllGetGlobalCombinations) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType local_type = kLocalTypes[i];
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType global_type = kLocalTypes[j];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType local_type = kValueTypes[i];
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType global_type = kValueTypes[j];
|
||||
FunctionSig sig(1, 0, &local_type);
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
@ -1644,10 +1646,10 @@ TEST_F(FunctionBodyDecoderTest, AllGetGlobalCombinations) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AllSetGlobalCombinations) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType local_type = kLocalTypes[i];
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType global_type = kLocalTypes[j];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType local_type = kValueTypes[i];
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType global_type = kValueTypes[j];
|
||||
FunctionSig sig(0, 1, &local_type);
|
||||
TestModuleEnv module_env;
|
||||
module = &module_env;
|
||||
@ -1679,9 +1681,9 @@ TEST_F(FunctionBodyDecoderTest, AsmJsGrowMemory) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AsmJsBinOpsCheckOrigin) {
|
||||
LocalType float32int32float32[] = {kAstF32, kAstI32, kAstF32};
|
||||
ValueType float32int32float32[] = {kWasmF32, kWasmI32, kWasmF32};
|
||||
FunctionSig sig_f_if(1, 2, float32int32float32);
|
||||
LocalType float64int32float64[] = {kAstF64, kAstI32, kAstF64};
|
||||
ValueType float64int32float64[] = {kWasmF64, kWasmI32, kWasmF64};
|
||||
FunctionSig sig_d_id(1, 2, float64int32float64);
|
||||
struct {
|
||||
WasmOpcode op;
|
||||
@ -1721,9 +1723,9 @@ TEST_F(FunctionBodyDecoderTest, AsmJsBinOpsCheckOrigin) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, AsmJsUnOpsCheckOrigin) {
|
||||
LocalType float32int32[] = {kAstF32, kAstI32};
|
||||
ValueType float32int32[] = {kWasmF32, kWasmI32};
|
||||
FunctionSig sig_f_i(1, 1, float32int32);
|
||||
LocalType float64int32[] = {kAstF64, kAstI32};
|
||||
ValueType float64int32[] = {kWasmF64, kWasmI32};
|
||||
FunctionSig sig_d_i(1, 1, float64int32);
|
||||
struct {
|
||||
WasmOpcode op;
|
||||
@ -1891,9 +1893,9 @@ TEST_F(FunctionBodyDecoderTest, Break_TypeCheck) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll1) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType storage[] = {kValueTypes[i], kValueTypes[i], kValueTypes[j]};
|
||||
FunctionSig sig(1, 2, storage);
|
||||
byte code[] = {WASM_BLOCK_T(
|
||||
sig.GetReturn(), WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))),
|
||||
@ -1909,9 +1911,9 @@ TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll1) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll2) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType storage[] = {kValueTypes[i], kValueTypes[i], kValueTypes[j]};
|
||||
FunctionSig sig(1, 2, storage);
|
||||
byte code[] = {WASM_IF_ELSE_T(sig.GetReturn(0), WASM_ZERO,
|
||||
WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)),
|
||||
@ -1927,9 +1929,9 @@ TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll2) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll3) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType storage[] = {kValueTypes[i], kValueTypes[i], kValueTypes[j]};
|
||||
FunctionSig sig(1, 2, storage);
|
||||
byte code[] = {WASM_IF_ELSE_T(sig.GetReturn(), WASM_ZERO,
|
||||
WASM_GET_LOCAL(1),
|
||||
@ -1946,16 +1948,16 @@ TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll3) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Break_Unify) {
|
||||
for (int which = 0; which < 2; which++) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType type = kLocalTypes[i];
|
||||
LocalType storage[] = {kAstI32, kAstI32, type};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType type = kValueTypes[i];
|
||||
ValueType storage[] = {kWasmI32, kWasmI32, type};
|
||||
FunctionSig sig(1, 2, storage);
|
||||
|
||||
byte code1[] = {WASM_BLOCK_T(
|
||||
type, WASM_IF(WASM_ZERO, WASM_BRV(1, WASM_GET_LOCAL(which))),
|
||||
WASM_GET_LOCAL(which ^ 1))};
|
||||
|
||||
if (type == kAstI32) {
|
||||
if (type == kWasmI32) {
|
||||
EXPECT_VERIFIES_SC(&sig, code1);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code1);
|
||||
@ -1965,14 +1967,14 @@ TEST_F(FunctionBodyDecoderTest, Break_Unify) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, BreakIf_cond_type) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType types[] = {kValueTypes[i], kValueTypes[i], kValueTypes[j]};
|
||||
FunctionSig sig(1, 2, types);
|
||||
byte code[] = {WASM_BLOCK_T(
|
||||
types[0], WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))};
|
||||
|
||||
if (types[2] == kAstI32) {
|
||||
if (types[2] == kWasmI32) {
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code);
|
||||
@ -1982,10 +1984,10 @@ TEST_F(FunctionBodyDecoderTest, BreakIf_cond_type) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, BreakIf_val_type) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
|
||||
LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j],
|
||||
kAstI32};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
|
||||
ValueType types[] = {kValueTypes[i], kValueTypes[i], kValueTypes[j],
|
||||
kWasmI32};
|
||||
FunctionSig sig(1, 3, types);
|
||||
byte code[] = {WASM_BLOCK_T(
|
||||
types[1], WASM_BRV_IF(0, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)),
|
||||
@ -2002,14 +2004,14 @@ TEST_F(FunctionBodyDecoderTest, BreakIf_val_type) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, BreakIf_Unify) {
|
||||
for (int which = 0; which < 2; which++) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType type = kLocalTypes[i];
|
||||
LocalType storage[] = {kAstI32, kAstI32, type};
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType type = kValueTypes[i];
|
||||
ValueType storage[] = {kWasmI32, kWasmI32, type};
|
||||
FunctionSig sig(1, 2, storage);
|
||||
byte code[] = {WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(which)),
|
||||
WASM_DROP, WASM_GET_LOCAL(which ^ 1))};
|
||||
|
||||
if (type == kAstI32) {
|
||||
if (type == kWasmI32) {
|
||||
EXPECT_VERIFIES_SC(&sig, code);
|
||||
} else {
|
||||
EXPECT_FAILURE_SC(&sig, code);
|
||||
@ -2141,11 +2143,11 @@ TEST_F(FunctionBodyDecoderTest, Select_fail1) {
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, Select_fail2) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType type = kLocalTypes[i];
|
||||
if (type == kAstI32) continue;
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType type = kValueTypes[i];
|
||||
if (type == kWasmI32) continue;
|
||||
|
||||
LocalType types[] = {type, kAstI32, type};
|
||||
ValueType types[] = {type, kWasmI32, type};
|
||||
FunctionSig sig(1, 2, types);
|
||||
|
||||
EXPECT_VERIFIES_S(&sig, WASM_SELECT(WASM_GET_LOCAL(1), WASM_GET_LOCAL(1),
|
||||
@ -2202,24 +2204,24 @@ TEST_F(FunctionBodyDecoderTest, TryCatch) {
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultiValBlock1) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1)),
|
||||
kExprI32Add);
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultiValBlock2) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1)),
|
||||
WASM_I32_ADD(WASM_NOP, WASM_NOP));
|
||||
}
|
||||
|
||||
TEST_F(FunctionBodyDecoderTest, MultiValBlockBr1) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
EXPECT_FAILURE(i_ii,
|
||||
WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_BR(0)),
|
||||
EXPECT_FAILURE(
|
||||
i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), WASM_BR(0)),
|
||||
kExprI32Add);
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
|
||||
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1), WASM_BR(0)),
|
||||
kExprI32Add);
|
||||
}
|
||||
@ -2227,17 +2229,17 @@ TEST_F(FunctionBodyDecoderTest, MultiValBlockBr1) {
|
||||
TEST_F(FunctionBodyDecoderTest, MultiValIf1) {
|
||||
FLAG_wasm_mv_prototype = true;
|
||||
EXPECT_FAILURE(
|
||||
i_ii, WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
|
||||
i_ii, WASM_IF_ELSE_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
|
||||
WASM_SEQ(WASM_GET_LOCAL(0)),
|
||||
WASM_SEQ(WASM_GET_LOCAL(1), WASM_GET_LOCAL(0))),
|
||||
kExprI32Add);
|
||||
EXPECT_FAILURE(i_ii,
|
||||
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))),
|
||||
kExprI32Add);
|
||||
EXPECT_VERIFIES(
|
||||
i_ii, WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
|
||||
i_ii, 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);
|
||||
@ -2543,13 +2545,13 @@ TEST_F(WasmOpcodeLengthTest, SimdExpressions) {
|
||||
EXPECT_LENGTH_N(2, kSimdPrefix, 0xff);
|
||||
}
|
||||
|
||||
typedef ZoneVector<LocalType> LocalTypeMap;
|
||||
typedef ZoneVector<ValueType> ValueTypeMap;
|
||||
|
||||
class LocalDeclDecoderTest : public TestWithZone {
|
||||
public:
|
||||
v8::internal::AccountingAllocator allocator;
|
||||
|
||||
size_t ExpectRun(LocalTypeMap map, size_t pos, LocalType expected,
|
||||
size_t ExpectRun(ValueTypeMap map, size_t pos, ValueType expected,
|
||||
size_t count) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
EXPECT_EQ(expected, map[pos++]);
|
||||
@ -2557,8 +2559,8 @@ class LocalDeclDecoderTest : public TestWithZone {
|
||||
return pos;
|
||||
}
|
||||
|
||||
LocalTypeMap Expand(BodyLocalDecls& decls) {
|
||||
ZoneVector<LocalType> map(zone());
|
||||
ValueTypeMap Expand(BodyLocalDecls& decls) {
|
||||
ZoneVector<ValueType> map(zone());
|
||||
for (auto p : decls.local_types) {
|
||||
map.insert(map.end(), p.second, p.first);
|
||||
}
|
||||
@ -2581,33 +2583,33 @@ TEST_F(LocalDeclDecoderTest, NoLocals) {
|
||||
}
|
||||
|
||||
TEST_F(LocalDeclDecoderTest, OneLocal) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType type = kLocalTypes[i];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType type = kValueTypes[i];
|
||||
const byte data[] = {
|
||||
1, 1, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))};
|
||||
1, 1, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(type))};
|
||||
BodyLocalDecls decls(zone());
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(1u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
ValueTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(1u, map.size());
|
||||
EXPECT_EQ(type, map[0]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LocalDeclDecoderTest, FiveLocals) {
|
||||
for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
|
||||
LocalType type = kLocalTypes[i];
|
||||
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
|
||||
ValueType type = kValueTypes[i];
|
||||
const byte data[] = {
|
||||
1, 5, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))};
|
||||
1, 5, static_cast<byte>(WasmOpcodes::ValueTypeCodeFor(type))};
|
||||
BodyLocalDecls decls(zone());
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(sizeof(data), decls.decls_encoded_size);
|
||||
EXPECT_EQ(5u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
ValueTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(5u, map.size());
|
||||
ExpectRun(map, 0, type, 5);
|
||||
}
|
||||
@ -2627,14 +2629,14 @@ TEST_F(LocalDeclDecoderTest, MixedLocals) {
|
||||
EXPECT_EQ(static_cast<uint32_t>(a + b + c + d),
|
||||
decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
ValueTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(static_cast<uint32_t>(a + b + c + d), map.size());
|
||||
|
||||
size_t pos = 0;
|
||||
pos = ExpectRun(map, pos, kAstI32, a);
|
||||
pos = ExpectRun(map, pos, kAstI64, b);
|
||||
pos = ExpectRun(map, pos, kAstF32, c);
|
||||
pos = ExpectRun(map, pos, kAstF64, d);
|
||||
pos = ExpectRun(map, pos, kWasmI32, a);
|
||||
pos = ExpectRun(map, pos, kWasmI64, b);
|
||||
pos = ExpectRun(map, pos, kWasmF32, c);
|
||||
pos = ExpectRun(map, pos, kWasmF64, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2646,9 +2648,9 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) {
|
||||
const byte* end = nullptr;
|
||||
LocalDeclEncoder local_decls(zone());
|
||||
|
||||
local_decls.AddLocals(5, kAstF32);
|
||||
local_decls.AddLocals(1337, kAstI32);
|
||||
local_decls.AddLocals(212, kAstI64);
|
||||
local_decls.AddLocals(5, kWasmF32);
|
||||
local_decls.AddLocals(1337, kWasmI32);
|
||||
local_decls.AddLocals(212, kWasmI64);
|
||||
local_decls.Prepend(zone(), &data, &end);
|
||||
|
||||
BodyLocalDecls decls(zone());
|
||||
@ -2656,11 +2658,11 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) {
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(5u + 1337u + 212u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
ValueTypeMap map = Expand(decls);
|
||||
size_t pos = 0;
|
||||
pos = ExpectRun(map, pos, kAstF32, 5);
|
||||
pos = ExpectRun(map, pos, kAstI32, 1337);
|
||||
pos = ExpectRun(map, pos, kAstI64, 212);
|
||||
pos = ExpectRun(map, pos, kWasmF32, 5);
|
||||
pos = ExpectRun(map, pos, kWasmI32, 1337);
|
||||
pos = ExpectRun(map, pos, kWasmI64, 212);
|
||||
}
|
||||
|
||||
class BytecodeIteratorTest : public TestWithZone {};
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user