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

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2252863003: [turbofan] Add Float32(Max|Min) machine operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Type is number now. Created 4 years, 3 months 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 unified diff | Download patch
« no previous file with comments | « src/utils.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/wasm/wasm-interpreter.h" 5 #include "src/wasm/wasm-interpreter.h"
6
7 #include "src/utils.h"
6 #include "src/wasm/ast-decoder.h" 8 #include "src/wasm/ast-decoder.h"
7 #include "src/wasm/decoder.h" 9 #include "src/wasm/decoder.h"
8 #include "src/wasm/wasm-external-refs.h" 10 #include "src/wasm/wasm-external-refs.h"
9 #include "src/wasm/wasm-module.h" 11 #include "src/wasm/wasm-module.h"
10 12
11 #include "src/base/accounting-allocator.h" 13 #include "src/base/accounting-allocator.h"
12 #include "src/zone-containers.h" 14 #include "src/zone-containers.h"
13 15
14 namespace v8 { 16 namespace v8 {
15 namespace internal { 17 namespace internal {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Some architectures (e.g. MIPS) need extra checking to preserve the payload 318 // Some architectures (e.g. MIPS) need extra checking to preserve the payload
317 // of a NaN operand. 319 // of a NaN operand.
318 if (result - result != 0) { 320 if (result - result != 0) {
319 if (std::isnan(a)) return quiet(a); 321 if (std::isnan(a)) return quiet(a);
320 if (std::isnan(b)) return quiet(b); 322 if (std::isnan(b)) return quiet(b);
321 } 323 }
322 return result; 324 return result;
323 } 325 }
324 326
325 static inline float ExecuteF32Min(float a, float b, TrapReason* trap) { 327 static inline float ExecuteF32Min(float a, float b, TrapReason* trap) {
326 if (std::isnan(a)) return quiet(a); 328 return JSMin(a, b);
327 if (std::isnan(b)) return quiet(b);
328 return std::min(a, b);
329 } 329 }
330 330
331 static inline float ExecuteF32Max(float a, float b, TrapReason* trap) { 331 static inline float ExecuteF32Max(float a, float b, TrapReason* trap) {
332 if (std::isnan(a)) return quiet(a); 332 return JSMax(a, b);
333 if (std::isnan(b)) return quiet(b);
334 return std::max(a, b);
335 } 333 }
336 334
337 static inline float ExecuteF32CopySign(float a, float b, TrapReason* trap) { 335 static inline float ExecuteF32CopySign(float a, float b, TrapReason* trap) {
338 return copysignf(a, b); 336 return copysignf(a, b);
339 } 337 }
340 338
341 static inline double ExecuteF64Sub(double a, double b, TrapReason* trap) { 339 static inline double ExecuteF64Sub(double a, double b, TrapReason* trap) {
342 double result = a - b; 340 double result = a - b;
343 // Some architectures (e.g. MIPS) need extra checking to preserve the payload 341 // Some architectures (e.g. MIPS) need extra checking to preserve the payload
344 // of a NaN operand. 342 // of a NaN operand.
345 if (result - result != 0) { 343 if (result - result != 0) {
346 if (std::isnan(a)) return quiet(a); 344 if (std::isnan(a)) return quiet(a);
347 if (std::isnan(b)) return quiet(b); 345 if (std::isnan(b)) return quiet(b);
348 } 346 }
349 return result; 347 return result;
350 } 348 }
351 349
352 static inline double ExecuteF64Min(double a, double b, TrapReason* trap) { 350 static inline double ExecuteF64Min(double a, double b, TrapReason* trap) {
353 if (std::isnan(a)) return quiet(a); 351 return JSMin(a, b);
354 if (std::isnan(b)) return quiet(b);
355 if ((a == 0.0) && (b == 0.0) && (copysign(1.0, a) != copysign(1.0, b))) {
356 // a and b are zero, and the sign differs: return -0.0.
357 return -0.0;
358 } else {
359 return (a < b) ? a : b;
360 }
361 } 352 }
362 353
363 static inline double ExecuteF64Max(double a, double b, TrapReason* trap) { 354 static inline double ExecuteF64Max(double a, double b, TrapReason* trap) {
364 if (std::isnan(a)) return quiet(a); 355 return JSMax(a, b);
365 if (std::isnan(b)) return quiet(b);
366 if ((a == 0.0) && (b == 0.0) && (copysign(1.0, a) != copysign(1.0, b))) {
367 // a and b are zero, and the sign differs: return 0.0.
368 return 0.0;
369 } else {
370 return (a > b) ? a : b;
371 }
372 } 356 }
373 357
374 static inline double ExecuteF64CopySign(double a, double b, TrapReason* trap) { 358 static inline double ExecuteF64CopySign(double a, double b, TrapReason* trap) {
375 return copysign(a, b); 359 return copysign(a, b);
376 } 360 }
377 361
378 static inline int32_t ExecuteI32AsmjsDivS(int32_t a, int32_t b, 362 static inline int32_t ExecuteI32AsmjsDivS(int32_t a, int32_t b,
379 TrapReason* trap) { 363 TrapReason* trap) {
380 if (b == 0) return 0; 364 if (b == 0) return 0;
381 if (b == -1 && a == std::numeric_limits<int32_t>::min()) { 365 if (b == -1 && a == std::numeric_limits<int32_t>::min()) {
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 1804
1821 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1805 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1822 Zone* zone, const byte* start, const byte* end) { 1806 Zone* zone, const byte* start, const byte* end) {
1823 ControlTransfers targets(zone, 0, start, end); 1807 ControlTransfers targets(zone, 0, start, end);
1824 return targets.map_; 1808 return targets.map_;
1825 } 1809 }
1826 1810
1827 } // namespace wasm 1811 } // namespace wasm
1828 } // namespace internal 1812 } // namespace internal
1829 } // namespace v8 1813 } // namespace v8
OLDNEW
« no previous file with comments | « src/utils.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698