OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 8107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8118 ? Smi::cast(JSArray::cast(object)->length())->value() | 8118 ? Smi::cast(JSArray::cast(object)->length())->value() |
8119 : object->elements()->length(); | 8119 : object->elements()->length(); |
8120 return length > 0; | 8120 return length > 0; |
8121 } | 8121 } |
8122 case FAST_HOLEY_SMI_ELEMENTS: | 8122 case FAST_HOLEY_SMI_ELEMENTS: |
8123 case FAST_HOLEY_ELEMENTS: { | 8123 case FAST_HOLEY_ELEMENTS: { |
8124 FixedArray* elements = FixedArray::cast(object->elements()); | 8124 FixedArray* elements = FixedArray::cast(object->elements()); |
8125 int length = object->IsJSArray() | 8125 int length = object->IsJSArray() |
8126 ? Smi::cast(JSArray::cast(object)->length())->value() | 8126 ? Smi::cast(JSArray::cast(object)->length())->value() |
8127 : elements->length(); | 8127 : elements->length(); |
| 8128 Isolate* isolate = GetIsolate(); |
8128 for (int i = 0; i < length; i++) { | 8129 for (int i = 0; i < length; i++) { |
8129 if (!elements->is_the_hole(i)) return true; | 8130 if (!elements->is_the_hole(isolate, i)) return true; |
8130 } | 8131 } |
8131 return false; | 8132 return false; |
8132 } | 8133 } |
8133 case FAST_HOLEY_DOUBLE_ELEMENTS: { | 8134 case FAST_HOLEY_DOUBLE_ELEMENTS: { |
8134 int length = object->IsJSArray() | 8135 int length = object->IsJSArray() |
8135 ? Smi::cast(JSArray::cast(object)->length())->value() | 8136 ? Smi::cast(JSArray::cast(object)->length())->value() |
8136 : object->elements()->length(); | 8137 : object->elements()->length(); |
8137 // Zero-length arrays would use the empty FixedArray... | 8138 // Zero-length arrays would use the empty FixedArray... |
8138 if (length == 0) return false; | 8139 if (length == 0) return false; |
8139 // ...so only cast to FixedDoubleArray otherwise. | 8140 // ...so only cast to FixedDoubleArray otherwise. |
(...skipping 7150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15290 uint32_t index) { | 15291 uint32_t index) { |
15291 uint32_t length = 0; | 15292 uint32_t length = 0; |
15292 CHECK(array->length()->ToArrayLength(&length)); | 15293 CHECK(array->length()->ToArrayLength(&length)); |
15293 if (length <= index) return HasReadOnlyLength(array); | 15294 if (length <= index) return HasReadOnlyLength(array); |
15294 return false; | 15295 return false; |
15295 } | 15296 } |
15296 | 15297 |
15297 | 15298 |
15298 template <typename BackingStore> | 15299 template <typename BackingStore> |
15299 static int FastHoleyElementsUsage(JSObject* object, BackingStore* store) { | 15300 static int FastHoleyElementsUsage(JSObject* object, BackingStore* store) { |
| 15301 Isolate* isolate = store->GetIsolate(); |
15300 int limit = object->IsJSArray() | 15302 int limit = object->IsJSArray() |
15301 ? Smi::cast(JSArray::cast(object)->length())->value() | 15303 ? Smi::cast(JSArray::cast(object)->length())->value() |
15302 : store->length(); | 15304 : store->length(); |
15303 int used = 0; | 15305 int used = 0; |
15304 for (int i = 0; i < limit; ++i) { | 15306 for (int i = 0; i < limit; ++i) { |
15305 if (!store->is_the_hole(i)) ++used; | 15307 if (!store->is_the_hole(isolate, i)) ++used; |
15306 } | 15308 } |
15307 return used; | 15309 return used; |
15308 } | 15310 } |
15309 | 15311 |
15310 | 15312 |
15311 int JSObject::GetFastElementsUsage() { | 15313 int JSObject::GetFastElementsUsage() { |
15312 FixedArrayBase* store = elements(); | 15314 FixedArrayBase* store = elements(); |
15313 switch (GetElementsKind()) { | 15315 switch (GetElementsKind()) { |
15314 case FAST_SMI_ELEMENTS: | 15316 case FAST_SMI_ELEMENTS: |
15315 case FAST_DOUBLE_ELEMENTS: | 15317 case FAST_DOUBLE_ELEMENTS: |
(...skipping 3470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18786 if (cell->value() != *new_value) { | 18788 if (cell->value() != *new_value) { |
18787 cell->set_value(*new_value); | 18789 cell->set_value(*new_value); |
18788 Isolate* isolate = cell->GetIsolate(); | 18790 Isolate* isolate = cell->GetIsolate(); |
18789 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18791 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18790 isolate, DependentCode::kPropertyCellChangedGroup); | 18792 isolate, DependentCode::kPropertyCellChangedGroup); |
18791 } | 18793 } |
18792 } | 18794 } |
18793 | 18795 |
18794 } // namespace internal | 18796 } // namespace internal |
18795 } // namespace v8 | 18797 } // namespace v8 |
OLD | NEW |