1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptinfo/src/xptiWorkingSet.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* Implementation of xptiWorkingSet. */ 1.10 + 1.11 +#include "mozilla/XPTInterfaceInfoManager.h" 1.12 + 1.13 +#include "xptiprivate.h" 1.14 +#include "nsString.h" 1.15 + 1.16 +using namespace mozilla; 1.17 + 1.18 +#define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16) 1.19 +#define XPTI_HASHTABLE_SIZE 2048 1.20 + 1.21 +XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet() 1.22 + : mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor") 1.23 + , mIIDTable(XPTI_HASHTABLE_SIZE) 1.24 + , mNameTable(XPTI_HASHTABLE_SIZE) 1.25 +{ 1.26 + MOZ_COUNT_CTOR(xptiWorkingSet); 1.27 + 1.28 + gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double), 1.29 + "xptiWorkingSet structs"); 1.30 +} 1.31 + 1.32 +static PLDHashOperator 1.33 +xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg) 1.34 +{ 1.35 + entry->LockedInvalidateInterfaceInfo(); 1.36 + return PL_DHASH_NEXT; 1.37 +} 1.38 + 1.39 +void 1.40 +XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos() 1.41 +{ 1.42 + ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor); 1.43 + mNameTable.EnumerateRead(xpti_Invalidator, nullptr); 1.44 +} 1.45 + 1.46 +XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet() 1.47 +{ 1.48 + MOZ_COUNT_DTOR(xptiWorkingSet); 1.49 + 1.50 + // Only destroy the arena if we're doing leak stats. Why waste shutdown 1.51 + // time touching pages if we don't have to? 1.52 +#ifdef NS_FREE_PERMANENT_DATA 1.53 + XPT_DestroyArena(gXPTIStructArena); 1.54 +#endif 1.55 +} 1.56 + 1.57 +XPTArena* gXPTIStructArena;