IonMonkey: Inline Array.prototype.{push,pop,shift,concat}

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: jandem, Assigned: jandem)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Assignee)

Description

5 years ago
Kraken's crypto tests use array.push and array.concat a lot. JM+TI inlines these functions, and also inlines array.pop and array.shift. IM should do the same.
(Assignee)

Comment 1

5 years ago
Created attachment 610058 [details] [diff] [review]
Part 1: Inline pop and shift

This is a small v8-deltablue win. I can land the jsarray* changes on m-c first.
Attachment #610058 - Flags: review?(dvander)
(Assignee)

Comment 2

5 years ago
Created attachment 610129 [details] [diff] [review]
Part 2: Inline push

The stub calls js::array_push directly now. I think I will change part 1 to do the same to avoid the jsarray* changes/complexity.

I will add array.concat once we have inline object allocation.
Attachment #610129 - Flags: review?(dvander)
Comment on attachment 610058 [details] [diff] [review]
Part 1: Inline pop and shift

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

Nice.

::: js/src/ion/VMFunctions.cpp
@@ +238,5 @@
>  
> +static inline void
> +SetReturnOverrideIfInvalidated(JSContext *cx, const Value &rval)
> +{
> +    if (!GetTopIonJSScript(cx)->ion)

This isn't quite enough, I think, because ->ion could be ION_DISABLED_SCRIPT or (maybe worse). You need to cache the original IonScript. Maybe we should have an AutoDetectInvalidation.
Attachment #610058 - Flags: review?(dvander) → review+
Attachment #610129 - Flags: review?(dvander) → review+
(Assignee)

Comment 4

5 years ago
Created attachment 611511 [details] [diff] [review]
Part 1: Inline pop and shift - v2

Avoids most of the jsarray.* changes and I added the AutoDetectInvalidation class you suggested.
Attachment #610058 - Attachment is obsolete: true
Attachment #611511 - Flags: review?(dvander)
Comment on attachment 611511 [details] [diff] [review]
Part 1: Inline pop and shift - v2

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

::: js/src/ion/VMFunctions.cpp
@@ +252,5 @@
> +    // If the result is |undefined|, the array was probably empty and we
> +    // have to monitor the return value.
> +    *rval = argv[0];
> +    if (rval->isUndefined()) {
> +        AutoDetectInvalidation adi(cx, rval);

I think it's better to move these AutoDetectInvalidation calls to the very top, since a slight breeze can invalidate script->ion, it's safer to grab it ASAP.
Attachment #611511 - Flags: review?(dvander) → review+
(Assignee)

Comment 6

5 years ago
https://hg.mozilla.org/projects/ionmonkey/rev/cdc5f3570a4c
https://hg.mozilla.org/projects/ionmonkey/rev/7b2c14a9fde2

Keeping this bug open for array.concat.
Marking FIXED, we can file a follow-up for array.concat.
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.