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 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); | 1147 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); |
1148 | 1148 |
1149 return result; | 1149 return result; |
1150 } | 1150 } |
1151 | 1151 |
1152 | 1152 |
1153 Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input) { | 1153 Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input) { |
1154 MachineOperatorBuilder* m = jsgraph()->machine(); | 1154 MachineOperatorBuilder* m = jsgraph()->machine(); |
1155 // Truncation of the input value is needed for the overflow check later. | 1155 // Truncation of the input value is needed for the overflow check later. |
1156 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1156 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
1157 // TODO(titzer): two conversions | 1157 Node* result = graph()->NewNode(m->TruncateFloat32ToUint32(), trunc); |
1158 Node* f64_trunc = graph()->NewNode(m->ChangeFloat32ToFloat64(), trunc); | |
1159 Node* result = graph()->NewNode(m->ChangeFloat64ToUint32(), f64_trunc); | |
1160 | 1158 |
1161 // Convert the result back to f64. If we end up at a different value than the | 1159 // Convert the result back to f32. If we end up at a different value than the |
1162 // truncated input value, then there has been an overflow and we trap. | 1160 // truncated input value, then there has been an overflow and we trap. |
1163 Node* check = Unop(wasm::kExprF64UConvertI32, result); | 1161 Node* check = Unop(wasm::kExprF32UConvertI32, result); |
1164 Node* overflow = Binop(wasm::kExprF64Ne, f64_trunc, check); | 1162 Node* overflow = Binop(wasm::kExprF32Ne, trunc, check); |
1165 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); | 1163 trap_->AddTrapIfTrue(kTrapFloatUnrepresentable, overflow); |
1166 | 1164 |
1167 return result; | 1165 return result; |
1168 } | 1166 } |
1169 | 1167 |
1170 | 1168 |
1171 Node* WasmGraphBuilder::BuildI32UConvertF64(Node* input) { | 1169 Node* WasmGraphBuilder::BuildI32UConvertF64(Node* input) { |
1172 MachineOperatorBuilder* m = jsgraph()->machine(); | 1170 MachineOperatorBuilder* m = jsgraph()->machine(); |
1173 if (module_ && module_->asm_js) { | 1171 if (module_ && module_->asm_js) { |
1174 return graph()->NewNode( | 1172 return graph()->NewNode( |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 code->Disassemble(buffer.start(), os); | 2090 code->Disassemble(buffer.start(), os); |
2093 } | 2091 } |
2094 #endif | 2092 #endif |
2095 return code; | 2093 return code; |
2096 } | 2094 } |
2097 | 2095 |
2098 | 2096 |
2099 } // namespace compiler | 2097 } // namespace compiler |
2100 } // namespace internal | 2098 } // namespace internal |
2101 } // namespace v8 | 2099 } // namespace v8 |
OLD | NEW |