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

Side by Side Diff: src/objects.cc

Issue 1767113004: [esnext] handle elements in FastObjectValuesOrEntries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make ElementsAccessor::GetCapacity() public, and use it Created 4 years, 9 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/elements.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8692 matching lines...) Expand 10 before | Expand all | Expand 10 after
8703 8703
8704 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( 8704 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
8705 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries, 8705 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries,
8706 Handle<FixedArray>* result) { 8706 Handle<FixedArray>* result) {
8707 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate); 8707 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate);
8708 8708
8709 if (!map->IsJSObjectMap()) return Just(false); 8709 if (!map->IsJSObjectMap()) return Just(false);
8710 if (!map->OnlyHasSimpleProperties()) return Just(false); 8710 if (!map->OnlyHasSimpleProperties()) return Just(false);
8711 8711
8712 Handle<JSObject> object(JSObject::cast(*receiver)); 8712 Handle<JSObject> object(JSObject::cast(*receiver));
8713 if (object->elements() != isolate->heap()->empty_fixed_array()) {
8714 return Just(false);
8715 }
8716 8713
8717 Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate); 8714 Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate);
8718 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); 8715 int number_of_own_descriptors = map->NumberOfOwnDescriptors();
8719 Handle<FixedArray> values_or_entries = 8716 int number_of_own_elements =
8720 isolate->factory()->NewFixedArray(number_of_own_descriptors); 8717 object->GetElementsAccessor()->GetCapacity(*object, object->elements());
8718 Handle<FixedArray> values_or_entries = isolate->factory()->NewFixedArray(
8719 number_of_own_descriptors + number_of_own_elements);
8721 int count = 0; 8720 int count = 0;
8722 8721
8723 bool stable = true; 8722 if (object->elements() != isolate->heap()->empty_fixed_array()) {
8723 MAYBE_RETURN(object->GetElementsAccessor()->CollectValuesOrEntries(
8724 isolate, object, values_or_entries, get_entries, &count,
8725 ENUMERABLE_STRINGS),
8726 Nothing<bool>());
8727 }
8728
8729 bool stable = object->map() == *map;
8724 8730
8725 for (int index = 0; index < number_of_own_descriptors; index++) { 8731 for (int index = 0; index < number_of_own_descriptors; index++) {
8726 Handle<Name> next_key(descriptors->GetKey(index), isolate); 8732 Handle<Name> next_key(descriptors->GetKey(index), isolate);
8727 if (!next_key->IsString()) continue; 8733 if (!next_key->IsString()) continue;
8728 Handle<Object> prop_value; 8734 Handle<Object> prop_value;
8729 8735
8730 // Directly decode from the descriptor array if |from| did not change shape. 8736 // Directly decode from the descriptor array if |from| did not change shape.
8731 if (stable) { 8737 if (stable) {
8732 PropertyDetails details = descriptors->GetDetails(index); 8738 PropertyDetails details = descriptors->GetDetails(index);
8733 if (!details.IsEnumerable()) continue; 8739 if (!details.IsEnumerable()) continue;
(...skipping 18 matching lines...) Expand all
8752 LookupIterator it(object, next_key, LookupIterator::OWN_SKIP_INTERCEPTOR); 8758 LookupIterator it(object, next_key, LookupIterator::OWN_SKIP_INTERCEPTOR);
8753 if (!it.IsFound()) continue; 8759 if (!it.IsFound()) continue;
8754 DCHECK(it.state() == LookupIterator::DATA || 8760 DCHECK(it.state() == LookupIterator::DATA ||
8755 it.state() == LookupIterator::ACCESSOR); 8761 it.state() == LookupIterator::ACCESSOR);
8756 if (!it.IsEnumerable()) continue; 8762 if (!it.IsEnumerable()) continue;
8757 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 8763 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
8758 isolate, prop_value, Object::GetProperty(&it), Nothing<bool>()); 8764 isolate, prop_value, Object::GetProperty(&it), Nothing<bool>());
8759 } 8765 }
8760 8766
8761 if (get_entries) { 8767 if (get_entries) {
8762 Handle<FixedArray> entry_storage = 8768 prop_value = MakeEntryPair(isolate, next_key, prop_value);
8763 isolate->factory()->NewUninitializedFixedArray(2);
8764 entry_storage->set(0, *next_key);
8765 entry_storage->set(1, *prop_value);
8766 prop_value = isolate->factory()->NewJSArrayWithElements(entry_storage,
8767 FAST_ELEMENTS, 2);
8768 } 8769 }
8769 8770
8770 values_or_entries->set(count, *prop_value); 8771 values_or_entries->set(count, *prop_value);
8771 count++; 8772 count++;
8772 } 8773 }
8773 8774
8774 if (count < values_or_entries->length()) values_or_entries->Shrink(count); 8775 if (count < values_or_entries->length()) values_or_entries->Shrink(count);
8775 *result = values_or_entries; 8776 *result = values_or_entries;
8776 return Just(true); 8777 return Just(true);
8777 } 8778 }
(...skipping 10956 matching lines...) Expand 10 before | Expand all | Expand 10 after
19734 if (cell->value() != *new_value) { 19735 if (cell->value() != *new_value) {
19735 cell->set_value(*new_value); 19736 cell->set_value(*new_value);
19736 Isolate* isolate = cell->GetIsolate(); 19737 Isolate* isolate = cell->GetIsolate();
19737 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19738 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19738 isolate, DependentCode::kPropertyCellChangedGroup); 19739 isolate, DependentCode::kPropertyCellChangedGroup);
19739 } 19740 }
19740 } 19741 }
19741 19742
19742 } // namespace internal 19743 } // namespace internal
19743 } // namespace v8 19744 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698