Bug 1172517 - track sharedness in global. r=luke
authorLars T Hansen <lhansen@mozilla.com>
Tue, 16 Jun 2015 15:19:25 +0200
changeset 249053 f5ce4d1cb3c294d740a7a625ff12e65957e08c71
parent 249052 e815b262f9ac0f747a09f36ddeca39540bb89b45
child 249054 ca242ef328e11bedb20c6feadd34a9a7d8629137
push id61133
push userlhansen@mozilla.com
push dateTue, 16 Jun 2015 13:21:46 +0000
treeherdermozilla-inbound@f5ce4d1cb3c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1172517
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1172517 - track sharedness in global. r=luke
js/src/asmjs/AsmJSValidate.cpp
js/src/jit-test/tests/asm.js/gating.js
--- a/js/src/asmjs/AsmJSValidate.cpp
+++ b/js/src/asmjs/AsmJSValidate.cpp
@@ -1163,17 +1163,20 @@ class MOZ_STACK_CLASS ModuleCompiler
             struct {
                 Type::Which type_;
                 uint32_t index_;
                 AsmJSNumLit literalValue_;
             } varOrConst;
             uint32_t funcIndex_;
             uint32_t funcPtrTableIndex_;
             uint32_t ffiIndex_;
-            Scalar::Type viewType_;
+            struct {
+                Scalar::Type viewType_;
+                bool isSharedView_;
+            } viewInfo;
             AsmJSMathBuiltinFunction mathBuiltinFunc_;
             AsmJSAtomicsBuiltinFunction atomicsBuiltinFunc_;
             AsmJSSimdType simdCtorType_;
             struct {
                 AsmJSSimdType type_;
                 AsmJSSimdOperation which_;
             } simdOp;
             struct {
@@ -1218,17 +1221,21 @@ class MOZ_STACK_CLASS ModuleCompiler
             MOZ_ASSERT(which_ == FFI);
             return u.ffiIndex_;
         }
         bool isAnyArrayView() const {
             return which_ == ArrayView || which_ == ArrayViewCtor;
         }
         Scalar::Type viewType() const {
             MOZ_ASSERT(isAnyArrayView());
-            return u.viewType_;
+            return u.viewInfo.viewType_;
+        }
+        bool viewIsSharedView() const {
+            MOZ_ASSERT(isAnyArrayView());
+            return u.viewInfo.isSharedView_;
         }
         bool isMathFunction() const {
             return which_ == MathBuiltinFunction;
         }
         AsmJSMathBuiltinFunction mathBuiltinFunction() const {
             MOZ_ASSERT(which_ == MathBuiltinFunction);
             return u.mathBuiltinFunc_;
         }
@@ -1795,26 +1802,28 @@ class MOZ_STACK_CLASS ModuleCompiler
     bool addArrayView(PropertyName* varName, Scalar::Type vt, PropertyName* maybeField, bool isSharedView) {
         if (!arrayViews_.append(ArrayView(varName, vt)))
             return false;
         Global* global = moduleLifo_.new_<Global>(Global::ArrayView);
         if (!global)
             return false;
         if (!module_->addArrayView(vt, maybeField, isSharedView))
             return false;
-        global->u.viewType_ = vt;
+        global->u.viewInfo.viewType_ = vt;
+        global->u.viewInfo.isSharedView_ = isSharedView;
         return globals_.putNew(varName, global);
     }
     bool addArrayViewCtor(PropertyName* varName, Scalar::Type vt, PropertyName* fieldName, bool isSharedView) {
         Global* global = moduleLifo_.new_<Global>(Global::ArrayViewCtor);
         if (!global)
             return false;
         if (!module_->addArrayViewCtor(vt, fieldName, isSharedView))
             return false;
-        global->u.viewType_ = vt;
+        global->u.viewInfo.viewType_ = vt;
+        global->u.viewInfo.isSharedView_ = isSharedView;
         return globals_.putNew(varName, global);
     }
     bool addMathBuiltinFunction(PropertyName* varName, AsmJSMathBuiltinFunction func, PropertyName* fieldName) {
         if (!module_->addMathBuiltinFunction(func, fieldName))
             return false;
         Global* global = moduleLifo_.new_<Global>(Global::MathBuiltinFunction);
         if (!global)
             return false;
@@ -3976,16 +3985,17 @@ CheckNewArrayView(ModuleCompiler& m, Pro
         if (!global)
             return m.failName(ctorExpr, "%s not found in module global scope", globalName);
 
         if (global->which() != ModuleCompiler::Global::ArrayViewCtor)
             return m.failName(ctorExpr, "%s must be an imported array view constructor", globalName);
 
         field = nullptr;
         type = global->viewType();
+        shared = global->viewIsSharedView();
     }
 
     if (!CheckNewArrayViewArgs(m, ctorExpr, bufferName))
         return false;
 
     if (!m.module().isValidViewSharedness(shared))
         return m.failName(ctorExpr, "%s has different sharedness than previous view constructors", globalName);
 
--- a/js/src/jit-test/tests/asm.js/gating.js
+++ b/js/src/jit-test/tests/asm.js/gating.js
@@ -2,21 +2,16 @@
 //
 // When run with -w this should produce a slew of warnings if shared
 // memory is not enabled.  There are several cases here because there
 // are various checks within Odin.
 //
 // Note code is not run, so the only issue here is whether it compiles
 // properly as asm.js.
 
-/*
-
-// Commented out until we can fix bug #1172517, which makes this fail
-// for other reasons.
-
 function module_a(stdlib, foreign, heap) {
     "use asm";
 
     // Without shared memory, this will be flagged as illegal view type
     var view = stdlib.SharedInt32Array;
     var i32a = new view(heap);
     var ld = stdlib.Atomics.load;
 
@@ -27,18 +22,16 @@ function module_a(stdlib, foreign, heap)
     }
 
     return { load: do_load };
 }
 
 if (this.SharedArrayBuffer)
     assertEq(isAsmJSModule(module_a), true);
 
-*/
-
 function module_b(stdlib, foreign, heap) {
     "use asm";
 
     // Without shared memory, this will be flagged as illegal view type
     var i32a = new stdlib.SharedInt32Array(heap);
     var ld = stdlib.Atomics.load;
 
     function do_load() {