Index: src/compiler/wasm-compiler.cc |
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
index a0f29c85089aaf8ac292facdb736e2bd6e2c213d..16ff311000236d7525095ac09c5ab8c0b4215309 100644 |
--- a/src/compiler/wasm-compiler.cc |
+++ b/src/compiler/wasm-compiler.cc |
@@ -1153,6 +1153,13 @@ Node* WasmGraphBuilder::BuildF64Max(Node* left, Node* right) { |
Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { |
MachineOperatorBuilder* m = jsgraph()->machine(); |
+ if (module_ && module_->asm_js()) { |
+ // asm.js must use the wacky JS semantics. |
+ input = graph()->NewNode(m->ChangeFloat32ToFloat64(), input); |
+ return graph()->NewNode( |
+ m->TruncateFloat64ToInt32(TruncationMode::kJavaScript), input); |
+ } |
+ |
// Truncation of the input value is needed for the overflow check later. |
Node* trunc = Unop(wasm::kExprF32Trunc, input); |
Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
@@ -1169,7 +1176,8 @@ Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { |
Node* WasmGraphBuilder::BuildI32SConvertF64(Node* input) { |
MachineOperatorBuilder* m = jsgraph()->machine(); |
- if (module_ && module_->asm_js) { |
+ if (module_ && module_->asm_js()) { |
+ // asm.js must use the wacky JS semantics. |
return graph()->NewNode( |
m->TruncateFloat64ToInt32(TruncationMode::kJavaScript), input); |
} |
@@ -1189,6 +1197,13 @@ Node* WasmGraphBuilder::BuildI32SConvertF64(Node* input) { |
Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input) { |
MachineOperatorBuilder* m = jsgraph()->machine(); |
+ if (module_ && module_->asm_js()) { |
+ // asm.js must use the wacky JS semantics. |
+ input = graph()->NewNode(m->ChangeFloat32ToFloat64(), input); |
+ return graph()->NewNode( |
+ m->TruncateFloat64ToInt32(TruncationMode::kJavaScript), input); |
+ } |
+ |
// Truncation of the input value is needed for the overflow check later. |
Node* trunc = Unop(wasm::kExprF32Trunc, input); |
Node* result = graph()->NewNode(m->TruncateFloat32ToUint32(), trunc); |
@@ -1205,7 +1220,8 @@ Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input) { |
Node* WasmGraphBuilder::BuildI32UConvertF64(Node* input) { |
MachineOperatorBuilder* m = jsgraph()->machine(); |
- if (module_ && module_->asm_js) { |
+ if (module_ && module_->asm_js()) { |
+ // asm.js must use the wacky JS semantics. |
return graph()->NewNode( |
m->TruncateFloat64ToInt32(TruncationMode::kJavaScript), input); |
} |
@@ -1889,7 +1905,7 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, |
Node* index, uint32_t offset) { |
Node* load; |
- if (module_ && module_->asm_js) { |
+ if (module_ && module_->asm_js()) { |
// asm.js semantics use CheckedLoad (i.e. OOB reads return 0ish). |
DCHECK_EQ(0, offset); |
const Operator* op = jsgraph()->machine()->CheckedLoad(memtype); |
@@ -1924,7 +1940,7 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, |
Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, |
uint32_t offset, Node* val) { |
Node* store; |
- if (module_ && module_->asm_js) { |
+ if (module_ && module_->asm_js()) { |
// asm.js semantics use CheckedStore (i.e. ignore OOB writes). |
DCHECK_EQ(0, offset); |
const Operator* op = |