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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 DCHECK(args.length() == 1); | 514 DCHECK(args.length() == 1); |
515 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 515 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
516 Debug* debug = isolate->debug(); | 516 Debug* debug = isolate->debug(); |
517 // Handle stepping into constructors if step into is active. | 517 // Handle stepping into constructors if step into is active. |
518 if (debug->StepInActive()) debug->HandleStepIn(function, true); | 518 if (debug->StepInActive()) debug->HandleStepIn(function, true); |
519 return *isolate->factory()->undefined_value(); | 519 return *isolate->factory()->undefined_value(); |
520 } | 520 } |
521 | 521 |
522 | 522 |
523 RUNTIME_FUNCTION(Runtime_DefaultConstructorCallSuper) { | 523 RUNTIME_FUNCTION(Runtime_DefaultConstructorCallSuper) { |
524 UNIMPLEMENTED(); | 524 HandleScope scope(isolate); |
525 return nullptr; | 525 DCHECK(args.length() == 2); |
526 CONVERT_ARG_HANDLE_CHECKED(JSFunction, original_constructor, 0); | |
527 CONVERT_ARG_HANDLE_CHECKED(JSFunction, actual_constructor, 1); | |
528 JavaScriptFrameIterator it(isolate); | |
529 | |
530 // Prepare the callee to the super call. The super constructor is stored as | |
531 // the prototype of the constructor we are currently executing. | |
532 Handle<Object> super_constructor; | |
533 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
534 isolate, super_constructor, | |
535 Runtime::GetPrototype(isolate, actual_constructor)); | |
536 | |
537 // Find the frame that holds the actual arguments passed to the function. | |
538 it.AdvanceToArgumentsFrame(); | |
539 JavaScriptFrame* frame = it.frame(); | |
540 | |
541 // Prepare the array containing all passed arguments. | |
542 int argument_count = frame->GetArgumentsLength(); | |
543 Handle<FixedArray> elements = | |
544 isolate->factory()->NewUninitializedFixedArray(argument_count); | |
545 for (int i = 0; i < argument_count; ++i) { | |
546 elements->set(i, frame->GetParameter(i)); | |
547 } | |
548 Handle<JSArray> arguments = isolate->factory()->NewJSArrayWithElements( | |
549 elements, FAST_ELEMENTS, argument_count); | |
550 | |
551 // Call $reflectConstruct(<super>, <args>, <new.target>) now. | |
552 Handle<Object> reflect; | |
553 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
554 isolate, reflect, | |
555 Object::GetProperty(isolate, | |
556 handle(isolate->native_context()->builtins()), | |
557 "$reflectConstruct")); | |
558 RUNTIME_ASSERT(reflect->IsJSFunction()); // Depends on --harmony-reflect. | |
adamk
2015/07/17 20:04:01
--harmony-reflect isn't shipping soon, I think you
Michael Starzinger
2015/07/20 09:03:56
I think I am confused about what is shipping and w
Michael Starzinger
2015/07/20 09:14:39
Oh boy, in Genesis::InitializeGlobal_harmony_refle
Michael Starzinger
2015/07/20 09:42:38
Done. I did so on the third patch set.
| |
559 Handle<Object> argv[] = {super_constructor, arguments, original_constructor}; | |
560 Handle<Object> result; | |
561 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
562 isolate, result, | |
563 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(), | |
564 arraysize(argv), argv)); | |
565 | |
566 return *result; | |
526 } | 567 } |
527 } // namespace internal | 568 } // namespace internal |
528 } // namespace v8 | 569 } // namespace v8 |
OLD | NEW |