Changeset 214219 in webkit for trunk/Source/JavaScriptCore/ftl


Ignore:
Timestamp:
Mar 21, 2017, 4:31:43 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Optimize Number.prototype.toString on Int32 / Int52 / Double
https://bugs.webkit.org/show_bug.cgi?id=167454

Reviewed by Saam Barati.

JSTests:

  • stress/number-to-string-abstract-operation.js: Added.

(shouldBe):
(int32ToString):
(shouldBe.int32ToString.new.Number.int52ToString):
(shouldBe.int32ToString.new.Number):
(shouldBe.doubleToString):

  • stress/number-to-string-radix.js: Added.

(shouldBe):
(int32ToString):
(shouldBe.int32ToString.new.Number.int52ToString):
(shouldBe.int32ToString.new.Number):
(shouldBe.doubleToString):

  • stress/number-to-string.js: Added.

(shouldBe):
(int32ToString):
(shouldBe.int32ToString.new.Number.int52ToString):
(shouldBe.int32ToString.new.Number):
(shouldBe.doubleToString):

Source/JavaScriptCore:

This patch improves Number.toString(radix) performance
by introducing NumberToStringWithRadix DFG node. It directly
calls the operation and it always returns String.

baseline patched

stanford-crypto-sha256-iterative 45.130+-0.928 44.032+-1.184 might be 1.0250x faster

Location:
trunk/Source/JavaScriptCore/ftl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r214069 r214219  
    280280    case DefineAccessorProperty:
    281281    case ToLowerCase:
     282    case NumberToStringWithRadix:
    282283    case CheckDOM:
    283284    case CallDOM:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r214071 r214219  
    10791079            compileToLowerCase();
    10801080            break;
     1081        case NumberToStringWithRadix:
     1082            compileNumberToStringWithRadix();
     1083            break;
    10811084        case CheckDOM:
    10821085            compileCheckDOM();
     
    49824985            return;
    49834986        }
     4987
     4988        case Int32Use:
     4989            setJSValue(vmCall(Int64, m_out.operation(operationInt32ToStringWithValidRadix), m_callFrame, lowInt32(m_node->child1()), m_out.constInt32(10)));
     4990            return;
     4991
     4992        case Int52RepUse:
     4993            setJSValue(vmCall(Int64, m_out.operation(operationInt52ToStringWithValidRadix), m_callFrame, lowStrictInt52(m_node->child1()), m_out.constInt32(10)));
     4994            return;
     4995
     4996        case DoubleRepUse:
     4997            setJSValue(vmCall(Int64, m_out.operation(operationDoubleToStringWithValidRadix), m_callFrame, lowDouble(m_node->child1()), m_out.constInt32(10)));
     4998            return;
    49844999           
    49855000        default:
     
    99839998        m_out.appendTo(continuation, lastNext);
    99849999        setJSValue(m_out.phi(pointerType(), fastResult, slowResult));
     10000    }
     10001
     10002    void compileNumberToStringWithRadix()
     10003    {
     10004        bool validRadixIsGuaranteed = false;
     10005        if (m_node->child2()->isInt32Constant()) {
     10006            int32_t radix = m_node->child2()->asInt32();
     10007            if (radix >= 2 && radix <= 36)
     10008                validRadixIsGuaranteed = true;
     10009        }
     10010
     10011        switch (m_node->child1().useKind()) {
     10012        case Int32Use:
     10013            setJSValue(vmCall(pointerType(), m_out.operation(validRadixIsGuaranteed ? operationInt32ToStringWithValidRadix : operationInt32ToString), m_callFrame, lowInt32(m_node->child1()), lowInt32(m_node->child2())));
     10014            break;
     10015        case Int52RepUse:
     10016            setJSValue(vmCall(pointerType(), m_out.operation(validRadixIsGuaranteed ? operationInt52ToStringWithValidRadix : operationInt52ToString), m_callFrame, lowStrictInt52(m_node->child1()), lowInt32(m_node->child2())));
     10017            break;
     10018        case DoubleRepUse:
     10019            setJSValue(vmCall(pointerType(), m_out.operation(validRadixIsGuaranteed ? operationDoubleToStringWithValidRadix : operationDoubleToString), m_callFrame, lowDouble(m_node->child1()), lowInt32(m_node->child2())));
     10020            break;
     10021        default:
     10022            RELEASE_ASSERT_NOT_REACHED();
     10023        }
    998510024    }
    998610025
Note: See TracChangeset for help on using the changeset viewer.