Bug 1274618 - Fixes max memory limit check and removes used fields. r?sunfish draft
authorYury Delendik <ydelendik@mozilla.com>
Mon, 23 May 2016 15:02:50 -0500
changeset 369820 34a1313b8fad7a5e0fe893f96e4d4c7fb9714726
parent 369819 d5310fbd3a8f8426ebad1b922cdd74fce012cd26
child 369821 ff49731c7d5e4918fd66bf54658c6addea02b5c1
push id18925
push userydelendik@mozilla.com
push dateMon, 23 May 2016 20:33:26 +0000
reviewerssunfish
bugs1274618
milestone49.0a1
Bug 1274618 - Fixes max memory limit check and removes used fields. r?sunfish MozReview-Commit-ID: LklvgSe1HsP
js/src/asmjs/WasmBinaryToAST.cpp
js/src/asmjs/WasmBinaryToText.cpp
js/src/jit-test/tests/wasm/totext1.js
--- a/js/src/asmjs/WasmBinaryToAST.cpp
+++ b/js/src/asmjs/WasmBinaryToAST.cpp
@@ -1185,29 +1185,29 @@ AstDecodeMemorySection(AstDecodeContext&
         return AstDecodeFail(c, "failed to start section");
     if (sectionStart == Decoder::NotStarted)
         return true;
 
     uint32_t initialSizePages;
     if (!c.d.readVarU32(&initialSizePages))
         return AstDecodeFail(c, "expected initial memory size");
 
-    CheckedInt<int32_t> initialSize = initialSizePages;
+    CheckedInt<uint32_t> initialSize = initialSizePages;
     initialSize *= PageSize;
     if (!initialSize.isValid())
         return AstDecodeFail(c, "initial memory size too big");
 
     uint32_t maxSizePages;
     if (!c.d.readVarU32(&maxSizePages))
         return AstDecodeFail(c, "expected initial memory size");
 
-    CheckedInt<int32_t> maxSize = maxSizePages;
+    CheckedInt<uint32_t> maxSize = maxSizePages;
     maxSize *= PageSize;
     if (!maxSize.isValid())
-        return AstDecodeFail(c, "initial memory size too big");
+        return AstDecodeFail(c, "maximum memory size too big");
 
     uint8_t exported;
     if (!c.d.readFixedU8(&exported))
         return AstDecodeFail(c, "expected exported byte");
 
     c.initialSizePages.emplace(initialSizePages);
     if (initialSizePages != maxSizePages) {
       c.maxSizePages.emplace(maxSizePages);
--- a/js/src/asmjs/WasmBinaryToText.cpp
+++ b/js/src/asmjs/WasmBinaryToText.cpp
@@ -13,48 +13,40 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "asmjs/WasmBinaryToText.h"
 
-#include "mozilla/CheckedInt.h"
-
 #include "jsnum.h"
 #include "jsprf.h"
 
 #include "asmjs/Wasm.h"
 #include "asmjs/WasmAST.h"
 #include "asmjs/WasmBinaryToAST.h"
 #include "asmjs/WasmTypes.h"
 #include "vm/ArrayBufferObject.h"
 #include "vm/StringBuffer.h"
 
 using namespace js;
 using namespace js::wasm;
 
-using mozilla::CheckedInt;
 using mozilla::IsInfinite;
 using mozilla::IsNaN;
 using mozilla::IsNegativeZero;
 
 struct WasmRenderContext
 {
     JSContext* cx;
     AstModule* module;
     StringBuffer& buffer;
     uint32_t indent;
 
-    DeclaredSigVector signatures;
-    Uint32Vector funcSigs;
-    Uint32Vector funcLocals;
-    Uint32Vector importSigs;
-
     uint32_t currentFuncIndex;
 
     WasmRenderContext(JSContext* cx, AstModule* module, StringBuffer& buffer)
       : cx(cx), module(module), buffer(buffer), indent(0), currentFuncIndex(0)
     {}
 };
 
 /*****************************************************************************/
--- a/js/src/jit-test/tests/wasm/totext1.js
+++ b/js/src/jit-test/tests/wasm/totext1.js
@@ -163,8 +163,11 @@ runTest(`
     (call $func1
       (call_indirect $type1 (i32.const 1) (i32.const 2))
       (call_import $import1 (f32.const 1.0))
     )
   )
   (export "test" $test)
   (memory 1)
 )`);
+
+// default memory export from binaryen
+runTest(`(module (func (nop)) (memory 0 65535))`);