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

Side by Side Diff: src/runtime/runtime-function.cc

Issue 1360793002: [builtins] Refactor Invoke to deal with any kind of callable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/cpu-profiler.h" 10 #include "src/cpu-profiler.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); 487 !Handle<JSFunction>::cast(bound_function)->shared()->bound());
488 488
489 int total_argc = 0; 489 int total_argc = 0;
490 base::SmartArrayPointer<Handle<Object>> param_data = 490 base::SmartArrayPointer<Handle<Object>> param_data =
491 Runtime::GetCallerArguments(isolate, bound_argc, &total_argc); 491 Runtime::GetCallerArguments(isolate, bound_argc, &total_argc);
492 for (int i = 0; i < bound_argc; i++) { 492 for (int i = 0; i < bound_argc; i++) {
493 param_data[i] = Handle<Object>( 493 param_data[i] = Handle<Object>(
494 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate); 494 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate);
495 } 495 }
496 496
497 if (!bound_function->IsJSFunction()) {
498 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
499 isolate, bound_function,
500 Execution::GetConstructorDelegate(isolate, bound_function));
501 }
502 DCHECK(bound_function->IsJSFunction());
503
504 Handle<Object> result; 497 Handle<Object> result;
505 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 498 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
506 isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function), 499 isolate, result, Execution::New(isolate, bound_function, bound_function,
507 total_argc, param_data.get())); 500 total_argc, param_data.get()));
508 return *result; 501 return *result;
509 } 502 }
510 503
511 504
512 RUNTIME_FUNCTION(Runtime_Call) { 505 RUNTIME_FUNCTION(Runtime_Call) {
513 HandleScope scope(isolate); 506 HandleScope scope(isolate);
514 DCHECK_LE(2, args.length()); 507 DCHECK_LE(2, args.length());
515 int const argc = args.length() - 2; 508 int const argc = args.length() - 2;
516 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); 509 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 isolate, argv[i], Object::GetElement(isolate, arguments, offset + i)); 550 isolate, argv[i], Object::GetElement(isolate, arguments, offset + i));
558 } 551 }
559 552
560 Handle<Object> result; 553 Handle<Object> result;
561 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 554 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
562 isolate, result, Execution::Call(isolate, fun, receiver, argc, argv)); 555 isolate, result, Execution::Call(isolate, fun, receiver, argc, argv));
563 return *result; 556 return *result;
564 } 557 }
565 558
566 559
567 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) {
568 HandleScope scope(isolate);
569 DCHECK(args.length() == 1);
570 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
571 RUNTIME_ASSERT(!object->IsJSFunction());
572 Handle<JSFunction> result;
573 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
574 isolate, result, Execution::GetFunctionDelegate(isolate, object));
575 return *result;
576 }
577
578
579 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) {
580 HandleScope scope(isolate);
581 DCHECK(args.length() == 1);
582 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
583 RUNTIME_ASSERT(!object->IsJSFunction());
584 Handle<JSFunction> result;
585 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
586 isolate, result, Execution::GetConstructorDelegate(isolate, object));
587 return *result;
588 }
589
590
591 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { 560 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) {
592 SealHandleScope shs(isolate); 561 SealHandleScope shs(isolate);
593 DCHECK(args.length() == 0); 562 DCHECK(args.length() == 0);
594 JavaScriptFrameIterator it(isolate); 563 JavaScriptFrameIterator it(isolate);
595 JavaScriptFrame* frame = it.frame(); 564 JavaScriptFrame* frame = it.frame();
596 return frame->IsConstructor() ? frame->GetOriginalConstructor() 565 return frame->IsConstructor() ? frame->GetOriginalConstructor()
597 : isolate->heap()->undefined_value(); 566 : isolate->heap()->undefined_value();
598 } 567 }
599 568
600 569
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 618
650 619
651 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { 620 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) {
652 HandleScope scope(isolate); 621 HandleScope scope(isolate);
653 DCHECK(args.length() == 0); 622 DCHECK(args.length() == 0);
654 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 623 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
655 NewTypeError(MessageTemplate::kStrongArity)); 624 NewTypeError(MessageTemplate::kStrongArity));
656 } 625 }
657 } // namespace internal 626 } // namespace internal
658 } // namespace v8 627 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698