OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 | 10 |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 wasm::kAstF64, left, | 1114 wasm::kAstF64, left, |
1115 right_gt_left.Phi(wasm::kAstF64, right, | 1115 right_gt_left.Phi(wasm::kAstF64, right, |
1116 left_is_not_nan.Phi(wasm::kAstF64, right, left))); | 1116 left_is_not_nan.Phi(wasm::kAstF64, right, left))); |
1117 } | 1117 } |
1118 | 1118 |
1119 | 1119 |
1120 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { | 1120 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { |
1121 MachineOperatorBuilder* m = jsgraph()->machine(); | 1121 MachineOperatorBuilder* m = jsgraph()->machine(); |
1122 // Truncation of the input value is needed for the overflow check later. | 1122 // Truncation of the input value is needed for the overflow check later. |
1123 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1123 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
1124 // TODO(titzer): two conversions | 1124 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
1125 Node* f64_trunc = graph()->NewNode(m->ChangeFloat32ToFloat64(), trunc); | |
1126 Node* result = graph()->NewNode(m->ChangeFloat64ToInt32(), f64_trunc); | |
1127 | 1125 |
1128 // Convert the result back to f64. If we end up at a different value than the | 1126 // Convert the result back to f64. If we end up at a different value than the |
1129 // truncated input value, then there has been an overflow and we trap. | 1127 // truncated input value, then there has been an overflow and we trap. |
1130 Node* check = Unop(wasm::kExprF64SConvertI32, result); | 1128 Node* check = Unop(wasm::kExprF32SConvertI32, result); |
1131 Node* overflow = Binop(wasm::kExprF64Ne, f64_trunc, check); | 1129 Node* overflow = Binop(wasm::kExprF32Ne, trunc, check); |
1132 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); | 1130 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); |
1133 | 1131 |
1134 return result; | 1132 return result; |
1135 } | 1133 } |
1136 | 1134 |
1137 | 1135 |
1138 Node* WasmGraphBuilder::BuildI32SConvertF64(Node* input) { | 1136 Node* WasmGraphBuilder::BuildI32SConvertF64(Node* input) { |
1139 MachineOperatorBuilder* m = jsgraph()->machine(); | 1137 MachineOperatorBuilder* m = jsgraph()->machine(); |
1140 // Truncation of the input value is needed for the overflow check later. | 1138 // Truncation of the input value is needed for the overflow check later. |
1141 Node* trunc = Unop(wasm::kExprF64Trunc, input); | 1139 Node* trunc = Unop(wasm::kExprF64Trunc, input); |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 code->Disassemble(buffer.start(), os); | 2020 code->Disassemble(buffer.start(), os); |
2023 } | 2021 } |
2024 #endif | 2022 #endif |
2025 return code; | 2023 return code; |
2026 } | 2024 } |
2027 | 2025 |
2028 | 2026 |
2029 } // namespace compiler | 2027 } // namespace compiler |
2030 } // namespace internal | 2028 } // namespace internal |
2031 } // namespace v8 | 2029 } // namespace v8 |
OLD | NEW |