Bug 1182428 - Recognize more rooted type names, r=jonco

This commit is contained in:
Steve Fink 2015-07-23 13:09:58 -07:00
parent a3a10f1d2f
commit ea2c66c77c
2 changed files with 23 additions and 18 deletions

View File

@ -245,21 +245,6 @@ function ignoreGCFunction(mangled)
return false;
}
function isRootedTypeName(name)
{
if (name == "mozilla::ErrorResult" ||
name == "JSErrorResult" ||
name == "WrappableJSErrorResult" ||
name == "js::frontend::TokenStream" ||
name == "js::frontend::TokenStream::Position" ||
name == "ModuleCompiler" ||
name == "JSAddonId")
{
return true;
}
return false;
}
function stripUCSAndNamespace(name)
{
if (name.startsWith('struct '))
@ -282,16 +267,36 @@ function stripUCSAndNamespace(name)
return name;
}
function isRootedPointerTypeName(name)
function isRootedGCTypeName(name)
{
return (name == "JSAddonId");
}
function isRootedGCPointerTypeName(name)
{
name = stripUCSAndNamespace(name);
if (name.startsWith('MaybeRooted<'))
return /\(js::AllowGC\)1u>::RootType/.test(name);
if (name == "ErrorResult" ||
name == "JSErrorResult" ||
name == "WrappableJSErrorResult" ||
name == "frontend::TokenStream" ||
name == "frontend::TokenStream::Position" ||
name == "ModuleCompiler")
{
return true;
}
return name.startsWith('Rooted') || name.startsWith('PersistentRooted');
}
function isRootedTypeName(name)
{
return isRootedGCTypeName(name) || isRootedGCPointerTypeName(name);
}
function isUnsafeStorage(typeName)
{
typeName = stripUCSAndNamespace(typeName);

View File

@ -116,9 +116,9 @@ function markGCType(typeName, child, why, typePtrLevel, fieldPtrLevel, indent)
if (ptrLevel > 2)
return;
if (ptrLevel == 0 && isRootedTypeName(typeName))
if (ptrLevel == 0 && isRootedGCTypeName(typeName))
return;
if (ptrLevel == 1 && isRootedPointerTypeName(typeName))
if (ptrLevel == 1 && isRootedGCPointerTypeName(typeName))
return;
if (ptrLevel == 0) {