Closed Bug 1205390 Opened 9 years ago Closed 9 years ago

asm.js: Make the move from SharedTypedArray to TypedArray

Categories

(Core :: JavaScript Engine: JIT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: lth, Assigned: lth)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

It's easy to make Odin accept the use of TypedArray constructors even for shared memory, thus bringing Odin closer to spec without having to land all the changes to remove SharedTypedArray.

The benefit of landing this early is that emscripten can move toward spec compliance sooner, and other implementations and Firefox will be able to share asm.js code.
Attached patch bug1205390-ta-on-shmem.patch (obsolete) — Splinter Review
POC, passes some basic testing.  Includes some test cases that need further work.
Attached file Some further test cases (obsolete) —
In the case of emscripten (or asm.js generally), the stdlib that is passed to the module constructor should not be "this" but should instead be an object that looks roughly as follows:

const atomicStdlib = {
    Atomics:      Atomics,
    Int8Array:    this.SharedInt8Array ? SharedInt8Array : Int8Array,
    Uint8Array:   this.SharedUint8Array ? SharedUint8Array : Uint8Array,
    Int16Array:   this.SharedInt16Array ? SharedInt16Array : Int16Array,
    Uint16Array:  this.SharedUint16Array ? SharedUint16Array : Uint16Array,
    Int32Array:   this.SharedInt32Array ? SharedInt32Array : Int32Array,
    Uint32Array:  this.SharedUint32Array ? SharedUint32Array : Uint32Array,
    Float32Array: this.SharedFloat32Array ? SharedFloat32Array : Float32Array,
    Float64Array: this.SharedFloat64Array ? SharedFloat64Array : Float64Array,
    ...
};

where ... indicates other things you might need.  This construction will allow the code to run in Firefox and non-Firefox browsers, and in Firefox even with --no-asmjs or a similar switch.

This hack can go away when bug 1176214 lands, but it will continue to work even then (Firefox will appear to the above code as a "non-Firefox" browser).
Attachment #8661982 - Attachment is obsolete: true
Attachment #8661985 - Attachment is obsolete: true
Attachment #8677606 - Flags: review?(luke)
Comment on attachment 8677606 [details] [diff] [review]
bug1205390-ta-on-shmem.patch

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

::: js/src/asmjs/AsmJSModule.h
@@ +1112,5 @@
>      }
> +    void setViewsAreShared() {
> +        if (pod.hasArrayView_)
> +            pod.isSharedView_ = true;
> +        for ( size_t i=0 ; i < globals_.length() ; i++ ) {

Can you remove the spaces in "( size_t" and "i++ )"?

::: js/src/asmjs/AsmJSValidate.cpp
@@ +1516,5 @@
>      }
>  
>      void startFunctionBodies() {
> +        if (atomicsPresent_) {
> +            for ( GlobalMap::Range r = globals_.all() ; !r.empty() ; r.popFront() ) {

Can you remove spaces in "( GlobalMap" and "popFront() )"?
Attachment #8677606 - Flags: review?(luke) → review+
Filed emscripten bug to surface this feature: https://github.com/kripken/emscripten/issues/3869.
https://hg.mozilla.org/mozilla-central/rev/8f72e3889e80
https://hg.mozilla.org/mozilla-central/rev/259d7b810268
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: