better rest param member expression deopt

This commit is contained in:
Sebastian McKenzie
2015-03-01 11:01:06 +11:00
parent 09e68d8d46
commit a57475abc9
3 changed files with 49 additions and 35 deletions

View File

@@ -29,7 +29,6 @@ var memberExpressionOptimisationVisitor = {
var prop = parent.property;
if (isNumber(prop.value) || t.isUnaryExpression(prop) || t.isBinaryExpression(prop)) {
state.candidates.push(this);
state.canOptimise = true;
return;
}
}
@@ -81,7 +80,7 @@ exports.Function = function (node, parent, scope) {
var state = {
outerBinding: scope.getBindingIdentifier(rest.name),
canOptimise: false,
canOptimise: true,
candidates: [],
method: node,
name: rest.name
@@ -90,7 +89,7 @@ exports.Function = function (node, parent, scope) {
scope.traverse(node, memberExpressionOptimisationVisitor, state);
// we only have shorthands and there's no other references
if (state.canOptimise) {
if (state.canOptimise && state.candidates.length) {
for (var i = 0; i < state.candidates.length; i++) {
var candidate = state.candidates[i];
candidate.node = argsId;