Closed Bug 933289 Opened 11 years ago Closed 3 years ago

Optimize assignments to non-scalar properties of typed objects

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

x86
Linux
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: nmatsakis, Unassigned)

References

Details

Attachments

(1 file)

Currently, if you have typed objects like:

    var PointType = new StructType(...);
    var LineType = new StructType({from: PointType, to: PointType});

and then you write:

    line.from = somePoint;

or

    line.from = {x: 22, y: 44};

The result is rather inefficient. Fully optimizing this can be done in two steps. Step one is this bug, which would be to have IonBuilder generate a call to the self-hosted helper ConvertAndCopyTo for such assignments. Hence line.from = {x: 22, y: 44} would be converted
to something roughly like:

    ConvertAndCopyTo(line, offsetof(Line, "from"), Point, {x: 22, y: 44})

This would be further optimized, but this further optimization is the subject of another bug.
Blocks: 933293
Attached patch Bug933289.diffSplinter Review
Attachment #826067 - Flags: review?(jdemooij)
Comment on attachment 826067 [details] [diff] [review]
Bug933289.diff

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

Looks fine, just one issue that blocks off-thread IonBuilder.

::: js/src/jit/IonBuilder.cpp
@@ +9803,5 @@
> +    Rooted<GlobalObject *> global(cx, cx->global());
> +    RootedPropertyName nameRoot(cx, cx->names().ConvertAndCopyTo);
> +    RootedValue convertAndCopyToValue(cx, UndefinedValue());
> +    if (!global->tryGetIntrinsicValueNoClone(cx, nameRoot, &convertAndCopyToValue))
> +        return false;

Using cx in IonBuilder still works but Brian is actively eliminating uses of it. I don't think we need one here, see also bug 934526 where he changed IonBuilder::jsop_intrinsic to not require a cx, can you use that here? You also don't need the RootedFunction/MutableHandleFunction then I think (IonBuilder won't GC).
Attachment #826067 - Flags: review?(jdemooij)
This will require some rebasing but we should try to land it.
Priority: -- → P3

Another old bug related to JS typed objects -> No longer valid.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: