Bug 918161 - Remove uses of JSContext when constructing vectors in IonBuilder, r=jandem.

This commit is contained in:
Brian Hackett 2013-09-20 07:40:10 -06:00
parent 630dd1ccdf
commit e4b900f5c9
6 changed files with 48 additions and 44 deletions

View File

@ -80,7 +80,7 @@ SetElemICInspector::sawTypedArrayWrite() const
}
bool
BaselineInspector::maybeShapesForPropertyOp(jsbytecode *pc, Vector<Shape *> &shapes)
BaselineInspector::maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes)
{
// Return a list of shapes seen by the baseline IC for the current op.
// An empty list indicates no shapes are known, or there was an uncacheable

View File

@ -94,7 +94,8 @@ class BaselineInspector
bool dimorphicStub(jsbytecode *pc, ICStub **pfirst, ICStub **psecond);
public:
bool maybeShapesForPropertyOp(jsbytecode *pc, Vector<Shape *> &shapes);
typedef Vector<Shape *, 4, IonAllocPolicy> ShapeVector;
bool maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes);
SetElemICInspector setElemICInspector(jsbytecode *pc) {
return makeICInspector<SetElemICInspector>(pc, ICStub::SetElem_Fallback);

View File

@ -162,7 +162,7 @@ IonBuilder::getSingleCallTarget(types::TemporaryTypeSet *calleeTypes)
bool
IonBuilder::getPolyCallTargets(types::TemporaryTypeSet *calleeTypes, bool constructing,
AutoObjectVector &targets, uint32_t maxTargets, bool *gotLambda)
ObjectVector &targets, uint32_t maxTargets, bool *gotLambda)
{
JS_ASSERT(targets.length() == 0);
JS_ASSERT(gotLambda);
@ -1142,8 +1142,8 @@ IonBuilder::traverseBytecode()
//
// This is used to catch problems where IonBuilder pops a value without
// adding any SSA uses and doesn't call setFoldedUnchecked on it.
Vector<MDefinition *> popped(cx);
Vector<size_t> poppedUses(cx);
Vector<MDefinition *, 4, IonAllocPolicy> popped;
Vector<size_t, 4, IonAllocPolicy> poppedUses;
unsigned nuses = GetUseCount(script_, pc - script_->code);
for (unsigned i = 0; i < nuses; i++) {
@ -3992,7 +3992,7 @@ IonBuilder::makeInliningDecision(JSFunction *target, CallInfo &callInfo)
}
uint32_t
IonBuilder::selectInliningTargets(AutoObjectVector &targets, CallInfo &callInfo, Vector<bool> &choiceSet)
IonBuilder::selectInliningTargets(ObjectVector &targets, CallInfo &callInfo, BoolVector &choiceSet)
{
uint32_t totalSize = 0;
uint32_t numInlineable = 0;
@ -4098,7 +4098,7 @@ IonBuilder::inlineSingleCall(CallInfo &callInfo, JSFunction *target)
}
IonBuilder::InliningStatus
IonBuilder::inlineCallsite(AutoObjectVector &targets, AutoObjectVector &originals,
IonBuilder::inlineCallsite(ObjectVector &targets, ObjectVector &originals,
bool lambda, CallInfo &callInfo)
{
if (!inliningEnabled())
@ -4138,7 +4138,7 @@ IonBuilder::inlineCallsite(AutoObjectVector &targets, AutoObjectVector &original
}
// Choose a subset of the targets for polymorphic inlining.
Vector<bool> choiceSet(cx);
BoolVector choiceSet;
uint32_t numInlined = selectInliningTargets(targets, callInfo, choiceSet);
if (numInlined == 0)
return InliningStatus_NotInlined;
@ -4160,7 +4160,7 @@ IonBuilder::inlineGenericFallback(JSFunction *target, CallInfo &callInfo, MBasic
return false;
// Create a new CallInfo to track modified state within this block.
CallInfo fallbackInfo(cx, callInfo.constructing());
CallInfo fallbackInfo(callInfo.constructing());
if (!fallbackInfo.init(callInfo))
return false;
fallbackInfo.popFormals(fallbackBlock);
@ -4198,7 +4198,7 @@ IonBuilder::inlineTypeObjectFallback(CallInfo &callInfo, MBasicBlock *dispatchBl
// We now move the MGetPropertyCache and friends into a fallback path.
// Create a new CallInfo to track modified state within the fallback path.
CallInfo fallbackInfo(cx, callInfo.constructing());
CallInfo fallbackInfo(callInfo.constructing());
if (!fallbackInfo.init(callInfo))
return false;
@ -4272,8 +4272,8 @@ IonBuilder::inlineTypeObjectFallback(CallInfo &callInfo, MBasicBlock *dispatchBl
}
bool
IonBuilder::inlineCalls(CallInfo &callInfo, AutoObjectVector &targets,
AutoObjectVector &originals, Vector<bool> &choiceSet,
IonBuilder::inlineCalls(CallInfo &callInfo, ObjectVector &targets,
ObjectVector &originals, BoolVector &choiceSet,
MGetPropertyCache *maybeCache)
{
// Only handle polymorphic inlining.
@ -4380,7 +4380,7 @@ IonBuilder::inlineCalls(CallInfo &callInfo, AutoObjectVector &targets,
inlineBlock->rewriteSlot(funIndex, funcDef);
// Create a new CallInfo to track modified state within the inline block.
CallInfo inlineInfo(cx, callInfo.constructing());
CallInfo inlineInfo(callInfo.constructing());
if (!inlineInfo.init(callInfo))
return false;
inlineInfo.popFormals(inlineBlock);
@ -4723,7 +4723,7 @@ IonBuilder::jsop_funcall(uint32_t argc)
types::TemporaryTypeSet *calleeTypes = current->peek(calleeDepth)->resultTypeSet();
JSFunction *native = getSingleCallTarget(calleeTypes);
if (!native || !native->isNative() || native->native() != &js_fun_call) {
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, argc))
return false;
return makeCall(native, callInfo, false);
@ -4758,7 +4758,7 @@ IonBuilder::jsop_funcall(uint32_t argc)
argc -= 1;
}
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, argc))
return false;
@ -4778,7 +4778,7 @@ IonBuilder::jsop_funapply(uint32_t argc)
types::TemporaryTypeSet *calleeTypes = current->peek(calleeDepth)->resultTypeSet();
JSFunction *native = getSingleCallTarget(calleeTypes);
if (argc != 2) {
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, argc))
return false;
return makeCall(native, callInfo, false);
@ -4796,7 +4796,7 @@ IonBuilder::jsop_funapply(uint32_t argc)
// Fallback to regular call if arg 2 is not definitely |arguments|.
if (argument->type() != MIRType_Magic) {
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, argc))
return false;
return makeCall(native, callInfo, false);
@ -4874,7 +4874,7 @@ IonBuilder::jsop_funapplyarguments(uint32_t argc)
// can inline the apply() target and don't care about the actual arguments
// that were passed in.
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
// Vp
MPassArg *passVp = current->pop()->toPassArg();
@ -4883,7 +4883,7 @@ IonBuilder::jsop_funapplyarguments(uint32_t argc)
passVp->block()->discard(passVp);
// Arguments
Vector<MDefinition *> args(cx);
MDefinitionVector args;
if (inliningDepth_) {
if (!args.append(inlineCallInfo_->argv().begin(), inlineCallInfo_->argv().end()))
return false;
@ -4936,7 +4936,7 @@ IonBuilder::jsop_call(uint32_t argc, bool constructing)
int calleeDepth = -((int)argc + 2);
// Acquire known call target if existent.
AutoObjectVector originals(cx);
ObjectVector originals;
bool gotLambda = false;
types::TemporaryTypeSet *calleeTypes = current->peek(calleeDepth)->resultTypeSet();
if (calleeTypes) {
@ -4948,7 +4948,7 @@ IonBuilder::jsop_call(uint32_t argc, bool constructing)
// If any call targets need to be cloned, clone them. Keep track of the
// originals as we need to case on them for poly inline.
bool hasClones = false;
AutoObjectVector targets(cx);
ObjectVector targets;
RootedFunction fun(cx);
RootedScript scriptRoot(cx, script());
for (uint32_t i = 0; i < originals.length(); i++) {
@ -4963,7 +4963,7 @@ IonBuilder::jsop_call(uint32_t argc, bool constructing)
return false;
}
CallInfo callInfo(cx, constructing);
CallInfo callInfo(constructing);
if (!callInfo.init(current, argc))
return false;
@ -5306,7 +5306,7 @@ IonBuilder::jsop_eval(uint32_t argc)
if (type != JSVAL_TYPE_OBJECT && type != JSVAL_TYPE_NULL && type != JSVAL_TYPE_UNDEFINED)
return abort("Direct eval from script with maybe-primitive 'this'");
CallInfo callInfo(cx, /* constructing = */ false);
CallInfo callInfo(/* constructing = */ false);
if (!callInfo.init(current, argc))
return false;
callInfo.unwrapArgs();
@ -5342,7 +5342,7 @@ IonBuilder::jsop_eval(uint32_t argc)
current->push(dynamicName);
current->push(thisv);
CallInfo evalCallInfo(cx, /* constructing = */ false);
CallInfo evalCallInfo(/* constructing = */ false);
if (!evalCallInfo.init(current, /* argc = */ 0))
return false;
@ -8321,7 +8321,7 @@ IonBuilder::getPropTryCommonGetter(bool *emitted, jsid id,
current->add(wrapper);
current->push(wrapper);
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, 0))
return false;
@ -8339,7 +8339,7 @@ IonBuilder::getPropTryCommonGetter(bool *emitted, jsid id,
}
static bool
CanInlinePropertyOpShapes(const Vector<Shape *> &shapes)
CanInlinePropertyOpShapes(const BaselineInspector::ShapeVector &shapes)
{
for (size_t i = 0; i < shapes.length(); i++) {
// We inline the property access as long as the shape is not in
@ -8361,7 +8361,7 @@ IonBuilder::getPropTryInlineAccess(bool *emitted, PropertyName *name, jsid id,
if (current->peek(-1)->type() != MIRType_Object)
return true;
Vector<Shape *> shapes(cx);
BaselineInspector::ShapeVector shapes;
if (!inspector->maybeShapesForPropertyOp(pc, shapes))
return false;
@ -8607,7 +8607,7 @@ IonBuilder::setPropTryCommonSetter(bool *emitted, MDefinition *obj,
// Call the setter. Note that we have to push the original value, not
// the setter's return value.
CallInfo callInfo(cx, false);
CallInfo callInfo(false);
if (!callInfo.init(current, 1))
return false;
@ -8702,7 +8702,7 @@ IonBuilder::setPropTryInlineAccess(bool *emitted, MDefinition *obj,
if (barrier)
return true;
Vector<Shape *> shapes(cx);
BaselineInspector::ShapeVector shapes;
if (!inspector->maybeShapesForPropertyOp(pc, shapes))
return false;

View File

@ -227,7 +227,7 @@ class IonBuilder : public MIRGenerator
JSFunction *getSingleCallTarget(types::TemporaryTypeSet *calleeTypes);
bool getPolyCallTargets(types::TemporaryTypeSet *calleeTypes, bool constructing,
AutoObjectVector &targets, uint32_t maxTargets, bool *gotLambda);
ObjectVector &targets, uint32_t maxTargets, bool *gotLambda);
bool canInlineTarget(JSFunction *target, bool constructing);
void popCfgStack();
@ -495,7 +495,8 @@ class IonBuilder : public MIRGenerator
// Oracles.
bool canEnterInlinedFunction(JSFunction *target);
bool makeInliningDecision(JSFunction *target, CallInfo &callInfo);
uint32_t selectInliningTargets(AutoObjectVector &targets, CallInfo &callInfo, Vector<bool> &choiceSet);
uint32_t selectInliningTargets(ObjectVector &targets, CallInfo &callInfo,
BoolVector &choiceSet);
// Native inlining helpers.
types::StackTypeSet *getOriginalInlineReturnTypeSet();
@ -570,10 +571,10 @@ class IonBuilder : public MIRGenerator
InliningStatus inlineSingleCall(CallInfo &callInfo, JSFunction *target);
// Call functions
InliningStatus inlineCallsite(AutoObjectVector &targets, AutoObjectVector &originals,
InliningStatus inlineCallsite(ObjectVector &targets, ObjectVector &originals,
bool lambda, CallInfo &callInfo);
bool inlineCalls(CallInfo &callInfo, AutoObjectVector &targets, AutoObjectVector &originals,
Vector<bool> &choiceSet, MGetPropertyCache *maybeCache);
bool inlineCalls(CallInfo &callInfo, ObjectVector &targets, ObjectVector &originals,
BoolVector &choiceSet, MGetPropertyCache *maybeCache);
// Inlining helpers.
bool inlineGenericFallback(JSFunction *target, CallInfo &callInfo, MBasicBlock *dispatchBlock,
@ -713,16 +714,15 @@ class CallInfo
{
MDefinition *fun_;
MDefinition *thisArg_;
Vector<MDefinition *> args_;
MDefinitionVector args_;
bool constructing_;
bool setter_;
public:
CallInfo(JSContext *cx, bool constructing)
CallInfo(bool constructing)
: fun_(NULL),
thisArg_(NULL),
args_(cx),
constructing_(constructing),
setter_(false)
{ }
@ -775,16 +775,16 @@ class CallInfo
return argc() + 2;
}
void setArgs(Vector<MDefinition *> *args) {
void setArgs(MDefinitionVector *args) {
JS_ASSERT(args_.length() == 0);
args_.append(args->begin(), args->end());
}
Vector<MDefinition *> &argv() {
MDefinitionVector &argv() {
return args_;
}
const Vector<MDefinition *> &argv() const {
const MDefinitionVector &argv() const {
return args_;
}

View File

@ -2468,7 +2468,7 @@ MLoadSlot::mightAlias(MDefinition *store)
}
void
InlinePropertyTable::trimTo(AutoObjectVector &targets, Vector<bool> &choiceSet)
InlinePropertyTable::trimTo(ObjectVector &targets, BoolVector &choiceSet)
{
for (size_t i = 0; i < targets.length(); i++) {
// If the target was inlined, don't erase the entry.
@ -2489,7 +2489,7 @@ InlinePropertyTable::trimTo(AutoObjectVector &targets, Vector<bool> &choiceSet)
}
void
InlinePropertyTable::trimToTargets(AutoObjectVector &targets)
InlinePropertyTable::trimToTargets(ObjectVector &targets)
{
IonSpew(IonSpew_Inlining, "Got inlineable property cache with %d cases",
(int)numEntries());

View File

@ -5845,6 +5845,9 @@ class MStoreFixedSlot
}
};
typedef Vector<JSObject *, 4, IonAllocPolicy> ObjectVector;
typedef Vector<bool, 4, IonAllocPolicy> BoolVector;
class InlinePropertyTable : public TempObject
{
struct Entry : public TempObject {
@ -5900,10 +5903,10 @@ class InlinePropertyTable : public TempObject
types::TemporaryTypeSet *buildTypeSetForFunction(JSFunction *func) const;
// Remove targets that vetoed inlining from the InlinePropertyTable.
void trimTo(AutoObjectVector &targets, Vector<bool> &choiceSet);
void trimTo(ObjectVector &targets, BoolVector &choiceSet);
// Ensure that the InlinePropertyTable's domain is a subset of |targets|.
void trimToTargets(AutoObjectVector &targets);
void trimToTargets(ObjectVector &targets);
};
class CacheLocationList : public InlineConcatList<CacheLocationList>