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

Side by Side Diff: src/objects.cc

Issue 1989263002: [keys] KeyAccumulator cleanups (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/keys.cc ('k') | no next file » | 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 8134 matching lines...) Expand 10 before | Expand all | Expand 10 after
8145 PropertyDetails details = descs->GetDetails(i); 8145 PropertyDetails details = descs->GetDetails(i);
8146 if (details.location() == kField) { 8146 if (details.location() == kField) {
8147 int candidate = details.field_index() + details.field_width_in_words(); 8147 int candidate = details.field_index() + details.field_width_in_words();
8148 if (candidate > free_index) free_index = candidate; 8148 if (candidate > free_index) free_index = candidate;
8149 } 8149 }
8150 } 8150 }
8151 return free_index; 8151 return free_index;
8152 } 8152 }
8153 8153
8154 8154
8155 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
8156 int len = array->length();
8157 for (int i = 0; i < len; i++) {
8158 Object* e = array->get(i);
8159 if (!(e->IsName() || e->IsNumber())) return false;
8160 }
8161 return true;
8162 }
8163
8164
8165 bool Map::OnlyHasSimpleProperties() { 8155 bool Map::OnlyHasSimpleProperties() {
8166 // Wrapped string elements aren't explicitly stored in the elements backing 8156 // Wrapped string elements aren't explicitly stored in the elements backing
8167 // store, but are loaded indirectly from the underlying string. 8157 // store, but are loaded indirectly from the underlying string.
8168 return !IsStringWrapperElementsKind(elements_kind()) && 8158 return !IsStringWrapperElementsKind(elements_kind()) &&
8169 instance_type() > LAST_SPECIAL_RECEIVER_TYPE && 8159 instance_type() > LAST_SPECIAL_RECEIVER_TYPE &&
8170 !has_hidden_prototype() && !is_dictionary_map(); 8160 !has_hidden_prototype() && !is_dictionary_map();
8171 } 8161 }
8172 8162
8173 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, 8163 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
8174 KeyCollectionType type, 8164 KeyCollectionType type,
8175 PropertyFilter filter, 8165 PropertyFilter filter,
8176 GetKeysConversion keys_conversion, 8166 GetKeysConversion keys_conversion,
8177 bool filter_proxy_keys) { 8167 bool filter_proxy_keys) {
8178 USE(ContainsOnlyValidKeys); 8168 return KeyAccumulator::GetKeys(object, type, filter, keys_conversion,
8179 Isolate* isolate = object->GetIsolate(); 8169 filter_proxy_keys);
8180 KeyAccumulator accumulator(isolate, type, filter);
8181 accumulator.set_filter_proxy_keys(filter_proxy_keys);
8182 MAYBE_RETURN(accumulator.CollectKeys(object, object),
8183 MaybeHandle<FixedArray>());
8184 Handle<FixedArray> keys = accumulator.GetKeys(keys_conversion);
8185 DCHECK(ContainsOnlyValidKeys(keys));
8186 return keys;
8187 } 8170 }
8188 8171
8189 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( 8172 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
8190 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries, 8173 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries,
8191 Handle<FixedArray>* result) { 8174 Handle<FixedArray>* result) {
8192 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate); 8175 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate);
8193 8176
8194 if (!map->IsJSObjectMap()) return Just(false); 8177 if (!map->IsJSObjectMap()) return Just(false);
8195 if (!map->OnlyHasSimpleProperties()) return Just(false); 8178 if (!map->OnlyHasSimpleProperties()) return Just(false);
8196 8179
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
8273 if (fast_values_or_entries.IsNothing()) return MaybeHandle<FixedArray>(); 8256 if (fast_values_or_entries.IsNothing()) return MaybeHandle<FixedArray>();
8274 if (fast_values_or_entries.FromJust()) return values_or_entries; 8257 if (fast_values_or_entries.FromJust()) return values_or_entries;
8275 } 8258 }
8276 8259
8277 PropertyFilter key_filter = 8260 PropertyFilter key_filter =
8278 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE); 8261 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE);
8279 KeyAccumulator accumulator(isolate, OWN_ONLY, key_filter); 8262 KeyAccumulator accumulator(isolate, OWN_ONLY, key_filter);
8280 MAYBE_RETURN(accumulator.CollectKeys(object, object), 8263 MAYBE_RETURN(accumulator.CollectKeys(object, object),
8281 MaybeHandle<FixedArray>()); 8264 MaybeHandle<FixedArray>());
8282 Handle<FixedArray> keys = accumulator.GetKeys(CONVERT_TO_STRING); 8265 Handle<FixedArray> keys = accumulator.GetKeys(CONVERT_TO_STRING);
8283 DCHECK(ContainsOnlyValidKeys(keys));
8284 8266
8285 values_or_entries = isolate->factory()->NewFixedArray(keys->length()); 8267 values_or_entries = isolate->factory()->NewFixedArray(keys->length());
8286 int length = 0; 8268 int length = 0;
8287 8269
8288 for (int i = 0; i < keys->length(); ++i) { 8270 for (int i = 0; i < keys->length(); ++i) {
8289 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate)); 8271 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate));
8290 8272
8291 if (filter & ONLY_ENUMERABLE) { 8273 if (filter & ONLY_ENUMERABLE) {
8292 PropertyDescriptor descriptor; 8274 PropertyDescriptor descriptor;
8293 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( 8275 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor(
(...skipping 10087 matching lines...) Expand 10 before | Expand all | Expand 10 after
18381 if (cell->value() != *new_value) { 18363 if (cell->value() != *new_value) {
18382 cell->set_value(*new_value); 18364 cell->set_value(*new_value);
18383 Isolate* isolate = cell->GetIsolate(); 18365 Isolate* isolate = cell->GetIsolate();
18384 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18366 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18385 isolate, DependentCode::kPropertyCellChangedGroup); 18367 isolate, DependentCode::kPropertyCellChangedGroup);
18386 } 18368 }
18387 } 18369 }
18388 18370
18389 } // namespace internal 18371 } // namespace internal
18390 } // namespace v8 18372 } // namespace v8
OLDNEW
« no previous file with comments | « src/keys.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698