Bug 1111252 - IonMonkey: Use Vector's API more cleverly to eliminate intermediate allocations r=waldo

This commit is contained in:
Dan Gohman 2015-01-14 16:32:02 -08:00
parent a26a6e7fdb
commit b72eb40328
4 changed files with 27 additions and 28 deletions

View File

@ -2265,16 +2265,17 @@ jit::SetEnterJitData(JSContext *cx, EnterJitData &data, RunState &state, AutoVal
if (data.numActualArgs >= numFormals) { if (data.numActualArgs >= numFormals) {
data.maxArgv = args.base() + 1; data.maxArgv = args.base() + 1;
} else { } else {
// Pad missing arguments with |undefined|. MOZ_ASSERT(vals.empty());
for (size_t i = 1; i < args.length() + 2; i++) { if (!vals.reserve(Max(args.length() + 1, numFormals + 1)))
if (!vals.append(args.base()[i])) return false;
return false;
}
while (vals.length() < numFormals + 1) { // Append |this| and any provided arguments.
if (!vals.append(UndefinedValue())) for (size_t i = 1; i < args.length() + 2; ++i)
return false; vals.infallibleAppend(args.base()[i]);
}
// Pad missing arguments with |undefined|.
while (vals.length() < numFormals + 1)
vals.infallibleAppend(UndefinedValue());
MOZ_ASSERT(vals.length() >= numFormals + 1); MOZ_ASSERT(vals.length() >= numFormals + 1);
data.maxArgv = vals.begin(); data.maxArgv = vals.begin();

View File

@ -315,8 +315,7 @@ IonBuilder::getPolyCallTargets(types::TemporaryTypeSet *calleeTypes, bool constr
return true; return true;
} }
DebugOnly<bool> appendOk = targets.append(obj); targets.infallibleAppend(obj);
MOZ_ASSERT(appendOk);
} }
// For now, only inline "singleton" lambda calls // For now, only inline "singleton" lambda calls
@ -4655,7 +4654,7 @@ IonBuilder::makeInliningDecision(JSObject *targetArg, CallInfo &callInfo)
} }
bool bool
IonBuilder::selectInliningTargets(ObjectVector &targets, CallInfo &callInfo, BoolVector &choiceSet, IonBuilder::selectInliningTargets(const ObjectVector &targets, CallInfo &callInfo, BoolVector &choiceSet,
uint32_t *numInlineable) uint32_t *numInlineable)
{ {
*numInlineable = 0; *numInlineable = 0;
@ -4840,7 +4839,7 @@ IonBuilder::inlineSingleCall(CallInfo &callInfo, JSObject *targetArg)
} }
IonBuilder::InliningStatus IonBuilder::InliningStatus
IonBuilder::inlineCallsite(ObjectVector &targets, ObjectVector &originals, IonBuilder::inlineCallsite(const ObjectVector &targets, ObjectVector &originals,
bool lambda, CallInfo &callInfo) bool lambda, CallInfo &callInfo)
{ {
if (targets.empty()) if (targets.empty())
@ -5024,7 +5023,7 @@ IonBuilder::inlineTypeObjectFallback(CallInfo &callInfo, MBasicBlock *dispatchBl
} }
bool bool
IonBuilder::inlineCalls(CallInfo &callInfo, ObjectVector &targets, IonBuilder::inlineCalls(CallInfo &callInfo, const ObjectVector &targets,
ObjectVector &originals, BoolVector &choiceSet, ObjectVector &originals, BoolVector &choiceSet,
MGetPropertyCache *maybeCache) MGetPropertyCache *maybeCache)
{ {
@ -5595,12 +5594,10 @@ IonBuilder::jsop_funapplyarguments(uint32_t argc)
vp->setImplicitlyUsedUnchecked(); vp->setImplicitlyUsedUnchecked();
// Arguments // Arguments
MDefinitionVector args(alloc());
if (inliningDepth_) { if (inliningDepth_) {
if (!args.appendAll(inlineCallInfo_->argv())) if (!callInfo.setArgs(inlineCallInfo_->argv()))
return false; return false;
} }
callInfo.setArgs(&args);
// This // This
MDefinition *argThis = current->pop(); MDefinition *argThis = current->pop();
@ -5663,6 +5660,8 @@ IonBuilder::jsop_call(uint32_t argc, bool constructing)
// Keep track of the originals as we need to case on them for poly inline. // Keep track of the originals as we need to case on them for poly inline.
bool hasClones = false; bool hasClones = false;
ObjectVector targets(alloc()); ObjectVector targets(alloc());
if (!targets.reserve(originals.length()))
return false;
for (uint32_t i = 0; i < originals.length(); i++) { for (uint32_t i = 0; i < originals.length(); i++) {
JSObject *obj = originals[i]; JSObject *obj = originals[i];
if (obj->is<JSFunction>()) { if (obj->is<JSFunction>()) {
@ -5676,8 +5675,7 @@ IonBuilder::jsop_call(uint32_t argc, bool constructing)
} }
} }
} }
if (!targets.append(obj)) targets.infallibleAppend(obj);
return false;
} }
CallInfo callInfo(alloc(), constructing); CallInfo callInfo(alloc(), constructing);

