Closed Bug 1060342 Opened 5 years ago Closed 5 years ago

Optimize TypeOfV codegen

Categories

(Core :: JavaScript Engine: JIT, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: jandem, Assigned: jandem)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
For TypeOfV we currently emit code to check for all types. This patch optimizes TypeOfV so that we only check for types in the input TypeSet.

For the micro-benchmark below I get the following results:

Before: 3306 ms
After:  1100 ms

Codegen looks like this:

cmpl       $0xffffff82, %ebx // type is |undefined|?
jne        ((688))
movl       $0x4212be0, %ebp  // "undefined"
jmp        ((698))
movl       $0x4213100, %ebp  // "string"

function f() {
    var t = new Date;
    var res = "";
    for (var i=0; i<1000000000; i++) {
	res = typeof ((i % 2) ? "" : undefined);
    }
    print(new Date - t);
    return res;
}
f();
Attachment #8481266 - Flags: review?(bhackett1024)
Attachment #8481266 - Flags: review?(bhackett1024) → review+
https://hg.mozilla.org/mozilla-central/rev/d01744d38216
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.