Chromium Code Reviews| 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 8734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8745 | 8745 |
| 8746 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( | 8746 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( |
| 8747 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries, | 8747 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries, |
| 8748 Handle<FixedArray>* result) { | 8748 Handle<FixedArray>* result) { |
| 8749 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate); | 8749 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate); |
| 8750 | 8750 |
| 8751 if (!map->IsJSObjectMap()) return Just(false); | 8751 if (!map->IsJSObjectMap()) return Just(false); |
| 8752 if (!map->OnlyHasSimpleProperties()) return Just(false); | 8752 if (!map->OnlyHasSimpleProperties()) return Just(false); |
| 8753 | 8753 |
| 8754 Handle<JSObject> object(JSObject::cast(*receiver)); | 8754 Handle<JSObject> object(JSObject::cast(*receiver)); |
| 8755 if (object->elements() != isolate->heap()->empty_fixed_array()) { | |
| 8756 return Just(false); | |
| 8757 } | |
| 8758 | 8755 |
| 8759 Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate); | 8756 Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate); |
| 8760 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 8757 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
| 8761 Handle<FixedArray> values_or_entries = | 8758 int number_of_own_elements = object->NumberOfOwnElements(ALL_PROPERTIES); |
|
Camillo Bruni
2016/03/16 16:04:02
This is a fairly costly operation for HOlEY elemen
caitp (gmail)
2016/03/17 13:28:40
Done
| |
| 8762 isolate->factory()->NewFixedArray(number_of_own_descriptors); | 8759 Handle<FixedArray> values_or_entries = isolate->factory()->NewFixedArray( |
| 8760 number_of_own_descriptors + number_of_own_elements); | |
| 8763 int count = 0; | 8761 int count = 0; |
| 8764 | 8762 |
| 8765 bool stable = true; | 8763 if (object->elements() != isolate->heap()->empty_fixed_array()) { |
| 8764 MAYBE_RETURN(object->GetElementsAccessor()->CollectValuesOrEntries( | |
| 8765 isolate, object, values_or_entries, get_entries, &count, | |
| 8766 ENUMERABLE_STRINGS), | |
| 8767 Nothing<bool>()); | |
| 8768 } | |
| 8769 | |
| 8770 bool stable = object->map() == *map; | |
| 8766 | 8771 |
| 8767 for (int index = 0; index < number_of_own_descriptors; index++) { | 8772 for (int index = 0; index < number_of_own_descriptors; index++) { |
| 8768 Handle<Name> next_key(descriptors->GetKey(index), isolate); | 8773 Handle<Name> next_key(descriptors->GetKey(index), isolate); |
| 8769 if (!next_key->IsString()) continue; | 8774 if (!next_key->IsString()) continue; |
| 8770 Handle<Object> prop_value; | 8775 Handle<Object> prop_value; |
| 8771 | 8776 |
| 8772 // Directly decode from the descriptor array if |from| did not change shape. | 8777 // Directly decode from the descriptor array if |from| did not change shape. |
| 8773 if (stable) { | 8778 if (stable) { |
| 8774 PropertyDetails details = descriptors->GetDetails(index); | 8779 PropertyDetails details = descriptors->GetDetails(index); |
| 8775 if (!details.IsEnumerable()) continue; | 8780 if (!details.IsEnumerable()) continue; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 8794 LookupIterator it(object, next_key, LookupIterator::OWN_SKIP_INTERCEPTOR); | 8799 LookupIterator it(object, next_key, LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 8795 if (!it.IsFound()) continue; | 8800 if (!it.IsFound()) continue; |
| 8796 DCHECK(it.state() == LookupIterator::DATA || | 8801 DCHECK(it.state() == LookupIterator::DATA || |
| 8797 it.state() == LookupIterator::ACCESSOR); | 8802 it.state() == LookupIterator::ACCESSOR); |
| 8798 if (!it.IsEnumerable()) continue; | 8803 if (!it.IsEnumerable()) continue; |
| 8799 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 8804 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 8800 isolate, prop_value, Object::GetProperty(&it), Nothing<bool>()); | 8805 isolate, prop_value, Object::GetProperty(&it), Nothing<bool>()); |
| 8801 } | 8806 } |
| 8802 | 8807 |
| 8803 if (get_entries) { | 8808 if (get_entries) { |
| 8804 Handle<FixedArray> entry_storage = | 8809 prop_value = MakeEntryPair(isolate, next_key, prop_value); |
| 8805 isolate->factory()->NewUninitializedFixedArray(2); | |
| 8806 entry_storage->set(0, *next_key); | |
| 8807 entry_storage->set(1, *prop_value); | |
| 8808 prop_value = isolate->factory()->NewJSArrayWithElements(entry_storage, | |
| 8809 FAST_ELEMENTS, 2); | |
| 8810 } | 8810 } |
| 8811 | 8811 |
| 8812 values_or_entries->set(count, *prop_value); | 8812 values_or_entries->set(count, *prop_value); |
| 8813 count++; | 8813 count++; |
| 8814 } | 8814 } |
| 8815 | 8815 |
| 8816 if (count < values_or_entries->length()) values_or_entries->Shrink(count); | 8816 if (count < values_or_entries->length()) values_or_entries->Shrink(count); |
| 8817 *result = values_or_entries; | 8817 *result = values_or_entries; |
| 8818 return Just(true); | 8818 return Just(true); |
| 8819 } | 8819 } |
| (...skipping 10947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19767 if (cell->value() != *new_value) { | 19767 if (cell->value() != *new_value) { |
| 19768 cell->set_value(*new_value); | 19768 cell->set_value(*new_value); |
| 19769 Isolate* isolate = cell->GetIsolate(); | 19769 Isolate* isolate = cell->GetIsolate(); |
| 19770 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19770 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19771 isolate, DependentCode::kPropertyCellChangedGroup); | 19771 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19772 } | 19772 } |
| 19773 } | 19773 } |
| 19774 | 19774 |
| 19775 } // namespace internal | 19775 } // namespace internal |
| 19776 } // namespace v8 | 19776 } // namespace v8 |
| OLD | NEW |