Bug 1637682 - Make sure to serialize/deserialize all code properties. r=bbouvier
authorLars T Hansen <lhansen@mozilla.com>
Thu, 14 May 2020 09:49:45 +0000
changeset 529823 99ddf2c70b4ff6d89b8303cacc034f245837c742
parent 529822 5a0128e4d3d54c2ff3741aa321e4f24a95a1a4fe
child 529824 175bb2f682a37f23fbe8e82485b5c4f5a2825e5b
push id37416
push usercsabou@mozilla.com
push dateThu, 14 May 2020 16:15:31 +0000
treeherdermozilla-central@80ba3f3cfaf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1637682
milestone78.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 1637682 - Make sure to serialize/deserialize all code properties. r=bbouvier Serialized/deserialized properties that are POD should be in the CacheablePod structure so that we don't have to worry about adding extra code to serialize/deserialize them; it's so easy to forget. Differential Revision: https://phabricator.services.mozilla.com/D75251
js/src/wasm/WasmCode.cpp
js/src/wasm/WasmCode.h
--- a/js/src/wasm/WasmCode.cpp
+++ b/js/src/wasm/WasmCode.cpp
@@ -915,50 +915,45 @@ bool MetadataTier::clone(const MetadataT
 
   return true;
 }
 
 size_t Metadata::serializedSize() const {
   return sizeof(pod()) + SerializedVectorSize(funcTypeIds) +
          SerializedPodVectorSize(globals) + SerializedPodVectorSize(tables) +
          sizeof(moduleName) + SerializedPodVectorSize(funcNames) +
-         filename.serializedSize() + sourceMapURL.serializedSize() +
-         sizeof(uint8_t);
+         filename.serializedSize() + sourceMapURL.serializedSize();
 }
 
 uint8_t* Metadata::serialize(uint8_t* cursor) const {
   MOZ_ASSERT(!debugEnabled && debugFuncArgTypes.empty() &&
              debugFuncReturnTypes.empty());
   cursor = WriteBytes(cursor, &pod(), sizeof(pod()));
   cursor = SerializeVector(cursor, funcTypeIds);
   cursor = SerializePodVector(cursor, globals);
   cursor = SerializePodVector(cursor, tables);
   cursor = WriteBytes(cursor, &moduleName, sizeof(moduleName));
   cursor = SerializePodVector(cursor, funcNames);
   cursor = filename.serialize(cursor);
   cursor = sourceMapURL.serialize(cursor);
-  cursor = WriteScalar(cursor, uint8_t(omitsBoundsChecks));
   return cursor;
 }
 
 /* static */ const uint8_t* Metadata::deserialize(const uint8_t* cursor) {
-  uint8_t scalarOmitsBoundsChecks = 0;
   (cursor = ReadBytes(cursor, &pod(), sizeof(pod()))) &&
       (cursor = DeserializeVector(cursor, &funcTypeIds)) &&
       (cursor = DeserializePodVector(cursor, &globals)) &&
       (cursor = DeserializePodVector(cursor, &tables)) &&
       (cursor = ReadBytes(cursor, &moduleName, sizeof(moduleName))) &&
       (cursor = DeserializePodVector(cursor, &funcNames)) &&
       (cursor = filename.deserialize(cursor)) &&
-      (cursor = sourceMapURL.deserialize(cursor)) &&
-      (cursor = ReadScalar<uint8_t>(cursor, &scalarOmitsBoundsChecks));
+      (cursor = sourceMapURL.deserialize(cursor));
   debugEnabled = false;
   debugFuncArgTypes.clear();
   debugFuncReturnTypes.clear();
-  omitsBoundsChecks = !!scalarOmitsBoundsChecks;
   return cursor;
 }
 
 size_t Metadata::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const {
   return SizeOfVectorExcludingThis(funcTypeIds, mallocSizeOf) +
          globals.sizeOfExcludingThis(mallocSizeOf) +
          tables.sizeOfExcludingThis(mallocSizeOf) +
          funcNames.sizeOfExcludingThis(mallocSizeOf) +
--- a/js/src/wasm/WasmCode.h
+++ b/js/src/wasm/WasmCode.h
@@ -321,56 +321,55 @@ struct MetadataCacheablePod {
   ModuleKind kind;
   MemoryUsage memoryUsage;
   uint32_t minMemoryLength;
   uint32_t globalDataLength;
   Maybe<uint32_t> maxMemoryLength;
   Maybe<uint32_t> startFuncIndex;
   Maybe<uint32_t> nameCustomSectionIndex;
   bool filenameIsURL;
+  bool bigIntEnabled;
+  bool v128Enabled;
+  bool omitsBoundsChecks;
 
   explicit MetadataCacheablePod(ModuleKind kind)
       : kind(kind),
         memoryUsage(MemoryUsage::None),
         minMemoryLength(0),
         globalDataLength(0),
-        filenameIsURL(false) {}
+        filenameIsURL(false),
+        bigIntEnabled(false),
+        v128Enabled(false),
+        omitsBoundsChecks(false) {}
 };
 
 typedef uint8_t ModuleHash[8];
 typedef Vector<ValTypeVector, 0, SystemAllocPolicy> FuncArgTypesVector;
 typedef Vector<ValTypeVector, 0, SystemAllocPolicy> FuncReturnTypesVector;
 
 struct Metadata : public ShareableBase<Metadata>, public MetadataCacheablePod {
   FuncTypeWithIdVector funcTypeIds;
   GlobalDescVector globals;
   TableDescVector tables;
   CacheableChars filename;
   CacheableChars sourceMapURL;
-  bool omitsBoundsChecks;
 
   // namePayload points at the name section's CustomSection::payload so that
   // the Names (which are use payload-relative offsets) can be used
   // independently of the Module without duplicating the name section.
   SharedBytes namePayload;
   Maybe<Name> moduleName;
   NameVector funcNames;
 
   // Debug-enabled code is not serialized.
   bool debugEnabled;
   FuncArgTypesVector debugFuncArgTypes;
   FuncReturnTypesVector debugFuncReturnTypes;
   ModuleHash debugHash;
 
-  // Feature flag that gets copied from ModuleEnvironment for BigInt support.
-  bool bigIntEnabled;
-
-  // Feature flag that gets copied from ModuleEnvironment for SIMD support.
-  bool v128Enabled;
-
   explicit Metadata(ModuleKind kind = ModuleKind::Wasm)
       : MetadataCacheablePod(kind), debugEnabled(false), debugHash() {}
   virtual ~Metadata() = default;
 
   MetadataCacheablePod& pod() { return *this; }
   const MetadataCacheablePod& pod() const { return *this; }
 
   bool usesMemory() const { return memoryUsage != MemoryUsage::None; }