Changeset 209899 in webkit


Ignore:
Timestamp:
Dec 15, 2016 6:38:27 PM (7 years ago)
Author:
keith_miller@apple.com
Message:

Fix validation of non-void if blocks with no else
https://bugs.webkit.org/show_bug.cgi?id=165938

Reviewed by Saam Barati.

JSTests:

Add a new failing test and a fix an existing one.

  • wasm/function-tests/dead-call.js:
  • wasm/function-tests/if-no-else-non-void.js: Added.

Source/JavaScriptCore:

We should not have been allowing non-void if-blocks that don't
have an else. Since this causes a value to be placed on the
stack that only appears under some control flow and not another.

  • wasm/WasmValidate.cpp:
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209891 r209899  
     12016-12-15  Keith Miller  <keith_miller@apple.com>
     2
     3        Fix validation of non-void if blocks with no else
     4        https://bugs.webkit.org/show_bug.cgi?id=165938
     5
     6        Reviewed by Saam Barati.
     7
     8        Add a new failing test and a fix an existing one.
     9
     10        * wasm/function-tests/dead-call.js:
     11        * wasm/function-tests/if-no-else-non-void.js: Added.
     12
    1132016-12-15  Keith Miller  <keith_miller@apple.com>
    214
  • trunk/JSTests/wasm/function-tests/dead-call.js

    r209891 r209899  
    1515          .Function("dead-call", { params: [], ret: "i32" })
    1616              .I32Const(0)
    17               .If("i32", b => b.Call(0).Return())
    18               .I32Const(1)
     17              .If("i32", b =>
     18                  b.Call(0)
     19                  .Return()
     20                  .Else()
     21                  .I32Const(1)
     22                 )
    1923          .End()
    2024
  • trunk/Source/JavaScriptCore/ChangeLog

    r209897 r209899  
     12016-12-15  Keith Miller  <keith_miller@apple.com>
     2
     3        Fix validation of non-void if blocks with no else
     4        https://bugs.webkit.org/show_bug.cgi?id=165938
     5
     6        Reviewed by Saam Barati.
     7
     8        We should not have been allowing non-void if-blocks that don't
     9        have an else. Since this causes a value to be placed on the
     10        stack that only appears under some control flow and not another.
     11
     12        * wasm/WasmValidate.cpp:
     13
    1142016-12-15  Filip Pizlo  <fpizlo@apple.com>
    215
  • trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp

    r209880 r209899  
    291291        return { };
    292292
     293    WASM_VALIDATOR_FAIL_IF(block.type() == BlockType::If, "If-block had a non-void result type: ", block.signature(), " but had no else-block");
    293294    WASM_VALIDATOR_FAIL_IF(stack.isEmpty(), "typed block falls through on empty stack");
    294295    WASM_VALIDATOR_FAIL_IF(block.signature() != stack.last(), "block fallthrough doesn't match its declared type");
     
    300301auto Validate::addEndToUnreachable(ControlEntry& entry) -> Result
    301302{
    302     if (entry.controlData.signature() != Void)
    303         entry.enclosedExpressionStack.append(entry.controlData.signature());
     303    auto block = entry.controlData;
     304    if (block.signature() != Void) {
     305        WASM_VALIDATOR_FAIL_IF(block.type() == BlockType::If, "If-block had a non-void result type: ", block.signature(), " but had no else-block");
     306        entry.enclosedExpressionStack.append(block.signature());
     307    }
    304308    return { };
    305309}
Note: See TracChangeset for help on using the changeset viewer.