Ignore:
Timestamp:
Nov 14, 2016, 5:09:33 PM (9 years ago)
Author:
[email protected]
Message:

Add Wasm select
https://bugs.webkit.org/show_bug.cgi?id=164743

Reviewed by Saam Barati.

JSTests:

  • wasm/function-tests/select.js: Added.

Source/JavaScriptCore:

Also, this patch fixes an issue with the jsc.cpp test harness where negative numbers would be sign extended
when they shouldn't be.

  • jsc.cpp:

(box):

  • wasm/WasmB3IRGenerator.cpp:
  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser<Context>::parseExpression):

  • wasm/WasmValidate.cpp:

(JSC::Wasm::Validate::addSelect):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp

    r208402 r208719  
    9494    bool WARN_UNUSED_RETURN binaryOp(BinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);
    9595    bool WARN_UNUSED_RETURN unaryOp(UnaryOpType, ExpressionType arg, ExpressionType& result);
     96    bool WARN_UNUSED_RETURN addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result);
    9697
    9798    // Control flow
     
    181182{
    182183    return ControlData(BlockType::Loop, signature);
     184}
     185
     186bool Validate::addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result)
     187{
     188    if (condition != I32) {
     189        m_errorMessage = makeString("Attempting to use ", toString(condition), " as the condition for select");
     190        return false;
     191    }
     192
     193    if (nonZero != zero) {
     194        m_errorMessage = makeString("Result types of select don't match. Got: ", toString(nonZero), " and ", toString(zero));
     195        return false;
     196    }
     197
     198    result = zero;
     199    return true;
    183200}
    184201
Note: See TracChangeset for help on using the changeset viewer.