Closed Bug 2044243 Opened 5 months ago Closed 5 months ago

Use sign-extended tags for value tests

Categories

(Core :: JavaScript Engine: JIT, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

Use sign-extended tags for value tests like we already do for ARM64.

function f(x) {
  return typeof x == "string";
}

Is compiled to:

srli      t4, t0, 47
lui       t5, 0x20
addiw     t5, t5, -10
xor       t0, t4, t5
seqz      t0, t0

This can be improved to:

srai      t0, t0, 47
xori      t0, t0, 0xfffffff6
seqz      t0, t0

And LIR=Unbox:Int32 can be improved from:

srli      t4, t0, 47
lui       t5, 0x20
addiw     t5, t5, -15
beq       t4, t5, 0
...

to:

srai      t4, t0, 47
li        t5, -15
beq       t4, t5, 0
...

This is similar to ARM64 and requires fewer instructions to test value types.

For example:

function f(x) {
  return typeof x == "string";
}

Was compiled to:

srli      t4, t0, 47
lui       t5, 0x20
addiw     t5, t5, -10
xor       t0, t4, t5
seqz      t0, t0

And is now just:

srai      t0, t0, 47
xori      t0, t0, 0xfffffff6
seqz      t0, t0

Or:

function f(x) {
  return typeof x == "string";
}

Was compiled to:

srli      t4, t0, 47
lui       t5, 0x20
addiw     t5, t5, -15
sltu      t0, t5, t4
xori      t0, t0, 0x1

And is now compiled to just two instructions (with the changes from bug 2044242):

srai      t0, t0, 47
sltiu     t0, t0, -14

Fallible unbox to Int32 used:

srli      t4, t0, 47
lui       t5, 0x20
addiw     t5, t5, -15
beq       t4, t5, 0
...

And now requires one less instruction:

srai      t4, t0, 47
li        t5, -15
beq       t4, t5, 0
...
Severity: -- → N/A
Priority: -- → P1
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch
QA Whiteboard: [qa-triage-done-c154/b153]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: