Closed Bug 836005 Opened 11 years ago Closed 11 years ago

BaselineCompiler: Optimize typed array getelem & length

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: evilpie, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

I think the length patch is simple enough. For the getelem patch, there is one annoyance with Uint32Arrays. Because I can't know if TI has seen a double type or just int, i just bail out for values that would require a double to represent. (This is the false in loadFromTypedArray). I am giving the later patch to djvj so we have some fair split.
Attachment #707798 - Flags: review?(jdemooij)
Attachment #707800 - Flags: review?(kvijayan)
Assignee: general → evilpies
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: x86_64 → All
Comment on attachment 707800 [details] [diff] [review]
typed array element

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

Nice work.

::: js/src/ion/BaselineIC.cpp
@@ +1644,5 @@
>              return false;
>  
>          stub->addNewStub(denseStub);
>      }
> +    if (obj->isTypedArray() && rhs.isInt32() && res.isNumber()) {

Nit: Make this into an "else if" attached to the previous if.  Makes it clear that these two cases are exclusive.

@@ +1742,5 @@
> +    Register key = masm.extractInt32(R1, ExtractTemp1);
> +
> +    // Bounds check.
> +    masm.unboxInt32(Address(obj, TypedArray::lengthOffset()), scratchReg);
> +    masm.branch32(Assembler::BelowOrEqual, scratchReg, key, &failure);

Need to check if (key >= 0) here.

@@ +1751,5 @@
> +    // Load the value.
> +    BaseIndex source(scratchReg, key, ScaleFromElemWidth(TypedArray::slotWidth(type_)));
> +    masm.loadFromTypedArray(type_, source, R0, false, scratchReg, &failure);
> +
> +    // Todo: type check for uint32 array

Nit: Can remove this TODO.  The GetElementMonitored will take care of the typeset updates.
Attachment #707800 - Flags: review?(kvijayan) → review+
Comment on attachment 707798 [details] [diff] [review]
typed array length

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

::: js/src/ion/BaselineIC.cpp
@@ +1988,5 @@
>          *attached = true;
>          stub->addNewStub(newStub);
>          return true;
>      }
> +    if (obj->isTypedArray() && res.isInt32()) {

Nit: JS_ASSERT(res.isInt32()) inside the |if| instead (unlike the array length, it can never be a double)
Attachment #707798 - Flags: review?(jdemooij) → review+
Attachment #717229 - Flags: review?(jdemooij)
Attachment #717229 - Flags: review?(jdemooij) → review+
Great!
https://hg.mozilla.org/projects/ionmonkey/rev/b7e4d01b541e
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: