зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1550037) for causing bustages in SharedFontList-impl.h
CLOSED TREE Backed out changeset 34ebd6260867 (bug 1550037) Backed out changeset 7571e5bc19e7 (bug 1550037) Backed out changeset 71fdead8eecb (bug 1550037)
This commit is contained in:
Родитель
9db27b76b5
Коммит
5da80eeda9
|
@ -4977,7 +4977,7 @@ mozilla::ipc::IPCResult ContentParent::RecvGetOutputColorProfileData(
|
|||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvGetFontListShmBlock(
|
||||
const uint32_t& aGeneration, const uint32_t& aIndex,
|
||||
base::SharedMemoryHandle* aOut) {
|
||||
mozilla::ipc::SharedMemoryBasic::Handle* aOut) {
|
||||
auto fontList = gfxPlatformFontList::PlatformFontList();
|
||||
MOZ_RELEASE_ASSERT(fontList, "gfxPlatformFontList not initialized?");
|
||||
fontList->ShareFontListShmBlockToProcess(aGeneration, aIndex, Pid(), aOut);
|
||||
|
|
|
@ -1148,7 +1148,7 @@ class ContentParent final
|
|||
|
||||
mozilla::ipc::IPCResult RecvGetFontListShmBlock(
|
||||
const uint32_t& aGeneration, const uint32_t& aIndex,
|
||||
base::SharedMemoryHandle* aOut);
|
||||
mozilla::ipc::SharedMemoryBasic::Handle* aOut);
|
||||
|
||||
mozilla::ipc::IPCResult RecvInitializeFamily(const uint32_t& aGeneration,
|
||||
const uint32_t& aFamilyIndex);
|
||||
|
|
|
@ -1266,7 +1266,7 @@ parent:
|
|||
* until it has mapped the font-list memory.
|
||||
*/
|
||||
sync GetFontListShmBlock(uint32_t aGeneration, uint32_t aIndex)
|
||||
returns (SharedMemoryHandle aHandle);
|
||||
returns (Handle aHandle);
|
||||
|
||||
/**
|
||||
* Ask the parent to initialize a given font family, so that face metadata
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "SharedFontList.h"
|
||||
|
||||
#include "base/shared_memory.h"
|
||||
#include "mozilla/ipc/SharedMemoryBasic.h"
|
||||
|
||||
#include "gfxFontUtils.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -224,13 +224,12 @@ class FontList {
|
|||
* specific child process.
|
||||
*/
|
||||
void ShareShmBlockToProcess(uint32_t aIndex, base::ProcessId aPid,
|
||||
base::SharedMemoryHandle* aOut) {
|
||||
MOZ_RELEASE_ASSERT(mReadOnlyShmems.Length() == mBlocks.Length());
|
||||
if (aIndex >= mReadOnlyShmems.Length()) {
|
||||
mozilla::ipc::SharedMemoryBasic::Handle* aOut) {
|
||||
if (aIndex >= mBlocks.Length()) {
|
||||
// Block index out of range
|
||||
*aOut = base::SharedMemory::NULLHandle();
|
||||
*aOut = mozilla::ipc::SharedMemoryBasic::NULLHandle();
|
||||
}
|
||||
if (!mReadOnlyShmems[aIndex]->ShareToProcess(aPid, aOut)) {
|
||||
if (!mBlocks[aIndex]->mShmem->ShareToProcess(aPid, aOut)) {
|
||||
MOZ_CRASH("failed to share block");
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +240,7 @@ class FontList {
|
|||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
||||
size_t result = mBlocks.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (const auto& b : mBlocks) {
|
||||
result += aMallocSizeOf(b.get()) + aMallocSizeOf(b->mShmem.get());
|
||||
result += aMallocSizeOf(b.get()) + aMallocSizeOf(b->mShmem);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -269,20 +268,20 @@ class FontList {
|
|||
|
||||
private:
|
||||
struct ShmBlock {
|
||||
// Takes ownership of aShmem
|
||||
ShmBlock(base::SharedMemory* aShmem) : mShmem(aShmem) {}
|
||||
|
||||
// Get pointer to the mapped memory.
|
||||
void* Memory() const { return mShmem->memory(); }
|
||||
ShmBlock(mozilla::ipc::SharedMemoryBasic* aShmem, void* aAddr)
|
||||
: mShmem(aShmem), mAddr(aAddr) {}
|
||||
|
||||
// The first 32-bit word of each block holds the current amount allocated
|
||||
// in that block; this is updated whenever a new record is stored in the
|
||||
// block.
|
||||
std::atomic<uint32_t>& Allocated() const {
|
||||
return *static_cast<std::atomic<uint32_t>*>(Memory());
|
||||
return *static_cast<std::atomic<uint32_t>*>(mAddr);
|
||||
}
|
||||
|
||||
mozilla::UniquePtr<base::SharedMemory> mShmem;
|
||||
RefPtr<mozilla::ipc::SharedMemoryBasic> mShmem;
|
||||
void* mAddr; // Address where the shared memory block is mapped in this
|
||||
// process; avoids virtual call to mShmem->memory() each time
|
||||
// we need to convert between Pointer and a real C++ pointer.
|
||||
};
|
||||
|
||||
Header& GetHeader() {
|
||||
|
@ -325,12 +324,6 @@ class FontList {
|
|||
* added a block (or blocks) to the list, and we need to update!
|
||||
*/
|
||||
nsTArray<mozilla::UniquePtr<ShmBlock>> mBlocks;
|
||||
|
||||
/**
|
||||
* Auxiliary array, used only in the parent process; holds read-only copies
|
||||
* of the shmem blocks; these are what will be shared to child processes.
|
||||
*/
|
||||
nsTArray<mozilla::UniquePtr<base::SharedMemory>> mReadOnlyShmems;
|
||||
};
|
||||
|
||||
} // namespace fontlist
|
||||
|
|
|
@ -60,7 +60,7 @@ void* Pointer::ToPtr(FontList* aFontList) const {
|
|||
}
|
||||
MOZ_ASSERT(block < aFontList->mBlocks.Length());
|
||||
}
|
||||
return static_cast<char*>(aFontList->mBlocks[block]->Memory()) + Offset();
|
||||
return static_cast<char*>(aFontList->mBlocks[block]->mAddr) + Offset();
|
||||
}
|
||||
|
||||
void String::Assign(const nsACString& aString, FontList* aList) {
|
||||
|
@ -519,29 +519,28 @@ FontList::~FontList() { DetachShmBlocks(); }
|
|||
|
||||
bool FontList::AppendShmBlock() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
base::SharedMemory* newShm = new base::SharedMemory();
|
||||
if (!newShm->CreateFreezeable(SHM_BLOCK_SIZE)) {
|
||||
ipc::SharedMemoryBasic* newShm = new ipc::SharedMemoryBasic();
|
||||
if (!newShm->Create(SHM_BLOCK_SIZE)) {
|
||||
MOZ_CRASH("failed to create shared memory");
|
||||
return false;
|
||||
}
|
||||
if (!newShm->Map(SHM_BLOCK_SIZE) || !newShm->memory()) {
|
||||
if (!newShm->Map(SHM_BLOCK_SIZE)) {
|
||||
MOZ_CRASH("failed to map shared memory");
|
||||
}
|
||||
|
||||
ShmBlock* block = new ShmBlock(newShm);
|
||||
char* addr = static_cast<char*>(newShm->memory());
|
||||
if (!addr) {
|
||||
MOZ_CRASH("null shared memory?");
|
||||
return false;
|
||||
}
|
||||
|
||||
ShmBlock* block = new ShmBlock(newShm, addr);
|
||||
// Allocate space for the Allocated() header field present in all blocks
|
||||
block->Allocated().store(4);
|
||||
|
||||
mBlocks.AppendElement(block);
|
||||
GetHeader().mBlockCount.store(mBlocks.Length());
|
||||
|
||||
auto* readOnly = new base::SharedMemory();
|
||||
if (!newShm->ReadOnlyCopy(readOnly)) {
|
||||
MOZ_CRASH("failed to create read-only copy");
|
||||
return false;
|
||||
}
|
||||
mReadOnlyShmems.AppendElement(readOnly);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -549,8 +548,7 @@ void FontList::DetachShmBlocks() {
|
|||
for (auto& i : mBlocks) {
|
||||
i->mShmem = nullptr;
|
||||
}
|
||||
mBlocks.Clear();
|
||||
mReadOnlyShmems.Clear();
|
||||
mBlocks.SetLength(0);
|
||||
}
|
||||
|
||||
FontList::ShmBlock* FontList::GetBlockFromParent(uint32_t aIndex) {
|
||||
|
@ -558,22 +556,27 @@ FontList::ShmBlock* FontList::GetBlockFromParent(uint32_t aIndex) {
|
|||
// If we have no existing blocks, we don't want a generation check yet;
|
||||
// the header in the first block will define the generation of this list
|
||||
uint32_t generation = aIndex == 0 ? 0 : GetGeneration();
|
||||
base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle();
|
||||
ipc::SharedMemoryBasic::Handle handle = ipc::SharedMemoryBasic::NULLHandle();
|
||||
if (!dom::ContentChild::GetSingleton()->SendGetFontListShmBlock(
|
||||
generation, aIndex, &handle)) {
|
||||
return nullptr;
|
||||
}
|
||||
base::SharedMemory* newShm = new base::SharedMemory();
|
||||
RefPtr<ipc::SharedMemoryBasic> newShm = new ipc::SharedMemoryBasic();
|
||||
if (!newShm->IsHandleValid(handle)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!newShm->SetHandle(handle, true)) {
|
||||
if (!newShm->SetHandle(handle,
|
||||
mozilla::ipc::SharedMemoryBasic::RightsReadOnly)) {
|
||||
MOZ_CRASH("failed to set shm handle");
|
||||
}
|
||||
if (!newShm->Map(SHM_BLOCK_SIZE) || !newShm->memory()) {
|
||||
if (!newShm->Map(SHM_BLOCK_SIZE)) {
|
||||
MOZ_CRASH("failed to map shared memory");
|
||||
}
|
||||
return new ShmBlock(newShm);
|
||||
char* addr = static_cast<char*>(newShm->memory());
|
||||
if (!addr) {
|
||||
MOZ_CRASH("null shared memory?");
|
||||
}
|
||||
return new ShmBlock(newShm, addr);
|
||||
}
|
||||
|
||||
bool FontList::UpdateShmBlocks() {
|
||||
|
@ -914,7 +917,7 @@ Pointer FontList::ToSharedPointer(const void* aPtr) {
|
|||
const char* p = (const char*)aPtr;
|
||||
const uint32_t blockCount = mBlocks.Length();
|
||||
for (uint32_t i = 0; i < blockCount; ++i) {
|
||||
const char* blockAddr = (const char*)mBlocks[i]->Memory();
|
||||
const char* blockAddr = (const char*)mBlocks[i]->mAddr;
|
||||
if (p >= blockAddr && p < blockAddr + SHM_BLOCK_SIZE) {
|
||||
return Pointer(i, p - blockAddr);
|
||||
}
|
||||
|
|
|
@ -2267,16 +2267,17 @@ void gfxPlatformFontList::CancelInitOtherFamilyNamesTask() {
|
|||
}
|
||||
|
||||
void gfxPlatformFontList::ShareFontListShmBlockToProcess(
|
||||
uint32_t aGeneration, uint32_t aIndex, base::ProcessId aPid,
|
||||
base::SharedMemoryHandle* aOut) {
|
||||
uint32_t aGeneration, uint32_t aIndex, /*base::ProcessId*/ uint32_t aPid,
|
||||
/*mozilla::ipc::SharedMemoryBasic::Handle*/ void* aOut) {
|
||||
auto list = SharedFontList();
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
auto out = static_cast<mozilla::ipc::SharedMemoryBasic::Handle*>(aOut);
|
||||
if (!aGeneration || list->GetGeneration() == aGeneration) {
|
||||
list->ShareShmBlockToProcess(aIndex, aPid, aOut);
|
||||
list->ShareShmBlockToProcess(aIndex, aPid, out);
|
||||
} else {
|
||||
*aOut = base::SharedMemory::NULLHandle();
|
||||
*out = mozilla::ipc::SharedMemoryBasic::NULLHandle();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "mozilla/RangedArray.h"
|
||||
#include "nsLanguageAtomService.h"
|
||||
|
||||
#include "base/shared_memory.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace fontlist {
|
||||
struct AliasData;
|
||||
|
@ -264,8 +262,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
// result in build failure due to (indirect) inclusion of windows.h
|
||||
// in generated bindings code.
|
||||
void ShareFontListShmBlockToProcess(
|
||||
uint32_t aGeneration, uint32_t aIndex, base::ProcessId aPid,
|
||||
base::SharedMemoryHandle* aOut);
|
||||
uint32_t aGeneration, uint32_t aIndex, /*base::ProcessId*/ uint32_t aPid,
|
||||
/*mozilla::ipc::SharedMemoryBasic::Handle*/ void* aOut);
|
||||
|
||||
void SetCharacterMap(uint32_t aGeneration,
|
||||
const mozilla::fontlist::Pointer& aFacePtr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче