Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Unified Diff: src/asmjs/asm-wasm-builder.cc

Issue 2465103002: [wasm] remove MachineType from asm-wasm-builder.cc (Closed)
Patch Set: [wasm] remove MachineType from asm-wasm-builder.cc Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6c6b3218f341662990859fa31c65ddc8f5665fa5 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 == AsmType::Int8Array()) {
opcode = kExprI32AsmjsStoreMem8;
- } else if (type == MachineType::Uint8()) {
+ } else if (type == AsmType::Uint8Array()) {
bradnelson 2016/11/08 17:59:22 We could optimize the array type in asm-types as t
aseemgarg 2016/11/08 21:15:44 I think you are addressing this as a separate patc
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 +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,40 +959,10 @@ 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);
- 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 +1000,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 == 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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698