Bug 1538820 - Baldr: rm dead CallFarJump (r=lth)
authorLuke Wagner <luke@mozilla.com>
Tue, 26 Mar 2019 15:23:41 +0000
changeset 466110 6ab89a7fb6b69c533596fe57691d2207960b6a5c
parent 466109 7899cc839c4f19507bb5ffbf001204551e493c92
child 466111 f755dfcfc421e45d63aef09ca95805c1cbd34a4d
push id81450
push userlwagner@mozilla.com
push dateTue, 26 Mar 2019 15:31:27 +0000
treeherderautoland@6ab89a7fb6b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1538820
milestone68.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 1538820 - Baldr: rm dead CallFarJump (r=lth) Actually, it's not totally dead, there is a ModuleGenerator-local use for patching far-jump islands. Differential Revision: https://phabricator.services.mozilla.com/D24764
js/src/jit/shared/Assembler-shared.h
js/src/wasm/WasmBuiltins.cpp
js/src/wasm/WasmCode.cpp
js/src/wasm/WasmGenerator.cpp
js/src/wasm/WasmGenerator.h
--- a/js/src/jit/shared/Assembler-shared.h
+++ b/js/src/jit/shared/Assembler-shared.h
@@ -688,41 +688,25 @@ struct GlobalAccess {
       : patchAt(patchAt), globalDataOffset(globalDataOffset) {}
 
   jit::CodeOffset patchAt;
   unsigned globalDataOffset;
 };
 
 typedef Vector<GlobalAccess, 0, SystemAllocPolicy> GlobalAccessVector;
 
-// A CallFarJump records the offset of a jump that needs to be patched to a
-// call at the end of the module when all calls have been emitted.
-
-struct CallFarJump {
-  uint32_t funcIndex;
-  jit::CodeOffset jump;
-
-  CallFarJump(uint32_t funcIndex, jit::CodeOffset jump)
-      : funcIndex(funcIndex), jump(jump) {}
-
-  void offsetBy(size_t delta) { jump.offsetBy(delta); }
-};
-
-typedef Vector<CallFarJump, 0, SystemAllocPolicy> CallFarJumpVector;
-
 }  // namespace wasm
 
 namespace jit {
 
 // The base class of all Assemblers for all archs.
 class AssemblerShared {
   wasm::CallSiteVector callSites_;
   wasm::CallSiteTargetVector callSiteTargets_;
   wasm::TrapSiteVectorArray trapSites_;
-  wasm::CallFarJumpVector callFarJumps_;
   wasm::SymbolicAccessVector symbolicAccesses_;
 
  protected:
   CodeLabelVector codeLabels_;
 
   bool enoughMemory_;
   bool embedsNurseryPointers_;
 
@@ -751,33 +735,29 @@ class AssemblerShared {
   void append(const wasm::CallSiteDesc& desc, CodeOffset retAddr,
               Args&&... args) {
     enoughMemory_ &= callSites_.emplaceBack(desc, retAddr.offset());
     enoughMemory_ &= callSiteTargets_.emplaceBack(std::forward<Args>(args)...);
   }
   void append(wasm::Trap trap, wasm::TrapSite site) {
     enoughMemory_ &= trapSites_[trap].append(site);
   }
-  void append(wasm::CallFarJump jmp) {
-    enoughMemory_ &= callFarJumps_.append(jmp);
-  }
   void append(const wasm::MemoryAccessDesc& access, uint32_t pcOffset) {
     appendOutOfBoundsTrap(access.trapOffset(), pcOffset);
   }
   void appendOutOfBoundsTrap(wasm::BytecodeOffset trapOffset,
                              uint32_t pcOffset) {
     append(wasm::Trap::OutOfBounds, wasm::TrapSite(pcOffset, trapOffset));
   }
   void append(wasm::SymbolicAccess access) {
     enoughMemory_ &= symbolicAccesses_.append(access);
   }
 
   wasm::CallSiteVector& callSites() { return callSites_; }
   wasm::CallSiteTargetVector& callSiteTargets() { return callSiteTargets_; }
   wasm::TrapSiteVectorArray& trapSites() { return trapSites_; }
-  wasm::CallFarJumpVector& callFarJumps() { return callFarJumps_; }
   wasm::SymbolicAccessVector& symbolicAccesses() { return symbolicAccesses_; }
 };
 
 }  // namespace jit
 }  // namespace js
 
 #endif /* jit_shared_Assembler_shared_h */
