Closed Bug 922172 Opened 11 years ago Closed 11 years ago

Add redimension method for typed objects

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: nmatsakis, Assigned: nmatsakis)

References

Details

Attachments

(1 file, 1 obsolete file)

Redimensioning arrays means dividing up the elements in distinct ways (e.g., converting a 10xT array into a 5x2xT array). It is a simpler form of casting that is quite useful for parallelism, and -- unlike going all the way to a byte array -- safe even with object or other reference types. The `redimension()` method is proposed for typed objects spec (though not yet in wiki)
Blocks: 578
Blocks: harmony:typedobjects
No longer blocks: 578
Attached patch Bug922172.diff (obsolete) — Splinter Review
Assignee: nobody → nmatsakis
Attachment #824849 - Flags: review?(till)
Attached patch Bug922172.diffSplinter Review
Accidentally included old version of patch file.
Attachment #824849 - Attachment is obsolete: true
Attachment #824849 - Flags: review?(till)
Attachment #824850 - Flags: review?(till)
Comment on attachment 824850 [details] [diff] [review]
Bug922172.diff

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

This is very nice. r=me with nits addressed, a license header added to the test file and a test added for redimensioning an array containing references.

::: js/src/builtin/TypedObject.js
@@ +461,5 @@
> +    newElementType = newElementType.elementType;
> +  }
> +
> +  // Check that the total number of elements does not change.
> +  if (oldElementCount !== newElementCount)

Nit: braces for multiline then content. Here and below.

@@ +463,5 @@
> +
> +  // Check that the total number of elements does not change.
> +  if (oldElementCount !== newElementCount)
> +    ThrowError(JSMSG_TYPEDOBJECT_HANDLE_BAD_ARGS,
> +               1,

Personally, I'd not put this on its own line. Up to you, though.
Attachment #824850 - Flags: review?(till) → review+
Till -- arrays of references are not supported until bug 898359 lands, but I'll add a test in that case.
Or rather, I can add a test as part of that bug.
https://hg.mozilla.org/mozilla-central/rev/660ff870ffa7
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: