Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: src/js/v8natives.js

Issue 1530893002: [proxies] Correctly handle proxies in Function.prototype.bind (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase and separate file for tests. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/v8natives.js
diff --git a/src/js/v8natives.js b/src/js/v8natives.js
index 0003f9f5096d51e34ecfaf2ee2be8951eb75f060..558bce2ce5e9c77a9efe810e1d0b5c720b7597b3 100644
--- a/src/js/v8natives.js
+++ b/src/js/v8natives.js
@@ -1302,9 +1302,7 @@ function FunctionToString() {
}
-// ES5 15.3.4.5
// ES6 9.2.3.2 Function.prototype.bind(thisArg , ...args)
-// TODO(cbruni): check again and remove FunctionProxies section further down
function FunctionBind(this_arg) { // Length is 1.
if (!IS_CALLABLE(this)) throw MakeTypeError(kFunctionBind);
@@ -1336,20 +1334,23 @@ function FunctionBind(this_arg) { // Length is 1.
return %Apply(bindings[0], bindings[1], argv, 0, bound_argc + argc);
};
+ var proto = %_GetPrototype(this); // in ES6 9.4.1.3 BoundFunctionCreate
+
var new_length = 0;
- var old_length = this.length;
- // FunctionProxies might provide a non-UInt32 value. If so, ignore it.
- if ((typeof old_length === "number") &&
- ((old_length >>> 0) === old_length)) {
- var argc = %_ArgumentsLength();
- if (argc > 0) argc--; // Don't count the thisArg as parameter.
- new_length = old_length - argc;
- if (new_length < 0) new_length = 0;
+ if (ObjectGetOwnPropertyDescriptor(this, "length") !== UNDEFINED) {
+ var old_length = this.length;
+ if (IS_NUMBER(old_length)) {
+ var argc = %_ArgumentsLength();
+ if (argc > 0) argc--; // Don't count the thisArg as parameter.
+ new_length = TO_INTEGER(old_length) - argc;
+ if (new_length < 0) new_length = 0;
+ }
}
+
// This runtime function finds any remaining arguments on the stack,
// so we don't pass the arguments object.
- var result = %FunctionBindArguments(boundFunction, this,
- this_arg, new_length);
+ var result = %FunctionBindArguments(boundFunction, this, this_arg,
+ new_length, proto);
var name = this.name;
var bound_name = IS_STRING(name) ? name : "";
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698