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

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

Issue 1359583002: [builtins] Add support for NewTarget to Execution::New. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Merge mips and mips64 ports. 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
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | 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 "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
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
OLDNEW
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698