Index: src/wasm/asm-wasm-builder.cc |
diff --git a/src/wasm/asm-wasm-builder.cc b/src/wasm/asm-wasm-builder.cc |
index 57df68b9f2c25bde9090a1b6a0d19081d1d4c08a..ca31c977f9852e538dfc3a171c23e9b1e4bbc424 100644 |
--- a/src/wasm/asm-wasm-builder.cc |
+++ b/src/wasm/asm-wasm-builder.cc |
@@ -77,7 +77,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitFunctionDeclaration(FunctionDeclaration* decl) { |
DCHECK(!in_function_); |
- DCHECK(current_function_builder_ == nullptr); |
+ DCHECK_NULL(current_function_builder_); |
uint16_t index = LookupOrInsertFunction(decl->proxy()->var()); |
current_function_builder_ = builder_->FunctionAt(index); |
in_function_ = true; |
@@ -169,7 +169,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitContinueStatement(ContinueStatement* stmt) { |
DCHECK(in_function_); |
- DCHECK(stmt->target() != NULL); |
+ DCHECK_NOT_NULL(stmt->target()); |
int i = static_cast<int>(breakable_blocks_.size()) - 1; |
int block_distance = 0; |
for (; i >= 0; i--) { |
@@ -190,7 +190,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitBreakStatement(BreakStatement* stmt) { |
DCHECK(in_function_); |
- DCHECK(stmt->target() != NULL); |
+ DCHECK_NOT_NULL(stmt->target()); |
int i = static_cast<int>(breakable_blocks_.size()) - 1; |
int block_distance = 0; |
for (; i >= 0; i--) { |
@@ -236,7 +236,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void CompileCase(CaseClause* clause, uint16_t fall_through, |
VariableProxy* tag) { |
Literal* label = clause->label()->AsLiteral(); |
- DCHECK(label != nullptr); |
+ DCHECK_NOT_NULL(label); |
block_size_++; |
current_function_builder_->Emit(kExprIf); |
current_function_builder_->Emit(kExprI32Ior); |
@@ -254,7 +254,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitSwitchStatement(SwitchStatement* stmt) { |
VariableProxy* tag = stmt->tag()->AsVariableProxy(); |
- DCHECK(tag != NULL); |
+ DCHECK_NOT_NULL(tag); |
BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false, |
0); |
uint16_t fall_through = current_function_builder_->AddLocal(kAstI32); |
@@ -344,7 +344,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
current_function_builder_->ReturnType(return_type); |
for (int i = 0; i < expr->parameter_count(); i++) { |
LocalType type = TypeFrom(func_type->Parameter(i)); |
- DCHECK(type != kAstStmt); |
+ DCHECK_NE(kAstStmt, type); |
LookupOrInsertLocal(scope->parameter(i), type); |
} |
} else { |
@@ -385,7 +385,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
} |
LocalType var_type = TypeOf(expr); |
- DCHECK(var_type != kAstStmt); |
+ DCHECK_NE(kAstStmt, var_type); |
if (var->IsContextSlot()) { |
AddLeb128(LookupOrInsertGlobal(var, var_type), false); |
} else { |
@@ -432,10 +432,10 @@ class AsmWasmBuilderImpl : public AstVisitor { |
ObjectLiteralProperty* prop = props->at(i); |
DCHECK(marking_exported); |
VariableProxy* expr = prop->value()->AsVariableProxy(); |
- DCHECK(expr != nullptr); |
+ DCHECK_NOT_NULL(expr); |
Variable* var = expr->var(); |
Literal* name = prop->key()->AsLiteral(); |
- DCHECK(name != nullptr); |
+ DCHECK_NOT_NULL(name); |
DCHECK(name->IsPropertyName()); |
const AstRawString* raw_name = name->AsRawPropertyName(); |
if (var->is_function()) { |
@@ -476,7 +476,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
next_table_index_ += funcs->values()->length(); |
for (int i = 0; i < funcs->values()->length(); i++) { |
VariableProxy* func = funcs->values()->at(i)->AsVariableProxy(); |
- DCHECK(func != nullptr); |
+ DCHECK_NOT_NULL(func); |
builder_->AddIndirectFunction(LookupOrInsertFunction(func->var())); |
} |
} |
@@ -499,7 +499,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
FunctionTableIndices* LookupFunctionTable(Variable* v) { |
ZoneHashMap::Entry* entry = |
function_tables_.Lookup(v, ComputePointerHash(v)); |
- DCHECK(entry != nullptr); |
+ DCHECK_NOT_NULL(entry); |
return reinterpret_cast<FunctionTableIndices*>(entry->value); |
} |
@@ -534,7 +534,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
uint16_t GetFunctionIndex(Variable* v, FunctionSig* sig) { |
ZoneHashMap::Entry* entry = table_.Lookup(v, ComputePointerHash(v)); |
- DCHECK(entry != nullptr); |
+ DCHECK_NOT_NULL(entry); |
ImportedFunctionIndices* indices = |
reinterpret_cast<ImportedFunctionIndices*>(entry->value); |
WasmModuleBuilder::SignatureMap::iterator pos = |
@@ -564,19 +564,19 @@ class AsmWasmBuilderImpl : public AstVisitor { |
BinaryOperation* binop = expr->value()->AsBinaryOperation(); |
if (binop != nullptr) { |
Property* prop = binop->left()->AsProperty(); |
- DCHECK(prop != nullptr); |
+ DCHECK_NOT_NULL(prop); |
LoadInitFunction(); |
is_set_op_ = true; |
RECURSE(Visit(expr->target())); |
DCHECK(!is_set_op_); |
if (binop->op() == Token::MUL) { |
DCHECK(binop->right()->IsLiteral()); |
- DCHECK(binop->right()->AsLiteral()->raw_value()->AsNumber() == 1.0); |
+ DCHECK_EQ(1.0, binop->right()->AsLiteral()->raw_value()->AsNumber()); |
DCHECK(binop->right()->AsLiteral()->raw_value()->ContainsDot()); |
VisitForeignVariable(true, prop); |
} else if (binop->op() == Token::BIT_OR) { |
DCHECK(binop->right()->IsLiteral()); |
- DCHECK(binop->right()->AsLiteral()->raw_value()->AsNumber() == 0.0); |
+ DCHECK_EQ(0.0, binop->right()->AsLiteral()->raw_value()->AsNumber()); |
DCHECK(!binop->right()->AsLiteral()->raw_value()->ContainsDot()); |
VisitForeignVariable(false, prop); |
} else { |
@@ -605,7 +605,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
if (funcs != nullptr && |
funcs->bounds().lower->AsArray()->Element()->IsFunction()) { |
VariableProxy* target = expr->target()->AsVariableProxy(); |
- DCHECK(target != nullptr); |
+ DCHECK_NOT_NULL(target); |
AddFunctionTable(target, funcs); |
} |
return; |
@@ -638,11 +638,11 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitForeignVariable(bool is_float, Property* expr) { |
DCHECK(expr->obj()->AsVariableProxy()); |
- DCHECK(expr->obj()->AsVariableProxy()->var()->location() == |
- VariableLocation::PARAMETER); |
- DCHECK(expr->obj()->AsVariableProxy()->var()->index() == 1); |
+ DCHECK(VariableLocation::PARAMETER == |
+ expr->obj()->AsVariableProxy()->var()->location()); |
+ DCHECK_EQ(1, expr->obj()->AsVariableProxy()->var()->index()); |
Literal* key_literal = expr->key()->AsLiteral(); |
- DCHECK(key_literal != nullptr); |
+ DCHECK_NOT_NULL(key_literal); |
if (!key_literal->value().is_null() && !foreign_.is_null() && |
foreign_->IsObject()) { |
Handle<Name> name = |
@@ -687,7 +687,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitProperty(Property* expr) { |
Expression* obj = expr->obj(); |
- DCHECK(obj->bounds().lower == obj->bounds().upper); |
+ DCHECK_EQ(obj->bounds().lower, obj->bounds().upper); |
Type* type = obj->bounds().lower; |
MachineType mtype; |
int size; |
@@ -736,7 +736,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
Literal* value = expr->key()->AsLiteral(); |
if (value) { |
DCHECK(value->raw_value()->IsNumber()); |
- DCHECK(kAstI32 == TypeOf(value)); |
+ DCHECK_EQ(kAstI32, TypeOf(value)); |
int val = static_cast<int>(value->raw_value()->AsNumber()); |
byte code[] = {WASM_I32(val * size)}; |
current_function_builder_->EmitCode(code, sizeof(code)); |
@@ -744,12 +744,12 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
BinaryOperation* binop = expr->key()->AsBinaryOperation(); |
if (binop) { |
- DCHECK(Token::SAR == binop->op()); |
+ DCHECK_EQ(Token::SAR, binop->op()); |
DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber()); |
DCHECK(kAstI32 == TypeOf(binop->right()->AsLiteral())); |
- DCHECK(size == |
- 1 << static_cast<int>( |
- binop->right()->AsLiteral()->raw_value()->AsNumber())); |
+ DCHECK_EQ(size, |
+ 1 << static_cast<int>( |
+ binop->right()->AsLiteral()->raw_value()->AsNumber())); |
// Mask bottom bits to match asm.js behavior. |
current_function_builder_->Emit(kExprI32And); |
byte code[] = {WASM_I8(~(size - 1))}; |
@@ -794,9 +794,9 @@ class AsmWasmBuilderImpl : public AstVisitor { |
case Call::KEYED_PROPERTY_CALL: { |
DCHECK(in_function_); |
Property* p = expr->expression()->AsProperty(); |
- DCHECK(p != nullptr); |
+ DCHECK_NOT_NULL(p); |
VariableProxy* var = p->obj()->AsVariableProxy(); |
- DCHECK(var != nullptr); |
+ DCHECK_NOT_NULL(var); |
FunctionTableIndices* indices = LookupFunctionTable(var->var()); |
current_function_builder_->EmitWithU8(kExprCallIndirect, |
indices->signature_index); |
@@ -823,7 +823,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
void VisitUnaryOperation(UnaryOperation* expr) { |
switch (expr->op()) { |
case Token::NOT: { |
- DCHECK(TypeOf(expr->expression()) == kAstI32); |
+ DCHECK_EQ(kAstI32, TypeOf(expr->expression())); |
current_function_builder_->Emit(kExprBoolNot); |
break; |
} |
@@ -837,7 +837,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
bool MatchIntBinaryOperation(BinaryOperation* expr, Token::Value op, |
int32_t val) { |
- DCHECK(expr->right() != nullptr); |
+ DCHECK_NOT_NULL(expr->right()); |
if (expr->op() == op && expr->right()->IsLiteral() && |
TypeOf(expr) == kAstI32) { |
Literal* right = expr->right()->AsLiteral(); |
@@ -851,7 +851,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
bool MatchDoubleBinaryOperation(BinaryOperation* expr, Token::Value op, |
double val) { |
- DCHECK(expr->right() != nullptr); |
+ DCHECK_NOT_NULL(expr->right()); |
if (expr->op() == op && expr->right()->IsLiteral() && |
TypeOf(expr) == kAstF64) { |
Literal* right = expr->right()->AsLiteral(); |
@@ -886,12 +886,12 @@ class AsmWasmBuilderImpl : public AstVisitor { |
ConvertOperation MatchXor(BinaryOperation* expr) { |
if (MatchIntBinaryOperation(expr, Token::BIT_XOR, 0xffffffff)) { |
- DCHECK(TypeOf(expr->left()) == kAstI32); |
- DCHECK(TypeOf(expr->right()) == kAstI32); |
+ DCHECK_EQ(kAstI32, TypeOf(expr->left())); |
+ DCHECK_EQ(kAstI32, TypeOf(expr->right())); |
BinaryOperation* op = expr->left()->AsBinaryOperation(); |
if (op != nullptr) { |
if (MatchIntBinaryOperation(op, Token::BIT_XOR, 0xffffffff)) { |
- DCHECK(TypeOf(op->right()) == kAstI32); |
+ DCHECK_EQ(kAstI32, TypeOf(op->right())); |
if (TypeOf(op->left()) != kAstI32) { |
return kToInt; |
} else { |
@@ -905,7 +905,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
ConvertOperation MatchMul(BinaryOperation* expr) { |
if (MatchDoubleBinaryOperation(expr, Token::MUL, 1.0)) { |
- DCHECK(TypeOf(expr->right()) == kAstF64); |
+ DCHECK_EQ(kAstF64, TypeOf(expr->right())); |
if (TypeOf(expr->left()) != kAstF64) { |
return kToDouble; |
} else { |
@@ -1119,7 +1119,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
TypeIndex TypeIndexOf(Expression* expr) { |
- DCHECK(expr->bounds().lower == expr->bounds().upper); |
+ DCHECK_EQ(expr->bounds().lower, expr->bounds().upper); |
Type* type = expr->bounds().lower; |
if (type->Is(cache_.kAsmFixnum)) { |
return kFixnum; |
@@ -1179,7 +1179,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
}; |
uint16_t LookupOrInsertLocal(Variable* v, LocalType type) { |
- DCHECK(current_function_builder_ != nullptr); |
+ DCHECK_NOT_NULL(current_function_builder_); |
ZoneHashMap::Entry* entry = |
local_variables_.Lookup(v, ComputePointerHash(v)); |
if (entry == nullptr) { |
@@ -1214,7 +1214,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
uint16_t LookupOrInsertFunction(Variable* v) { |
- DCHECK(builder_ != nullptr); |
+ DCHECK_NOT_NULL(builder_); |
ZoneHashMap::Entry* entry = functions_.Lookup(v, ComputePointerHash(v)); |
if (entry == nullptr) { |
uint16_t index = builder_->AddFunction(); |
@@ -1228,7 +1228,7 @@ class AsmWasmBuilderImpl : public AstVisitor { |
} |
LocalType TypeOf(Expression* expr) { |
- DCHECK(expr->bounds().lower == expr->bounds().upper); |
+ DCHECK_EQ(expr->bounds().lower, expr->bounds().upper); |
return TypeFrom(expr->bounds().lower); |
} |