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

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

Issue 2571563004: [Turbofan] Implement super calls with spread bytecode in assembly code. (Closed)
Patch Set: MIPS64 port Created 3 years, 11 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
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/accessors.h" 10 #include "src/accessors.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); 452 CONVERT_ARG_CHECKED(JSFunction, active_function, 0);
453 Object* prototype = active_function->map()->prototype(); 453 Object* prototype = active_function->map()->prototype();
454 if (!prototype->IsConstructor()) { 454 if (!prototype->IsConstructor()) {
455 HandleScope scope(isolate); 455 HandleScope scope(isolate);
456 return ThrowNotSuperConstructor(isolate, handle(prototype, isolate), 456 return ThrowNotSuperConstructor(isolate, handle(prototype, isolate),
457 handle(active_function, isolate)); 457 handle(active_function, isolate));
458 } 458 }
459 return prototype; 459 return prototype;
460 } 460 }
461 461
462 RUNTIME_FUNCTION(Runtime_NewWithSpread) {
463 HandleScope scope(isolate);
464 DCHECK_LE(3, args.length());
465 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, constructor, 0);
466 CONVERT_ARG_HANDLE_CHECKED(Object, new_target, 1);
467
468 int constructor_argc = args.length() - 2;
469 CONVERT_ARG_HANDLE_CHECKED(Object, spread, args.length() - 1);
470
471 // Iterate over the spread if we need to.
472 if (spread->IterationHasObservableEffects()) {
473 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable();
474 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
475 isolate, spread,
476 Execution::Call(isolate, spread_iterable_function,
477 isolate->factory()->undefined_value(), 1, &spread));
478 }
479
480 uint32_t spread_length;
481 Handle<JSArray> spread_array = Handle<JSArray>::cast(spread);
482 CHECK(spread_array->length()->ToArrayIndex(&spread_length));
483 int result_length = constructor_argc - 1 + spread_length;
484 ScopedVector<Handle<Object>> construct_args(result_length);
485
486 // Append each of the individual args to the result.
487 for (int i = 0; i < constructor_argc - 1; i++) {
488 construct_args[i] = args.at<Object>(2 + i);
489 }
490
491 // Append element of the spread to the result.
492 ElementsAccessor* accessor = spread_array->GetElementsAccessor();
493 for (uint32_t i = 0; i < spread_length; i++) {
494 DCHECK(accessor->HasElement(spread_array, i));
495 Handle<Object> element = accessor->Get(spread_array, i);
496 construct_args[constructor_argc - 1 + i] = element;
497 }
498
499 // Call the constructor.
500 RETURN_RESULT_OR_FAILURE(
501 isolate, Execution::New(isolate, constructor, new_target, result_length,
502 construct_args.start()));
503 }
504
505 } // namespace internal 462 } // namespace internal
506 } // namespace v8 463 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698