Closed Bug 1788177 Opened 2 years ago Closed 2 years ago

Enable ShouldInitFixedSlots for LNewPlainObject

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(3 files)

Enable ShouldInitFixedSlots (bug 1009664) for LNewPlainObject. This improves the codegen for var obj = {a: 0, b:0};

From:

[Codegen]                                 # LIR=NewPlainObject
[Codegen] movabsq    $0x23421d862300, %r14
[Codegen] movabsq    $0x7f2e68e0e690, %r13
[Codegen] movq       0x0(%r13), %r10
[Codegen] addq       $48, %r10
[Codegen] cmpq       %r10, 0x18(%r13)
[Codegen] jb         .Lfrom210
[Codegen] movq       %r10, 0x0(%r13)
[Codegen] subq       $40, %r10
[Codegen] movabsq    $0x7f2e68e30848, %r11
[Codegen] movq       %r11, -0x8(%r10)
[Codegen] movq       %r14, 0x0(%r10)
[Codegen] movabsq    $0x55f86dfdb908, %r11
[Codegen] movq       %r11, 0x8(%r10)
[Codegen] movabsq    $0x55f86dfdb8e0, %r11
[Codegen] movq       %r11, 0x10(%r10)
[Codegen] movabsq    $0xfff9800000000000, %r13
[Codegen] movq       %r13, 0x18(%r10)
[Codegen] movq       %r13, 0x20(%r10)
[Codegen] .set .Llabel281, .
[Codegen]                                 # LIR=OsiPoint
[Codegen] .set .Llabel281, .
[Codegen] .set .Llabel281, .
[Codegen] .set .Llabel281, .
[Codegen]                                 # LIR=StoreFixedSlotT
[Codegen] movabsq    $0x7f2e68e30010, %r11
[Codegen] testl      $0x1, 0x0(%r11)
[Codegen] je         .Lfrom304
[Codegen] movq       0x18(%r10), %r11
[Codegen] shrq       $47, %r11
[Codegen] cmpl       $0x1fff6, %r11d
[Codegen] jb         .Lfrom325
[Codegen] push       %rdx
[Codegen] leaq       0x18(%r10), %rdx
[Codegen] call       .Lfrom335
[Codegen] pop        %rdx
[Codegen] .set .Llabel336, .
[Codegen] .set .Lfrom325, .Llabel336
[Codegen] .set .Llabel336, .
[Codegen] .set .Lfrom304, .Llabel336
[Codegen] movabsq    $0xfff8800000000000, %r11
[Codegen] movq       %r11, 0x18(%r10)
[Codegen]                                 # LIR=StoreFixedSlotT
[Codegen] movabsq    $0x7f2e68e30010, %r11
[Codegen] testl      $0x1, 0x0(%r11)
[Codegen] je         .Lfrom373
[Codegen] movq       0x20(%r10), %r11
[Codegen] shrq       $47, %r11
[Codegen] cmpl       $0x1fff6, %r11d
[Codegen] jb         .Lfrom394
[Codegen] push       %rdx
[Codegen] leaq       0x20(%r10), %rdx
[Codegen] call       .Lfrom404
[Codegen] pop        %rdx
[Codegen] .set .Llabel405, .
[Codegen] .set .Lfrom394, .Llabel405
[Codegen] .set .Llabel405, .
[Codegen] .set .Lfrom373, .Llabel405
[Codegen] movabsq    $0xfff8800000000000, %r11
[Codegen] movq       %r11, 0x20(%r10)

To:

[Codegen]                                 # LIR=NewPlainObject
[Codegen] movabsq    $0x2c9aec462300, %r14
[Codegen] movabsq    $0x7fb1e1d0e690, %r13
[Codegen] movq       0x0(%r13), %r10
[Codegen] addq       $48, %r10
[Codegen] cmpq       %r10, 0x18(%r13)
[Codegen] jb         .Lfrom210
[Codegen] movq       %r10, 0x0(%r13)
[Codegen] subq       $40, %r10
[Codegen] movabsq    $0x7fb1e1d34448, %r11
[Codegen] movq       %r11, -0x8(%r10)
[Codegen] movq       %r14, 0x0(%r10)
[Codegen] movabsq    $0x55d12b401908, %r11
[Codegen] movq       %r11, 0x8(%r10)
[Codegen] movabsq    $0x55d12b4018e0, %r11
[Codegen] movq       %r11, 0x10(%r10)
[Codegen] .set .Llabel263, .
[Codegen]                                 # LIR=OsiPoint
[Codegen] .set .Llabel263, .
[Codegen] .set .Llabel263, .
[Codegen] .set .Llabel263, .
[Codegen]                                 # LIR=StoreFixedSlotT
[Codegen] movabsq    $0xfff8800000000000, %r11
[Codegen] movq       %r11, 0x18(%r10)
[Codegen]                                 # LIR=StoreFixedSlotT
[Codegen] movabsq    $0xfff8800000000000, %r11
[Codegen] movq       %r11, 0x20(%r10)

std::pair<uint32_t, uint32_t> can be returned in a single register on 64-bit
platforms.

There are three callers to ShouldInitFixedSlots():

  1. LNewObject:
    The non-VM call instruction is only used for Object.create calls, in which
    case any following store instruction definitely won't be MFixedStore, but
    instead MAddAndStoreSlot. That means any optimisations from ShouldInitFixedSlots
    don't apply for this case.

  2. LNewNamedLambdaObject:
    The template object contains a fixed slot which holds an Object value (the
    callee function), so ShouldInitFixedSlots won't perform any optimisations.
    (ShouldInitFixedSlots requires that all fixed slots have Undefined as their
    initial value.)

  3. LNewCallObject:
    The template object contains a fixed slot which holds either an Object or a Null
    value (the enclosing environment object), so ShouldInitFixedSlots won't perform
    any optimisations.

That means all current callers of ShouldInitFixedSlots are actually no-ops.

MacroAssembler::initGCSlots() is now always called with initContents=true,
so we can remove the parameter.

Depends on D156053

Change ShouldInitFixedSlots so we can use it for LNewPlainObject by directly
passing the shape and the number of fixed slots.

All fixed slots for LNewPlainObject are initialised to Undefined, so we can
remove the first loop which iterates over all fixed slots. Between MNewPlainObject
and the MStoreFixedSlot instructions, we may have some (hoisted) constants and
a MGuardShape instruction, which we need to skip. The MStoreFixedSlot aren't
scattered over multiple blocks, so we can remove the MGoto handling. Also remove
the MNop handling, because we no longer emit MNop except for
assertRecoveredOnBailoutResult(). (We should probably rename MNop at this
point.)

Depends on D156054

Pushed by andre.bargull@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/b807e5423079
Part 1: Return std::pair from FindStartOfUninitializedAndUndefinedSlots. r=jandem
https://hg.mozilla.org/integration/autoland/rev/bf83a41a519a
Part 2: Remove non-working ShouldInitFixedSlots calls. r=jandem
https://hg.mozilla.org/integration/autoland/rev/88c791bdc5ee
Part 3: Enable ShouldInitFixedSlots for CreatePlainObject. r=jandem
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: