OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2303 DCHECK_NE(NONE, attributes); | 2303 DCHECK_NE(NONE, attributes); |
2304 object->RequireSlowElements(*arguments); | 2304 object->RequireSlowElements(*arguments); |
2305 parameter_map->set(1, *arguments); | 2305 parameter_map->set(1, *arguments); |
2306 } else { | 2306 } else { |
2307 Handle<FixedArrayBase> arguments( | 2307 Handle<FixedArrayBase> arguments( |
2308 FixedArrayBase::cast(parameter_map->get(1))); | 2308 FixedArrayBase::cast(parameter_map->get(1))); |
2309 DictionaryElementsAccessor::ReconfigureImpl( | 2309 DictionaryElementsAccessor::ReconfigureImpl( |
2310 object, arguments, entry - length, value, attributes); | 2310 object, arguments, entry - length, value, attributes); |
2311 } | 2311 } |
2312 } | 2312 } |
2313 | |
2314 static void CollectElementIndicesImpl(Handle<JSObject> object, | |
2315 Handle<FixedArrayBase> backing_store, | |
2316 KeyAccumulator* keys, uint32_t range, | |
2317 PropertyFilter filter, | |
2318 uint32_t offset) { | |
2319 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store); | |
2320 uint32_t length = parameter_map->length() - 2; | |
2321 uint32_t i; | |
2322 for (i = offset; i < length; ++i) { | |
2323 if (!parameter_map->get(i + 2)->IsTheHole()) { | |
2324 keys->AddKey(i); | |
2325 } | |
2326 } | |
2327 | |
2328 { | |
2329 DisallowHeapAllocation no_allocation; | |
2330 Handle<SeededNumberDictionary> dict( | |
2331 SeededNumberDictionary::cast(parameter_map->get(1))); | |
2332 uint32_t arguments_length = dict->Capacity(); | |
2333 if (range < arguments_length) arguments_length = range; | |
2334 uint32_t index; | |
2335 for (; i < arguments_length; ++i) { | |
2336 Object* key = dict->KeyAt(i); | |
2337 if (!key->IsTheHole() && key->ToUint32(&index)) { | |
2338 if (filter != ALL_PROPERTIES && | |
2339 DictionaryElementsAccessor::GetDetailsImpl(*dict, i).attributes()) | |
2340 continue; | |
2341 keys->AddKey(index); | |
2342 } | |
2343 } | |
2344 } | |
2345 keys->SortCurrentElementsList(); | |
Camillo Bruni
2016/03/10 09:15:14
I would prefer a base implementation in SloppyArgu
caitp (gmail)
2016/03/10 16:58:33
Done.
| |
2346 } | |
2347 | |
2348 static Handle<FixedArray> DirectCollectElementIndicesImpl( | |
2349 Isolate* isolate, Handle<JSObject> object, | |
2350 Handle<FixedArrayBase> backing_store, GetKeysConversion convert, | |
2351 PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices) { | |
2352 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(backing_store); | |
2353 uint32_t length = parameter_map->length() - 2; | |
2354 uint32_t insertion_index = 0; | |
2355 uint32_t i; | |
2356 for (i = 0; i < length; ++i) { | |
2357 if (!parameter_map->get(i + 2)->IsTheHole()) { | |
2358 if (convert == CONVERT_TO_STRING) { | |
2359 Handle<String> index_string = isolate->factory()->Uint32ToString(i); | |
2360 list->set(insertion_index, *index_string); | |
2361 } else { | |
2362 list->set(insertion_index, Smi::FromInt(i), SKIP_WRITE_BARRIER); | |
2363 } | |
2364 insertion_index++; | |
2365 } | |
2366 } | |
2367 | |
2368 { | |
2369 Handle<SeededNumberDictionary> dict( | |
2370 SeededNumberDictionary::cast(parameter_map->get(1))); | |
2371 uint32_t arguments_length = dict->Capacity(); | |
2372 for (; i < arguments_length; ++i) { | |
2373 Object* key = dict->KeyAt(i); | |
2374 uint32_t index; | |
2375 if (!key->IsTheHole() && key->ToUint32(&index)) { | |
2376 if (filter != ALL_PROPERTIES && | |
2377 DictionaryElementsAccessor::GetDetailsImpl(*dict, i).attributes()) | |
2378 continue; | |
2379 if (convert == CONVERT_TO_STRING) { | |
2380 Handle<String> index_string = | |
2381 isolate->factory()->Uint32ToString(index); | |
2382 list->set(insertion_index, *index_string); | |
2383 } else { | |
2384 list->set(insertion_index, Smi::FromInt(index), SKIP_WRITE_BARRIER); | |
2385 } | |
2386 insertion_index++; | |
2387 } | |
2388 } | |
2389 } | |
2390 | |
2391 *nof_indices = insertion_index; | |
2392 return list; | |
2393 } | |
2394 | |
2395 static void AddElementsToKeyAccumulatorImpl(Handle<JSObject> receiver, | |
2396 KeyAccumulator* accumulator, | |
2397 AddKeyConversion convert) { | |
2398 Handle<FixedArray> parameter_map(FixedArray::cast(receiver->elements())); | |
2399 uint32_t length = parameter_map->length() - 2; | |
2400 uint32_t i; | |
2401 for (i = 0; i < length; ++i) { | |
2402 if (!parameter_map->get(i + 2)->IsTheHole()) { | |
2403 accumulator->AddKey(Smi::FromInt(i), convert); | |
2404 } | |
2405 } | |
2406 | |
2407 { | |
2408 Handle<SeededNumberDictionary> dict( | |
2409 SeededNumberDictionary::cast(parameter_map->get(1))); | |
2410 uint32_t arguments_length = dict->Capacity(); | |
2411 for (; i < arguments_length; ++i) { | |
2412 Object* key = dict->KeyAt(i); | |
2413 uint32_t index; | |
2414 if (!key->IsTheHole() && key->ToUint32(&index)) { | |
2415 accumulator->AddKey(key, convert); | |
2416 } | |
2417 } | |
2418 } | |
2419 } | |
2313 }; | 2420 }; |
2314 | 2421 |
2315 | 2422 |
2316 class FastSloppyArgumentsElementsAccessor | 2423 class FastSloppyArgumentsElementsAccessor |
2317 : public SloppyArgumentsElementsAccessor< | 2424 : public SloppyArgumentsElementsAccessor< |
2318 FastSloppyArgumentsElementsAccessor, FastHoleyObjectElementsAccessor, | 2425 FastSloppyArgumentsElementsAccessor, FastHoleyObjectElementsAccessor, |
2319 ElementsKindTraits<FAST_SLOPPY_ARGUMENTS_ELEMENTS> > { | 2426 ElementsKindTraits<FAST_SLOPPY_ARGUMENTS_ELEMENTS> > { |
2320 public: | 2427 public: |
2321 explicit FastSloppyArgumentsElementsAccessor(const char* name) | 2428 explicit FastSloppyArgumentsElementsAccessor(const char* name) |
2322 : SloppyArgumentsElementsAccessor< | 2429 : SloppyArgumentsElementsAccessor< |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2774 } | 2881 } |
2775 } | 2882 } |
2776 | 2883 |
2777 DCHECK(j == result_len); | 2884 DCHECK(j == result_len); |
2778 return result_array; | 2885 return result_array; |
2779 } | 2886 } |
2780 | 2887 |
2781 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2888 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
2782 } // namespace internal | 2889 } // namespace internal |
2783 } // namespace v8 | 2890 } // namespace v8 |
OLD | NEW |