Closed Bug 781368 Opened 12 years ago Closed 12 years ago

IonMonkey: Fold TypeOf strings in MConstant.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sstangl, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
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 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?
Attached patch patch v2Splinter Review
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 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+
http://hg.mozilla.org/projects/ionmonkey/rev/0400c12c5295
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.