Skip to content

Instantly share code, notes, and snippets.

@hotsphink
Created July 8, 2019 18:06
Show Gist options
  • Save hotsphink/e1b84c03929e436b8efc48fcc4901bfb to your computer and use it in GitHub Desktop.
Save hotsphink/e1b84c03929e436b8efc48fcc4901bfb to your computer and use it in GitHub Desktop.
mkgist-created gist
void JSString::traceBase(JSTracer* trc) {
MOZ_ASSERT(hasBase());
JSString* oldBase = d.s.u3.base;
if (I am a DependentString) {
// Handle the case where I am a dependent string of an undependend string,
// and therefore my chars are actually coming from its base.
base = my base
while (my chars do not come from MaybeForwarded(base).chars) {
if (base.hasBase)
base = base.base
else
break // I might be a dependent string of an inline string or something
}
offset = baseOffset();
}
// Update the base from a nursery pointer to a tenured pointer, if necessary.
TraceManuallyBarrieredEdge(trc, &d.s.u3.base, "base");
// If I updated the base pointer to a deduplicated string, then
// re-point my chars to the deduplicated string's chars.
if (oldBase != d.s.u3.base) {
char* oldBaseChars = oldBase->chars;
if (mychars is within oldBaseChars..length)
repoint to d.s.u3.base's chars
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment