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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 DCHECK(args.length() == 2); | 518 DCHECK(args.length() == 2); |
519 CONVERT_ARG_HANDLE_CHECKED(JSFunction, original_constructor, 0); | 519 CONVERT_ARG_HANDLE_CHECKED(JSFunction, original_constructor, 0); |
520 CONVERT_ARG_HANDLE_CHECKED(JSFunction, super_constructor, 1); | 520 CONVERT_ARG_HANDLE_CHECKED(JSFunction, super_constructor, 1); |
521 JavaScriptFrameIterator it(isolate); | 521 JavaScriptFrameIterator it(isolate); |
522 | 522 |
523 // Determine the actual arguments passed to the function. | 523 // Determine the actual arguments passed to the function. |
524 int argument_count = 0; | 524 int argument_count = 0; |
525 base::SmartArrayPointer<Handle<Object>> arguments = | 525 base::SmartArrayPointer<Handle<Object>> arguments = |
526 Runtime::GetCallerArguments(isolate, 0, &argument_count); | 526 Runtime::GetCallerArguments(isolate, 0, &argument_count); |
527 | 527 |
528 // Prepare the array containing all passed arguments. | |
529 Handle<FixedArray> elements = | |
530 isolate->factory()->NewUninitializedFixedArray(argument_count); | |
531 for (int i = 0; i < argument_count; ++i) { | |
532 elements->set(i, *arguments[i]); | |
533 } | |
534 Handle<JSArray> array = isolate->factory()->NewJSArrayWithElements( | |
535 elements, FAST_ELEMENTS, argument_count); | |
536 | |
537 // Call %reflect_construct(<super>, <args>, <new.target>) now. | |
538 Handle<JSFunction> reflect = isolate->reflect_construct(); | |
539 Handle<Object> argv[] = {super_constructor, array, original_constructor}; | |
540 Handle<Object> result; | 528 Handle<Object> result; |
541 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 529 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
542 isolate, result, | 530 isolate, result, Execution::New(super_constructor, original_constructor, |
543 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(), | 531 argument_count, arguments.get())); |
544 arraysize(argv), argv)); | |
545 | 532 |
546 return *result; | 533 return *result; |
547 } | 534 } |
| 535 |
548 } // namespace internal | 536 } // namespace internal |
549 } // namespace v8 | 537 } // namespace v8 |
OLD | NEW |