View File

@ -708,7 +708,7 @@ class IonBuilder
// Oracles. // Oracles.
InliningDecision canInlineTarget(JSFunction *target, CallInfo &callInfo); InliningDecision canInlineTarget(JSFunction *target, CallInfo &callInfo);
InliningDecision makeInliningDecision(JSObject *target, CallInfo &callInfo); InliningDecision makeInliningDecision(JSObject *target, CallInfo &callInfo);
bool selectInliningTargets(ObjectVector &targets, CallInfo &callInfo, bool selectInliningTargets(const ObjectVector &targets, CallInfo &callInfo,
BoolVector &choiceSet, uint32_t *numInlineable); BoolVector &choiceSet, uint32_t *numInlineable);
// Native inlining helpers. // Native inlining helpers.
@ -816,9 +816,9 @@ class IonBuilder
InliningStatus inlineSingleCall(CallInfo &callInfo, JSObject *target); InliningStatus inlineSingleCall(CallInfo &callInfo, JSObject *target);
// Call functions // Call functions
InliningStatus inlineCallsite(ObjectVector &targets, ObjectVector &originals, InliningStatus inlineCallsite(const ObjectVector &targets, ObjectVector &originals,
bool lambda, CallInfo &callInfo); bool lambda, CallInfo &callInfo);
bool inlineCalls(CallInfo &callInfo, ObjectVector &targets, ObjectVector &originals, bool inlineCalls(CallInfo &callInfo, const ObjectVector &targets, ObjectVector &originals,
BoolVector &choiceSet, MGetPropertyCache *maybeCache); BoolVector &choiceSet, MGetPropertyCache *maybeCache);
// Inlining helpers. // Inlining helpers.
@ -1112,9 +1112,9 @@ class CallInfo
return argc() + 2; return argc() + 2;
} }
void setArgs(MDefinitionVector *args) { bool setArgs(const MDefinitionVector &args) {
MOZ_ASSERT(args_.empty()); MOZ_ASSERT(args_.empty());
args_.appendAll(*args); return args_.appendAll(args);
} }
MDefinitionVector &argv() { MDefinitionVector &argv() {

View File

@ -2729,10 +2729,10 @@ CloneForDeadBranches(TempAllocator &alloc, MInstruction *candidate)
MDefinitionVector operands(alloc); MDefinitionVector operands(alloc);
size_t end = candidate->numOperands(); size_t end = candidate->numOperands();
for (size_t i = 0; i < end; i++) { if (!operands.reserve(end))
if (!operands.append(candidate->getOperand(i))) return false;
return false; for (size_t i = 0; i < end; ++i)
} operands.infallibleAppend(candidate->getOperand(i));
MInstruction *clone = candidate->clone(alloc, operands); MInstruction *clone = candidate->clone(alloc, operands);
clone->setRange(nullptr); clone->setRange(nullptr);