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

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

Issue 1240993002: [turbofan] Support handling of default super calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Always install internal functions. Created 5 years, 5 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
« no previous file with comments | « src/compiler/linkage.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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.
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
OLDNEW
« no previous file with comments | « src/compiler/linkage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698