Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index c596a9ca67d78858b52bf4ed98d27b058cd571ba..b1b33bc456d37b3887decb7d0543e39eda9cdadb 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -4238,9 +4238,10 @@ BUILTIN(FunctionConstructor) { |
return *result; |
} |
+namespace { |
-// ES6 section 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) |
-BUILTIN(FunctionPrototypeBind) { |
+Object* DoFunctionBind(Isolate* isolate, |
+ BuiltinArguments<BuiltinExtraArguments::kNone> args) { |
HandleScope scope(isolate); |
DCHECK_LE(1, args.length()); |
if (!args.receiver()->IsCallable()) { |
@@ -4324,6 +4325,23 @@ BUILTIN(FunctionPrototypeBind) { |
return *function; |
} |
+} // namespace |
+ |
+// ES6 section 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) |
+BUILTIN(FunctionPrototypeBind) { return DoFunctionBind(isolate, args); } |
+ |
+// TODO(verwaest): This is a temporary helper until the FastFunctionBind stub |
+// can |
Igor Sheludko
2016/06/07 16:24:34
Please fix comment wrapping.
|
+// tailcall to the builtin directly. |
+RUNTIME_FUNCTION(Runtime_FunctionBind) { |
+ DCHECK_EQ(2, args.length()); |
+ Arguments* incoming = reinterpret_cast<Arguments*>(args[0]); |
+ // Rewrap the arguments as builtins arguments. |
+ BuiltinArguments<BuiltinExtraArguments::kNone> caller_args( |
+ incoming->length() + 1, incoming->arguments() + 1); |
+ return DoFunctionBind(isolate, caller_args); |
+} |
+ |
// ES6 section 19.2.3.5 Function.prototype.toString ( ) |
BUILTIN(FunctionPrototypeToString) { |
HandleScope scope(isolate); |