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

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

Issue 2252393002: [elements, turbofan] Implement simple GrowElements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Android build Created 4 years, 4 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/objects.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 "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/elements.h" 10 #include "src/elements.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]); 368 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]);
369 369
370 if (key < 0) { 370 if (key < 0) {
371 return object->elements(); 371 return object->elements();
372 } 372 }
373 373
374 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); 374 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
375 uint32_t index = static_cast<uint32_t>(key); 375 uint32_t index = static_cast<uint32_t>(key);
376 376
377 if (index >= capacity) { 377 if (index >= capacity) {
378 if (object->map()->is_prototype_map() || 378 if (!object->GetElementsAccessor()->GrowCapacity(object, index)) {
379 object->WouldConvertToSlowElements(index)) {
380 // We don't want to allow operations that cause lazy deopt. Return a Smi
381 // as a signal that optimized code should eagerly deoptimize.
382 return Smi::FromInt(0); 379 return Smi::FromInt(0);
383 } 380 }
384
385 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1);
386 object->GetElementsAccessor()->GrowCapacityAndConvert(object, new_capacity);
387 } 381 }
388 382
389 // On success, return the fixed array elements. 383 // On success, return the fixed array elements.
390 return object->elements(); 384 return object->elements();
391 } 385 }
392 386
393 387
394 RUNTIME_FUNCTION(Runtime_HasComplexElements) { 388 RUNTIME_FUNCTION(Runtime_HasComplexElements) {
395 HandleScope scope(isolate); 389 HandleScope scope(isolate);
396 DCHECK(args.length() == 1); 390 DCHECK(args.length() == 1);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (search_element->StrictEquals(*element_k)) { 634 if (search_element->StrictEquals(*element_k)) {
641 return *index_obj; 635 return *index_obj;
642 } 636 }
643 } 637 }
644 } 638 }
645 return Smi::FromInt(-1); 639 return Smi::FromInt(-1);
646 } 640 }
647 641
648 } // namespace internal 642 } // namespace internal
649 } // namespace v8 643 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698