Bug 940033 - js::HashMapEntry::{key,value} fields should be private, with accessors, and the former should expose a const reference. r=jimb

--HG--
extra : rebase_source : 439d194ed15bf87e9643c9c09d4512ff7f616fcc
This commit is contained in:
Jeff Walden 2013-11-25 17:35:09 -08:00
parent 2db00edd4f
commit 0d8f37059b
48 changed files with 309 additions and 290 deletions

View File

@ -1014,11 +1014,11 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JS::Handle<JSObject*> obj)
JSObjWrapperTable::AddPtr p = sJSObjWrappers.lookupForAdd(key);
if (p/* && p->value*/) {
MOZ_ASSERT(p->value);
if (p/* && p->value()*/) {
MOZ_ASSERT(p->value());
// Found a live nsJSObjWrapper, return it.
return _retainobject(p->value);
return _retainobject(p->value());
}
// No existing nsJSObjWrapper, create one.
@ -1873,7 +1873,7 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
{
if (sJSObjWrappers.initialized()) {
for (JSObjWrapperTable::Enum e(sJSObjWrappers); !e.empty(); e.popFront()) {
nsJSObjWrapper *npobj = e.front().value;
nsJSObjWrapper *npobj = e.front().value();
MOZ_ASSERT(npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass);
if (npobj->mNpp == npp) {
npobj->ClearJSObject();

View File

@ -30,9 +30,9 @@ void
ObjectStore::trace(JSTracer *trc)
{
for (ObjectTable::Range r(table_.all()); !r.empty(); r.popFront()) {
DebugOnly<JSObject *> prior = r.front().value.get();
JS_CallHeapObjectTracer(trc, &r.front().value, "ipc-object");
MOZ_ASSERT(r.front().value == prior);
DebugOnly<JSObject *> prior = r.front().value().get();
JS_CallHeapObjectTracer(trc, &r.front().value(), "ipc-object");
MOZ_ASSERT(r.front().value() == prior);
}
}
@ -42,7 +42,7 @@ ObjectStore::find(ObjectId id)
ObjectTable::Ptr p = table_.lookup(id);
if (!p)
return nullptr;
return p->value;
return p->value();
}
bool
@ -82,9 +82,9 @@ void
ObjectIdCache::trace(JSTracer *trc)
{
for (ObjectIdTable::Range r(table_->all()); !r.empty(); r.popFront()) {
JSObject *obj = r.front().key;
JSObject *obj = r.front().key();
JS_CallObjectTracer(trc, &obj, "ipc-id");
MOZ_ASSERT(obj == r.front().key);
MOZ_ASSERT(obj == r.front().key());
}
}
@ -94,7 +94,7 @@ ObjectIdCache::find(JSObject *obj)
ObjectIdTable::Ptr p = table_->lookup(obj);
if (!p)
return 0;
return p->value;
return p->value();
}
bool

View File

@ -60,8 +60,8 @@ class HashMap
struct MapHashPolicy : HashPolicy
{
typedef Key KeyType;
static const Key &getKey(TableEntry &e) { return e.key; }
static void setKey(TableEntry &e, Key &k) { HashPolicy::rekey(const_cast<Key &>(e.key), k); }
static const Key &getKey(TableEntry &e) { return e.key(); }
static void setKey(TableEntry &e, Key &k) { HashPolicy::rekey(e.mutableKey(), k); }
};
typedef detail::HashTable<TableEntry, MapHashPolicy, AllocPolicy> Impl;
@ -151,7 +151,7 @@ class HashMap
template<typename KeyInput, typename ValueInput>
bool relookupOrAdd(AddPtr &p, KeyInput &&k, ValueInput &&v) {
Entry e(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
return impl.relookupOrAdd(p, e.key, mozilla::Move(e));
return impl.relookupOrAdd(p, e.key(), mozilla::Move(e));
}
// |all()| returns a Range containing |count()| elements. E.g.:
@ -223,7 +223,7 @@ class HashMap
bool put(KeyInput &&k, ValueInput &&v) {
AddPtr p = lookupForAdd(k);
if (p) {
p->value = mozilla::Forward<ValueInput>(v);
p->value() = mozilla::Forward<ValueInput>(v);
return true;
}
return add(p, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
@ -233,7 +233,7 @@ class HashMap
template<typename KeyInput, typename ValueInput>
bool putNew(KeyInput &&k, ValueInput &&v) {
Entry e(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
return impl.putNew(e.key, mozilla::Move(e));
return impl.putNew(e.key(), mozilla::Move(e));
}
// Add (k,defaultValue) if |k| is not found. Return a false-y Ptr on oom.
@ -616,25 +616,37 @@ struct DefaultHasher<float>
template <class Key, class Value>
class HashMapEntry
{
Key key_;
Value value_;
template <class, class, class> friend class detail::HashTable;
template <class> friend class detail::HashTableEntry;
template <class, class, class, class> friend class HashMap;
HashMapEntry(const HashMapEntry &) MOZ_DELETE;
void operator=(const HashMapEntry &) MOZ_DELETE;
Key & mutableKey() { return key_; }
public:
template<typename KeyInput, typename ValueInput>
HashMapEntry(KeyInput &&k, ValueInput &&v)
: key(mozilla::Forward<KeyInput>(k)), value(mozilla::Forward<ValueInput>(v)) { }
: key_(mozilla::Forward<KeyInput>(k)),
value_(mozilla::Forward<ValueInput>(v))
{}
HashMapEntry(HashMapEntry &&rhs)
: key(mozilla::Move(const_cast<Key &>(rhs.key))), value(mozilla::Move(rhs.value)) { }
: key_(mozilla::Move(rhs.key_)),
value_(mozilla::Move(rhs.value_))
{}
typedef Key KeyType;
typedef Value ValueType;
const Key key;
Value value;
const Key & key() const { return key_; }
const Value & value() const { return value_; }
Value & value() { return value_; }
private:
HashMapEntry(const HashMapEntry &) MOZ_DELETE;
void operator=(const HashMapEntry &) MOZ_DELETE;
};
} // namespace js

View File

@ -343,13 +343,13 @@ struct ZoneStats : js::ZoneStatsPod
MOZ_ASSERT(other.notableStrings.empty());
for (StringsHashMap::Range r = other.strings.all(); !r.empty(); r.popFront()) {
StringsHashMap::AddPtr p = strings.lookupForAdd(r.front().key);
StringsHashMap::AddPtr p = strings.lookupForAdd(r.front().key());
if (p) {
// We've seen this string before; add its size to our tally.
p->value.add(r.front().value);
p->value().add(r.front().value());
} else {
// We haven't seen this string before; add it to the hashtable.
strings.add(p, r.front().key, r.front().value);
strings.add(p, r.front().key(), r.front().value());
}
}
}

View File

@ -2923,14 +2923,14 @@ BuildTypeSource(JSContext* cx,
break;
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront())
fieldsArray[r.front().value.mIndex] = &r.front();
fieldsArray[r.front().value().mIndex] = &r.front();
for (size_t i = 0; i < length; ++i) {
const FieldInfoHash::Entry* entry = fieldsArray[i];
AppendString(result, "{ \"");
AppendString(result, entry->key);
AppendString(result, entry->key());
AppendString(result, "\": ");
BuildTypeSource(cx, entry->value.mType, true, result);
BuildTypeSource(cx, entry->value().mType, true, result);
AppendString(result, " }");
if (i != length - 1)
AppendString(result, ", ");
@ -3073,19 +3073,19 @@ BuildDataSource(JSContext* cx,
return false;
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront())
fieldsArray[r.front().value.mIndex] = &r.front();
fieldsArray[r.front().value().mIndex] = &r.front();
for (size_t i = 0; i < length; ++i) {
const FieldInfoHash::Entry* entry = fieldsArray[i];
if (isImplicit) {
AppendString(result, "\"");
AppendString(result, entry->key);
AppendString(result, entry->key());
AppendString(result, "\": ");
}
char* fieldData = static_cast<char*>(data) + entry->value.mOffset;
RootedObject entryType(cx, entry->value.mType);
char* fieldData = static_cast<char*>(data) + entry->value().mOffset;
RootedObject entryType(cx, entry->value().mType);
if (!BuildDataSource(cx, entryType, fieldData, true, result))
return false;
@ -3352,11 +3352,11 @@ CType::Trace(JSTracer* trc, JSObject* obj)
FieldInfoHash* fields =
static_cast<FieldInfoHash*>(JSVAL_TO_PRIVATE(slot));
for (FieldInfoHash::Enum e(*fields); !e.empty(); e.popFront()) {
JSString *key = e.front().key;
JSString *key = e.front().key();
JS_CallStringTracer(trc, &key, "fieldName");
if (key != e.front().key)
if (key != e.front().key())
e.rekeyFront(JS_ASSERT_STRING_IS_FLAT(key));
JS_CallHeapObjectTracer(trc, &e.front().value.mType, "fieldType");
JS_CallHeapObjectTracer(trc, &e.front().value().mType, "fieldType");
}
break;
@ -4931,10 +4931,10 @@ StructType::BuildFFIType(JSContext* cx, JSObject* obj)
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) {
const FieldInfoHash::Entry& entry = r.front();
ffi_type* fieldType = CType::GetFFIType(cx, entry.value.mType);
ffi_type* fieldType = CType::GetFFIType(cx, entry.value().mType);
if (!fieldType)
return nullptr;
elements[entry.value.mIndex] = fieldType;
elements[entry.value().mIndex] = fieldType;
}
} else {
@ -5072,7 +5072,7 @@ StructType::ConstructData(JSContext* cx,
// ImplicitConvert each field.
if (args.length() == fields->count()) {
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) {
const FieldInfo& field = r.front().value;
const FieldInfo& field = r.front().value();
STATIC_ASSUME(field.mIndex < fields->count()); /* Quantified invariant */
if (!ImplicitConvert(cx, args[field.mIndex], field.mType,
buffer + field.mOffset,
@ -5108,7 +5108,7 @@ StructType::LookupField(JSContext* cx, JSObject* obj, JSFlatString *name)
FieldInfoHash::Ptr ptr = GetFieldInfo(obj)->lookup(name);
if (ptr)
return &ptr->value;
return &ptr->value();
JSAutoByteString bytes(cx, name);
if (!bytes)
@ -5136,8 +5136,8 @@ StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront()) {
const FieldInfoHash::Entry& entry = r.front();
// Add the field descriptor to the array.
if (!AddFieldToArray(cx, &fieldsVec[entry.value.mIndex],
entry.key, entry.value.mType))
if (!AddFieldToArray(cx, &fieldsVec[entry.value().mIndex],
entry.key(), entry.value().mType))
return nullptr;
}

View File

@ -134,12 +134,12 @@ class InlineMap
K &key() {
JS_ASSERT(found());
return isInlinePtr ? inlPtr->key : mapPtr->key;
return isInlinePtr ? inlPtr->key : mapPtr->key();
}
V &value() {
JS_ASSERT(found());
return isInlinePtr ? inlPtr->value : mapPtr->value;
return isInlinePtr ? inlPtr->value : mapPtr->value();
}
}; /* class Ptr */
@ -178,7 +178,7 @@ class InlineMap
JS_ASSERT(found());
if (isInlinePtr)
return inlAddPtr->value;
return mapAddPtr->value;
return mapAddPtr->value();
}
}; /* class AddPtr */
@ -356,7 +356,7 @@ class InlineMap
JS_ASSERT(!empty());
if (isInlineRange())
return Entry(cur->key, cur->value);
return Entry(mapRange.front().key, mapRange.front().value);
return Entry(mapRange.front().key(), mapRange.front().value());
}
void popFront() {

View File

@ -115,8 +115,8 @@ frontend::InitAtomMap(frontend::AtomIndexMap *indices, HeapPtrAtom *atoms)
typedef AtomIndexMap::WordMap WordMap;
const WordMap &wm = indices->asMap();
for (WordMap::Range r = wm.all(); !r.empty(); r.popFront()) {
JSAtom *atom = r.front().key;
jsatomid index = r.front().value;
JSAtom *atom = r.front().key();
jsatomid index = r.front().value();
JS_ASSERT(index < indices->count());
atoms[index].init(atom);
}

View File

@ -474,11 +474,11 @@ AutoGCRooter::trace(JSTracer *trc)
case OBJOBJHASHMAP: {
AutoObjectObjectHashMap::HashMapImpl &map = static_cast<AutoObjectObjectHashMap *>(this)->map;
for (AutoObjectObjectHashMap::Enum e(map); !e.empty(); e.popFront()) {
MarkObjectRoot(trc, &e.front().value, "AutoObjectObjectHashMap value");
JS_SET_TRACING_LOCATION(trc, (void *)&e.front().key);
JSObject *key = e.front().key;
MarkObjectRoot(trc, &e.front().value(), "AutoObjectObjectHashMap value");
JS_SET_TRACING_LOCATION(trc, (void *)&e.front().key());
JSObject *key = e.front().key();
MarkObjectRoot(trc, &key, "AutoObjectObjectHashMap key");
if (key != e.front().key)
if (key != e.front().key())
e.rekeyFront(key);
}
return;
@ -488,9 +488,9 @@ AutoGCRooter::trace(JSTracer *trc)
AutoObjectUnsigned32HashMap *self = static_cast<AutoObjectUnsigned32HashMap *>(this);
AutoObjectUnsigned32HashMap::HashMapImpl &map = self->map;
for (AutoObjectUnsigned32HashMap::Enum e(map); !e.empty(); e.popFront()) {
JSObject *key = e.front().key;
JSObject *key = e.front().key();
MarkObjectRoot(trc, &key, "AutoObjectUnsignedHashMap key");
if (key != e.front().key)
if (key != e.front().key())
e.rekeyFront(key);
}
return;
@ -684,16 +684,18 @@ js::gc::MarkRuntime(JSTracer *trc, bool useSavedRoots)
for (RootRange r = rt->gcRootsHash.all(); !r.empty(); r.popFront()) {
const RootEntry &entry = r.front();
const char *name = entry.value.name ? entry.value.name : "root";
if (entry.value.type == JS_GC_ROOT_VALUE_PTR) {
MarkValueRoot(trc, reinterpret_cast<Value *>(entry.key), name);
} else if (*reinterpret_cast<void **>(entry.key)){
if (entry.value.type == JS_GC_ROOT_STRING_PTR)
MarkStringRoot(trc, reinterpret_cast<JSString **>(entry.key), name);
else if (entry.value.type == JS_GC_ROOT_OBJECT_PTR)
MarkObjectRoot(trc, reinterpret_cast<JSObject **>(entry.key), name);
else if (entry.value.type == JS_GC_ROOT_SCRIPT_PTR)
MarkScriptRoot(trc, reinterpret_cast<JSScript **>(entry.key), name);
const char *name = entry.value().name ? entry.value().name : "root";
JSGCRootType type = entry.value().type;
void *key = entry.key();
if (type == JS_GC_ROOT_VALUE_PTR) {
MarkValueRoot(trc, reinterpret_cast<Value *>(key), name);
} else if (*reinterpret_cast<void **>(key)){
if (type == JS_GC_ROOT_STRING_PTR)
MarkStringRoot(trc, reinterpret_cast<JSString **>(key), name);
else if (type == JS_GC_ROOT_OBJECT_PTR)
MarkObjectRoot(trc, reinterpret_cast<JSObject **>(key), name);
else if (type == JS_GC_ROOT_SCRIPT_PTR)
MarkScriptRoot(trc, reinterpret_cast<JSScript **>(key), name);
else
MOZ_ASSUME_UNREACHABLE("unexpected js::RootInfo::type value");
}

View File

@ -1396,13 +1396,14 @@ class MOZ_STACK_CLASS ModuleCompiler
const Global *lookupGlobal(PropertyName *name) const {
if (GlobalMap::Ptr p = globals_.lookup(name))
return p->value;
return p->value();
return nullptr;
}
Func *lookupFunction(PropertyName *name) {
if (GlobalMap::Ptr p = globals_.lookup(name)) {
if (p->value->which() == Global::Function)
return functions_[p->value->funcIndex()];
Global *value = p->value();
if (value->which() == Global::Function)
return functions_[value->funcIndex()];
}
return nullptr;
}
@ -1420,7 +1421,7 @@ class MOZ_STACK_CLASS ModuleCompiler
}
bool lookupStandardLibraryMathName(PropertyName *name, AsmJSMathBuiltin *mathBuiltin) const {
if (MathNameMap::Ptr p = standardLibraryMathNames_.lookup(name)) {
*mathBuiltin = p->value;
*mathBuiltin = p->value();
return true;
}
return false;
@ -1551,7 +1552,7 @@ class MOZ_STACK_CLASS ModuleCompiler
ExitDescriptor exitDescriptor(name, Move(sig));
ExitMap::AddPtr p = exits_.lookupForAdd(exitDescriptor);
if (p) {
*exitIndex = p->value;
*exitIndex = p->value();
return true;
}
if (!module_->addExit(ffiIndex, exitIndex))
@ -1979,7 +1980,7 @@ class FunctionCompiler
const Local *lookupLocal(PropertyName *name) const
{
if (LocalMap::Ptr p = locals_.lookup(name))
return &p->value;
return &p->value();
return nullptr;
}
@ -2536,7 +2537,7 @@ class FunctionCompiler
{
bool createdJoinBlock = false;
if (UnlabeledBlockMap::Ptr p = unlabeledContinues_.lookup(pn)) {
if (!bindBreaksOrContinues(&p->value, &createdJoinBlock, pn))
if (!bindBreaksOrContinues(&p->value(), &createdJoinBlock, pn))
return false;
unlabeledContinues_.remove(p);
}
@ -2698,7 +2699,7 @@ class FunctionCompiler
const LabelVector &labels = *maybeLabels;
for (unsigned i = 0; i < labels.length(); i++) {
if (LabeledBlockMap::Ptr p = map->lookup(labels[i])) {
if (!bindBreaksOrContinues(&p->value, createdJoinBlock, pn))
if (!bindBreaksOrContinues(&p->value(), createdJoinBlock, pn))
return false;
map->remove(p);
}
@ -2717,7 +2718,7 @@ class FunctionCompiler
if (!map->add(p, key, Move(empty)))
return false;
}
if (!p->value.append(curBlock_))
if (!p->value().append(curBlock_))
return false;
curBlock_ = nullptr;
return true;
@ -2727,7 +2728,7 @@ class FunctionCompiler
{
bool createdJoinBlock = false;
if (UnlabeledBlockMap::Ptr p = unlabeledBreaks_.lookup(pn)) {
if (!bindBreaksOrContinues(&p->value, &createdJoinBlock, pn))
if (!bindBreaksOrContinues(&p->value(), &createdJoinBlock, pn))
return false;
unlabeledBreaks_.remove(p);
}
@ -6373,7 +6374,7 @@ GenerateStubs(ModuleCompiler &m)
// The order of the iterations here is non-deterministic, since
// m.allExits() is a hash keyed by pointer values!
for (ModuleCompiler::ExitMap::Range r = m.allExits(); !r.empty(); r.popFront()) {
GenerateFFIExit(m, r.front().key, r.front().value, &throwLabel);
GenerateFFIExit(m, r.front().key(), r.front().value(), &throwLabel);
if (m.masm().oom())
return false;
}

View File

@ -891,7 +891,7 @@ void
jit::JitCompartment::toggleBaselineStubBarriers(bool enabled)
{
for (ICStubCodeMap::Enum e(*stubCodes_); !e.empty(); e.popFront()) {
IonCode *code = *e.front().value.unsafeGet();
IonCode *code = *e.front().value().unsafeGet();
code->togglePreBarriers(enabled);
}
}

View File

@ -603,7 +603,7 @@ JitRuntime::getVMWrapper(const VMFunction &f) const
JitRuntime::VMWrapperMap::Ptr p = functionWrappers_->readonlyThreadsafeLookup(&f);
JS_ASSERT(p);
return p->value;
return p->value();
}
template <AllowGC allowGC>

View File

@ -1377,7 +1377,7 @@ FindDominatingBoundsCheck(BoundsCheckMap &checks, MBoundsCheck *check, size_t in
// See the comment in ValueNumberer::findDominatingDef.
HashNumber hash = BoundsCheckHashIgnoreOffset(check);
BoundsCheckMap::Ptr p = checks.lookup(hash);
if (!p || index > p->value.validUntil) {
if (!p || index > p->value().validUntil) {
// We didn't find a dominating bounds check.
BoundsCheckInfo info;
info.check = check;
@ -1389,7 +1389,7 @@ FindDominatingBoundsCheck(BoundsCheckMap &checks, MBoundsCheck *check, size_t in
return check;
}
return p->value.check;
return p->value().check;
}
// Extract a linear sum from ins, if possible (otherwise giving the sum 'ins + 0').

View File

@ -368,7 +368,7 @@ class JitCompartment
IonCode *getStubCode(uint32_t key) {
ICStubCodeMap::AddPtr p = stubCodes_->lookupForAdd(key);
if (p)
return p->value;
return p->value();
return nullptr;
}
bool putStubCode(uint32_t key, Handle<IonCode *> stubCode) {

View File

@ -35,14 +35,14 @@ ValueNumberer::lookupValue(MDefinition *ins)
if (p) {
// make sure this is in the correct group
setClass(ins, p->key);
setClass(ins, p->key());
} else {
if (!values.add(p, ins, ins->id()))
return 0;
breakClass(ins);
}
return p->value;
return p->value();
}
MDefinition *
@ -309,7 +309,7 @@ ValueNumberer::findDominatingDef(InstructionMap &defs, MDefinition *ins, size_t
JS_ASSERT(ins->valueNumber() != 0);
InstructionMap::Ptr p = defs.lookup(ins->valueNumber());
MDefinition *dom;
if (!p || index > p->value.validUntil) {
if (!p || index > p->value().validUntil) {
DominatingValue value;
value.def = ins;
// Since we are traversing the dominator tree in pre-order, when we
@ -326,7 +326,7 @@ ValueNumberer::findDominatingDef(InstructionMap &defs, MDefinition *ins, size_t
dom = ins;
} else {
dom = p->value.def;
dom = p->value().def;
}
return dom;

View File

@ -660,7 +660,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
JS_ASSERT(functionWrappers_->initialized());
VMWrapperMap::AddPtr p = functionWrappers_->lookupForAdd(&f);
if (p)
return p->value;
return p->value();
// Generate a separated code for the wrapper.
MacroAssembler masm(cx);

View File

@ -28,7 +28,7 @@ MacroAssemblerX64::loadConstantDouble(double d, const FloatRegister &dest)
}
size_t doubleIndex;
if (DoubleMap::AddPtr p = doubleMap_.lookupForAdd(d)) {
doubleIndex = p->value;
doubleIndex = p->value();
} else {
doubleIndex = doubles_.length();
enoughMemory_ &= doubles_.append(Double(d));
@ -62,7 +62,7 @@ MacroAssemblerX64::loadConstantFloat32(float f, const FloatRegister &dest)
}
size_t floatIndex;
if (FloatMap::AddPtr p = floatMap_.lookupForAdd(f)) {
floatIndex = p->value;
floatIndex = p->value();
} else {
floatIndex = floats_.length();
enoughMemory_ &= floats_.append(Float(f));

View File

@ -510,7 +510,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
JS_ASSERT(functionWrappers_->initialized());
VMWrapperMap::AddPtr p = functionWrappers_->lookupForAdd(&f);
if (p)
return p->value;
return p->value();
// Generate a separated code for the wrapper.
MacroAssembler masm;

View File

@ -29,7 +29,7 @@ MacroAssemblerX86::getDouble(double d)
size_t doubleIndex;
DoubleMap::AddPtr p = doubleMap_.lookupForAdd(d);
if (p) {
doubleIndex = p->value;
doubleIndex = p->value();
} else {
doubleIndex = doubles_.length();
enoughMemory_ &= doubles_.append(Double(d));
@ -75,7 +75,7 @@ MacroAssemblerX86::getFloat(float f)
size_t floatIndex;
FloatMap::AddPtr p = floatMap_.lookupForAdd(f);
if (p) {
floatIndex = p->value;
floatIndex = p->value();
} else {
floatIndex = floats_.length();
enoughMemory_ &= floats_.append(Float(f));

View File

@ -545,7 +545,7 @@ JitRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
JS_ASSERT(functionWrappers_->initialized());
VMWrapperMap::AddPtr p = functionWrappers_->lookupForAdd(&f);
if (p)
return p->value;
return p->value();
// Generate a separated code for the wrapper.
MacroAssembler masm;

View File

@ -61,15 +61,15 @@ MapsAreEqual(IntMap &am, IntMap &bm)
fprintf(stderr, "A.count() == %u and B.count() == %u\n", am.count(), bm.count());
}
for (IntMap::Range r = am.all(); !r.empty(); r.popFront()) {
if (!bm.has(r.front().key)) {
if (!bm.has(r.front().key())) {
equal = false;
fprintf(stderr, "B does not have %x which is in A\n", r.front().key);
fprintf(stderr, "B does not have %x which is in A\n", r.front().key());
}
}
for (IntMap::Range r = bm.all(); !r.empty(); r.popFront()) {
if (!am.has(r.front().key)) {
if (!am.has(r.front().key())) {
equal = false;
fprintf(stderr, "A does not have %x which is in B\n", r.front().key);
fprintf(stderr, "A does not have %x which is in B\n", r.front().key());
}
}
return equal;
@ -141,17 +141,17 @@ SlowRekey(IntMap *m) {
tmp.init();
for (IntMap::Range r = m->all(); !r.empty(); r.popFront()) {
if (NewKeyFunction::shouldBeRemoved(r.front().key))
if (NewKeyFunction::shouldBeRemoved(r.front().key()))
continue;
uint32_t hi = NewKeyFunction::rekey(r.front().key);
uint32_t hi = NewKeyFunction::rekey(r.front().key());
if (tmp.has(hi))
return false;
tmp.putNew(hi, r.front().value);
tmp.putNew(hi, r.front().value());
}
m->clear();
for (IntMap::Range r = tmp.all(); !r.empty(); r.popFront()) {
m->putNew(r.front().key, r.front().value);
m->putNew(r.front().key(), r.front().value());
}
return true;
@ -193,8 +193,8 @@ BEGIN_TEST(testHashRekeyManual)
CHECK(MapsAreEqual(am, bm));
for (IntMap::Enum e(am); !e.empty(); e.popFront()) {
uint32_t tmp = LowToHigh::rekey(e.front().key);
if (tmp != e.front().key)
uint32_t tmp = LowToHigh::rekey(e.front().key());
if (tmp != e.front().key())
e.rekeyFront(tmp);
}
CHECK(SlowRekey<LowToHigh>(&bm));
@ -243,11 +243,11 @@ BEGIN_TEST(testHashRekeyManualRemoval)
CHECK(MapsAreEqual(am, bm));
for (IntMap::Enum e(am); !e.empty(); e.popFront()) {
if (LowToHighWithRemoval::shouldBeRemoved(e.front().key)) {
if (LowToHighWithRemoval::shouldBeRemoved(e.front().key())) {
e.removeFront();
} else {
uint32_t tmp = LowToHighWithRemoval::rekey(e.front().key);
if (tmp != e.front().key)
uint32_t tmp = LowToHighWithRemoval::rekey(e.front().key());
if (tmp != e.front().key())
e.rekeyFront(tmp);
}
}

View File

@ -1095,7 +1095,7 @@ JS_TransplantObject(JSContext *cx, HandleObject origobj, HandleObject target)
// There might already be a wrapper for the original object in
// the new compartment. If there is, we use its identity and swap
// in the contents of |target|.
newIdentity = &p->value.toObject();
newIdentity = &p->value().toObject();
// When we remove origv from the wrapper map, its wrapper, newIdentity,
// must immediately cease to be a cross-compartment wrapper. Neuter it.

View File

@ -101,8 +101,8 @@ JSCompartment::sweepCallsiteClones()
{
if (callsiteClones.initialized()) {
for (CallsiteCloneTable::Enum e(callsiteClones); !e.empty(); e.popFront()) {
CallsiteCloneKey key = e.front().key;
JSFunction *fun = e.front().value;
CallsiteCloneKey key = e.front().key();
JSFunction *fun = e.front().value();
if (!IsScriptMarked(&key.script) || !IsObjectMarked(&fun))
e.removeFront();
}
@ -128,7 +128,7 @@ js::ExistingCloneFunctionAtCallsite(const CallsiteCloneTable &table, JSFunction
CallsiteCloneTable::Ptr p = table.lookup(CallsiteCloneKey(fun, script, script->pcToOffset(pc)));
if (p)
return p->value;
return p->value();
return nullptr;
}

View File

@ -229,7 +229,7 @@ JSCompartment::wrap(JSContext *cx, JSString **strp)
/* Check the cache. */
RootedValue key(cx, StringValue(str));
if (WrapperMap::Ptr p = crossCompartmentWrappers.lookup(key)) {
*strp = p->value.get().toString();
*strp = p->value().get().toString();
return true;
}
@ -333,7 +333,7 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin
/* If we already have a wrapper for this value, use it. */
RootedValue key(cx, ObjectValue(*obj));
if (WrapperMap::Ptr p = crossCompartmentWrappers.lookup(key)) {
obj.set(&p->value.get().toObject());
obj.set(&p->value().get().toObject());
JS_ASSERT(obj->is<CrossCompartmentWrapperObject>());
JS_ASSERT(obj->getParent() == global);
return true;
@ -449,8 +449,8 @@ JSCompartment::markCrossCompartmentWrappers(JSTracer *trc)
JS_ASSERT(!zone()->isCollecting());
for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
Value v = e.front().value;
if (e.front().key.kind == CrossCompartmentKey::ObjectWrapper) {
Value v = e.front().value();
if (e.front().key().kind == CrossCompartmentKey::ObjectWrapper) {
ProxyObject *wrapper = &v.toObject().as<ProxyObject>();
/*
@ -474,12 +474,12 @@ void
JSCompartment::markAllCrossCompartmentWrappers(JSTracer *trc)
{
for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
CrossCompartmentKey key = e.front().key;
CrossCompartmentKey key = e.front().key();
MarkGCThingRoot(trc, (void **)&key.wrapped, "CrossCompartmentKey::wrapped");
if (key.debugger)
MarkObjectRoot(trc, &key.debugger, "CrossCompartmentKey::debugger");
MarkValueRoot(trc, e.front().value.unsafeGet(), "CrossCompartmentWrapper");
if (key.wrapped != e.front().key.wrapped || key.debugger != e.front().key.debugger)
MarkValueRoot(trc, e.front().value().unsafeGet(), "CrossCompartmentWrapper");
if (key.wrapped != e.front().key().wrapped || key.debugger != e.front().key().debugger)
e.rekeyFront(key);
}
}
@ -577,14 +577,16 @@ JSCompartment::sweepCrossCompartmentWrappers()
/* Remove dead wrappers from the table. */
for (WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
CrossCompartmentKey key = e.front().key;
CrossCompartmentKey key = e.front().key();
bool keyDying = IsCellAboutToBeFinalized(&key.wrapped);
bool valDying = IsValueAboutToBeFinalized(e.front().value.unsafeGet());
bool valDying = IsValueAboutToBeFinalized(e.front().value().unsafeGet());
bool dbgDying = key.debugger && IsObjectAboutToBeFinalized(&key.debugger);
if (keyDying || valDying || dbgDying) {
JS_ASSERT(key.kind != CrossCompartmentKey::StringWrapper);
e.removeFront();
} else if (key.wrapped != e.front().key.wrapped || key.debugger != e.front().key.debugger) {
} else if (key.wrapped != e.front().key().wrapped ||
key.debugger != e.front().key().debugger)
{
e.rekeyFront(key);
}
}

View File

@ -610,11 +610,11 @@ struct WrapperValue
* is in use, the AutoWrapper rooter will ensure the wrapper gets marked.
*/
explicit WrapperValue(const WrapperMap::Ptr &ptr)
: value(*ptr->value.unsafeGet())
: value(*ptr->value().unsafeGet())
{}
explicit WrapperValue(const WrapperMap::Enum &e)
: value(*e.front().value.unsafeGet())
: value(*e.front().value().unsafeGet())
{}
Value &get() { return value; }

View File

@ -91,9 +91,9 @@ JSCompartment::wrap(JSContext *cx, JS::MutableHandleValue vp, JS::HandleObject e
JS::RootedValue v(cx, vp);
if (js::WrapperMap::Ptr p = crossCompartmentWrappers.lookup(v)) {
#ifdef DEBUG
cacheResult = &p->value.get().toObject();
cacheResult = &p->value().get().toObject();
#else
vp.set(p->value);
vp.set(p->value());
return true;
#endif
}

View File

@ -660,7 +660,7 @@ js::VisitGrayWrapperTargets(Zone *zone, GCThingCallback callback, void *closure)
JSRuntime *rt = zone->runtimeFromMainThread();
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) {
for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) {
gc::Cell *thing = e.front().key.wrapped;
gc::Cell *thing = e.front().key().wrapped;
if (!IsInsideNursery(rt, thing) && thing->isMarked(gc::GRAY))
callback(closure, thing);
}

View File

@ -2881,7 +2881,7 @@ InCrossCompartmentMap(JSObject *src, Cell *dst, JSGCTraceKind dstKind)
if (dstKind == JSTRACE_OBJECT) {
Value key = ObjectValue(*static_cast<JSObject *>(dst));
if (WrapperMap::Ptr p = srccomp->lookupWrapper(key)) {
if (*p->value.unsafeGet() == ObjectValue(*src))
if (*p->value().unsafeGet() == ObjectValue(*src))
return true;
}
}
@ -2891,7 +2891,7 @@ InCrossCompartmentMap(JSObject *src, Cell *dst, JSGCTraceKind dstKind)
* know the right hashtable key, so we have to iterate.
*/
for (JSCompartment::WrapperEnum e(srccomp); !e.empty(); e.popFront()) {
if (e.front().key.wrapped == dst && ToMarkable(e.front().value) == src)
if (e.front().key().wrapped == dst && ToMarkable(e.front().value()) == src)
return true;
}
@ -3124,7 +3124,7 @@ BeginMarkPhase(JSRuntime *rt)
/* Set the maybeAlive flag based on cross-compartment edges. */
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
Cell *dst = e.front().key.wrapped;
Cell *dst = e.front().key().wrapped;
dst->tenuredZone()->maybeAlive = true;
}
}
@ -3252,7 +3252,7 @@ js::gc::MarkingValidator::~MarkingValidator()
return;
for (BitmapMap::Range r(map.all()); !r.empty(); r.popFront())
js_delete(r.front().value);
js_delete(r.front().value());
}
void
@ -3358,7 +3358,7 @@ js::gc::MarkingValidator::nonIncrementalMark()
for (GCChunkSet::Range r(runtime->gcChunkSet.all()); !r.empty(); r.popFront()) {
Chunk *chunk = r.front();
ChunkBitmap *bitmap = &chunk->bitmap;
ChunkBitmap *entry = map.lookup(chunk)->value;
ChunkBitmap *entry = map.lookup(chunk)->value();
Swap(*entry, *bitmap);
}
@ -3390,7 +3390,7 @@ js::gc::MarkingValidator::validate()
if (!ptr)
continue; /* Allocated after we did the non-incremental mark. */
ChunkBitmap *bitmap = ptr->value;
ChunkBitmap *bitmap = ptr->value();
ChunkBitmap *incBitmap = &chunk->bitmap;
for (size_t i = 0; i < ArenasPerChunk; i++) {
@ -3482,7 +3482,7 @@ DropStringWrappers(JSRuntime *rt)
*/
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
if (e.front().key.kind == CrossCompartmentKey::StringWrapper)
if (e.front().key().kind == CrossCompartmentKey::StringWrapper)
e.removeFront();
}
}
@ -3507,9 +3507,9 @@ void
JSCompartment::findOutgoingEdges(ComponentFinder<JS::Zone> &finder)
{
for (js::WrapperMap::Enum e(crossCompartmentWrappers); !e.empty(); e.popFront()) {
CrossCompartmentKey::Kind kind = e.front().key.kind;
CrossCompartmentKey::Kind kind = e.front().key().kind;
JS_ASSERT(kind != CrossCompartmentKey::StringWrapper);
Cell *other = e.front().key.wrapped;
Cell *other = e.front().key().wrapped;
if (kind == CrossCompartmentKey::ObjectWrapper) {
/*
* Add edge to wrapped object compartment if wrapped object is not
@ -4033,8 +4033,8 @@ BeginSweepPhase(JSRuntime *rt, bool lastGC)
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
JS_ASSERT(!c->gcIncomingGrayPointers);
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
if (e.front().key.kind != CrossCompartmentKey::StringWrapper)
AssertNotOnGrayList(&e.front().value.get().toObject());
if (e.front().key().kind != CrossCompartmentKey::StringWrapper)
AssertNotOnGrayList(&e.front().value().get().toObject());
}
}
#endif
@ -4256,8 +4256,8 @@ EndSweepPhase(JSRuntime *rt, JSGCInvocationKind gckind, bool lastGC)
JS_ASSERT(!c->gcLiveArrayBuffers);
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
if (e.front().key.kind != CrossCompartmentKey::StringWrapper)
AssertNotOnGrayList(&e.front().value.get().toObject());
if (e.front().key().kind != CrossCompartmentKey::StringWrapper)
AssertNotOnGrayList(&e.front().value().get().toObject());
}
}
#endif

View File

@ -1822,7 +1822,7 @@ TypeCompartment::addAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
AllocationSiteTable::Ptr p = cx->compartment()->types.allocationSiteTable->lookup(nkey);
if (p)
res = p->value;
res = p->value();
}
if (!res) {
@ -2303,7 +2303,7 @@ TypeCompartment::setTypeToHomogenousArray(ExclusiveContext *cx,
ArrayTableKey key(elementType, obj->getProto());
DependentAddPtr<ArrayTypeTable> p(cx, *arrayTypeTable, key);
if (p) {
obj->setType(p->value);
obj->setType(p->value());
} else {
/* Make a new type to use for future arrays with the same elements. */
RootedObject objProto(cx, obj->getProto());
@ -2492,11 +2492,11 @@ TypeCompartment::fixObjectType(ExclusiveContext *cx, JSObject *obj)
ObjectTypeTable::AddPtr p = objectTypeTable->lookupForAdd(lookup);
if (p) {
JS_ASSERT(obj->getProto() == p->value.object->proto);
JS_ASSERT(obj->lastProperty() == p->value.shape);
JS_ASSERT(obj->getProto() == p->value().object->proto);
JS_ASSERT(obj->lastProperty() == p->value().shape);
UpdateObjectTableEntryTypes(cx, p->value, properties.begin(), properties.length());
obj->setType(p->value.object);
UpdateObjectTableEntryTypes(cx, p->value(), properties.begin(), properties.length());
obj->setType(p->value().object);
return;
}
@ -2595,20 +2595,20 @@ TypeCompartment::newTypedObject(JSContext *cx, IdValuePair *properties, size_t n
cx->clearPendingException();
return nullptr;
}
JS_ASSERT(obj->getProto() == p->value.object->proto);
JS_ASSERT(obj->getProto() == p->value().object->proto);
RootedShape shape(cx, p->value.shape);
RootedShape shape(cx, p->value().shape);
if (!JSObject::setLastProperty(cx, obj, shape)) {
cx->clearPendingException();
return nullptr;
}
UpdateObjectTableEntryTypes(cx, p->value, properties, nproperties);
UpdateObjectTableEntryTypes(cx, p->value(), properties, nproperties);
for (size_t i = 0; i < nproperties; i++)
obj->setSlot(i, properties[i].value);
obj->setType(p->value.object);
obj->setType(p->value().object);
return obj;
}
@ -4026,7 +4026,7 @@ TypeCompartment::sweep(FreeOp *fop)
if (arrayTypeTable) {
for (ArrayTypeTable::Enum e(*arrayTypeTable); !e.empty(); e.popFront()) {
const ArrayTableKey &key = e.front().key;
const ArrayTableKey &key = e.front().key();
JS_ASSERT(key.type.isUnknown() || !key.type.isSingleObject());
bool remove = false;
@ -4036,7 +4036,7 @@ TypeCompartment::sweep(FreeOp *fop)
if (IsTypeObjectAboutToBeFinalized(&typeObject))
remove = true;
}
if (IsTypeObjectAboutToBeFinalized(e.front().value.unsafeGet()))
if (IsTypeObjectAboutToBeFinalized(e.front().value().unsafeGet()))
remove = true;
if (remove) {
@ -4052,8 +4052,8 @@ TypeCompartment::sweep(FreeOp *fop)
if (objectTypeTable) {
for (ObjectTypeTable::Enum e(*objectTypeTable); !e.empty(); e.popFront()) {
const ObjectTableKey &key = e.front().key;
ObjectTableEntry &entry = e.front().value;
const ObjectTableKey &key = e.front().key();
ObjectTableEntry &entry = e.front().value();
bool remove = false;
if (IsTypeObjectAboutToBeFinalized(entry.object.unsafeGet()))
@ -4088,12 +4088,12 @@ TypeCompartment::sweep(FreeOp *fop)
if (allocationSiteTable) {
for (AllocationSiteTable::Enum e(*allocationSiteTable); !e.empty(); e.popFront()) {
AllocationSiteKey key = e.front().key;
AllocationSiteKey key = e.front().key();
bool keyDying = IsScriptAboutToBeFinalized(&key.script);
bool valDying = IsTypeObjectAboutToBeFinalized(e.front().value.unsafeGet());
bool valDying = IsTypeObjectAboutToBeFinalized(e.front().value().unsafeGet());
if (keyDying || valDying)
e.removeFront();
else if (key.script != e.front().key.script)
else if (key.script != e.front().key().script)
e.rekeyFront(key);
}
}
@ -4118,8 +4118,8 @@ TypeCompartment::sweepShapes(FreeOp *fop)
*/
if (objectTypeTable) {
for (ObjectTypeTable::Enum e(*objectTypeTable); !e.empty(); e.popFront()) {
const ObjectTableKey &key = e.front().key;
ObjectTableEntry &entry = e.front().value;
const ObjectTableKey &key = e.front().key();
ObjectTableEntry &entry = e.front().value();
if (IsShapeAboutToBeFinalized(entry.shape.unsafeGet())) {
fop->free_(key.properties);
@ -4233,8 +4233,8 @@ TypeCompartment::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf,
!e.empty();
e.popFront())
{
const ObjectTableKey &key = e.front().key;
const ObjectTableEntry &value = e.front().value;
const ObjectTableKey &key = e.front().key();
const ObjectTableEntry &value = e.front().value();
/* key.ids and values.types have the same length. */
*objectTypeTables += mallocSizeOf(key.properties) + mallocSizeOf(value.types);

View File

@ -721,7 +721,7 @@ TypeScript::InitObject(JSContext *cx, JSScript *script, jsbytecode *pc, JSProtoK
AllocationSiteTable::Ptr p = cx->compartment()->types.allocationSiteTable->lookup(key);
if (p)
return p->value;
return p->value();
return cx->compartment()->types.addAllocationSiteTypeObject(cx, key);
}

View File

@ -3008,7 +3008,7 @@ ProxyObject::trace(JSTracer *trc, JSObject *obj)
*/
Value key = ObjectValue(*referent);
WrapperMap::Ptr p = proxy->compartment()->lookupWrapper(key);
JS_ASSERT(*p->value.unsafeGet() == ObjectValue(*proxy));
JS_ASSERT(*p->value().unsafeGet() == ObjectValue(*proxy));
}
}
#endif

View File

@ -912,30 +912,30 @@ js::PCCounts
JSScript::getPCCounts(jsbytecode *pc) {
JS_ASSERT(containsPC(pc));
ScriptCountsMap::Ptr p = GetScriptCountsMapEntry(this);
return p->value.pcCountsVector[pcToOffset(pc)];
return p->value().pcCountsVector[pcToOffset(pc)];
}
void
JSScript::addIonCounts(jit::IonScriptCounts *ionCounts)
{
ScriptCountsMap::Ptr p = GetScriptCountsMapEntry(this);
if (p->value.ionCounts)
ionCounts->setPrevious(p->value.ionCounts);
p->value.ionCounts = ionCounts;
if (p->value().ionCounts)
ionCounts->setPrevious(p->value().ionCounts);
p->value().ionCounts = ionCounts;
}
jit::IonScriptCounts *
JSScript::getIonCounts()
{
ScriptCountsMap::Ptr p = GetScriptCountsMapEntry(this);
return p->value.ionCounts;
return p->value().ionCounts;
}
ScriptCounts
JSScript::releaseScriptCounts()
{
ScriptCountsMap::Ptr p = GetScriptCountsMapEntry(this);
ScriptCounts counts = p->value;
ScriptCounts counts = p->value();
compartment()->scriptCountsMap->remove(p);
hasScriptCounts = false;
return counts;
@ -1082,7 +1082,7 @@ SourceDataCache::lookup(ScriptSource *ss, const AutoSuppressPurge &asp)
if (!map_)
return nullptr;
if (Map::Ptr p = map_->lookup(ss))
return p->value;
return p->value();
return nullptr;
}
@ -1113,7 +1113,7 @@ SourceDataCache::purge()
return;
for (Map::Range r = map_->all(); !r.empty(); r.popFront())
js_delete(const_cast<jschar*>(r.front().value));
js_delete(const_cast<jschar*>(r.front().value()));
js_delete(map_);
map_ = nullptr;
@ -2164,7 +2164,7 @@ js::GetSrcNote(GSNCache &cache, JSScript *script, jsbytecode *pc)
if (cache.code == script->code()) {
JS_ASSERT(cache.map.initialized());
GSNCache::Map::Ptr p = cache.map.lookup(pc);
return p ? p->value : nullptr;
return p ? p->value() : nullptr;
}
size_t offset = 0;
@ -2591,7 +2591,7 @@ JSScript::debugScript()
JS_ASSERT(map);
DebugScriptMap::Ptr p = map->lookup(this);
JS_ASSERT(p);
return p->value;
return p->value();
}
DebugScript *
@ -2602,7 +2602,7 @@ JSScript::releaseDebugScript()
JS_ASSERT(map);
DebugScriptMap::Ptr p = map->lookup(this);
JS_ASSERT(p);
DebugScript *debug = p->value;
DebugScript *debug = p->value();
map->remove(p);
hasDebugScript = false;
return debug;

View File

@ -35,16 +35,17 @@ class AutoEntryHolder {
public:
AutoEntryHolder(JSContext *cx, Map &map, Map::Ptr p)
: map(map), p(p), gen(map.generation()), obj(cx, p->key.object), id(cx, p->key.id) {
JS_ASSERT(!p->value.held);
p->value.held = true;
: map(map), p(p), gen(map.generation()), obj(cx, p->key().object), id(cx, p->key().id)
{
JS_ASSERT(!p->value().held);
p->value().held = true;
}
~AutoEntryHolder() {
if (gen != map.generation())
p = map.lookup(WatchKey(obj, id));
if (p)
p->value.held = false;
p->value().held = false;
}
};
@ -84,12 +85,12 @@ WatchpointMap::unwatch(JSObject *obj, jsid id,
{
if (Map::Ptr p = map.lookup(WatchKey(obj, id))) {
if (handlerp)
*handlerp = p->value.handler;
*handlerp = p->value().handler;
if (closurep) {
// Read barrier to prevent an incorrectly gray closure from escaping the
// watchpoint. See the comment before UnmarkGrayChildren in gc/Marking.cpp
JS::ExposeGCThingToActiveJS(p->value.closure, JSTRACE_OBJECT);
*closurep = p->value.closure;
JS::ExposeGCThingToActiveJS(p->value().closure, JSTRACE_OBJECT);
*closurep = p->value().closure;
}
map.remove(p);
}
@ -100,7 +101,7 @@ WatchpointMap::unwatchObject(JSObject *obj)
{
for (Map::Enum e(map); !e.empty(); e.popFront()) {
Map::Entry &entry = e.front();
if (entry.key.object == obj)
if (entry.key().object == obj)
e.removeFront();
}
}
@ -115,14 +116,14 @@ bool
WatchpointMap::triggerWatchpoint(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp)
{
Map::Ptr p = map.lookup(WatchKey(obj, id));
if (!p || p->value.held)
if (!p || p->value().held)
return true;
AutoEntryHolder holder(cx, map, p);
/* Copy the entry, since GC would invalidate p. */
JSWatchPointHandler handler = p->value.handler;
RootedObject closure(cx, p->value.closure);
JSWatchPointHandler handler = p->value().handler;
RootedObject closure(cx, p->value().closure);
/* Determine the property's old value. */
Value old;
@ -156,27 +157,28 @@ WatchpointMap::markIteratively(JSTracer *trc)
bool marked = false;
for (Map::Enum e(map); !e.empty(); e.popFront()) {
Map::Entry &entry = e.front();
JSObject *priorKeyObj = entry.key.object;
jsid priorKeyId(entry.key.id.get());
bool objectIsLive = IsObjectMarked(const_cast<EncapsulatedPtrObject *>(&entry.key.object));
if (objectIsLive || entry.value.held) {
JSObject *priorKeyObj = entry.key().object;
jsid priorKeyId(entry.key().id.get());
bool objectIsLive =
IsObjectMarked(const_cast<EncapsulatedPtrObject *>(&entry.key().object));
if (objectIsLive || entry.value().held) {
if (!objectIsLive) {
MarkObject(trc, const_cast<EncapsulatedPtrObject *>(&entry.key.object),
MarkObject(trc, const_cast<EncapsulatedPtrObject *>(&entry.key().object),
"held Watchpoint object");
marked = true;
}
JS_ASSERT(JSID_IS_STRING(priorKeyId) || JSID_IS_INT(priorKeyId));
MarkId(trc, const_cast<EncapsulatedId *>(&entry.key.id), "WatchKey::id");
MarkId(trc, const_cast<EncapsulatedId *>(&entry.key().id), "WatchKey::id");
if (entry.value.closure && !IsObjectMarked(&entry.value.closure)) {
MarkObject(trc, &entry.value.closure, "Watchpoint::closure");
if (entry.value().closure && !IsObjectMarked(&entry.value().closure)) {
MarkObject(trc, &entry.value().closure, "Watchpoint::closure");
marked = true;
}
/* We will sweep this entry in sweepAll if !objectIsLive. */
if (priorKeyObj != entry.key.object || priorKeyId != entry.key.id)
e.rekeyFront(WatchKey(entry.key.object, entry.key.id));
if (priorKeyObj != entry.key().object || priorKeyId != entry.key().id)
e.rekeyFront(WatchKey(entry.key().object, entry.key().id));
}
}
return marked;
@ -187,14 +189,14 @@ WatchpointMap::markAll(JSTracer *trc)
{
for (Map::Enum e(map); !e.empty(); e.popFront()) {
Map::Entry &entry = e.front();
WatchKey key = entry.key;
WatchKey key = entry.key();
WatchKey prior = key;
JS_ASSERT(JSID_IS_STRING(prior.id) || JSID_IS_INT(prior.id));
MarkObject(trc, const_cast<EncapsulatedPtrObject *>(&key.object),
"held Watchpoint object");
MarkId(trc, const_cast<EncapsulatedId *>(&key.id), "WatchKey::id");
MarkObject(trc, &entry.value.closure, "Watchpoint::closure");
MarkObject(trc, &entry.value().closure, "Watchpoint::closure");
if (prior.object != key.object || prior.id != key.id)
e.rekeyFront(key);
@ -215,12 +217,12 @@ WatchpointMap::sweep()
{
for (Map::Enum e(map); !e.empty(); e.popFront()) {
Map::Entry &entry = e.front();
JSObject *obj(entry.key.object);
JSObject *obj(entry.key().object);
if (IsObjectAboutToBeFinalized(&obj)) {
JS_ASSERT(!entry.value.held);
JS_ASSERT(!entry.value().held);
e.removeFront();
} else if (obj != entry.key.object) {
e.rekeyFront(WatchKey(obj, entry.key.id));
} else if (obj != entry.key().object) {
e.rekeyFront(WatchKey(obj, entry.key().id));
}
}
}
@ -241,7 +243,7 @@ WatchpointMap::trace(WeakMapTracer *trc)
for (Map::Range r = map.all(); !r.empty(); r.popFront()) {
Map::Entry &entry = r.front();
trc->callback(trc, nullptr,
entry.key.object.get(), JSTRACE_OBJECT,
entry.value.closure.get(), JSTRACE_OBJECT);
entry.key().object.get(), JSTRACE_OBJECT,
entry.value().closure.get(), JSTRACE_OBJECT);
}
}

View File

@ -89,7 +89,7 @@ class WeakValueCache : public HashMap<Key, Value, HashPolicy, AllocPolicy>
void sweep(FreeOp *fop) {
// Remove all entries whose values remain unmarked.
for (Enum e(*this); !e.empty(); e.popFront()) {
if (gc::IsAboutToBeFinalized(e.front().value))
if (gc::IsAboutToBeFinalized(e.front().value()))
e.removeFront();
}
@ -97,7 +97,7 @@ class WeakValueCache : public HashMap<Key, Value, HashPolicy, AllocPolicy>
// Once we've swept, all remaining edges should stay within the
// known-live part of the graph.
for (Range r = Base::all(); !r.empty(); r.popFront())
JS_ASSERT(!gc::IsAboutToBeFinalized(r.front().value));
JS_ASSERT(!gc::IsAboutToBeFinalized(r.front().value()));
#endif
}
};

View File

@ -200,9 +200,9 @@ WeakMap_get_impl(JSContext *cx, CallArgs args)
if (ObjectValueMap::Ptr ptr = map->lookup(key)) {
// Read barrier to prevent an incorrectly gray value from escaping the
// weak map. See the comment before UnmarkGrayChildren in gc/Marking.cpp
ExposeValueToActiveJS(ptr->value.get());
ExposeValueToActiveJS(ptr->value().get());
args.rval().set(ptr->value);
args.rval().set(ptr->value());
return true;
}
}
@ -357,7 +357,7 @@ JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *objArg, JSObject **re
// Prevent GC from mutating the weakmap while iterating.
gc::AutoSuppressGC suppress(cx);
for (ObjectValueMap::Base::Range r = map->all(); !r.empty(); r.popFront()) {
RootedObject key(cx, r.front().key);
RootedObject key(cx, r.front().key());
if (!cx->compartment()->wrap(cx, &key))
return false;
if (!js_NewbornArrayPush(cx, arr, ObjectValue(*key)))

View File

@ -148,16 +148,16 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
void nonMarkingTraceKeys(JSTracer *trc) {
for (Enum e(*this); !e.empty(); e.popFront()) {
Key key(e.front().key);
Key key(e.front().key());
gc::Mark(trc, &key, "WeakMap entry key");
if (key != e.front().key)
if (key != e.front().key())
entryMoved(e, key);
}
}
void nonMarkingTraceValues(JSTracer *trc) {
for (Range r = Base::all(); !r.empty(); r.popFront())
gc::Mark(trc, &r.front().value, "WeakMap entry value");
gc::Mark(trc, &r.front().value(), "WeakMap entry value");
}
bool keyNeedsMark(JSObject *key) {
@ -181,17 +181,17 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
bool markedAny = false;
for (Enum e(*this); !e.empty(); e.popFront()) {
/* If the entry is live, ensure its key and value are marked. */
Key key(e.front().key);
Key key(e.front().key());
if (gc::IsMarked(const_cast<Key *>(&key))) {
if (markValue(trc, &e.front().value))
if (markValue(trc, &e.front().value()))
markedAny = true;
if (e.front().key != key)
if (e.front().key() != key)
entryMoved(e, key);
} else if (keyNeedsMark(key)) {
gc::Mark(trc, const_cast<Key *>(&key), "proxy-preserved WeakMap entry key");
if (e.front().key != key)
gc::Mark(trc, &key, "proxy-preserved WeakMap entry key");
if (e.front().key() != key)
entryMoved(e, key);
gc::Mark(trc, &e.front().value, "WeakMap entry value");
gc::Mark(trc, &e.front().value(), "WeakMap entry value");
markedAny = true;
}
key.unsafeSet(nullptr);
@ -202,10 +202,10 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
void sweep() {
/* Remove all entries whose keys remain unmarked. */
for (Enum e(*this); !e.empty(); e.popFront()) {
Key k(e.front().key);
Key k(e.front().key());
if (gc::IsAboutToBeFinalized(&k))
e.removeFront();
else if (k != e.front().key)
else if (k != e.front().key())
entryMoved(e, k);
}
/*
@ -218,12 +218,12 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
/* memberOf can be nullptr, which means that the map is not part of a JSObject. */
void traceMappings(WeakMapTracer *tracer) {
for (Range r = Base::all(); !r.empty(); r.popFront()) {
gc::Cell *key = gc::ToMarkable(r.front().key);
gc::Cell *value = gc::ToMarkable(r.front().value);
gc::Cell *key = gc::ToMarkable(r.front().key());
gc::Cell *value = gc::ToMarkable(r.front().value());
if (key && value) {
tracer->callback(tracer, memberOf,
key, gc::TraceKind(r.front().key),
value, gc::TraceKind(r.front().value));
key, gc::TraceKind(r.front().key()),
value, gc::TraceKind(r.front().value()));
}
}
}
@ -242,10 +242,10 @@ protected:
void assertEntriesNotAboutToBeFinalized() {
#if DEBUG
for (Range r = Base::all(); !r.empty(); r.popFront()) {
Key k(r.front().key);
Key k(r.front().key());
JS_ASSERT(!gc::IsAboutToBeFinalized(&k));
JS_ASSERT(!gc::IsAboutToBeFinalized(&r.front().value));
JS_ASSERT(k == r.front().key);
JS_ASSERT(!gc::IsAboutToBeFinalized(&r.front().value()));
JS_ASSERT(k == r.front().key());
}
#endif
}

View File

@ -893,7 +893,7 @@ js::NukeCrossCompartmentWrappers(JSContext* cx,
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
// Some cross-compartment wrappers are for strings. We're not
// interested in those.
const CrossCompartmentKey &k = e.front().key;
const CrossCompartmentKey &k = e.front().key();
if (k.kind != CrossCompartmentKey::ObjectWrapper)
continue;
@ -941,7 +941,7 @@ js::RemapWrapper(JSContext *cx, JSObject *wobjArg, JSObject *newTargetArg)
// The old value should still be in the cross-compartment wrapper map, and
// the lookup should return wobj.
WrapperMap::Ptr p = wcompartment->lookupWrapper(origv);
JS_ASSERT(&p->value.unsafeGet()->toObject() == wobj);
JS_ASSERT(&p->value().unsafeGet()->toObject() == wobj);
wcompartment->removeWrapper(p);
// When we remove origv from the wrapper map, its wrapper, wobj, must
@ -1025,7 +1025,7 @@ js::RecomputeWrappers(JSContext *cx, const CompartmentFilter &sourceFilter,
// Iterate over the wrappers, filtering appropriately.
for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) {
// Filter out non-objects.
const CrossCompartmentKey &k = e.front().key;
const CrossCompartmentKey &k = e.front().key();
if (k.kind != CrossCompartmentKey::ObjectWrapper)
continue;

View File

@ -246,8 +246,8 @@ class HeapReverser : public JSTracer, public JS::CustomAutoRooter
if (!map.initialized())
return;
for (Map::Enum e(map); !e.empty(); e.popFront()) {
gc::MarkGCThingRoot(trc, const_cast<void **>(&e.front().key), "HeapReverser::map::key");
e.front().value.trace(trc);
gc::MarkGCThingRoot(trc, const_cast<void **>(&e.front().key()), "HeapReverser::map::key");
e.front().value().trace(trc);
}
for (Child *c = work.begin(); c != work.end(); ++c)
gc::MarkGCThingRoot(trc, &c->cell, "HeapReverser::Child");
@ -281,7 +281,7 @@ HeapReverser::traverseEdge(void *cell, JSGCTraceKind kind)
}
/* Add this edge to the reversed map. */
return a->value.incoming.append(Move(e));
return a->value().incoming.append(Move(e));
}
bool
@ -427,7 +427,7 @@ ReferenceFinder::visit(void *cell, Path *path)
HeapReverser::Map::Ptr p = reverser.map.lookup(cell);
JS_ASSERT(p);
HeapReverser::Node *node = &p->value;
HeapReverser::Node *node = &p->value();
/* Is |cell| a representable cell, reached via a non-empty path? */
if (path != nullptr) {

View File

@ -211,7 +211,7 @@ class Debugger::FrameRange
JSObject *frontFrame() const {
JS_ASSERT(!empty());
return entry->value;
return entry->value();
}
Debugger *frontDebugger() const {
@ -468,7 +468,7 @@ Debugger::getScriptFrame(JSContext *cx, AbstractFramePtr frame, MutableHandleVal
return false;
}
}
vp.setObject(*p->value);
vp.setObject(*p->value());
return true;
}
@ -501,7 +501,7 @@ Debugger::hasAnyLiveHooks() const
}
for (FrameMap::Range r = frames.all(); !r.empty(); r.popFront()) {
JSObject *frameObj = r.front().value;
JSObject *frameObj = r.front().value();
if (!frameObj->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined() ||
!frameObj->getReservedSlot(JSSLOT_DEBUGFRAME_ONPOP_HANDLER).isUndefined())
return true;
@ -674,7 +674,7 @@ Debugger::wrapEnvironment(JSContext *cx, Handle<Env*> env, MutableHandleValue rv
JSObject *envobj;
DependentAddPtr<ObjectWeakMap> p(cx, environments, env);
if (p) {
envobj = p->value;
envobj = p->value();
} else {
/* Create a new Debugger.Environment for env. */
JSObject *proto = &object->getReservedSlot(JSSLOT_DEBUG_ENV_PROTO).toObject();
@ -715,7 +715,7 @@ Debugger::wrapDebuggeeValue(JSContext *cx, MutableHandleValue vp)
DependentAddPtr<ObjectWeakMap> p(cx, objects, obj);
if (p) {
vp.setObject(*p->value);
vp.setObject(*p->value());
} else {
/* Create a new Debugger.Object for obj. */
JSObject *proto = &object->getReservedSlot(JSSLOT_DEBUG_OBJECT_PROTO).toObject();
@ -1267,8 +1267,8 @@ Debugger::onSingleStep(JSContext *cx, MutableHandleValue vp)
for (Debugger **p = debuggers->begin(); p != debuggers->end(); p++) {
Debugger *dbg = *p;
for (FrameMap::Range r = dbg->frames.all(); !r.empty(); r.popFront()) {
AbstractFramePtr frame = r.front().key;
JSObject *frameobj = r.front().value;
AbstractFramePtr frame = r.front().key();
JSObject *frameobj = r.front().value();
if (frame.script() == trappingScript &&
!frameobj->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER).isUndefined())
{
@ -1594,7 +1594,7 @@ Debugger::trace(JSTracer *trc)
* frames.)
*/
for (FrameMap::Range r = frames.all(); !r.empty(); r.popFront()) {
RelocatablePtrObject &frameobj = r.front().value;
RelocatablePtrObject &frameobj = r.front().value();
JS_ASSERT(frameobj->getPrivate());
MarkObject(trc, &frameobj, "live Debugger.Frame");
}
@ -2272,9 +2272,9 @@ Debugger::removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global,
* which slowPathOnLeaveFrame would have to examine.
*/
for (FrameMap::Enum e(frames); !e.empty(); e.popFront()) {
AbstractFramePtr frame = e.front().key;
AbstractFramePtr frame = e.front().key();
if (&frame.script()->global() == global) {
DebuggerFrame_freeScriptFrameIterData(fop, e.front().value);
DebuggerFrame_freeScriptFrameIterData(fop, e.front().value());
e.removeFront();
}
}
@ -2454,7 +2454,7 @@ class Debugger::ScriptQuery {
for (CompartmentToScriptMap::Range r = innermostForCompartment.all();
!r.empty();
r.popFront()) {
if (!v->append(r.front().value)) {
if (!v->append(r.front().value())) {
js_ReportOutOfMemory(cx);
return false;
}
@ -2599,9 +2599,9 @@ class Debugger::ScriptQuery {
CompartmentToScriptMap::AddPtr p = innermostForCompartment.lookupForAdd(compartment);
if (p) {
/* Is our newly found script deeper than the last one we found? */
JSScript *incumbent = p->value;
JSScript *incumbent = p->value();
if (script->staticLevel > incumbent->staticLevel)
p->value = script;
p->value() = script;
} else {
/*
* This is the first matching script we've encountered for this
@ -2818,8 +2818,8 @@ Debugger::wrapScript(JSContext *cx, HandleScript script)
}
}
JS_ASSERT(GetScriptReferent(p->value) == script);
return p->value;
JS_ASSERT(GetScriptReferent(p->value()) == script);
return p->value();
}
static JSObject *
@ -3711,8 +3711,8 @@ Debugger::wrapSource(JSContext *cx, HandleScriptSource source)
}
}
JS_ASSERT(GetSourceReferent(p->value) == source);
return p->value;
JS_ASSERT(GetSourceReferent(p->value()) == source);
return p->value();
}
static bool

View File

@ -107,9 +107,9 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
public:
void markKeys(JSTracer *tracer) {
for (Enum e(*static_cast<Base *>(this)); !e.empty(); e.popFront()) {
Key key = e.front().key;
Key key = e.front().key();
gc::Mark(tracer, &key, "Debugger WeakMap key");
if (key != e.front().key)
if (key != e.front().key())
e.rekeyFront(key);
key.unsafeSet(nullptr);
}
@ -117,7 +117,7 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
bool hasKeyInZone(JS::Zone *zone) {
CountMap::Ptr p = zoneCounts.lookup(zone);
JS_ASSERT_IF(p, p->value > 0);
JS_ASSERT_IF(p, p->value() > 0);
return p;
}
@ -125,7 +125,7 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
/* Override sweep method to also update our edge cache. */
void sweep() {
for (Enum e(*static_cast<Base *>(this)); !e.empty(); e.popFront()) {
Key k(e.front().key);
Key k(e.front().key());
if (gc::IsAboutToBeFinalized(&k)) {
e.removeFront();
decZoneCount(k->zone());
@ -138,16 +138,16 @@ class DebuggerWeakMap : private WeakMap<Key, Value, DefaultHasher<Key> >
CountMap::Ptr p = zoneCounts.lookupWithDefault(zone, 0);
if (!p)
return false;
++p->value;
++p->value();
return true;
}
void decZoneCount(JS::Zone *zone) {
CountMap::Ptr p = zoneCounts.lookup(zone);
JS_ASSERT(p);
JS_ASSERT(p->value > 0);
--p->value;
if (p->value == 0)
JS_ASSERT(p->value() > 0);
--p->value();
if (p->value() == 0)
zoneCounts.remove(zone);
}
};

View File

@ -289,7 +289,7 @@ StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKin
normalStringThingSize, strCharsSize);
zStats->strings.add(p, str, info);
} else {
p->value.add(shortStringThingSize, normalStringThingSize, strCharsSize);
p->value().add(shortStringThingSize, normalStringThingSize, strCharsSize);
}
}
@ -393,8 +393,8 @@ FindNotableStrings(ZoneStats &zStats)
for (ZoneStats::StringsHashMap::Range r = zStats.strings.all(); !r.empty(); r.popFront()) {
JSString *str = r.front().key;
StringInfo &info = r.front().value;
JSString *str = r.front().key();
StringInfo &info = r.front().value();
// If this string is too small, or if we can't grow the notableStrings
// vector, skip this string.

View File

@ -669,7 +669,7 @@ RegExpCompartment::sweep(JSRuntime *rt)
{
#ifdef DEBUG
for (Map::Range r = map_.all(); !r.empty(); r.popFront())
JS_ASSERT(inUse_.has(r.front().value));
JS_ASSERT(inUse_.has(r.front().value()));
#endif
map_.clear();
@ -696,7 +696,7 @@ RegExpCompartment::get(ExclusiveContext *cx, JSAtom *source, RegExpFlag flags, R
Key key(source, flags);
Map::AddPtr p = map_.lookupForAdd(key);
if (p) {
g->init(*p->value);
g->init(*p->value());
return true;
}

View File

@ -33,7 +33,7 @@ SPSProfiler::~SPSProfiler()
{
if (strings.initialized()) {
for (ProfileStringMap::Enum e(strings); !e.empty(); e.popFront())
js_free(const_cast<char *>(e.front().value));
js_free(const_cast<char *>(e.front().value()));
}
}
@ -80,7 +80,7 @@ SPSProfiler::profileString(JSContext *cx, JSScript *script, JSFunction *maybeFun
JS_ASSERT(strings.initialized());
ProfileStringMap::AddPtr s = strings.lookupForAdd(script);
if (s)
return s->value;
return s->value();
const char *str = allocProfileString(cx, script, maybeFun);
if (str == nullptr)
return nullptr;
@ -104,7 +104,7 @@ SPSProfiler::onScriptFinalized(JSScript *script)
if (!strings.initialized())
return;
if (ProfileStringMap::Ptr entry = strings.lookup(script)) {
const char *tofree = entry->value;
const char *tofree = entry->value();
strings.remove(entry);
js_free(const_cast<char *>(tofree));
}

View File

@ -94,7 +94,7 @@ js::ScopeCoordinateName(ScopeCoordinateNameCache &cache, JSScript *script, jsbyt
ScopeCoordinate sc(pc);
if (shape == cache.shape) {
ScopeCoordinateNameCache::Map::Ptr p = cache.map.lookup(sc.slot);
id = p->value;
id = p->value();
} else {
Shape::Range<NoGC> r(shape);
while (r.front().slot() != sc.slot)
@ -1592,13 +1592,13 @@ DebugScopes::sweep(JSRuntime *rt)
* creating an uncollectable cycle with suspended generator frames.
*/
for (MissingScopeMap::Enum e(missingScopes); !e.empty(); e.popFront()) {
if (IsObjectAboutToBeFinalized(e.front().value.unsafeGet()))
if (IsObjectAboutToBeFinalized(e.front().value().unsafeGet()))
e.removeFront();
}
for (LiveScopeMap::Enum e(liveScopes); !e.empty(); e.popFront()) {
ScopeObject *scope = e.front().key;
AbstractFramePtr frame = e.front().value;
ScopeObject *scope = e.front().key();
AbstractFramePtr frame = e.front().value();
/*
* Scopes can be finalized when a debugger-synthesized ScopeObject is
@ -1661,7 +1661,7 @@ DebugScopes::hasDebugScope(JSContext *cx, ScopeObject &scope)
if (ObjectWeakMap::Ptr p = scopes->proxiedScopes.lookup(&scope)) {
JS_ASSERT(CanUseDebugScopeMaps(cx));
return &p->value->as<DebugScopeObject>();
return &p->value()->as<DebugScopeObject>();
}
return nullptr;
@ -1701,7 +1701,7 @@ DebugScopes::hasDebugScope(JSContext *cx, const ScopeIter &si)
if (MissingScopeMap::Ptr p = scopes->missingScopes.lookup(si)) {
JS_ASSERT(CanUseDebugScopeMaps(cx));
return p->value;
return p->value();
}
return nullptr;
}
@ -1758,11 +1758,11 @@ DebugScopes::onPopCall(AbstractFramePtr frame, JSContext *cx)
CallObject &callobj = frame.scopeChain()->as<CallObject>();
scopes->liveScopes.remove(&callobj);
if (ObjectWeakMap::Ptr p = scopes->proxiedScopes.lookup(&callobj))
debugScope = &p->value->as<DebugScopeObject>();
debugScope = &p->value()->as<DebugScopeObject>();
} else {
ScopeIter si(frame, cx);
if (MissingScopeMap::Ptr p = scopes->missingScopes.lookup(si)) {
debugScope = p->value;
debugScope = p->value();
scopes->liveScopes.remove(&debugScope->scope().as<CallObject>());
scopes->missingScopes.remove(p);
}
@ -1831,7 +1831,7 @@ DebugScopes::onPopBlock(JSContext *cx, AbstractFramePtr frame)
} else {
ScopeIter si(frame, cx);
if (MissingScopeMap::Ptr p = scopes->missingScopes.lookup(si)) {
ClonedBlockObject &clone = p->value->scope().as<ClonedBlockObject>();
ClonedBlockObject &clone = p->value()->scope().as<ClonedBlockObject>();
clone.copyUnaliasedValues(frame);
scopes->liveScopes.remove(&clone);
scopes->missingScopes.remove(p);
@ -1881,7 +1881,7 @@ DebugScopes::onGeneratorFrameChange(AbstractFramePtr from, AbstractFramePtr to,
JS_ASSERT(toIter.scope().compartment() == cx->compartment());
LiveScopeMap::AddPtr livePtr = scopes->liveScopes.lookupForAdd(&toIter.scope());
if (livePtr) {
livePtr->value = to;
livePtr->value() = to;
} else {
scopes->liveScopes.add(livePtr, &toIter.scope(), to); // OOM here?
liveScopesPostWriteBarrier(cx->runtime(), &scopes->liveScopes, &toIter.scope());
@ -1890,8 +1890,8 @@ DebugScopes::onGeneratorFrameChange(AbstractFramePtr from, AbstractFramePtr to,
ScopeIter si(toIter, from, cx);
JS_ASSERT(si.frame().scopeChain()->compartment() == cx->compartment());
if (MissingScopeMap::Ptr p = scopes->missingScopes.lookup(si)) {
DebugScopeObject &debugScope = *p->value;
scopes->liveScopes.lookup(&debugScope.scope())->value = to;
DebugScopeObject &debugScope = *p->value();
scopes->liveScopes.lookup(&debugScope.scope())->value() = to;
scopes->missingScopes.remove(p);
scopes->missingScopes.put(toIter, &debugScope); // OOM here?
}
@ -1967,7 +1967,7 @@ DebugScopes::hasLiveFrame(ScopeObject &scope)
return NullFramePtr();
if (LiveScopeMap::Ptr p = scopes->liveScopes.lookup(&scope)) {
AbstractFramePtr frame = p->value;
AbstractFramePtr frame = p->value();
/*
* Since liveScopes is effectively a weak pointer, we need a read

View File

@ -891,7 +891,7 @@ CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
{
DependentAddPtr<CloneMemory> p(cx, clonedObjects, srcObj.get());
if (p)
return p->value;
return p->value();
RootedObject clone(cx);
if (srcObj->is<JSFunction>()) {
if (srcObj->as<JSFunction>().isWrappable()) {

View File

@ -829,7 +829,7 @@ JSStructuredCloneWriter::startObject(HandleObject obj, bool *backref)
/* Handle cycles in the object graph. */
CloneMemory::AddPtr p = memory.lookupForAdd(obj);
if ((*backref = p))
return out.writePair(SCTAG_BACK_REFERENCE_OBJECT, p->value);
return out.writePair(SCTAG_BACK_REFERENCE_OBJECT, p->value());
if (!memory.add(p, obj, memory.count()))
return false;

View File

@ -85,7 +85,7 @@ void
JSObject2WrappedJSMap::FindDyingJSObjects(nsTArray<nsXPCWrappedJS*>* dying)
{
for (Map::Range r = mTable.all(); !r.empty(); r.popFront()) {
nsXPCWrappedJS* wrapper = r.front().value;
nsXPCWrappedJS* wrapper = r.front().value();
MOZ_ASSERT(wrapper, "found a null JS wrapper!");
// walk the wrapper chain and find any whose JSObject is to be finalized
@ -101,7 +101,7 @@ void
JSObject2WrappedJSMap::ShutdownMarker()
{
for (Map::Range r = mTable.all(); !r.empty(); r.popFront()) {
nsXPCWrappedJS* wrapper = r.front().value;
nsXPCWrappedJS* wrapper = r.front().value();
MOZ_ASSERT(wrapper, "found a null JS wrapper!");
MOZ_ASSERT(wrapper->IsValid(), "found an invalid JS wrapper!");
wrapper->SystemIsBeingShutDown();

View File

@ -41,7 +41,7 @@ public:
inline nsXPCWrappedJS* Find(JSObject* Obj) {
NS_PRECONDITION(Obj,"bad param");
Map::Ptr p = mTable.lookup(Obj);
return p ? p->value : nullptr;
return p ? p->value() : nullptr;
}
inline nsXPCWrappedJS* Add(JSContext* cx, nsXPCWrappedJS* wrapper) {
@ -49,7 +49,7 @@ public:
JSObject* obj = wrapper->GetJSObjectPreserveColor();
Map::AddPtr p = mTable.lookupForAdd(obj);
if (p)
return p->value;
return p->value();
if (!mTable.add(p, obj, wrapper))
return nullptr;
JS_StoreObjectPostBarrierCallback(cx, KeyMarkCallback, obj, this);
@ -65,7 +65,7 @@ public:
inline void Dump(int16_t depth) {
for (Map::Range r = mTable.all(); !r.empty(); r.popFront())
r.front().value->DebugDump(depth);
r.front().value()->DebugDump(depth);
}
void FindDyingJSObjects(nsTArray<nsXPCWrappedJS*>* dying);
@ -634,7 +634,7 @@ public:
inline JSObject* Find(JSObject* key) {
NS_PRECONDITION(key, "bad param");
if (Map::Ptr p = mTable.lookup(key))
return p->value;
return p->value();
return nullptr;
}
@ -643,7 +643,7 @@ public:
NS_PRECONDITION(key,"bad param");
Map::AddPtr p = mTable.lookupForAdd(key);
if (p)
return p->value;
return p->value();
if (!mTable.add(p, key, value))
return nullptr;
MOZ_ASSERT(xpc::GetCompartmentPrivate(key)->scope->mWaiverWrapperMap == this);
@ -660,10 +660,10 @@ public:
void Sweep() {
for (Map::Enum e(mTable); !e.empty(); e.popFront()) {
JSObject *updated = e.front().key;
if (JS_IsAboutToBeFinalizedUnbarriered(&updated) || JS_IsAboutToBeFinalized(&e.front().value))
JSObject *updated = e.front().key();
if (JS_IsAboutToBeFinalizedUnbarriered(&updated) || JS_IsAboutToBeFinalized(&e.front().value()))
e.removeFront();
else if (updated != e.front().key)
else if (updated != e.front().key())
e.rekeyFront(updated);
}
}
@ -675,12 +675,12 @@ public:
* We reparent wrappers that have as their parent an inner window
* whose outer has the new inner window as its current inner.
*/
JS::RootedObject parent(aCx, JS_GetParent(e.front().value));
JS::RootedObject parent(aCx, JS_GetParent(e.front().value()));
JS::RootedObject outer(aCx, JS_ObjectToOuterObject(aCx, parent));
if (outer) {
JSObject *inner = JS_ObjectToInnerObject(aCx, outer);
if (inner == aNewInner && inner != parent)
JS_SetParent(aCx, e.front().value, aNewInner);
JS_SetParent(aCx, e.front().value(), aNewInner);
} else {
JS_ClearPendingException(aCx);
}

View File

@ -48,7 +48,7 @@ nsNthIndexCache::IndexDeterminedFromPreviousSibling(nsIContent* aSibling,
if (SiblingMatchesElement(aSibling, aChild, aIsOfType)) {
Cache::Ptr siblingEntry = aCache.lookup(aSibling);
if (siblingEntry) {
int32_t siblingIndex = siblingEntry->value;
int32_t siblingIndex = siblingEntry->value();
NS_ASSERTION(siblingIndex != 0,
"How can a non-anonymous node have an anonymous sibling?");
if (siblingIndex > 0) {
@ -93,7 +93,7 @@ nsNthIndexCache::GetNthIndex(Element* aChild, bool aIsOfType,
return 0;
}
int32_t &slot = entry->value;
int32_t &slot = entry->value();
if (slot != -2 && (slot != -1 || aCheckEdgeOnly)) {
return slot;
}