Bug 967474 - Fix TypeScript initialization to not race with compilation threads. r=bhackett

--HG--
extra : rebase_source : 28b5cc109a2656a3ea1c21dc398da08db90926c8
This commit is contained in:
Jan de Mooij 2014-02-05 12:03:35 +01:00
parent 2e62d21844
commit abd10fb3ae

View File

@ -3679,24 +3679,30 @@ JSScript::makeTypes(JSContext *cx)
unsigned count = TypeScript::NumTypeSets(this);
types = (TypeScript *) cx->calloc_(sizeof(TypeScript) + (sizeof(StackTypeSet) * count));
if (!types) {
TypeScript *typeScript = (TypeScript *) cx->calloc_(sizeof(TypeScript) + (sizeof(StackTypeSet) * count));
if (!typeScript) {
cx->compartment()->types.setPendingNukeTypes(cx);
return false;
}
new(types) TypeScript();
new(typeScript) TypeScript();
TypeSet *typeArray = types->typeArray();
TypeSet *typeArray = typeScript->typeArray();
for (unsigned i = 0; i < count; i++)
new (&typeArray[i]) StackTypeSet();
{
AutoLockForCompilation lock(cx);
types = typeScript;
}
#ifdef DEBUG
for (unsigned i = 0; i < nTypeSets(); i++)
for (unsigned i = 0; i < nTypeSets(); i++) {
InferSpew(ISpewOps, "typeSet: %sT%p%s bytecode%u #%u",
InferSpewColor(&typeArray[i]), &typeArray[i], InferSpewColorReset(),
i, id());
}
TypeSet *thisTypes = TypeScript::ThisTypes(this);
InferSpew(ISpewOps, "typeSet: %sT%p%s this #%u",
InferSpewColor(thisTypes), thisTypes, InferSpewColorReset(),