Bug 1226732 - Use stable hashing and builtin sweeping for ipc::ObjectIdMap; r=billm

This commit is contained in:
Terrence Cole
2015-11-25 11:59:09 -08:00
parent 34c006ba22
commit 1919c2a750
2 changed files with 10 additions and 35 deletions

View File

@@ -11,6 +11,7 @@
#include "mozilla/dom/DOMTypes.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/jsipc/PJavaScript.h"
#include "js/GCHashTable.h"
#include "nsJSUtils.h"
namespace mozilla {
@@ -51,6 +52,10 @@ class ObjectId {
return ObjectId(data >> FLAG_BITS, data & 1);
}
// For use with StructGCPolicy.
void trace(JSTracer*) const {}
bool needsSweep() const { return false; }
private:
ObjectId() : serialNumber_(0), hasXrayWaiver_(false) {}
@@ -103,8 +108,8 @@ class IdToObjectMap
// Map JSObjects -> ids
class ObjectToIdMap
{
typedef js::PointerHasher<JSObject*, 3> Hasher;
typedef js::HashMap<JSObject*, ObjectId, Hasher, js::SystemAllocPolicy> Table;
using Hasher = js::MovableCellHasher<JS::Heap<JSObject*>>;
using Table = js::GCHashMap<JS::Heap<JSObject*>, ObjectId, Hasher, js::SystemAllocPolicy>;
public:
explicit ObjectToIdMap(JSRuntime* rt);
@@ -120,8 +125,6 @@ class ObjectToIdMap
void clear();
private:
static void keyMarkCallback(JSTracer* trc, JSObject* key, void* data);
JSRuntime* rt_;
Table table_;
};