| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 backing_store, filter); | 538 backing_store, filter); |
| 539 } | 539 } |
| 540 | 540 |
| 541 static bool HasElementImpl(Handle<JSObject> holder, uint32_t index, | 541 static bool HasElementImpl(Handle<JSObject> holder, uint32_t index, |
| 542 Handle<FixedArrayBase> backing_store, | 542 Handle<FixedArrayBase> backing_store, |
| 543 PropertyFilter filter) { | 543 PropertyFilter filter) { |
| 544 return ElementsAccessorSubclass::GetEntryForIndexImpl( | 544 return ElementsAccessorSubclass::GetEntryForIndexImpl( |
| 545 *holder, *backing_store, index, filter) != kMaxUInt32; | 545 *holder, *backing_store, index, filter) != kMaxUInt32; |
| 546 } | 546 } |
| 547 | 547 |
| 548 bool HasAccessors(JSObject* holder) final { |
| 549 return ElementsAccessorSubclass::HasAccessorsImpl(holder, |
| 550 holder->elements()); |
| 551 } |
| 552 |
| 553 static bool HasAccessorsImpl(JSObject* holder, |
| 554 FixedArrayBase* backing_store) { |
| 555 return false; |
| 556 } |
| 557 |
| 548 Handle<Object> Get(Handle<FixedArrayBase> backing_store, | 558 Handle<Object> Get(Handle<FixedArrayBase> backing_store, |
| 549 uint32_t entry) final { | 559 uint32_t entry) final { |
| 550 return ElementsAccessorSubclass::GetImpl(backing_store, entry); | 560 return ElementsAccessorSubclass::GetImpl(backing_store, entry); |
| 551 } | 561 } |
| 552 | 562 |
| 553 static Handle<Object> GetImpl(Handle<FixedArrayBase> backing_store, | 563 static Handle<Object> GetImpl(Handle<FixedArrayBase> backing_store, |
| 554 uint32_t entry) { | 564 uint32_t entry) { |
| 555 uint32_t index = GetIndexForEntryImpl(*backing_store, entry); | 565 uint32_t index = GetIndexForEntryImpl(*backing_store, entry); |
| 556 return BackingStore::get(Handle<BackingStore>::cast(backing_store), index); | 566 return BackingStore::get(Handle<BackingStore>::cast(backing_store), index); |
| 557 } | 567 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 SeededNumberDictionary::cast(obj->elements())); | 1051 SeededNumberDictionary::cast(obj->elements())); |
| 1042 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 1052 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
| 1043 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 1053 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
| 1044 USE(result); | 1054 USE(result); |
| 1045 DCHECK(result->IsTrue()); | 1055 DCHECK(result->IsTrue()); |
| 1046 Handle<FixedArray> new_elements = | 1056 Handle<FixedArray> new_elements = |
| 1047 SeededNumberDictionary::Shrink(dict, index); | 1057 SeededNumberDictionary::Shrink(dict, index); |
| 1048 obj->set_elements(*new_elements); | 1058 obj->set_elements(*new_elements); |
| 1049 } | 1059 } |
| 1050 | 1060 |
| 1061 static bool HasAccessorsImpl(JSObject* holder, |
| 1062 FixedArrayBase* backing_store) { |
| 1063 SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); |
| 1064 if (!dict->requires_slow_elements()) return false; |
| 1065 int capacity = dict->Capacity(); |
| 1066 for (int i = 0; i < capacity; i++) { |
| 1067 Object* key = dict->KeyAt(i); |
| 1068 if (!dict->IsKey(key)) continue; |
| 1069 DCHECK(!dict->IsDeleted(i)); |
| 1070 PropertyDetails details = dict->DetailsAt(i); |
| 1071 if (details.type() == ACCESSOR_CONSTANT) return true; |
| 1072 } |
| 1073 return false; |
| 1074 } |
| 1075 |
| 1051 static Object* GetRaw(FixedArrayBase* store, uint32_t entry) { | 1076 static Object* GetRaw(FixedArrayBase* store, uint32_t entry) { |
| 1052 SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); | 1077 SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); |
| 1053 return backing_store->ValueAt(entry); | 1078 return backing_store->ValueAt(entry); |
| 1054 } | 1079 } |
| 1055 | 1080 |
| 1056 static Handle<Object> GetImpl(Handle<FixedArrayBase> store, uint32_t entry) { | 1081 static Handle<Object> GetImpl(Handle<FixedArrayBase> store, uint32_t entry) { |
| 1057 Isolate* isolate = store->GetIsolate(); | 1082 Isolate* isolate = store->GetIsolate(); |
| 1058 return handle(GetRaw(*store, entry), isolate); | 1083 return handle(GetRaw(*store, entry), isolate); |
| 1059 } | 1084 } |
| 1060 | 1085 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 ElementsKindTraits<Kind> >(name) {} | 1831 ElementsKindTraits<Kind> >(name) {} |
| 1807 | 1832 |
| 1808 typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore; | 1833 typedef typename ElementsKindTraits<Kind>::BackingStore BackingStore; |
| 1809 typedef TypedElementsAccessor<Kind> AccessorClass; | 1834 typedef TypedElementsAccessor<Kind> AccessorClass; |
| 1810 | 1835 |
| 1811 static inline void SetImpl(FixedArrayBase* backing_store, uint32_t entry, | 1836 static inline void SetImpl(FixedArrayBase* backing_store, uint32_t entry, |
| 1812 Object* value) { | 1837 Object* value) { |
| 1813 BackingStore::cast(backing_store)->SetValue(entry, value); | 1838 BackingStore::cast(backing_store)->SetValue(entry, value); |
| 1814 } | 1839 } |
| 1815 | 1840 |
| 1841 static bool HasAccessorsImpl(JSObject* holder, |
| 1842 FixedArrayBase* backing_store) { |
| 1843 return false; |
| 1844 } |
| 1845 |
| 1816 static inline void SetImpl(FixedArrayBase* backing_store, uint32_t entry, | 1846 static inline void SetImpl(FixedArrayBase* backing_store, uint32_t entry, |
| 1817 Object* value, WriteBarrierMode mode) { | 1847 Object* value, WriteBarrierMode mode) { |
| 1818 BackingStore::cast(backing_store)->SetValue(entry, value); | 1848 BackingStore::cast(backing_store)->SetValue(entry, value); |
| 1819 } | 1849 } |
| 1820 | 1850 |
| 1821 static Handle<Object> GetImpl(Handle<FixedArrayBase> backing_store, | 1851 static Handle<Object> GetImpl(Handle<FixedArrayBase> backing_store, |
| 1822 uint32_t entry) { | 1852 uint32_t entry) { |
| 1823 uint32_t index = GetIndexForEntryImpl(*backing_store, entry); | 1853 uint32_t index = GetIndexForEntryImpl(*backing_store, entry); |
| 1824 return BackingStore::get(Handle<BackingStore>::cast(backing_store), index); | 1854 return BackingStore::get(Handle<BackingStore>::cast(backing_store), index); |
| 1825 } | 1855 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 FixedArray* parameter_map = FixedArray::cast(parameters); | 1993 FixedArray* parameter_map = FixedArray::cast(parameters); |
| 1964 uint32_t length = parameter_map->length() - 2; | 1994 uint32_t length = parameter_map->length() - 2; |
| 1965 if (entry < length) { | 1995 if (entry < length) { |
| 1966 return !GetParameterMapArg(parameter_map, entry)->IsTheHole(); | 1996 return !GetParameterMapArg(parameter_map, entry)->IsTheHole(); |
| 1967 } | 1997 } |
| 1968 | 1998 |
| 1969 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 1999 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
| 1970 return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); | 2000 return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); |
| 1971 } | 2001 } |
| 1972 | 2002 |
| 2003 static bool HasAccessorsImpl(JSObject* holder, |
| 2004 FixedArrayBase* backing_store) { |
| 2005 FixedArray* parameter_map = FixedArray::cast(backing_store); |
| 2006 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
| 2007 return ArgumentsAccessor::HasAccessorsImpl(holder, arguments); |
| 2008 } |
| 2009 |
| 1973 static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, | 2010 static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, |
| 1974 uint32_t entry) { | 2011 uint32_t entry) { |
| 1975 FixedArray* parameter_map = FixedArray::cast(parameters); | 2012 FixedArray* parameter_map = FixedArray::cast(parameters); |
| 1976 uint32_t length = parameter_map->length() - 2; | 2013 uint32_t length = parameter_map->length() - 2; |
| 1977 if (entry < length) return entry; | 2014 if (entry < length) return entry; |
| 1978 | 2015 |
| 1979 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 2016 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| 1980 return ArgumentsAccessor::GetIndexForEntryImpl(arguments, entry - length); | 2017 return ArgumentsAccessor::GetIndexForEntryImpl(arguments, entry - length); |
| 1981 } | 2018 } |
| 1982 | 2019 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 } | 2452 } |
| 2416 } | 2453 } |
| 2417 | 2454 |
| 2418 DCHECK(j == result_len); | 2455 DCHECK(j == result_len); |
| 2419 return result_array; | 2456 return result_array; |
| 2420 } | 2457 } |
| 2421 | 2458 |
| 2422 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2459 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 2423 } // namespace internal | 2460 } // namespace internal |
| 2424 } // namespace v8 | 2461 } // namespace v8 |
| OLD | NEW |