Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index e614103b4d4a8695666e6f78e470703ac0454f31..c9bcfcd2b204a8037dc70f5bd61b632bbefc8895 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -8521,6 +8521,42 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { |
} |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { |
+ HandleScope scope(isolate); |
+ ASSERT(args.length() >= 2); |
+ CONVERT_CHECKED(JSReceiver, fun, args[args.length() - 1]); |
+ Object* receiver = args[0]; |
+ int argc = args.length() - 2; |
+ |
+ // If there are too many arguments, allocate argv via malloc. |
+ const int argv_small_size = 10; |
+ Handle<Object> argv_small_buffer[argv_small_size]; |
+ SmartArrayPointer<Handle<Object> > argv_large_buffer; |
+ Handle<Object>* argv = argv_small_buffer; |
+ if (argc > argv_small_size) { |
+ argv = new Handle<Object>[argc]; |
+ if (argv == NULL) return isolate->StackOverflow(); |
+ argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); |
+ } |
+ |
+ for (int i = 0; i < argc; ++i) { |
+ MaybeObject* maybe = args[1 + i]; |
+ Object* object; |
+ if (!maybe->To<Object>(&object)) return maybe; |
+ argv[i] = Handle<Object>(object); |
+ } |
+ |
+ bool threw; |
+ Handle<JSReceiver> hfun(fun); |
+ Handle<Object> hreceiver(receiver); |
+ Handle<Object> result = |
+ Execution::Call(hfun, hreceiver, argc, argv, &threw, true); |
+ |
+ if (threw) return Failure::Exception(); |
+ return *result; |
+} |
+ |
+ |
RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { |
HandleScope scope(isolate); |
ASSERT(args.length() == 5); |