Bug 1155793 part 1. Make it possible to safely change the number of bits in the slotIndex field in jitinfo. r=efaust

This commit is contained in:
Boris Zbarsky 2015-04-17 22:01:02 -04:00
parent f54052e8b0
commit a0a149646c
2 changed files with 28 additions and 11 deletions

View File

@ -8211,7 +8211,7 @@ class CGMemberJITInfo(CGThing):
initializer = fill(
"""
{
{ ${opName} },
{ ${opName} },
prototypes::id::${name},
PrototypeTraits<prototypes::id::${name}>::Depth,
JSJitInfo::${opType},
@ -8239,6 +8239,10 @@ class CGMemberJITInfo(CGThing):
slotIndex=slotIndex)
return initializer.rstrip()
slotAssert = dedent(
"""
static_assert(%s <= JSJitInfo::maxSlotIndex, "We won't fit");
""" % slotIndex)
if args is not None:
argTypes = "%s_argTypes" % infoName
args = [CGMemberJITInfo.getJSArgType(arg.type) for arg in args]
@ -8248,21 +8252,27 @@ class CGMemberJITInfo(CGThing):
(argTypes, ", ".join(args)))
return fill(
"""
$*{argTypesDecl}
static const JSTypedMethodJitInfo ${infoName} = {
${jitInfo},
${jitInfo},
${argTypes}
};
$*{slotAssert}
""",
argTypesDecl=argTypesDecl,
infoName=infoName,
jitInfo=jitInfoInitializer(True),
argTypes=argTypes)
jitInfo=indent(jitInfoInitializer(True)),
argTypes=argTypes,
slotAssert=slotAssert)
return ("\n"
"static const JSJitInfo %s = %s;\n"
% (infoName, jitInfoInitializer(False)))
return fill(
"""
static const JSJitInfo ${infoName} = ${jitInfo};
$*{slotAssert}
""",
infoName=infoName,
jitInfo=jitInfoInitializer(False),
slotAssert=slotAssert)
def define(self):
if self.member.isAttr():

View File

@ -2346,6 +2346,7 @@ struct JSJitInfo {
#define JITINFO_OP_TYPE_BITS 4
#define JITINFO_ALIAS_SET_BITS 4
#define JITINFO_RETURN_TYPE_BITS 8
#define JITINFO_SLOT_INDEX_BITS 11
// The OpType that says what sort of function we are.
uint32_t type_ : JITINFO_OP_TYPE_BITS;
@ -2385,9 +2386,15 @@ struct JSJitInfo {
slot of the "this" object. */
uint32_t isTypedMethod : 1; /* True if this is an instance of
JSTypedMethodJitInfo. */
uint32_t slotIndex : 11; /* If isAlwaysInSlot or isSometimesInSlot is
true, the index of the slot to get the value
from. Otherwise 0. */
uint32_t slotIndex : JITINFO_SLOT_INDEX_BITS; /* If isAlwaysInSlot or
isSometimesInSlot is true,
the index of the slot to
get the value from.
Otherwise 0. */
static const size_t maxSlotIndex = (1 << JITINFO_SLOT_INDEX_BITS) - 1;
#undef JITINFO_SLOT_INDEX_BITS
};
static_assert(sizeof(JSJitInfo) == (sizeof(void*) + 2 * sizeof(uint32_t)),