• ahaas's avatar
    [wasm] Detect unrepresentability in the float32-to-int32 conversion correctly on arm. · de369129
    ahaas authored
    In the current implementation of wasm an unrepresentable input of the
    float32-to-int32 conversion is detected by first truncating the input, then
    converting the truncated input to int32 and back to float32, and then checking
    whether the result is the same as the truncated input.
    
    This input check does not work on arm and arm64 for an input of (INT32_MAX + 1)
    because on these platforms the float32-to-int32 conversion results in INT32_MAX
    if the input is greater than INT32_MAX.  When INT32_MAX is converted back to
    float32, then the result is (INT32_MAX + 1) again because INT32_MAX cannot be
    represented precisely as float32, and rounding-to-nearest results in (INT32_MAX
    + 1). Since (INT32_MAX + 1) equals the truncated input value, the input appears
    to be representable.
    
    With the changes in this CL, the result of the float32-to-int32 conversion is
    incremented by 1 if the original result was INT32_MAX. Thereby the detection of
    unrepresenable inputs in wasm works. Note that since INT32_MAX cannot be
    represented precisely in float32, it can also never be a valid result of the
    float32-to-int32 conversion.
    
    @v8-mips-ports, can you do a similar implementation for mips?
    
    R=titzer@chromium.org, Rodolph.Perfetta@arm.com
    
    Review-Url: https://codereview.chromium.org/2105313002
    Cr-Commit-Position: refs/heads/master@{#37448}
    de369129
Name
Last commit
Last update
..
OWNERS Loading commit data...
asm-types.cc Loading commit data...
asm-types.h Loading commit data...
asm-wasm-builder.cc Loading commit data...
asm-wasm-builder.h Loading commit data...
ast-decoder.cc Loading commit data...
ast-decoder.h Loading commit data...
decoder.h Loading commit data...
encoder.cc Loading commit data...
encoder.h Loading commit data...
leb-helper.h Loading commit data...
module-decoder.cc Loading commit data...
module-decoder.h Loading commit data...
switch-logic.cc Loading commit data...
switch-logic.h Loading commit data...
wasm-debug.cc Loading commit data...
wasm-debug.h Loading commit data...
wasm-external-refs.cc Loading commit data...
wasm-external-refs.h Loading commit data...
wasm-function-name-table.cc Loading commit data...
wasm-function-name-table.h Loading commit data...
wasm-interpreter.cc Loading commit data...
wasm-interpreter.h Loading commit data...
wasm-js.cc Loading commit data...
wasm-js.h Loading commit data...
wasm-macro-gen.h Loading commit data...
wasm-module.cc Loading commit data...
wasm-module.h Loading commit data...
wasm-opcodes.cc Loading commit data...
wasm-opcodes.h Loading commit data...
wasm-result.cc Loading commit data...
wasm-result.h Loading commit data...