Changeset 204588 in webkit


Ignore:
Timestamp:
Aug 17, 2016 6:35:55 PM (8 years ago)
Author:
keith_miller@apple.com
Message:

Add WASM support for i64 simple opcodes.
https://bugs.webkit.org/show_bug.cgi?id=160928

Reviewed by Michael Saboff.

This patch also removes the unsigned int32 mod operator, which is not supported by B3 yet.

  • wasm/WASMB3IRGenerator.cpp:

(JSC::WASM::toB3Op):
(JSC::WASM::B3IRGenerator::unaryOp):

  • wasm/WASMFunctionParser.h:

(JSC::WASM::WASMFunctionParser<Context>::parseExpression):

  • wasm/WASMOps.h:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r204586 r204588  
     12016-08-17  Keith Miller  <keith_miller@apple.com>
     2
     3        Add WASM support for i64 simple opcodes.
     4        https://bugs.webkit.org/show_bug.cgi?id=160928
     5
     6        Reviewed by Michael Saboff.
     7
     8        This patch also removes the unsigned int32 mod operator, which is not supported by B3 yet.
     9
     10        * wasm/WASMB3IRGenerator.cpp:
     11        (JSC::WASM::toB3Op):
     12        (JSC::WASM::B3IRGenerator::unaryOp):
     13        * wasm/WASMFunctionParser.h:
     14        (JSC::WASM::WASMFunctionParser<Context>::parseExpression):
     15        * wasm/WASMOps.h:
     16
    1172016-08-17  JF Bastien  <jfbastien@apple.com>
    218
  • trunk/Source/JavaScriptCore/wasm/WASMB3IRGenerator.cpp

    r204539 r204588  
    4242using namespace B3;
    4343
    44 inline JSC::B3::Opcode toB3Op(WASMBinaryOpType op)
     44inline B3::Opcode toB3Op(WASMBinaryOpType op)
    4545{
    4646    switch (op) {
     
    5151}
    5252
     53inline B3::Opcode toB3Op(WASMUnaryOpType op)
     54{
     55    switch (op) {
     56#define CREATE_CASE(name, op, b3op) case WASMUnaryOpType::name: return b3op;
     57    FOR_EACH_WASM_UNARY_OP(CREATE_CASE)
     58#undef CREATE_CASE
     59    }
     60}
     61
    5362class B3IRGenerator {
    5463public:
     
    6170
    6271    bool WARN_UNUSED_RETURN binaryOp(WASMBinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);
     72    bool WARN_UNUSED_RETURN unaryOp(WASMUnaryOpType, ExpressionType arg, ExpressionType& result);
    6373
    6474    bool WARN_UNUSED_RETURN addBlock();
     
    8898{
    8999    // TODO: Add locals.
     100}
     101
     102bool B3IRGenerator::unaryOp(WASMUnaryOpType op, ExpressionType arg, ExpressionType& result)
     103{
     104    result = m_currentBlock->appendNew<Value>(m_proc, toB3Op(op), Origin(), arg);
     105    return true;
    90106}
    91107
  • trunk/Source/JavaScriptCore/wasm/WASMFunctionParser.h

    r204539 r204588  
    113113#define CREATE_CASE(name, id, b3op) case name:
    114114    FOR_EACH_WASM_BINARY_OP(CREATE_CASE) {
    115 #undef CREATE_CASE
    116115        ExpressionType left = m_expressionStack.takeLast();
    117116        ExpressionType right = m_expressionStack.takeLast();
     
    122121        return true;
    123122    }
     123
     124    FOR_EACH_WASM_UNARY_OP(CREATE_CASE) {
     125        ExpressionType arg = m_expressionStack.takeLast();
     126        ExpressionType result;
     127        if (!m_context.unaryOp(static_cast<WASMUnaryOpType>(op), arg, result))
     128            return false;
     129        m_expressionStack.append(result);
     130        return true;
     131    }
     132#undef CREATE_CASE
    124133
    125134    case WASMOpType::I32Const: {
  • trunk/Source/JavaScriptCore/wasm/WASMOps.h

    r204539 r204588  
    4040    macro(End, 0x0f, NA)
    4141
    42 #define FOR_EACH_WASM_UNARY_OP(macro)
     42#define FOR_EACH_WASM_UNARY_OP(macro) \
     43    macro(I32Clz, 0x57, Clz) \
     44    /* macro(I32Ctz, 0x58) */ \
     45    /* macro(I32PopCnt, 0x59) */ \
     46    /* macro(I32Eqz, 0x5a) */ \
     47    macro(I64Clz, 0x72, Clz) \
     48    /* macro(I64Ctz, 0x73) */ \
     49    /* macro(I64PopCnt, 0x74) */ \
     50    /* macro(I64Eqz, 0xba) */
    4351
    4452#define FOR_EACH_WASM_BINARY_OP(macro) \
     
    4957    /* macro(I32DivU, 0x44) */ \
    5058    macro(I32RemS, 0x45, Mod) \
    51     macro(I32RemU, 0x46, Mod) \
     59    /* macro(I32RemU, 0x46, Mod) */ \
    5260    macro(I32And, 0x47, BitAnd) \
    5361    macro(I32Or, 0x48, BitOr) \
     
    6876    macro(I32GtU, 0x55, Above) \
    6977    macro(I32GeU, 0x56, AboveEqual) \
     78    macro(I64Add, 0x5b, Add) \
     79    macro(I64Sub, 0x5c, Sub) \
     80    macro(I64Mul, 0x5d, Mul) \
     81    macro(I64DivS, 0x5e, Div) \
     82    /* macro(I64DivU, 0x5f) */ \
     83    macro(I64RemS, 0x60, Mod) \
     84    /* macro(I64RemU, 0x61) */ \
     85    macro(I64And, 0x62, BitAnd) \
     86    macro(I64Or, 0x63, BitOr) \
     87    macro(I64Xor, 0x64, BitXor) \
     88    macro(I64Shl, 0x65, Shl) \
     89    macro(I64ShrU, 0x66, SShr) \
     90    macro(I64ShrS, 0x67, ZShr) \
     91    /* macro(I64RotR, 0xb8) */ \
     92    /* macro(I64RotL, 0xb9) */ \
     93    macro(I64Eq, 0x68, Equal) \
     94    macro(I64Ne, 0x69, NotEqual) \
     95    macro(I64LtS, 0x6a, LessThan) \
     96    macro(I64LeS, 0x6b, LessEqual) \
     97    macro(I64LtU, 0x6c, Below) \
     98    macro(I64LeU, 0x6d, BelowEqual) \
     99
    70100
    71101#define FOR_EACH_WASM_OP(macro) \
     
    81111};
    82112
    83 
    84 
    85113enum class WASMBinaryOpType : uint8_t {
    86114    FOR_EACH_WASM_BINARY_OP(CREATE_ENUM_VALUE)
    87115};
     116
     117enum class WASMUnaryOpType : uint8_t {
     118    FOR_EACH_WASM_UNARY_OP(CREATE_ENUM_VALUE)
     119};
     120
     121#undef CREATE_ENUM_VALUE
    88122
    89123} // namespace WASM
     
    91125} // namespace JSC
    92126
    93 #undef CREATE_ENUM_VALUE
    94 
    95127#endif // ENABLE(WEBASSEMBLY)
Note: See TracChangeset for help on using the changeset viewer.