IonMonkey: Fold TypeOf strings in MConstant.

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: sstangl, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

5 years ago
Created attachment 650345 [details] [diff] [review]
patch

JSOP_TYPEOF can produce an MConstant string, but we still lower to LCompareS, which takes a VM call. Instead, we should just fold away the comparison where possible.

Miniscule performance improvement on kraken-crypto-pbkdf2.
Attachment #650345 - Flags: review?(efaust)

Comment 1

5 years ago
Comment on attachment 650345 [details] [diff] [review]
patch

Review of attachment 650345 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/ion/MIR.cpp
@@ +1354,5 @@
> +        if (left == right)
> +            equal = true;
> +        else if (!EqualStrings(GetIonContext()->cx, lhs.toString(), rhs.toString(), &equal))
> +            return false;
> +        *result = (equal ^ (jsop_ != JSOP_EQ && jsop_ != JSOP_STRICTEQ));

So if jsop_ == JSOP_LT, and equal came back false, result must be true? Are we guaranteed of that ordering?
(Reporter)

Comment 2

5 years ago
Created attachment 650350 [details] [diff] [review]
patch v2

Whoops. Calling EqualStrings() is obviously only a useful optimization if we're going to be checking whether strings are equal.
Attachment #650345 - Attachment is obsolete: true
Attachment #650345 - Flags: review?(efaust)
Attachment #650350 - Flags: review?(efaust)

Comment 3

5 years ago
Comment on attachment 650350 [details] [diff] [review]
patch v2

Review of attachment 650350 [details] [diff] [review]:
-----------------------------------------------------------------

r=me.

::: js/src/ion/Lowering.cpp
@@ +351,5 @@
> +        return add(new LGoto(num ? ifTrue : ifFalse));
> +    }
> +
> +    // Constant Boolean operand.
> +    if (opd->type() == MIRType_Boolean && opd->isConstant()) {

In theory it makes more sense to test ops->isConsant() first, since that's less likely to be true, but this is more in line with the structure of the existing code.

::: js/src/ion/MIR.cpp
@@ +1360,5 @@
> +        if (left == right)
> +            equal = true;
> +        else if (!EqualStrings(GetIonContext()->cx, lhs.toString(), rhs.toString(), &equal))
> +            return false;
> +        *result = (equal ^ (jsop_ != JSOP_EQ && jsop_ != JSOP_STRICTEQ));

We could still make JSOP_GE and JSOP_LE work here in the equal case, at least. At any rate, this could use a comment.
Attachment #650350 - Flags: review?(efaust) → review+
(Reporter)

Comment 4

5 years ago
http://hg.mozilla.org/projects/ionmonkey/rev/0400c12c5295
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.