Bug 1311994 - Baldr: remove Wasm object (r=sunfish)
authorLuke Wagner <luke@mozilla.com>
Mon, 24 Oct 2016 13:20:59 -0500
changeset 319248 3e3bb5d0a8a9ca195c9b9861c1f6073732fc874c
parent 319247 7fd8ec5750d3cdcfc0852998177b7a58d8d904c0
child 319249 2431c088b4c11110274e97a5e8d3acb935db2119
push id30865
push usercbook@mozilla.com
push dateTue, 25 Oct 2016 08:31:38 +0000
treeherdermozilla-central@78b863e9fcd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssunfish
bugs1311994
milestone52.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 1311994 - Baldr: remove Wasm object (r=sunfish) MozReview-Commit-ID: CkrYWLFoKAE
js/src/asmjs/WasmJS.cpp
js/src/jit-test/lib/wasm-binary.js
js/src/jit-test/tests/wasm/binary.js
js/src/jsprototypes.h
js/src/vm/GlobalObject.cpp
--- a/js/src/asmjs/WasmJS.cpp
+++ b/js/src/asmjs/WasmJS.cpp
@@ -67,16 +67,19 @@ wasm::HasCompilerSupport(ExclusiveContex
 
 #if defined(JS_CODEGEN_NONE) || defined(JS_CODEGEN_ARM64)
     return false;
 #else
     return true;
 #endif
 }
 
+// ============================================================================
+// Imports
+
 template<typename T>
 JSObject*
 js::wasm::CreateCustomNaNObject(JSContext* cx, T* addr)
 {
     MOZ_ASSERT(IsNaN(*addr));
 
     RootedObject obj(cx, JS_NewPlainObject(cx));
     if (!obj)
@@ -177,19 +180,16 @@ wasm::ReadI64Object(JSContext* cx, Handl
     if (!JS_GetProperty(cx, obj, "high", &val))
         return false;
     if (!ToInt32(cx, val, &i32[1]))
         return false;
 
     return true;
 }
 
-// ============================================================================
-// (Temporary) Wasm class and static methods
-
 static bool
 ThrowBadImportArg(JSContext* cx)
 {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_IMPORT_ARG);
     return false;
 }
 
 static bool
@@ -327,16 +327,19 @@ GetImports(JSContext* cx,
         }
     }
 
     MOZ_ASSERT(globalIndex == globals.length() || !globals[globalIndex].isImport());
 
     return true;
 }
 