--- a/js/src/wasm/WasmBuiltins.cpp
+++ b/js/src/wasm/WasmBuiltins.cpp
@@ -1144,19 +1144,17 @@ bool wasm::EnsureBuiltinThunksInitialize
   memset(thunks->codeBase + masm.bytesNeeded(), 0,
          allocSize - masm.bytesNeeded());
 
   masm.processCodeLabels(thunks->codeBase);
   PatchDebugSymbolicAccesses(thunks->codeBase, masm);
 
   MOZ_ASSERT(masm.callSites().empty());
   MOZ_ASSERT(masm.callSiteTargets().empty());
-  MOZ_ASSERT(masm.callFarJumps().empty());
   MOZ_ASSERT(masm.trapSites().empty());
-  MOZ_ASSERT(masm.callFarJumps().empty());
 
   ExecutableAllocator::cacheFlush(thunks->codeBase, thunks->codeSize);
   if (!ExecutableAllocator::makeExecutable(thunks->codeBase,
                                            thunks->codeSize)) {
     return false;
   }
 
   builtinThunks = thunks.release();
--- a/js/src/wasm/WasmCode.cpp
+++ b/js/src/wasm/WasmCode.cpp
@@ -680,19 +680,17 @@ bool LazyStubTier::createMany(const Uint
   }
   MOZ_ASSERT(codeRanges.length() == numExpectedRanges,
              "incorrect number of entries per function");
 
   masm.finish();
 
   MOZ_ASSERT(masm.callSites().empty());
   MOZ_ASSERT(masm.callSiteTargets().empty());
-  MOZ_ASSERT(masm.callFarJumps().empty());
   MOZ_ASSERT(masm.trapSites().empty());
-  MOZ_ASSERT(masm.callFarJumps().empty());
 
   if (masm.oom()) {
     return false;
   }
 
   size_t codeLength = LazyStubSegment::AlignBytesNeeded(masm.bytesNeeded());
 
   if (!stubSegments_.length() ||
--- a/js/src/wasm/WasmGenerator.cpp
+++ b/js/src/wasm/WasmGenerator.cpp
@@ -47,17 +47,16 @@ bool CompiledCode::swap(MacroAssembler& 
   MOZ_ASSERT(bytes.empty());
   if (!masm.swapBuffer(bytes)) {
     return false;
   }
 
   callSites.swap(masm.callSites());
   callSiteTargets.swap(masm.callSiteTargets());
   trapSites.swap(masm.trapSites());
-  callFarJumps.swap(masm.callFarJumps());
   symbolicAccesses.swap(masm.symbolicAccesses());
   codeLabels.swap(masm.codeLabels());
   return true;
 }
 
 // ****************************************************************************
 // ModuleGenerator
 
@@ -663,23 +662,16 @@ bool ModuleGenerator::linkCompiledCode(C
       ts->offsetBy(offsetInModule);
     };
     if (!AppendForEach(&metadataTier_->trapSites[trap], code.trapSites[trap],
                        trapSiteOp)) {
       return false;
     }
   }
 
