OLD | NEW |
---|---|
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/v8.h" | 5 #include "src/v8.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/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 } | 604 } |
605 | 605 |
606 Handle<Object> result; | 606 Handle<Object> result; |
607 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 607 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
608 isolate, result, | 608 isolate, result, |
609 Execution::Call(isolate, fun, receiver, argc, argv, true)); | 609 Execution::Call(isolate, fun, receiver, argc, argv, true)); |
610 return *result; | 610 return *result; |
611 } | 611 } |
612 | 612 |
613 | 613 |
614 RUNTIME_FUNCTION(Runtime_ApplyConstruct) { | |
615 HandleScope scope(isolate); | |
616 DCHECK(args.length() == 4); | |
617 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | |
618 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 1); | |
619 CONVERT_INT32_ARG_CHECKED(offset, 2); | |
620 CONVERT_INT32_ARG_CHECKED(argc, 3); | |
621 RUNTIME_ASSERT(offset >= 0); | |
622 // Loose upper bound to allow fuzzing. We'll most likely run out of | |
623 // stack space before hitting this limit. | |
624 static int kMaxArgc = 1000000; | |
arv (Not doing code reviews)
2015/02/18 15:07:06
Maybe define a const that is shared with Runtime_A
| |
625 RUNTIME_ASSERT(argc >= 0 && argc <= kMaxArgc); | |
626 | |
627 // If there are too many arguments, allocate argv via malloc. | |
arv (Not doing code reviews)
2015/02/18 15:07:06
Code sharing? Maybe you need to use a macro though
caitp (gmail)
2015/02/18 15:32:08
Eventually, there is going to be Reflect.apply() a
| |
628 const int argv_small_size = 10; | |
629 Handle<Object> argv_small_buffer[argv_small_size]; | |
630 SmartArrayPointer<Handle<Object> > argv_large_buffer; | |
631 Handle<Object>* argv = argv_small_buffer; | |
632 if (argc > argv_small_size) { | |
633 argv = new Handle<Object>[argc]; | |
634 if (argv == NULL) return isolate->StackOverflow(); | |
635 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); | |
636 } | |
637 | |
638 for (int i = 0; i < argc; ++i) { | |
639 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
640 isolate, argv[i], Object::GetElement(isolate, arguments, offset + i)); | |
641 } | |
642 | |
643 Handle<Object> result; | |
644 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
645 Execution::New(fun, argc, argv)); | |
646 return *result; | |
647 } | |
648 | |
649 | |
614 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { | 650 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { |
615 HandleScope scope(isolate); | 651 HandleScope scope(isolate); |
616 DCHECK(args.length() == 1); | 652 DCHECK(args.length() == 1); |
617 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 653 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
618 RUNTIME_ASSERT(!object->IsJSFunction()); | 654 RUNTIME_ASSERT(!object->IsJSFunction()); |
619 return *Execution::GetFunctionDelegate(isolate, object); | 655 return *Execution::GetFunctionDelegate(isolate, object); |
620 } | 656 } |
621 | 657 |
622 | 658 |
623 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { | 659 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { |
(...skipping 21 matching lines...) Expand all Loading... | |
645 | 681 |
646 | 682 |
647 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { | 683 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
648 SealHandleScope shs(isolate); | 684 SealHandleScope shs(isolate); |
649 DCHECK(args.length() == 1); | 685 DCHECK(args.length() == 1); |
650 CONVERT_ARG_CHECKED(Object, obj, 0); | 686 CONVERT_ARG_CHECKED(Object, obj, 0); |
651 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 687 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
652 } | 688 } |
653 } | 689 } |
654 } // namespace v8::internal | 690 } // namespace v8::internal |
OLD | NEW |