Bug 1465470 Part 2 - Preserve iteration order for frontend name tables, r=jorendorff.

--HG--
extra : rebase_source : 7738eb3d80815f4caab4beae848541b84befd57b
This commit is contained in:
Brian Hackett 2018-07-23 15:00:13 +00:00
parent 7cb270f8b8
commit 51d8e11435

View File

@ -142,11 +142,23 @@ struct RecyclableAtomMapValueWrapper
} }
}; };
struct NameMapHasher : public DefaultHasher<JSAtom*>
{
static inline HashNumber hash(const Lookup& l) {
// Name maps use the atom's precomputed hash code, which is based on
// the atom's contents rather than its pointer value. This is necessary
// to preserve iteration order while recording/replaying: iteration can
// affect generated script bytecode and the order in which e.g. lookup
// property hooks are performed on the associated global.
return l->hash();
}
};
template <typename MapValue> template <typename MapValue>
using RecyclableNameMap = InlineMap<JSAtom*, using RecyclableNameMap = InlineMap<JSAtom*,
RecyclableAtomMapValueWrapper<MapValue>, RecyclableAtomMapValueWrapper<MapValue>,
24, 24,
DefaultHasher<JSAtom*>, NameMapHasher,
SystemAllocPolicy>; SystemAllocPolicy>;
using DeclaredNameMap = RecyclableNameMap<DeclaredNameInfo>; using DeclaredNameMap = RecyclableNameMap<DeclaredNameInfo>;