From 8d661a339fdaf5a609e70196deb90345875d51ed Mon Sep 17 00:00:00 2001 From: aseemgarg Date: Tue, 8 Nov 2016 13:49:26 -0800 Subject: [PATCH] [wasm] remove MachineType from asm-wasm-builder.cc R=bradnelson@chromium.org BUG= Review-Url: https://codereview.chromium.org/2465103002 Cr-Commit-Position: refs/heads/master@{#40849} --- src/asmjs/asm-wasm-builder.cc | 83 +++++++++++------------------------ 1 file changed, 26 insertions(+), 57 deletions(-) diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc index 26fec8ab7b..cac6fbd8b3 100644 --- a/src/asmjs/asm-wasm-builder.cc +++ b/src/asmjs/asm-wasm-builder.cc @@ -19,7 +19,6 @@ #include "src/ast/ast.h" #include "src/ast/scopes.h" -#include "src/codegen.h" namespace v8 { namespace internal { @@ -755,7 +754,7 @@ class AsmWasmBuilderImpl final : public AstVisitor { } }; - 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 +765,7 @@ class AsmWasmBuilderImpl final : public AstVisitor { 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 +813,7 @@ class AsmWasmBuilderImpl final : public AstVisitor { 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 +848,21 @@ class AsmWasmBuilderImpl final : public AstVisitor { } // Note that unlike StoreMem, AsmjsStoreMem ignores out-of-bounds writes. WasmOpcode opcode; - if (type == MachineType::Int8()) { + if (type == AsmType::Int8Array()) { opcode = kExprI32AsmjsStoreMem8; - } else if (type == MachineType::Uint8()) { + } else if (type == AsmType::Uint8Array()) { opcode = kExprI32AsmjsStoreMem8; - } else if (type == MachineType::Int16()) { + } else if (type == AsmType::Int16Array()) { opcode = kExprI32AsmjsStoreMem16; - } else if (type == MachineType::Uint16()) { + } else if (type == AsmType::Uint16Array()) { opcode = kExprI32AsmjsStoreMem16; - } else if (type == MachineType::Int32()) { + } else if (type == AsmType::Int32Array()) { opcode = kExprI32AsmjsStoreMem; - } else if (type == MachineType::Uint32()) { + } else if (type == AsmType::Uint32Array()) { opcode = kExprI32AsmjsStoreMem; - } else if (type == MachineType::Float32()) { + } else if (type == AsmType::Float32Array()) { opcode = kExprF32AsmjsStoreMem; - } else if (type == MachineType::Float64()) { + } else if (type == AsmType::Float64Array()) { opcode = kExprF64AsmjsStoreMem; } else { UNREACHABLE(); @@ -930,12 +929,12 @@ class AsmWasmBuilderImpl final : public AstVisitor { } 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,40 +958,10 @@ class AsmWasmBuilderImpl final : public AstVisitor { } } - void VisitPropertyAndEmitIndex(Property* expr, MachineType* mtype) { + void VisitPropertyAndEmitIndex(Property* expr, AsmType** atype) { Expression* obj = expr->obj(); - AsmType* type = typer_->TypeOf(obj); - int size; - if (type->IsA(AsmType::Uint8Array())) { - *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(); - } + *atype = typer_->TypeOf(obj); + int size = (*atype)->ElementSizeInBytes(); if (size == 1) { // Allow more general expression in byte arrays than the spec // strictly permits. @@ -1030,24 +999,24 @@ class AsmWasmBuilderImpl final : public AstVisitor { } void VisitProperty(Property* expr) { - MachineType type; + AsmType* type = AsmType::None(); VisitPropertyAndEmitIndex(expr, &type); WasmOpcode opcode; - if (type == MachineType::Int8()) { + if (type == AsmType::Int8Array()) { opcode = kExprI32AsmjsLoadMem8S; - } else if (type == MachineType::Uint8()) { + } else if (type == AsmType::Uint8Array()) { opcode = kExprI32AsmjsLoadMem8U; - } else if (type == MachineType::Int16()) { + } else if (type == AsmType::Int16Array()) { opcode = kExprI32AsmjsLoadMem16S; - } else if (type == MachineType::Uint16()) { + } else if (type == AsmType::Uint16Array()) { opcode = kExprI32AsmjsLoadMem16U; - } else if (type == MachineType::Int32()) { + } else if (type == AsmType::Int32Array()) { opcode = kExprI32AsmjsLoadMem; - } else if (type == MachineType::Uint32()) { + } else if (type == AsmType::Uint32Array()) { opcode = kExprI32AsmjsLoadMem; - } else if (type == MachineType::Float32()) { + } else if (type == AsmType::Float32Array()) { opcode = kExprF32AsmjsLoadMem; - } else if (type == MachineType::Float64()) { + } else if (type == AsmType::Float64Array()) { opcode = kExprF64AsmjsLoadMem; } else { UNREACHABLE();