-  auto callFarJumpOp = [=](uint32_t, CallFarJump* cfj) {
-    cfj->offsetBy(offsetInModule);
-  };
-  if (!AppendForEach(&callFarJumps_, code.callFarJumps, callFarJumpOp)) {
-    return false;
-  }
-
   for (const SymbolicAccess& access : code.symbolicAccesses) {
     uint32_t patchAt = offsetInModule + access.patchAt.offset();
     if (!linkData_->symbolicLinks[access.target].append(patchAt)) {
       return false;
     }
   }
 
   for (const CodeLabel& codeLabel : code.codeLabels) {
@@ -918,17 +910,16 @@ bool ModuleGenerator::finishCodegen() {
     masm_.patchFarJump(farJump, debugTrapCodeOffset_);
   }
 
   // None of the linking or far-jump operations should emit masm metadata.
 
   MOZ_ASSERT(masm_.callSites().empty());
   MOZ_ASSERT(masm_.callSiteTargets().empty());
   MOZ_ASSERT(masm_.trapSites().empty());
-  MOZ_ASSERT(masm_.callFarJumps().empty());
   MOZ_ASSERT(masm_.symbolicAccesses().empty());
   MOZ_ASSERT(masm_.codeLabels().empty());
 
   masm_.finish();
   return !masm_.oom();
 }
 
 bool ModuleGenerator::finishMetadataTier() {
@@ -1257,17 +1248,16 @@ size_t CompiledCode::sizeOfExcludingThis
   for (const TrapSiteVector& vec : trapSites) {
     trapSitesSize += vec.sizeOfExcludingThis(mallocSizeOf);
   }
 
   return bytes.sizeOfExcludingThis(mallocSizeOf) +
          codeRanges.sizeOfExcludingThis(mallocSizeOf) +
          callSites.sizeOfExcludingThis(mallocSizeOf) +
          callSiteTargets.sizeOfExcludingThis(mallocSizeOf) + trapSitesSize +
-         callFarJumps.sizeOfExcludingThis(mallocSizeOf) +
          symbolicAccesses.sizeOfExcludingThis(mallocSizeOf) +
          codeLabels.sizeOfExcludingThis(mallocSizeOf);
 }
 
 size_t CompileTask::sizeOfExcludingThis(
     mozilla::MallocSizeOf mallocSizeOf) const {
   return lifo.sizeOfExcludingThis(mallocSizeOf) +
          inputs.sizeOfExcludingThis(mallocSizeOf) +
--- a/js/src/wasm/WasmGenerator.h
+++ b/js/src/wasm/WasmGenerator.h
@@ -57,41 +57,38 @@ typedef Vector<FuncCompileInput, 8, Syst
 // input functions or stubs.
 
 struct CompiledCode {
   Bytes bytes;
   CodeRangeVector codeRanges;
   CallSiteVector callSites;
   CallSiteTargetVector callSiteTargets;
   TrapSiteVectorArray trapSites;
-  CallFarJumpVector callFarJumps;
   SymbolicAccessVector symbolicAccesses;
   jit::CodeLabelVector codeLabels;
   StackMaps stackMaps;
 
   MOZ_MUST_USE bool swap(jit::MacroAssembler& masm);
 
   void clear() {
     bytes.clear();
     codeRanges.clear();
     callSites.clear();
     callSiteTargets.clear();
     trapSites.clear();
-    callFarJumps.clear();
     symbolicAccesses.clear();
     codeLabels.clear();
     stackMaps.clear();
     MOZ_ASSERT(empty());
   }
 
   bool empty() {
     return bytes.empty() && codeRanges.empty() && callSites.empty() &&
            callSiteTargets.empty() && trapSites.empty() &&
-           callFarJumps.empty() && symbolicAccesses.empty() &&
-           codeLabels.empty() && stackMaps.empty();
+           symbolicAccesses.empty() && codeLabels.empty() && stackMaps.empty();
   }
 
   size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 };
 
 // The CompileTaskState of a ModuleGenerator contains the mutable state shared
 // between helper threads executing CompileTasks. Each CompileTask started on a
 // helper thread eventually either ends up in the 'finished' list or increments
@@ -132,16 +129,22 @@ struct CompileTask {
 // lifetime of a ModuleGenerator, a sequence of FunctionGenerators are created
 // and destroyed to compile the individual function bodies. After generating all
 // functions, ModuleGenerator::finish() must be called to complete the
 // compilation and extract the resulting wasm module.
 
 class MOZ_STACK_CLASS ModuleGenerator {
   typedef Vector<CompileTask, 0, SystemAllocPolicy> CompileTaskVector;
   typedef Vector<jit::CodeOffset, 0, SystemAllocPolicy> CodeOffsetVector;
+  struct CallFarJump {
+    uint32_t funcIndex;
+    jit::CodeOffset jump;
+    CallFarJump(uint32_t fi, jit::CodeOffset j) : funcIndex(fi), jump(j) {}
+  };
+  typedef Vector<CallFarJump, 0, SystemAllocPolicy> CallFarJumpVector;
 
   // Constant parameters
   SharedCompileArgs const compileArgs_;
   UniqueChars* const error_;
   const Atomic<bool>* const cancelled_;
   ModuleEnvironment* const env_;
 
   // Data that is moved into the result of finish()