Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1863 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); | 1863 WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value()); |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 | 1866 |
| 1867 Object** FixedArray::data_start() { | 1867 Object** FixedArray::data_start() { |
| 1868 return HeapObject::RawField(this, kHeaderSize); | 1868 return HeapObject::RawField(this, kHeaderSize); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 | 1871 |
| 1872 bool DescriptorArray::IsEmpty() { | 1872 bool DescriptorArray::IsEmpty() { |
| 1873 ASSERT(this->IsSmi() || | 1873 // TODO(verwaest) Reenable and change >= above when descriptor array is |
| 1874 this->length() > kFirstIndex || | 1874 // immutable again. |
|
danno
2012/06/01 13:49:55
Re-enable this assert appropriately.
Toon Verwaest
2012/06/04 09:17:48
Done.
| |
| 1875 this == HEAP->empty_descriptor_array()); | 1875 // ASSERT(this->IsSmi() || |
| 1876 return this->IsSmi() || length() <= kFirstIndex; | 1876 // this->length() > kFirstIndex || |
| 1877 // this == HEAP->empty_descriptor_array()); | |
| 1878 return this->IsSmi() || length() < kFirstIndex; | |
| 1877 } | 1879 } |
| 1878 | 1880 |
| 1879 | 1881 |
| 1882 bool DescriptorArray::MayContainTransitions() { | |
| 1883 return length() >= kTransitionsIndex; | |
| 1884 } | |
| 1885 | |
| 1886 | |
| 1880 int DescriptorArray::bit_field3_storage() { | 1887 int DescriptorArray::bit_field3_storage() { |
| 1881 Object* storage = READ_FIELD(this, kBitField3StorageOffset); | 1888 Object* storage = READ_FIELD(this, kBitField3StorageOffset); |
| 1882 return Smi::cast(storage)->value(); | 1889 return Smi::cast(storage)->value(); |
| 1883 } | 1890 } |
| 1884 | 1891 |
| 1885 void DescriptorArray::set_bit_field3_storage(int value) { | 1892 void DescriptorArray::set_bit_field3_storage(int value) { |
| 1886 ASSERT(!IsEmpty()); | 1893 ASSERT(this->MayContainTransitions()); |
| 1887 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); | 1894 WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value)); |
| 1888 } | 1895 } |
| 1889 | 1896 |
| 1890 | 1897 |
| 1891 void DescriptorArray::NoIncrementalWriteBarrierSwap(FixedArray* array, | 1898 void DescriptorArray::NoIncrementalWriteBarrierSwap(FixedArray* array, |
| 1892 int first, | 1899 int first, |
| 1893 int second) { | 1900 int second) { |
| 1894 Object* tmp = array->get(first); | 1901 Object* tmp = array->get(first); |
| 1895 NoIncrementalWriteBarrierSet(array, first, array->get(second)); | 1902 NoIncrementalWriteBarrierSet(array, first, array->get(second)); |
| 1896 NoIncrementalWriteBarrierSet(array, second, tmp); | 1903 NoIncrementalWriteBarrierSet(array, second, tmp); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1918 int DescriptorArray::SearchWithCache(String* name) { | 1925 int DescriptorArray::SearchWithCache(String* name) { |
| 1919 int number = GetIsolate()->descriptor_lookup_cache()->Lookup(this, name); | 1926 int number = GetIsolate()->descriptor_lookup_cache()->Lookup(this, name); |
| 1920 if (number == DescriptorLookupCache::kAbsent) { | 1927 if (number == DescriptorLookupCache::kAbsent) { |
| 1921 number = Search(name); | 1928 number = Search(name); |
| 1922 GetIsolate()->descriptor_lookup_cache()->Update(this, name, number); | 1929 GetIsolate()->descriptor_lookup_cache()->Update(this, name, number); |
| 1923 } | 1930 } |
| 1924 return number; | 1931 return number; |
| 1925 } | 1932 } |
| 1926 | 1933 |
| 1927 | 1934 |
| 1935 Map* DescriptorArray::elements_transition() { | |
| 1936 if (!this->MayContainTransitions()) { | |
| 1937 return NULL; | |
| 1938 } | |
| 1939 Object* transition_map = get(kTransitionsIndex); | |
| 1940 if (transition_map == Smi::FromInt(0)) { | |
| 1941 return NULL; | |
| 1942 } else { | |
| 1943 return Map::cast(transition_map); | |
| 1944 } | |
| 1945 } | |
| 1946 | |
| 1947 | |
| 1948 void DescriptorArray::set_elements_transition( | |
| 1949 Map* transition_map, WriteBarrierMode mode) { | |
| 1950 ASSERT(this->length() >= kFirstIndex); | |
| 1951 Heap* heap = GetHeap(); | |
| 1952 WRITE_FIELD(this, kTransitionsOffset, transition_map); | |
| 1953 CONDITIONAL_WRITE_BARRIER( | |
| 1954 heap, this, kTransitionsOffset, transition_map, mode); | |
| 1955 ASSERT(DescriptorArray::cast(this)); | |
| 1956 } | |
| 1957 | |
| 1958 | |
| 1928 Object** DescriptorArray::GetKeySlot(int descriptor_number) { | 1959 Object** DescriptorArray::GetKeySlot(int descriptor_number) { |
| 1929 ASSERT(descriptor_number < number_of_descriptors()); | 1960 ASSERT(descriptor_number < number_of_descriptors()); |
| 1930 return HeapObject::RawField( | 1961 return HeapObject::RawField( |
| 1931 reinterpret_cast<HeapObject*>(this), | 1962 reinterpret_cast<HeapObject*>(this), |
| 1932 OffsetOfElementAt(ToKeyIndex(descriptor_number))); | 1963 OffsetOfElementAt(ToKeyIndex(descriptor_number))); |
| 1933 } | 1964 } |
| 1934 | 1965 |
| 1935 | 1966 |
| 1936 String* DescriptorArray::GetKey(int descriptor_number) { | 1967 String* DescriptorArray::GetKey(int descriptor_number) { |
| 1937 ASSERT(descriptor_number < number_of_descriptors()); | 1968 ASSERT(descriptor_number < number_of_descriptors()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2004 bool DescriptorArray::IsProperty(int descriptor_number) { | 2035 bool DescriptorArray::IsProperty(int descriptor_number) { |
| 2005 Entry entry(this, descriptor_number); | 2036 Entry entry(this, descriptor_number); |
| 2006 return IsPropertyDescriptor(&entry); | 2037 return IsPropertyDescriptor(&entry); |
| 2007 } | 2038 } |
| 2008 | 2039 |
| 2009 | 2040 |
| 2010 bool DescriptorArray::IsTransitionOnly(int descriptor_number) { | 2041 bool DescriptorArray::IsTransitionOnly(int descriptor_number) { |
| 2011 switch (GetType(descriptor_number)) { | 2042 switch (GetType(descriptor_number)) { |
| 2012 case MAP_TRANSITION: | 2043 case MAP_TRANSITION: |
| 2013 case CONSTANT_TRANSITION: | 2044 case CONSTANT_TRANSITION: |
| 2014 case ELEMENTS_TRANSITION: | |
| 2015 return true; | 2045 return true; |
| 2016 case CALLBACKS: { | 2046 case CALLBACKS: { |
| 2017 Object* value = GetValue(descriptor_number); | 2047 Object* value = GetValue(descriptor_number); |
| 2018 if (!value->IsAccessorPair()) return false; | 2048 if (!value->IsAccessorPair()) return false; |
| 2019 AccessorPair* accessors = AccessorPair::cast(value); | 2049 AccessorPair* accessors = AccessorPair::cast(value); |
| 2020 return accessors->getter()->IsMap() && accessors->setter()->IsMap(); | 2050 return accessors->getter()->IsMap() && accessors->setter()->IsMap(); |
| 2021 } | 2051 } |
| 2022 case NORMAL: | 2052 case NORMAL: |
| 2023 case FIELD: | 2053 case FIELD: |
| 2024 case CONSTANT_FUNCTION: | 2054 case CONSTANT_FUNCTION: |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3446 Object* Map::GetBackPointer() { | 3476 Object* Map::GetBackPointer() { |
| 3447 Object* object = READ_FIELD(this, kPrototypeTransitionsOrBackPointerOffset); | 3477 Object* object = READ_FIELD(this, kPrototypeTransitionsOrBackPointerOffset); |
| 3448 if (object->IsFixedArray()) { | 3478 if (object->IsFixedArray()) { |
| 3449 return FixedArray::cast(object)->get(kProtoTransitionBackPointerOffset); | 3479 return FixedArray::cast(object)->get(kProtoTransitionBackPointerOffset); |
| 3450 } else { | 3480 } else { |
| 3451 return object; | 3481 return object; |
| 3452 } | 3482 } |
| 3453 } | 3483 } |
| 3454 | 3484 |
| 3455 | 3485 |
| 3486 Map* Map::elements_transition() { | |
| 3487 return instance_descriptors()->elements_transition(); | |
| 3488 } | |
| 3489 | |
| 3490 | |
| 3491 void Map::set_elements_transition(Map* transitioned_map) { | |
| 3492 return instance_descriptors()->set_elements_transition(transitioned_map); | |
| 3493 } | |
| 3494 | |
| 3495 | |
| 3456 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { | 3496 void Map::SetBackPointer(Object* value, WriteBarrierMode mode) { |
| 3457 Heap* heap = GetHeap(); | 3497 Heap* heap = GetHeap(); |
| 3458 ASSERT(instance_type() >= FIRST_JS_RECEIVER_TYPE); | 3498 ASSERT(instance_type() >= FIRST_JS_RECEIVER_TYPE); |
| 3459 ASSERT((value->IsUndefined() && GetBackPointer()->IsMap()) || | 3499 ASSERT((value->IsUndefined() && GetBackPointer()->IsMap()) || |
| 3460 (value->IsMap() && GetBackPointer()->IsUndefined())); | 3500 (value->IsMap() && GetBackPointer()->IsUndefined())); |
| 3461 Object* object = READ_FIELD(this, kPrototypeTransitionsOrBackPointerOffset); | 3501 Object* object = READ_FIELD(this, kPrototypeTransitionsOrBackPointerOffset); |
| 3462 if (object->IsFixedArray()) { | 3502 if (object->IsFixedArray()) { |
| 3463 FixedArray::cast(object)->set( | 3503 FixedArray::cast(object)->set( |
| 3464 kProtoTransitionBackPointerOffset, value, mode); | 3504 kProtoTransitionBackPointerOffset, value, mode); |
| 3465 } else { | 3505 } else { |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4043 heap->AllocateFixedArrayWithHoles(kElementsKindCount); | 4083 heap->AllocateFixedArrayWithHoles(kElementsKindCount); |
| 4044 FixedArray* maps; | 4084 FixedArray* maps; |
| 4045 if (!maybe_maps->To(&maps)) return maybe_maps; | 4085 if (!maybe_maps->To(&maps)) return maybe_maps; |
| 4046 | 4086 |
| 4047 Map* current_map = initial_map; | 4087 Map* current_map = initial_map; |
| 4048 ElementsKind kind = current_map->elements_kind(); | 4088 ElementsKind kind = current_map->elements_kind(); |
| 4049 ASSERT(kind == GetInitialFastElementsKind()); | 4089 ASSERT(kind == GetInitialFastElementsKind()); |
| 4050 maps->set(kind, current_map); | 4090 maps->set(kind, current_map); |
| 4051 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; | 4091 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; |
| 4052 i < kFastElementsKindCount; ++i) { | 4092 i < kFastElementsKindCount; ++i) { |
| 4053 ElementsKind transitioned_kind = GetFastElementsKindFromSequenceIndex(i); | 4093 Map* new_map; |
| 4054 MaybeObject* maybe_new_map = current_map->CopyDropTransitions(); | 4094 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i); |
| 4055 Map* new_map = NULL; | 4095 MaybeObject* maybe_new_map = |
| 4056 if (!maybe_new_map->To<Map>(&new_map)) return maybe_new_map; | 4096 current_map->CreateNextElementsTransition(next_kind); |
| 4057 new_map->set_elements_kind(transitioned_kind); | 4097 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 4058 maybe_new_map = current_map->AddElementsTransition(transitioned_kind, | 4098 maps->set(next_kind, new_map); |
| 4059 new_map); | |
| 4060 if (maybe_new_map->IsFailure()) return maybe_new_map; | |
| 4061 maps->set(transitioned_kind, new_map); | |
| 4062 current_map = new_map; | 4099 current_map = new_map; |
| 4063 } | 4100 } |
| 4064 global_context->set_js_array_maps(maps); | 4101 global_context->set_js_array_maps(maps); |
| 4065 } | 4102 } |
| 4066 set_initial_map(initial_map); | 4103 set_initial_map(initial_map); |
| 4067 return this; | 4104 return this; |
| 4068 } | 4105 } |
| 4069 | 4106 |
| 4070 | 4107 |
| 4071 bool JSFunction::has_initial_map() { | 4108 bool JSFunction::has_initial_map() { |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5063 #undef WRITE_UINT32_FIELD | 5100 #undef WRITE_UINT32_FIELD |
| 5064 #undef READ_SHORT_FIELD | 5101 #undef READ_SHORT_FIELD |
| 5065 #undef WRITE_SHORT_FIELD | 5102 #undef WRITE_SHORT_FIELD |
| 5066 #undef READ_BYTE_FIELD | 5103 #undef READ_BYTE_FIELD |
| 5067 #undef WRITE_BYTE_FIELD | 5104 #undef WRITE_BYTE_FIELD |
| 5068 | 5105 |
| 5069 | 5106 |
| 5070 } } // namespace v8::internal | 5107 } } // namespace v8::internal |
| 5071 | 5108 |
| 5072 #endif // V8_OBJECTS_INL_H_ | 5109 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |