⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 199639 in webkit


Ignore:
Timestamp:
Apr 16, 2016, 9:55:02 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] DFG should support relational comparisons of Number and Other
https://bugs.webkit.org/show_bug.cgi?id=156669

Patch by Benjamin Poulain <bpoulain@webkit.org> on 2016-04-16
Reviewed by Darin Adler.

In Sunspider/3d-raytrace, DFG falls back to JSValue in some important
relational compare because profiling sees "undefined" from time to time.

This case is fairly common outside Sunspider too because of out-of-bounds array access.
Unfortunately for us, our fallback for compare is really inefficient.

Fortunately, relational comparison with null/undefined/true/false are trival.
We can just convert both side to Double. That's what this patch adds.

I also extended constant folding for those cases because I noticed
a bunch of "undefined" constant going through DoubleRep at runtime.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • tests/stress/compare-number-and-other.js: Added.

(opaqueSideEffect):
(let.operator.of.operators.eval.testPolymorphic):
(let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.eval.testMonomorphic):
(let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.testMonomorphicLeftConstant):
(let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.testMonomorphicRightConstant):
(let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.i.testPolymorphic):

Location:
trunk/Source/JavaScriptCore
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r199638 r199639  
     12016-04-16  Benjamin Poulain  <bpoulain@webkit.org>
     2
     3        [JSC] DFG should support relational comparisons of Number and Other
     4        https://bugs.webkit.org/show_bug.cgi?id=156669
     5
     6        Reviewed by Darin Adler.
     7
     8        In Sunspider/3d-raytrace, DFG falls back to JSValue in some important
     9        relational compare because profiling sees "undefined" from time to time.
     10
     11        This case is fairly common outside Sunspider too because of out-of-bounds array access.
     12        Unfortunately for us, our fallback for compare is really inefficient.
     13
     14        Fortunately, relational comparison with null/undefined/true/false are trival.
     15        We can just convert both side to Double. That's what this patch adds.
     16
     17        I also extended constant folding for those cases because I noticed
     18        a bunch of "undefined" constant going through DoubleRep at runtime.
     19
     20        * dfg/DFGAbstractInterpreterInlines.h:
     21        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     22        * dfg/DFGFixupPhase.cpp:
     23        (JSC::DFG::FixupPhase::fixupNode):
     24        * tests/stress/compare-number-and-other.js: Added.
     25        (opaqueSideEffect):
     26        (let.operator.of.operators.eval.testPolymorphic):
     27        (let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.eval.testMonomorphic):
     28        (let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.testMonomorphicLeftConstant):
     29        (let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.testMonomorphicRightConstant):
     30        (let.operator.of.operators.let.left.of.typeCases.let.right.of.typeCases.i.testPolymorphic):
     31
    1322016-04-16  Benjamin Poulain  <bpoulain@apple.com>
    233
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r199514 r199639  
    393393    case DoubleRep: {
    394394        JSValue child = forNode(node->child1()).value();
    395         if (child && child.isNumber()) {
    396             setConstant(node, jsDoubleNumber(child.asNumber()));
    397             break;
     395        if (child) {
     396            if (child.isNumber()) {
     397                setConstant(node, jsDoubleNumber(child.asNumber()));
     398                break;
     399            }
     400            if (child.isUndefined()) {
     401                setConstant(node, jsDoubleNumber(PNaN));
     402                break;
     403            }
     404            if (child.isNull() || child.isFalse()) {
     405                setConstant(node, jsDoubleNumber(0));
     406                break;
     407            }
     408            if (child.isTrue()) {
     409                setConstant(node, jsDoubleNumber(1));
     410                break;
     411            }
    398412        }
    399413
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r199514 r199639  
    454454                fixDoubleOrBooleanEdge(node->child1());
    455455                fixDoubleOrBooleanEdge(node->child2());
     456            }
     457            if (node->op() != CompareEq
     458                && node->child1()->shouldSpeculateNotCell()
     459                && node->child2()->shouldSpeculateNotCell()) {
     460                if (node->child1()->shouldSpeculateNumberOrBoolean())
     461                    fixDoubleOrBooleanEdge(node->child1());
     462                else
     463                    fixEdge<DoubleRepUse>(node->child1());
     464                if (node->child2()->shouldSpeculateNumberOrBoolean())
     465                    fixDoubleOrBooleanEdge(node->child2());
     466                else
     467                    fixEdge<DoubleRepUse>(node->child2());
    456468                node->clearFlags(NodeMustGenerate);
    457469                break;
Note: See TracChangeset for help on using the changeset viewer.