Bug 1271022 - use Vector::podResizeToFit in wasm::Module (r=bbouvier)

MozReview-Commit-ID: Booqdgl1QFT

--HG--
extra : rebase_source : 444f3453ce6cecacac47e6b67621fa74bf90e313
This commit is contained in:
Luke Wagner 2016-05-09 09:00:47 -05:00
parent df166c688f
commit 54c2332e47
3 changed files with 40 additions and 0 deletions

View File

@ -932,6 +932,13 @@ ModuleGenerator::finish(CacheableCharsVector&& prettyFuncNames,
if (!finishStaticLinkData(module_->code.get(), module_->codeBytes, link.get()))
return false;
// These Vectors can get large and the excess capacity can be significant,
// so realloc them down to size.
module_->heapAccesses.podResizeToFit();
module_->codeRanges.podResizeToFit();
module_->callSites.podResizeToFit();
module_->callThunks.podResizeToFit();
*module = Move(module_);
*linkData = Move(link);
*exportMap = Move(exportMap_);

View File

@ -293,6 +293,14 @@ class CodeRange
};
};
} // namespace wasm
} // namespace js
namespace mozilla {
template <> struct IsPod<js::wasm::CodeRange> : TrueType {};
}
namespace js {
namespace wasm {
typedef Vector<CodeRange, 0, SystemAllocPolicy> CodeRangeVector;
// A CallThunk describes the offset and target of thunks so that they may be
@ -314,6 +322,14 @@ struct CallThunk
typedef Vector<CallThunk, 0, SystemAllocPolicy> CallThunkVector;
} // namespace wasm
} // namespace js
namespace mozilla {
template <> struct IsPod<js::wasm::CallThunk> : TrueType {};
}
namespace js {
namespace wasm {
// CacheableChars is used to cacheably store UniqueChars.
struct CacheableChars : UniqueChars

View File

@ -466,6 +466,15 @@ class CallSiteAndTarget : public CallSite
uint32_t targetIndex() const { MOZ_ASSERT(isInternal()); return targetIndex_; }
};
} // namespace wasm
} // namespace js
namespace mozilla {
template <> struct IsPod<js::wasm::CallSite> : TrueType {};
template <> struct IsPod<js::wasm::CallSiteAndTarget> : TrueType {};
}
namespace js {
namespace wasm {
typedef Vector<CallSite, 0, SystemAllocPolicy> CallSiteVector;
typedef Vector<CallSiteAndTarget, 0, SystemAllocPolicy> CallSiteAndTargetVector;
@ -568,6 +577,14 @@ class HeapAccess {
};
#endif
} // namespace wasm
} // namespace js
namespace mozilla {
template <> struct IsPod<js::wasm::HeapAccess> : TrueType {};
}
namespace js {
namespace wasm {
typedef Vector<HeapAccess, 0, SystemAllocPolicy> HeapAccessVector;
// A wasm::SymbolicAddress represents a pointer to a well-known function or