OLD | NEW |
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]); | 367 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]); |
368 | 368 |
369 if (key < 0) { | 369 if (key < 0) { |
370 return object->elements(); | 370 return object->elements(); |
371 } | 371 } |
372 | 372 |
373 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); | 373 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); |
374 uint32_t index = static_cast<uint32_t>(key); | 374 uint32_t index = static_cast<uint32_t>(key); |
375 | 375 |
376 if (index >= capacity) { | 376 if (index >= capacity) { |
377 if (object->map()->is_prototype_map() || | 377 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); |
378 object->WouldConvertToSlowElements(index)) { | 378 if (!object->GetElementsAccessor()->GrowCapacity(object, new_capacity)) { |
379 // We don't want to allow operations that cause lazy deopt. Return a Smi | |
380 // as a signal that optimized code should eagerly deoptimize. | |
381 return Smi::FromInt(0); | 379 return Smi::FromInt(0); |
382 } | 380 } |
383 | |
384 uint32_t new_capacity = JSObject::NewElementsCapacity(index + 1); | |
385 object->GetElementsAccessor()->GrowCapacityAndConvert(object, new_capacity); | |
386 } | 381 } |
387 | 382 |
388 // On success, return the fixed array elements. | 383 // On success, return the fixed array elements. |
389 return object->elements(); | 384 return object->elements(); |
390 } | 385 } |
391 | 386 |
392 | 387 |
393 RUNTIME_FUNCTION(Runtime_HasComplexElements) { | 388 RUNTIME_FUNCTION(Runtime_HasComplexElements) { |
394 HandleScope scope(isolate); | 389 HandleScope scope(isolate); |
395 DCHECK(args.length() == 1); | 390 DCHECK(args.length() == 1); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // If SameValueZero(searchElement, elementK) is true, return true. | 534 // If SameValueZero(searchElement, elementK) is true, return true. |
540 if (search_element->SameValueZero(*element_k)) { | 535 if (search_element->SameValueZero(*element_k)) { |
541 return isolate->heap()->true_value(); | 536 return isolate->heap()->true_value(); |
542 } | 537 } |
543 } | 538 } |
544 return isolate->heap()->false_value(); | 539 return isolate->heap()->false_value(); |
545 } | 540 } |
546 | 541 |
547 } // namespace internal | 542 } // namespace internal |
548 } // namespace v8 | 543 } // namespace v8 |
OLD | NEW |