Issue #2083 - Part 1: Make RegExpShared a GC thing.

Based on Mozilla bug 1345177.
Changes from the original bug's patch:

- We don't have JS::CurrentThreadIsHeapCollecting, so let's use
  trc->runtime()->isHeapCollecting() instead.
- Mozilla bug 1337117 renamed runtimeFromMainThread to
  runtimeFromActiveCooperatingThread for Firefox 54, so let's use the former
This commit is contained in:
Job Bautista 2023-01-26 15:02:09 +08:00 committed by roytam1
commit 3796c7c1e1
29 changed files with 384 additions and 412 deletions

View file

@ -357,7 +357,12 @@ static const FinalizePhase BackgroundFinalizePhases[] = {
},
{
gcstats::PHASE_SWEEP_SCOPE, {
AllocKind::SCOPE
AllocKind::SCOPE,
}
},
{
gcstats::PHASE_SWEEP_REGEXP_SHARED, {
AllocKind::REGEXP_SHARED,
}
},
{
@ -1599,7 +1604,6 @@ static const AllocKind AllocKindsToRelocate[] = {
AllocKind::OBJECT16_BACKGROUND,
AllocKind::SCRIPT,
AllocKind::LAZY_SCRIPT,
AllocKind::SCOPE,
AllocKind::SHAPE,
AllocKind::ACCESSOR_SHAPE,
AllocKind::BASE_SHAPE,
@ -1607,7 +1611,9 @@ static const AllocKind AllocKindsToRelocate[] = {
AllocKind::STRING,
AllocKind::EXTERNAL_STRING,
AllocKind::FAT_INLINE_ATOM,
AllocKind::ATOM
AllocKind::ATOM,
AllocKind::SCOPE,
AllocKind::REGEXP_SHARED
};
Arena*
@ -1931,61 +1937,23 @@ GCRuntime::relocateArenas(Zone* zone, JS::gcreason::Reason reason, Arena*& reloc
return true;
}
void
MovingTracer::onObjectEdge(JSObject** objp)
template <typename T>
inline void
MovingTracer::updateEdge(T** thingp)
{
JSObject* obj = *objp;
if (obj->runtimeFromAnyThread() == runtime() && IsForwarded(obj))
*objp = Forwarded(obj);
auto thing = *thingp;
if (thing->runtimeFromAnyThread() == runtime() && IsForwarded(thing))
*thingp = Forwarded(thing);
}
void
MovingTracer::onShapeEdge(Shape** shapep)
{
Shape* shape = *shapep;
if (shape->runtimeFromAnyThread() == runtime() && IsForwarded(shape))
*shapep = Forwarded(shape);
}
void
MovingTracer::onStringEdge(JSString** stringp)
{
JSString* string = *stringp;
if (string->runtimeFromAnyThread() == runtime() && IsForwarded(string))
*stringp = Forwarded(string);
}
void
MovingTracer::onScriptEdge(JSScript** scriptp)
{
JSScript* script = *scriptp;
if (script->runtimeFromAnyThread() == runtime() && IsForwarded(script))
*scriptp = Forwarded(script);
}
void
MovingTracer::onLazyScriptEdge(LazyScript** lazyp)
{
LazyScript* lazy = *lazyp;
if (lazy->runtimeFromAnyThread() == runtime() && IsForwarded(lazy))
*lazyp = Forwarded(lazy);
}
void
MovingTracer::onBaseShapeEdge(BaseShape** basep)
{
BaseShape* base = *basep;
if (base->runtimeFromAnyThread() == runtime() && IsForwarded(base))
*basep = Forwarded(base);
}
void
MovingTracer::onScopeEdge(Scope** scopep)
{
Scope* scope = *scopep;
if (scope->runtimeFromAnyThread() == runtime() && IsForwarded(scope))
*scopep = Forwarded(scope);
}
void MovingTracer::onObjectEdge(JSObject** objp) { updateEdge(objp); }
void MovingTracer::onShapeEdge(Shape** shapep) { updateEdge(shapep); }
void MovingTracer::onStringEdge(JSString** stringp) { updateEdge(stringp); }
void MovingTracer::onScriptEdge(JSScript** scriptp) { updateEdge(scriptp); }
void MovingTracer::onLazyScriptEdge(LazyScript** lazyp) { updateEdge(lazyp); }
void MovingTracer::onBaseShapeEdge(BaseShape** basep) { updateEdge(basep); }
void MovingTracer::onScopeEdge(Scope** scopep) { updateEdge(scopep); }
void MovingTracer::onRegExpSharedEdge(RegExpShared** sharedp) { updateEdge(sharedp); }
void
Zone::prepareForCompacting()