+// ============================================================================
+// Fuzzing support
+
 static bool
 DescribeScriptedCaller(JSContext* cx, ScriptedCaller* scriptedCaller)
 {
     // Note: JS::DescribeScriptedCaller returns whether a scripted caller was
     // found, not whether an error was thrown. This wrapper function converts
     // back to the more ordinary false-if-error form.
 
     JS::AutoFilename af;
@@ -390,66 +393,16 @@ wasm::Eval(JSContext* cx, Handle<TypedAr
     RootedWasmMemoryObject memory(cx);
     ValVector globals;
     if (!GetImports(cx, *module, importObj, &funcs, &table, &memory, &globals))
         return false;
 
     return module->instantiate(cx, funcs, table, memory, globals, nullptr, instanceObj);
 }
 
-#if JS_HAS_TOSOURCE
-static bool
-wasm_toSource(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    args.rval().setString(cx->names().Wasm);
-    return true;
-}
-#endif
-
-static const JSFunctionSpec wasm_static_methods[] = {
-#if JS_HAS_TOSOURCE
-    JS_FN(js_toSource_str,     wasm_toSource,     0, 0),
-#endif
-    JS_FS_END
-};
-
-const Class js::WasmClass = {
-    js_Wasm_str,
-    JSCLASS_HAS_CACHED_PROTO(JSProto_Wasm)
-};
-
-JSObject*
-js::InitWasmClass(JSContext* cx, HandleObject global)
-{
-    MOZ_RELEASE_ASSERT(HasCompilerSupport(cx));
-    MOZ_ASSERT(cx->options().wasm());
-
-    RootedObject proto(cx, global->as<GlobalObject>().getOrCreateObjectPrototype(cx));
-    if (!proto)
-        return nullptr;
-
-    RootedObject Wasm(cx, NewObjectWithGivenProto(cx, &WasmClass, proto, SingletonObject));
-    if (!Wasm)
-        return nullptr;
-
-    if (!JS_DefineProperty(cx, global, js_Wasm_str, Wasm, JSPROP_RESOLVING))
-        return nullptr;
-
-    RootedValue version(cx, Int32Value(EncodingVersion));
-    if (!JS_DefineProperty(cx, Wasm, "experimentalVersion", version, JSPROP_RESOLVING))
-        return nullptr;
-
-    if (!JS_DefineFunctions(cx, Wasm, wasm_static_methods))
-        return nullptr;
-
-    global->as<GlobalObject>().setConstructor(JSProto_Wasm, ObjectValue(*Wasm));
-    return Wasm;
-}
-
 // ============================================================================
 // Common functions
 
 static bool
 ToNonWrappingUint32(JSContext* cx, HandleValue v, uint32_t max, const char* kind, const char* noun,
                     uint32_t* u32)
 {
     double dbl;
--- a/js/src/jit-test/lib/wasm-binary.js
+++ b/js/src/jit-test/lib/wasm-binary.js
@@ -1,19 +1,20 @@
 // MagicNumber = 0x6d736100;
 const magic0 = 0x00;  // '\0'
 const magic1 = 0x61;  // 'a'
 const magic2 = 0x73;  // 's'
 const magic3 = 0x6d;  // 'm'
 
 // EncodingVersion (temporary; to be set to 1 at some point before release)
-const ver0 = (Wasm.experimentalVersion >>>  0) & 0xff;
-const ver1 = (Wasm.experimentalVersion >>>  8) & 0xff;
-const ver2 = (Wasm.experimentalVersion >>> 16) & 0xff;
-const ver3 = (Wasm.experimentalVersion >>> 24) & 0xff;
+const experimentalVersion = 0xd;
+const ver0 = (experimentalVersion >>>  0) & 0xff;
+const ver1 = (experimentalVersion >>>  8) & 0xff;
+const ver2 = (experimentalVersion >>> 16) & 0xff;
+const ver3 = (experimentalVersion >>> 24) & 0xff;
 
 // Section opcodes
 const userDefinedId    = 0;
 const typeId           = 1;
 const importId         = 2;
 const functionId       = 3;
 const tableId          = 4;
 const memoryId         = 5;
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -7,17 +7,17 @@ const CompileError = WebAssembly.Compile
 const magicError = /failed to match magic number/;
 const unknownSection = /expected user-defined section/;
 
 function sectionError(section) {
     return RegExp(`failed to start ${section} section`);
 }
 
 function versionError(actual) {
-    var expect = Wasm.experimentalVersion;
+    var expect = experimentalVersion;
     var str = `binary version 0x${actual.toString(16)} does not match expected version 0x${expect.toString(16)}`;
     return RegExp(str);
 }
 
 function toU8(array) {
     for (let b of array)
         assertEq(b < 256, true);
     return Uint8Array.from(array);
--- a/js/src/jsprototypes.h
+++ b/js/src/jsprototypes.h
@@ -112,19 +112,18 @@ IF_SAB(real,imaginary)(SharedArrayBuffer
 IF_INTL(real,imaginary) (Intl,                  41,     InitIntlClass,          CLASP(Intl)) \
 IF_BDATA(real,imaginary)(TypedObject,           42,     InitTypedObjectModuleObject,   OCLASP(TypedObjectModule)) \
     real(Reflect,               43,     InitReflect,            nullptr) \
 IF_SIMD(real,imaginary)(SIMD,                   44,     InitSimdClass, OCLASP(Simd)) \
     real(WeakSet,               45,     InitWeakSetClass,       OCLASP(WeakSet)) \
     real(TypedArray,            46,     InitViaClassSpec,       &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
 IF_SAB(real,imaginary)(Atomics, 47,     InitAtomicsClass, OCLASP(Atomics)) \
     real(SavedFrame,            48,     InitViaClassSpec,       &js::SavedFrame::class_) \
-    real(Wasm,                  49,     InitWasmClass,          CLASP(Wasm)) \
-    real(WebAssembly,           50,     InitWebAssemblyClass,   CLASP(WebAssembly)) \
-    imaginary(WasmModule,       51,     dummy,                  dummy) \
-    imaginary(WasmInstance,     52,     dummy,                  dummy) \
-    imaginary(WasmMemory,       53,     dummy,                  dummy) \
-    imaginary(WasmTable,        54,     dummy,                  dummy) \
-IF_PROMISE(real,imaginary)(Promise,             55,     InitViaClassSpec, OCLASP(Promise)) \
+    real(WebAssembly,           49,     InitWebAssemblyClass,   CLASP(WebAssembly)) \
+    imaginary(WasmModule,       50,     dummy,                  dummy) \
+    imaginary(WasmInstance,     51,     dummy,                  dummy) \
+    imaginary(WasmMemory,       52,     dummy,                  dummy) \
+    imaginary(WasmTable,        53,     dummy,                  dummy) \
+IF_PROMISE(real,imaginary)(Promise,             54,     InitViaClassSpec, OCLASP(Promise)) \
 
 #define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro)
 
 #endif /* jsprototypes_h */
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -93,17 +93,17 @@ js::GlobalObject::getTypedObjectModule()
     // only gets called from contexts where TypedObject must be initialized
     MOZ_ASSERT(v.isObject());
     return v.toObject().as<TypedObjectModuleObject>();
 }
 
 /* static */ bool
 GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key)
 {
-    if (key == JSProto_Wasm || key == JSProto_WebAssembly)
+    if (key == JSProto_WebAssembly)
         return !cx->options().wasm() || !wasm::HasCompilerSupport(cx);
 
 #ifdef ENABLE_SHARED_ARRAY_BUFFER
     // Return true if the given constructor has been disabled at run-time.
     switch (key) {
       case JSProto_Atomics:
       case JSProto_SharedArrayBuffer:
         return !cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled();