зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1543208 - Prevent GC from seeing uninitialized well-known symbols r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D26841 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c2bdc62aa5
Коммит
547a99ec14
|
@ -20,6 +20,7 @@
|
||||||
#include "jstypes.h"
|
#include "jstypes.h"
|
||||||
|
|
||||||
#include "builtin/String.h"
|
#include "builtin/String.h"
|
||||||
|
#include "gc/GC.h"
|
||||||
#include "gc/Marking.h"
|
#include "gc/Marking.h"
|
||||||
#include "js/CharacterEncoding.h"
|
#include "js/CharacterEncoding.h"
|
||||||
#include "js/Symbol.h"
|
#include "js/Symbol.h"
|
||||||
|
@ -283,15 +284,18 @@ bool JSRuntime::initializeAtoms(JSContext* cx) {
|
||||||
emptyString = commonNames->empty;
|
emptyString = commonNames->empty;
|
||||||
|
|
||||||
// Create the well-known symbols.
|
// Create the well-known symbols.
|
||||||
wellKnownSymbols = js_new<WellKnownSymbols>();
|
auto wks = js_new<WellKnownSymbols>();
|
||||||
if (!wellKnownSymbols) {
|
if (!wks) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent GC until we have fully initialized the well known symbols table.
|
||||||
|
// Faster than zeroing the array and null checking during every GC.
|
||||||
|
gc::AutoSuppressGC nogc(cx);
|
||||||
|
|
||||||
ImmutablePropertyNamePtr* descriptions =
|
ImmutablePropertyNamePtr* descriptions =
|
||||||
commonNames->wellKnownSymbolDescriptions();
|
commonNames->wellKnownSymbolDescriptions();
|
||||||
ImmutableSymbolPtr* symbols =
|
ImmutableSymbolPtr* symbols = reinterpret_cast<ImmutableSymbolPtr*>(wks);
|
||||||
reinterpret_cast<ImmutableSymbolPtr*>(wellKnownSymbols.ref());
|
|
||||||
for (size_t i = 0; i < JS::WellKnownSymbolLimit; i++) {
|
for (size_t i = 0; i < JS::WellKnownSymbolLimit; i++) {
|
||||||
HandlePropertyName description = descriptions[i];
|
HandlePropertyName description = descriptions[i];
|
||||||
JS::Symbol* symbol = JS::Symbol::new_(cx, JS::SymbolCode(i), description);
|
JS::Symbol* symbol = JS::Symbol::new_(cx, JS::SymbolCode(i), description);
|
||||||
|
@ -302,6 +306,7 @@ bool JSRuntime::initializeAtoms(JSContext* cx) {
|
||||||
symbols[i].init(symbol);
|
symbols[i].init(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wellKnownSymbols = wks;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче