Chromium Code Reviews| Index: src/asmjs/asm-wasm-builder.cc |
| diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc |
| index 2db8d03c11aba5c0344dc4064433065a4b42bda4..fb8f05d45f9a76c61c245336e3397c3d3d389370 100644 |
| --- a/src/asmjs/asm-wasm-builder.cc |
| +++ b/src/asmjs/asm-wasm-builder.cc |
| @@ -755,7 +755,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| } |
| }; |
| - void EmitAssignmentLhs(Expression* target, MachineType* mtype) { |
| + void EmitAssignmentLhs(Expression* target, AsmType** atype) { |
| // Match the left hand side of the assignment. |
| VariableProxy* target_var = target->AsVariableProxy(); |
| if (target_var != nullptr) { |
| @@ -766,7 +766,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| Property* target_prop = target->AsProperty(); |
| if (target_prop != nullptr) { |
| // Left hand side is a property access, i.e. the asm.js heap. |
| - VisitPropertyAndEmitIndex(target_prop, mtype); |
| + VisitPropertyAndEmitIndex(target_prop, atype); |
| return; |
| } |
| @@ -814,7 +814,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| RECURSE(Visit(value)); |
| } |
| - void EmitAssignment(Assignment* expr, MachineType type, ValueFate fate) { |
| + void EmitAssignment(Assignment* expr, AsmType* type, ValueFate fate) { |
| // Match the left hand side of the assignment. |
| VariableProxy* target_var = expr->target()->AsVariableProxy(); |
| if (target_var != nullptr) { |
| @@ -849,21 +849,21 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| } |
| // Note that unlike StoreMem, AsmjsStoreMem ignores out-of-bounds writes. |
| WasmOpcode opcode; |
| - if (type == MachineType::Int8()) { |
| + if (type->IsA(AsmType::Int8Array())) { |
|
bradnelson
2016/11/02 13:24:22
IsA is more expensive (since it has a bunch of fal
aseemgarg
2016/11/02 19:40:01
Done.
|
| opcode = kExprI32AsmjsStoreMem8; |
| - } else if (type == MachineType::Uint8()) { |
| + } else if (type->IsA(AsmType::Uint8Array())) { |
| opcode = kExprI32AsmjsStoreMem8; |
| - } else if (type == MachineType::Int16()) { |
| + } else if (type->IsA(AsmType::Int16Array())) { |
| opcode = kExprI32AsmjsStoreMem16; |
| - } else if (type == MachineType::Uint16()) { |
| + } else if (type->IsA(AsmType::Uint16Array())) { |
| opcode = kExprI32AsmjsStoreMem16; |
| - } else if (type == MachineType::Int32()) { |
| + } else if (type->IsA(AsmType::Int32Array())) { |
| opcode = kExprI32AsmjsStoreMem; |
| - } else if (type == MachineType::Uint32()) { |
| + } else if (type->IsA(AsmType::Uint32Array())) { |
| opcode = kExprI32AsmjsStoreMem; |
| - } else if (type == MachineType::Float32()) { |
| + } else if (type->IsA(AsmType::Float32Array())) { |
| opcode = kExprF32AsmjsStoreMem; |
| - } else if (type == MachineType::Float64()) { |
| + } else if (type->IsA(AsmType::Float64Array())) { |
| opcode = kExprF64AsmjsStoreMem; |
| } else { |
| UNREACHABLE(); |
| @@ -930,12 +930,12 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| } |
| if (as_init) LoadInitFunction(); |
| - MachineType mtype = MachineType::None(); |
| + AsmType* atype = AsmType::None(); |
| bool is_nop = false; |
| - EmitAssignmentLhs(expr->target(), &mtype); |
| + EmitAssignmentLhs(expr->target(), &atype); |
| EmitAssignmentRhs(expr->target(), expr->value(), &is_nop); |
| if (!is_nop) { |
| - EmitAssignment(expr, mtype, fate); |
| + EmitAssignment(expr, atype, fate); |
| } |
| if (as_init) UnLoadInitFunction(); |
| } |
| @@ -959,36 +959,26 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| } |
| } |
| - void VisitPropertyAndEmitIndex(Property* expr, MachineType* mtype) { |
| + void VisitPropertyAndEmitIndex(Property* expr, AsmType** atype) { |
| Expression* obj = expr->obj(); |
| AsmType* type = typer_->TypeOf(obj); |
| + *atype = type; |
| int size; |
| if (type->IsA(AsmType::Uint8Array())) { |
|
bradnelson
2016/11/02 13:24:22
Switch this to calling:
size = type->ElementSizeI
aseemgarg
2016/11/02 19:40:01
Done.
|
| - *mtype = MachineType::Uint8(); |
| size = 1; |
| } else if (type->IsA(AsmType::Int8Array())) { |
| - *mtype = MachineType::Int8(); |
| size = 1; |
| } else if (type->IsA(AsmType::Uint16Array())) { |
| - *mtype = MachineType::Uint16(); |
| size = 2; |
| } else if (type->IsA(AsmType::Int16Array())) { |
| - *mtype = MachineType::Int16(); |
| size = 2; |
| } else if (type->IsA(AsmType::Uint32Array())) { |
| - *mtype = MachineType::Uint32(); |
| size = 4; |
| } else if (type->IsA(AsmType::Int32Array())) { |
| - *mtype = MachineType::Int32(); |
| - size = 4; |
| - } else if (type->IsA(AsmType::Uint32Array())) { |
| - *mtype = MachineType::Uint32(); |
| size = 4; |
| } else if (type->IsA(AsmType::Float32Array())) { |
| - *mtype = MachineType::Float32(); |
| size = 4; |
| } else if (type->IsA(AsmType::Float64Array())) { |
| - *mtype = MachineType::Float64(); |
| size = 8; |
| } else { |
| UNREACHABLE(); |
| @@ -1030,24 +1020,24 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { |
| } |
| void VisitProperty(Property* expr) { |
| - MachineType type; |
| + AsmType* type = AsmType::None(); |
| VisitPropertyAndEmitIndex(expr, &type); |
| WasmOpcode opcode; |
| - if (type == MachineType::Int8()) { |
| + if (type->IsA(AsmType::Int8Array())) { |
|
bradnelson
2016/11/02 13:24:22
Same as above, IsA isn't cheap.
aseemgarg
2016/11/02 19:40:01
Done.
|
| opcode = kExprI32AsmjsLoadMem8S; |
| - } else if (type == MachineType::Uint8()) { |
| + } else if (type->IsA(AsmType::Uint8Array())) { |
| opcode = kExprI32AsmjsLoadMem8U; |
| - } else if (type == MachineType::Int16()) { |
| + } else if (type->IsA(AsmType::Int16Array())) { |
| opcode = kExprI32AsmjsLoadMem16S; |
| - } else if (type == MachineType::Uint16()) { |
| + } else if (type->IsA(AsmType::Uint16Array())) { |
| opcode = kExprI32AsmjsLoadMem16U; |
| - } else if (type == MachineType::Int32()) { |
| + } else if (type->IsA(AsmType::Int32Array())) { |
| opcode = kExprI32AsmjsLoadMem; |
| - } else if (type == MachineType::Uint32()) { |
| + } else if (type->IsA(AsmType::Uint32Array())) { |
| opcode = kExprI32AsmjsLoadMem; |
| - } else if (type == MachineType::Float32()) { |
| + } else if (type->IsA(AsmType::Float32Array())) { |
| opcode = kExprF32AsmjsLoadMem; |
| - } else if (type == MachineType::Float64()) { |
| + } else if (type->IsA(AsmType::Float64Array())) { |
| opcode = kExprF64AsmjsLoadMem; |
| } else { |
| UNREACHABLE(); |