Bug 960653 - part 1 - assert that we don't overflow JSJitInfo fields in bindings codegen; r=bz

This commit is contained in:
Nathan Froyd 2014-01-16 11:20:51 -05:00
parent 60870c35b6
commit 80ee4b7f7c

View File

@ -11506,6 +11506,14 @@ class GlobalGenRoots():
idEnum.append(ifaceChainMacro(1))
def fieldSizeAssert(amount, jitInfoField, message):
maxFieldValue = "(uint64_t(1) << (sizeof(((JSJitInfo*)nullptr)->%s) * 8))" % jitInfoField
return CGGeneric(declare="static_assert(%s < %s, \"%s\");\n\n"
% (amount, maxFieldValue, message))
idEnum.append(fieldSizeAssert("id::_ID_Count", "protoID",
"Too many prototypes!"));
# Wrap all of that in our namespaces.
idEnum = CGNamespace.build(['mozilla', 'dom', 'prototypes'],
CGWrapper(idEnum, pre='\n'))
@ -11514,8 +11522,11 @@ class GlobalGenRoots():
curr = CGList([idEnum])
# Let things know the maximum length of the prototype chain.
maxMacro = CGGeneric(declare="#define MAX_PROTOTYPE_CHAIN_LENGTH " + str(config.maxProtoChainLength))
maxMacroName = "MAX_PROTOTYPE_CHAIN_LENGTH"
maxMacro = CGGeneric(declare="#define " + maxMacroName + " " + str(config.maxProtoChainLength))
curr.append(CGWrapper(maxMacro, post='\n\n'))
curr.append(fieldSizeAssert(maxMacroName, "depth",
"Some inheritance chain is too long!"));
# Constructor ID enum.
constructors = [d.name for d in config.getDescriptors(hasInterfaceObject=True)]