forked from mirrors/gecko-dev
Bug 1746380 - Part 5: Optimize well-known symbol construction. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D135104
This commit is contained in:
parent
a669c9d445
commit
25d28be9b9
4 changed files with 10 additions and 3 deletions
|
|
@ -36,7 +36,7 @@ MOZ_ALWAYS_INLINE bool AtomMarkingRuntime::inlinedMarkAtomInternal(
|
|||
js::gc::TenuredCell* cell = &thing->asTenured();
|
||||
MOZ_ASSERT(cell->zoneFromAnyThread()->isAtomsZone());
|
||||
|
||||
// The context's zone will be null during initialization of the runtime.
|
||||
// The embedding is allowed to atomize during initialization.
|
||||
if (!cx->zone()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,8 +302,8 @@ bool JSRuntime::initializeAtoms(JSContext* cx) {
|
|||
commonNames->wellKnownSymbolDescriptions();
|
||||
ImmutableSymbolPtr* symbols = reinterpret_cast<ImmutableSymbolPtr*>(wks);
|
||||
for (size_t i = 0; i < JS::WellKnownSymbolLimit; i++) {
|
||||
HandlePropertyName description = descriptions[i];
|
||||
JS::Symbol* symbol = JS::Symbol::new_(cx, JS::SymbolCode(i), description);
|
||||
JS::Symbol* symbol =
|
||||
JS::Symbol::newWellKnown(cx, JS::SymbolCode(i), descriptions[i]);
|
||||
if (!symbol) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ Symbol* Symbol::new_(JSContext* cx, JS::SymbolCode code,
|
|||
return sym;
|
||||
}
|
||||
|
||||
Symbol* Symbol::newWellKnown(JSContext* cx, JS::SymbolCode code,
|
||||
HandlePropertyName description) {
|
||||
return newInternal(cx, code, cx->runtime()->randomHashCode(), description);
|
||||
}
|
||||
|
||||
Symbol* Symbol::for_(JSContext* cx, HandleString description) {
|
||||
RootedAtom atom(cx, AtomizeString(cx, description));
|
||||
if (!atom) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ class Symbol
|
|||
public:
|
||||
static Symbol* new_(JSContext* cx, SymbolCode code,
|
||||
js::HandleString description);
|
||||
static Symbol* newWellKnown(JSContext* cx, SymbolCode code,
|
||||
js::HandlePropertyName description);
|
||||
static Symbol* for_(JSContext* cx, js::HandleString description);
|
||||
|
||||
SymbolCode code() const { return code_; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue