OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 14628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14639 Object* length = JSArray::cast(object)->length(); | 14639 Object* length = JSArray::cast(object)->length(); |
14640 if (!length->IsSmi()) return false; | 14640 if (!length->IsSmi()) return false; |
14641 *new_capacity = static_cast<uint32_t>(Smi::cast(length)->value()); | 14641 *new_capacity = static_cast<uint32_t>(Smi::cast(length)->value()); |
14642 } else { | 14642 } else { |
14643 *new_capacity = dictionary->max_number_key() + 1; | 14643 *new_capacity = dictionary->max_number_key() + 1; |
14644 } | 14644 } |
14645 *new_capacity = Max(index + 1, *new_capacity); | 14645 *new_capacity = Max(index + 1, *new_capacity); |
14646 | 14646 |
14647 uint32_t dictionary_size = static_cast<uint32_t>(dictionary->Capacity()) * | 14647 uint32_t dictionary_size = static_cast<uint32_t>(dictionary->Capacity()) * |
14648 SeededNumberDictionary::kEntrySize; | 14648 SeededNumberDictionary::kEntrySize; |
| 14649 |
| 14650 // Turn fast if the dictionary only saves 50% space. |
14649 return 2 * dictionary_size >= *new_capacity; | 14651 return 2 * dictionary_size >= *new_capacity; |
14650 } | 14652 } |
14651 | 14653 |
14652 | 14654 |
14653 // static | 14655 // static |
14654 MaybeHandle<Object> JSObject::AddDataElement(Handle<JSObject> object, | 14656 MaybeHandle<Object> JSObject::AddDataElement(Handle<JSObject> object, |
14655 uint32_t index, | 14657 uint32_t index, |
14656 Handle<Object> value, | 14658 Handle<Object> value, |
14657 PropertyAttributes attributes) { | 14659 PropertyAttributes attributes) { |
14658 MAYBE_RETURN_NULL( | 14660 MAYBE_RETURN_NULL( |
(...skipping 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18541 if (cell->value() != *new_value) { | 18543 if (cell->value() != *new_value) { |
18542 cell->set_value(*new_value); | 18544 cell->set_value(*new_value); |
18543 Isolate* isolate = cell->GetIsolate(); | 18545 Isolate* isolate = cell->GetIsolate(); |
18544 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18546 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18545 isolate, DependentCode::kPropertyCellChangedGroup); | 18547 isolate, DependentCode::kPropertyCellChangedGroup); |
18546 } | 18548 } |
18547 } | 18549 } |
18548 | 18550 |
18549 } // namespace internal | 18551 } // namespace internal |
18550 } // namespace v8 | 18552 } // namespace v8 |
OLD | NEW |