Skip to content

Commit

Permalink
Bug 1451524: Switch the default interceptor VM policy over from uniqu…
Browse files Browse the repository at this point in the history
…e to shared; r=handyman
  • Loading branch information
dblohm7 committed Apr 25, 2018
1 parent 1c804a6 commit 74faba8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions mozglue/misc/interceptor/VMSharingPolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "mozilla/Assertions.h"
#include "mozilla/Types.h"
#include "mozilla/StaticPtr.h"

namespace mozilla {
namespace interceptor {
Expand Down Expand Up @@ -165,15 +164,17 @@ class VMSharingPolicyShared : public MMPolicyBase
return;
}

MOZ_RELEASE_ASSERT(sPerProcVM->append(ProcMapEntry(aArgs...)));
bool appended = sPerProcVM->append(ProcMapEntry(aArgs...));
MOZ_RELEASE_ASSERT(appended);
}

explicit operator bool() const
{
AutoCriticalSection lock(&sCS);

ProcMapEntry* entry;
MOZ_RELEASE_ASSERT(find(mPid, &entry));
bool found = find(mPid, &entry);
MOZ_RELEASE_ASSERT(found);

return !!entry->mVMPolicy;
}
Expand All @@ -183,7 +184,8 @@ class VMSharingPolicyShared : public MMPolicyBase
AutoCriticalSection lock(&sCS);

ProcMapEntry* entry;
MOZ_RELEASE_ASSERT(find(mPid, &entry));
bool found = find(mPid, &entry);
MOZ_RELEASE_ASSERT(found);

return entry->mVMPolicy;
}
Expand Down Expand Up @@ -241,7 +243,8 @@ class VMSharingPolicyShared : public MMPolicyBase
AutoCriticalSection lock(&sCS);

ProcMapEntry* entry;
MOZ_RELEASE_ASSERT(find(mPid, &entry));
bool found = find(mPid, &entry);
MOZ_RELEASE_ASSERT(found);

TrampolineCollection<MMPolicy> items(Move(entry->mVMPolicy.Items()));

Expand Down Expand Up @@ -292,12 +295,12 @@ class VMSharingPolicyShared : public MMPolicyBase
static DWORD GetPid(HANDLE aHandle) { return ::GetProcessId(aHandle); }

DWORD mPid;
static StaticAutoPtr<MapT> sPerProcVM;
static MapT* sPerProcVM;
static CRITICAL_SECTION sCS;
};

template <typename MMPolicy, uint32_t kChunkSize>
StaticAutoPtr<typename VMSharingPolicyShared<MMPolicy, kChunkSize>::MapT>
typename VMSharingPolicyShared<MMPolicy, kChunkSize>::MapT *
VMSharingPolicyShared<MMPolicy, kChunkSize>::sPerProcVM;

template <typename MMPolicy, uint32_t kChunkSize>
Expand Down
2 changes: 1 addition & 1 deletion mozglue/misc/nsWindowsDllInterceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ enum
};

template <typename VMPolicy =
mozilla::interceptor::VMSharingPolicyUnique<
mozilla::interceptor::VMSharingPolicyShared<
mozilla::interceptor::MMPolicyInProcess, kDefaultTrampolineSize>>
class WindowsDllInterceptor final
{
Expand Down

0 comments on commit 74faba8

Please sign in to comment.