Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try our best to prevent deopt #124

Merged
merged 1 commit into from
Dec 18, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/backburner.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,34 @@ Backburner.prototype = {
}
},

join: function(target, method /*, args */) {
join: function(/* target, method , args */) {
var method, target;

if (this.currentInstance) {
if (!method) {
method = target;
var length = arguments.length;
if (length === 1) {
method = arguments[0];
target = null;
} else {
target = arguments[0];
method = arguments[1];
}

if (isString(method)) {
method = target[method];
}

return method.apply(target, slice.call(arguments, 2));
if (length === 1) {
return method();
} else if (length === 2) {
return method.call(target);
} else {
var args = new Array(length - 2);
for (var i =0, l = length - 2; i < l; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess slicing here would deopt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slicing on arguments does... :(
v8 is starting to fix this, but mobile devices don't update fast enough. Hopefully someday we can remove these hacks

args[i] = arguments[i + 2];
}
return method.apply(target, args);
}
} else {
return this.run.apply(this, arguments);
}
Expand Down