Bug 1521058 - Baldr: fix IDB deserialization flags on arm64 (r=lth)
authorLuke Wagner <luke@mozilla.com>
Fri, 18 Jan 2019 12:10:35 -0600
changeset 511694 bd64d6e1a11b985615399215422e536be229890d
parent 511693 193394b152f20e41a339fe145cbb4bdba0f64780
child 511695 f02a78b58aa5bd31b65571ec03114c55b3439371
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1521058
milestone66.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 1521058 - Baldr: fix IDB deserialization flags on arm64 (r=lth)
js/src/wasm/WasmModule.cpp
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -21,18 +21,20 @@
 #include <chrono>
 #include <thread>
 
 #include "builtin/TypedObject.h"
 #include "jit/JitOptions.h"
 #include "js/BuildId.h"  // JS::BuildIdCharVector
 #include "threading/LockGuard.h"
 #include "util/NSPR.h"
+#include "wasm/WasmBaselineCompile.h"
 #include "wasm/WasmCompile.h"
 #include "wasm/WasmInstance.h"
+#include "wasm/WasmIonCompile.h"
 #include "wasm/WasmJS.h"
 #include "wasm/WasmSerialize.h"
 
 #include "vm/ArrayBufferObject-inl.h"
 #include "vm/Debugger-inl.h"
 #include "vm/JSAtom-inl.h"
 
 using namespace js;
@@ -381,16 +383,22 @@ static UniqueMapping MapFile(PRFileDesc*
   uint8_t* memory = (uint8_t*)PR_MemMap(map, 0, info->size);
   PR_CloseFileMap(map);
   return UniqueMapping(memory, MemUnmap(info->size));
 }
 
 RefPtr<JS::WasmModule> wasm::DeserializeModule(PRFileDesc* bytecodeFile,
                                                UniqueChars filename,
                                                unsigned line) {
+  // We have to compile new code here so if we're fundamentally unable to
+  // compile, we have to fail.
+  if (!BaselineCanCompile() && !IonCanCompile()) {
+    return nullptr;
+  }
+
   PRFileInfo bytecodeInfo;
   UniqueMapping bytecodeMapping = MapFile(bytecodeFile, &bytecodeInfo);
   if (!bytecodeMapping) {
     return nullptr;
   }
 
   MutableBytes bytecode = js_new<ShareableBytes>();
   if (!bytecode ||
@@ -404,27 +412,28 @@ RefPtr<JS::WasmModule> wasm::Deserialize
   scriptedCaller.filename = std::move(filename);
   scriptedCaller.line = line;
 
   MutableCompileArgs args = js_new<CompileArgs>(std::move(scriptedCaller));
   if (!args) {
     return nullptr;
   }
 
-  // The true answer to whether shared memory is enabled is provided by
-  // cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()
-  // where cx is the context that originated the call that caused this
-  // deserialization attempt to happen.  We don't have that context here, so
-  // we assume that shared memory is enabled; we will catch a wrong assumption
-  // later, during instantiation.
+  // The true answer to whether various flags are enabled is provided by
+  // the JSContext that originated the call that caused this deserialization
+  // attempt to happen. We don't have that context here, so we assume that
+  // shared memory is enabled; we will catch a wrong assumption later, during
+  // instantiation.
   //
   // (We would prefer to store this value with the Assumptions when
   // serializing, and for the caller of the deserialization machinery to
   // provide the value from the originating context.)
 
+  args->ionEnabled = true;
+  args->baselineEnabled = true;
   args->sharedMemoryEnabled = true;
 
   UniqueChars error;
   UniqueCharsVector warnings;
   SharedModule module = CompileBuffer(*args, *bytecode, &error, &warnings);
   if (!module) {
     return nullptr;
   }