Changeset 223318 in webkit for trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
- Timestamp:
- Oct 14, 2017, 8:35:48 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r223232 r223318 1989 1989 OpcodeID opcodeID = this->opcodeID(); 1990 1990 1991 if (opcodeID == op_less || opcodeID == op_lesseq || opcodeID == op_greater || opcodeID == op_greatereq) { 1992 auto isUInt32 = [&] (ExpressionNode* node) -> std::optional<UInt32Result> { 1993 if (node->isBinaryOpNode() && static_cast<BinaryOpNode*>(node)->opcodeID() == op_urshift) 1994 return UInt32Result::UInt32; 1995 if (node->isNumber() && static_cast<NumberNode*>(node)->isIntegerNode()) { 1996 int32_t value = static_cast<int32_t>(static_cast<IntegerNode*>(node)->value()); 1997 if (value >= 0) 1998 return UInt32Result::Constant; 1999 } 2000 return std::nullopt; 2001 }; 2002 auto leftResult = isUInt32(m_expr1); 2003 auto rightResult = isUInt32(m_expr2); 2004 if ((leftResult && rightResult) && (leftResult.value() == UInt32Result::UInt32 || rightResult.value() == UInt32Result::UInt32)) { 2005 auto* left = m_expr1; 2006 auto* right = m_expr2; 2007 if (left->isBinaryOpNode()) { 2008 ASSERT(static_cast<BinaryOpNode*>(left)->opcodeID() == op_urshift); 2009 static_cast<BinaryOpNode*>(left)->m_shouldToUnsignedResult = false; 2010 } 2011 if (right->isBinaryOpNode()) { 2012 ASSERT(static_cast<BinaryOpNode*>(right)->opcodeID() == op_urshift); 2013 static_cast<BinaryOpNode*>(right)->m_shouldToUnsignedResult = false; 2014 } 2015 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(left, m_rightHasAssignments, right->isPure(generator)); 2016 RefPtr<RegisterID> src2 = generator.emitNode(right); 2017 generator.emitExpressionInfo(position(), position(), position()); 2018 2019 // Since the both sides only accept Int32, replacing operands is not observable to users. 2020 bool replaceOperands = false; 2021 OpcodeID resultOp = opcodeID; 2022 switch (opcodeID) { 2023 case op_less: 2024 resultOp = op_below; 2025 break; 2026 case op_lesseq: 2027 resultOp = op_beloweq; 2028 break; 2029 case op_greater: 2030 resultOp = op_below; 2031 replaceOperands = true; 2032 break; 2033 case op_greatereq: 2034 resultOp = op_beloweq; 2035 replaceOperands = true; 2036 break; 2037 default: 2038 RELEASE_ASSERT_NOT_REACHED(); 2039 } 2040 OperandTypes operandTypes(left->resultDescriptor(), right->resultDescriptor()); 2041 if (replaceOperands) { 2042 std::swap(src1, src2); 2043 operandTypes = OperandTypes(right->resultDescriptor(), left->resultDescriptor()); 2044 } 2045 return generator.emitBinaryOp(resultOp, generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), operandTypes); 2046 } 2047 } 2048 1991 2049 if (opcodeID == op_add && m_expr1->isAdd() && m_expr1->resultDescriptor().definitelyIsString()) { 1992 2050 generator.emitExpressionInfo(position(), position(), position()); … … 2024 2082 } 2025 2083 RegisterID* result = generator.emitBinaryOp(opcodeID, generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), OperandTypes(left->resultDescriptor(), right->resultDescriptor())); 2026 if (opcodeID == op_urshift && dst != generator.ignoredResult()) 2027 return generator.emitUnaryOp(op_unsigned, result, result); 2084 if (m_shouldToUnsignedResult) { 2085 if (opcodeID == op_urshift && dst != generator.ignoredResult()) 2086 return generator.emitUnaryOp(op_unsigned, result, result); 2087 } 2028 2088 return result; 2029 2089 }
Note:
See TracChangeset
for help on using the changeset viewer.