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

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

Issue 2557963004: [Runtime] Use ElementsAccessor in NewWithSpread. (Closed)
Patch Set: Created 4 years 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 | « no previous file | 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 "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"
11 #include "src/arguments.h" 11 #include "src/arguments.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/elements.h"
13 #include "src/frames-inl.h" 14 #include "src/frames-inl.h"
14 #include "src/isolate-inl.h" 15 #include "src/isolate-inl.h"
15 #include "src/messages.h" 16 #include "src/messages.h"
16 #include "src/runtime/runtime.h" 17 #include "src/runtime/runtime.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
21 22
22 RUNTIME_FUNCTION(Runtime_ThrowNonMethodError) { 23 RUNTIME_FUNCTION(Runtime_ThrowNonMethodError) {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 CHECK(spread_array->length()->ToArrayIndex(&spread_length)); 449 CHECK(spread_array->length()->ToArrayIndex(&spread_length));
449 int result_length = constructor_argc - 1 + spread_length; 450 int result_length = constructor_argc - 1 + spread_length;
450 ScopedVector<Handle<Object>> construct_args(result_length); 451 ScopedVector<Handle<Object>> construct_args(result_length);
451 452
452 // Append each of the individual args to the result. 453 // Append each of the individual args to the result.
453 for (int i = 0; i < constructor_argc - 1; i++) { 454 for (int i = 0; i < constructor_argc - 1; i++) {
454 construct_args[i] = args.at<Object>(2 + i); 455 construct_args[i] = args.at<Object>(2 + i);
455 } 456 }
456 457
457 // Append element of the spread to the result. 458 // Append element of the spread to the result.
459 ElementsAccessor* accessor = spread_array->GetElementsAccessor();
458 for (uint32_t i = 0; i < spread_length; i++) { 460 for (uint32_t i = 0; i < spread_length; i++) {
459 // TODO(petermarshall): Use ElementAccessors here. 461 DCHECK(accessor->HasElement(spread_array, i));
460 LookupIterator it(isolate, spread, i); 462 Handle<Object> element = accessor->Get(spread_array, i);
461 Handle<Object> element = spread_array->GetDataProperty(&it);
462 construct_args[constructor_argc - 1 + i] = element; 463 construct_args[constructor_argc - 1 + i] = element;
463 } 464 }
464 465
465 // Call the constructor. 466 // Call the constructor.
466 RETURN_RESULT_OR_FAILURE( 467 RETURN_RESULT_OR_FAILURE(
467 isolate, Execution::New(isolate, constructor, new_target, result_length, 468 isolate, Execution::New(isolate, constructor, new_target, result_length,
468 construct_args.start())); 469 construct_args.start()));
469 } 470 }
470 471
471 } // namespace internal 472 } // namespace internal
472 } // namespace v8 473 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698