Bug 1461938 part 25 - Move randomKeyGenerator_ from JSCompartment to JS::Realm. r=evilpie

This commit is contained in:
Jan de Mooij 2018-05-23 15:27:04 +02:00
parent 1c6e8b72c0
commit e9f0432b1a
3 changed files with 9 additions and 10 deletions

View File

@ -633,7 +633,7 @@ MapObject*
MapObject::create(JSContext* cx, HandleObject proto /* = nullptr */)
{
auto map = cx->make_unique<ValueMap>(cx->zone(),
cx->compartment()->randomHashCodeScrambler());
cx->realm()->randomHashCodeScrambler());
if (!map || !map->init()) {
ReportOutOfMemory(cx);
return nullptr;
@ -1316,7 +1316,7 @@ SetObject*
SetObject::create(JSContext* cx, HandleObject proto /* = nullptr */)
{
auto set = cx->make_unique<ValueSet>(cx->zone(),
cx->compartment()->randomHashCodeScrambler());
cx->realm()->randomHashCodeScrambler());
if (!set || !set->init()) {
ReportOutOfMemory(cx);
return nullptr;

View File

@ -55,7 +55,6 @@ JSCompartment::JSCompartment(Zone* zone)
nonSyntacticLexicalEnvironments_(nullptr),
gcIncomingGrayPointers(nullptr),
validAccessPtr(nullptr),
randomKeyGenerator_(runtime_->forkRandomKeyGenerator()),
debugEnvs(nullptr),
enumerators(nullptr),
jitCompartment_(nullptr),
@ -69,6 +68,7 @@ Realm::Realm(JS::Zone* zone, const JS::RealmOptions& options)
creationOptions_(options.creationOptions()),
behaviors_(options.behaviors()),
global_(nullptr),
randomKeyGenerator_(runtime_->forkRandomKeyGenerator()),
wasm(zone->runtimeFromMainThread())
{
MOZ_ASSERT_IF(creationOptions_.mergeable(),
@ -1336,7 +1336,7 @@ Realm::randomHashCode()
}
mozilla::HashCodeScrambler
JSCompartment::randomHashCodeScrambler()
Realm::randomHashCodeScrambler()
{
return mozilla::HashCodeScrambler(randomKeyGenerator_.next(),
randomKeyGenerator_.next());

View File

@ -751,12 +751,6 @@ struct JSCompartment
void findOutgoingEdges(js::gc::ZoneComponentFinder& finder);
private:
mozilla::non_crypto::XorShift128PlusRNG randomKeyGenerator_;
public:
mozilla::HashCodeScrambler randomHashCodeScrambler();
static size_t offsetOfRegExps() {
return offsetof(JSCompartment, regExps);
}
@ -817,6 +811,9 @@ class JS::Realm : public JSCompartment
// Random number generator for Math.random().
mozilla::Maybe<mozilla::non_crypto::XorShift128PlusRNG> randomNumberGenerator_;
// Random number generator for randomHashCodeScrambler().
mozilla::non_crypto::XorShift128PlusRNG randomKeyGenerator_;
JSPrincipals* principals_ = nullptr;
// Used by memory reporters and invalid otherwise.
@ -1228,6 +1225,8 @@ class JS::Realm : public JSCompartment
}
js::HashNumber randomHashCode();
mozilla::HashCodeScrambler randomHashCodeScrambler();
};
namespace js {