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

Side by Side Diff: src/runtime/runtime-array.cc

Issue 2002203002: [api] Add more parameters to Object::GetPropertyNames (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-05-06_keys_fast_path_1995263002
Patch Set: addressing nits Created 4 years, 6 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/objects-inl.h ('k') | src/runtime/runtime-forin.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/elements.h" 10 #include "src/elements.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 static_cast<uint32_t>(Max(string_length, backing_store_length)))); 192 static_cast<uint32_t>(Max(string_length, backing_store_length))));
193 } 193 }
194 194
195 if (!array->elements()->IsDictionary()) { 195 if (!array->elements()->IsDictionary()) {
196 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || 196 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() ||
197 array->HasFastDoubleElements()); 197 array->HasFastDoubleElements());
198 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); 198 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
199 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); 199 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
200 } 200 }
201 201
202 KeyAccumulator accumulator(isolate, OWN_ONLY, ALL_PROPERTIES); 202 KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly,
203 ALL_PROPERTIES);
203 // No need to separate prototype levels since we only get element keys. 204 // No need to separate prototype levels since we only get element keys.
204 for (PrototypeIterator iter(isolate, array, 205 for (PrototypeIterator iter(isolate, array,
205 PrototypeIterator::START_AT_RECEIVER); 206 PrototypeIterator::START_AT_RECEIVER);
206 !iter.IsAtEnd(); iter.Advance()) { 207 !iter.IsAtEnd(); iter.Advance()) {
207 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || 208 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() ||
208 PrototypeIterator::GetCurrent<JSObject>(iter) 209 PrototypeIterator::GetCurrent<JSObject>(iter)
209 ->HasIndexedInterceptor()) { 210 ->HasIndexedInterceptor()) {
210 // Bail out if we find a proxy or interceptor, likely not worth 211 // Bail out if we find a proxy or interceptor, likely not worth
211 // collecting keys in that case. 212 // collecting keys in that case.
212 return *isolate->factory()->NewNumberFromUint(length); 213 return *isolate->factory()->NewNumberFromUint(length);
213 } 214 }
214 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); 215 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
215 accumulator.CollectOwnElementIndices(array, current); 216 accumulator.CollectOwnElementIndices(array, current);
216 } 217 }
217 // Erase any keys >= length. 218 // Erase any keys >= length.
218 Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); 219 Handle<FixedArray> keys =
220 accumulator.GetKeys(GetKeysConversion::kKeepNumbers);
219 int j = 0; 221 int j = 0;
220 for (int i = 0; i < keys->length(); i++) { 222 for (int i = 0; i < keys->length(); i++) {
221 if (NumberToUint32(keys->get(i)) >= length) continue; 223 if (NumberToUint32(keys->get(i)) >= length) continue;
222 if (i != j) keys->set(j, keys->get(i)); 224 if (i != j) keys->set(j, keys->get(i));
223 j++; 225 j++;
224 } 226 }
225 227
226 if (j != keys->length()) { 228 if (j != keys->length()) {
227 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( 229 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
228 *keys, keys->length() - j); 230 *keys, keys->length() - j);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { 504 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) {
503 HandleScope scope(isolate); 505 HandleScope scope(isolate);
504 DCHECK(args.length() == 1); 506 DCHECK(args.length() == 1);
505 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); 507 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0);
506 RETURN_RESULT_OR_FAILURE( 508 RETURN_RESULT_OR_FAILURE(
507 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); 509 isolate, Object::ArraySpeciesConstructor(isolate, original_array));
508 } 510 }
509 511
510 } // namespace internal 512 } // namespace internal
511 } // namespace v8 513 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime-forin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698