Closed Bug 1309701 Opened 8 years ago Closed 8 years ago

Improve synthesized typed array constructor for shared memory

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file, 1 obsolete file)

The shared typed array constructor in tests/ecma_6/TypedArray/shell.js can be improved which will allow us to run more tests with shared memory. And we should also try to remove some of code duplication to create the shared constructors in each test.
Attached patch bug1309701.patch (obsolete) — Splinter Review
Mostly straight forward updates for the TypedArray tests. Only notable changes:

ecma_6/shell.js
- Make a copy in Permutations so the same input can be used multiple times.

ecma_6/TypedArray/shell.js
- Create a proper %TypedArray% subclass for the synthesized constructor.

ecma_6/TypedArray/sort_globals.js
- Replace assertDeepEq with assertEqArray to avoid a test failure due to fun_resolve resolving "length" and "name" in different order.
Attachment #8800409 - Flags: review?(evilpies)
Comment on attachment 8800409 [details] [diff] [review]
bug1309701.patch

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

This is awesome, thank you.

::: js/src/tests/ecma_6/TypedArray/from_mapping.js
@@ +36,5 @@
>  }
>  
>  // %TypedArray%.from(obj, map) is not exactly the same as %TypedArray%.from(obj).map(mapFn).
>  assertDeepEq(Int8Array.from([150], v => v / 2), new Int8Array([75]));
> +assertDeepEq(Int8Array.from([150]).map(v => v / 2), new Int8Array([-53]));

:)

::: js/src/tests/ecma_6/TypedArray/shell.js
@@ +26,4 @@
>  
> +    const sharedConstructors = new WeakMap();
> +
> +    const typedArrayConstructors = Object.freeze([

YES! We should have done this from the beginning.

@@ +52,5 @@
> +        ...(typeof SharedArrayBuffer === "function" ? sharedTypedArrayConstructors : []),
> +    ]);
> +
> +    function sharedConstructor(baseConstructor) {
> +        class SharedTypedArray extends Object_getPrototypeOf(baseConstructor) {

Can you add a short comment explaining why we need this class?

@@ +90,5 @@
> +    function isSharedConstructor(c) {
> +        return Reflect_apply(WeakMap_prototype_has, sharedConstructors, [c]);
> +    }
> +
> +    function isFloatingConstructor(c) {

I think this is kind of a weird name. Why not isFloatConstructor or FloatingPoint, FP. Just Floating by itself doesn't work well.
Attachment #8800409 - Flags: review?(evilpies) → review+
Attached patch bug1309701.patchSplinter Review
Updated patch per review comments. Carrying r+ from evilpie.

Also added the missing shared typed array constructor for Uint8ClampedArray (per bug 1176214, comment 65).
Attachment #8800409 - Attachment is obsolete: true
Attachment #8801162 - Flags: review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f6161756e151
Improve the TypedArray constructor for shared memory to support more tests. r=evilpie
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/f6161756e151
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: