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 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1906 String* entry = array->GetKey(sort_index); | 1906 String* entry = array->GetKey(sort_index); |
| 1907 if (entry->Hash() != hash) break; | 1907 if (entry->Hash() != hash) break; |
| 1908 if (entry->Equals(name)) return sort_index; | 1908 if (entry->Equals(name)) return sort_index; |
| 1909 } | 1909 } |
| 1910 | 1910 |
| 1911 return T::kNotFound; | 1911 return T::kNotFound; |
| 1912 } | 1912 } |
| 1913 | 1913 |
| 1914 // Perform a linear search in this fixed array. len is the number of entry | 1914 // Perform a linear search in this fixed array. len is the number of entry |
| 1915 // indices that are valid. | 1915 // indices that are valid. |
| 1916 template<typename T> | 1916 template<SearchMode search_mode, typename T> |
| 1917 int LinearSearch(T* array, String* name, int len) { | 1917 int LinearSearch(T* array, String* name, int len, int valid_entries) { |
| 1918 uint32_t hash = name->Hash(); | 1918 uint32_t hash = name->Hash(); |
| 1919 for (int number = 0; number < len; number++) { | 1919 if (search_mode == ALL_ENTRIES) { |
| 1920 int sorted_index = array->GetSortedKeyIndex(number); | 1920 for (int number = 0; number < len; number++) { |
| 1921 String* entry = array->GetKey(sorted_index); | 1921 int sorted_index = array->GetSortedKeyIndex(number); |
| 1922 uint32_t current_hash = entry->Hash(); | 1922 String* entry = array->GetKey(sorted_index); |
| 1923 if (current_hash > hash) break; | 1923 uint32_t current_hash = entry->Hash(); |
| 1924 if (current_hash == hash && entry->Equals(name)) return sorted_index; | 1924 if (current_hash > hash) break; |
| 1925 if (current_hash == hash && entry->Equals(name)) return sorted_index; | |
| 1926 } | |
| 1927 } else { | |
| 1928 ASSERT(len >= valid_entries); | |
| 1929 for (int number = 0; number < valid_entries; number++) { | |
| 1930 String* entry = array->GetKey(number); | |
| 1931 uint32_t current_hash = entry->Hash(); | |
| 1932 if (current_hash == hash && entry->Equals(name)) return number; | |
| 1933 } | |
| 1925 } | 1934 } |
| 1926 return T::kNotFound; | 1935 return T::kNotFound; |
| 1927 } | 1936 } |
| 1928 | 1937 |
| 1929 | 1938 |
| 1930 template<typename T> | 1939 template<SearchMode search_mode, typename T> |
| 1931 int Search(T* array, String* name) { | 1940 int Search(T* array, String* name, int valid_entries) { |
| 1932 SLOW_ASSERT(array->IsSortedNoDuplicates()); | 1941 if (search_mode == VALID_ENTRIES) { |
| 1942 SLOW_ASSERT(array->IsSortedNoDuplicates(valid_entries)); | |
| 1943 } else { | |
| 1944 SLOW_ASSERT(array->IsSortedNoDuplicates()); | |
| 1945 } | |
| 1933 | 1946 |
| 1934 int nof = array->number_of_entries(); | 1947 int nof = array->number_of_entries(); |
| 1935 if (nof == 0) return T::kNotFound; | 1948 if (nof == 0) return T::kNotFound; |
| 1936 | 1949 |
| 1937 // Fast case: do linear search for small arrays. | 1950 // Fast case: do linear search for small arrays. |
| 1938 const int kMaxElementsForLinearSearch = 8; | 1951 const int kMaxElementsForLinearSearch = 8; |
| 1939 if (nof < kMaxElementsForLinearSearch) { | 1952 if (search_mode == VALID_ENTRIES || |
| 1940 return LinearSearch(array, name, nof); | 1953 (search_mode == ALL_ENTRIES && nof < kMaxElementsForLinearSearch)) { |
| 1954 return LinearSearch<search_mode>(array, name, nof, valid_entries); | |
| 1941 } | 1955 } |
| 1942 | 1956 |
| 1943 // Slow case: perform binary search. | 1957 // Slow case: perform binary search. |
| 1944 return BinarySearch(array, name, 0, nof - 1); | 1958 return BinarySearch(array, name, 0, nof - 1); |
| 1945 } | 1959 } |
| 1946 | 1960 |
| 1947 | 1961 |
| 1948 int DescriptorArray::Search(String* name) { | 1962 int DescriptorArray::Search(String* name, int valid_descriptors) { |
| 1949 return internal::Search(this, name); | 1963 return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors); |
| 1950 } | 1964 } |
| 1951 | 1965 |
| 1952 | 1966 |
| 1953 int DescriptorArray::SearchWithCache(String* name) { | 1967 int DescriptorArray::SearchWithCache(String* name, Map* map) { |
| 1954 if (number_of_descriptors() == 0) return kNotFound; | 1968 // name->PrintLn(); |
|
Jakob Kummerow
2012/09/11 14:24:25
nit: leftover?
Toon Verwaest
2012/09/11 14:49:23
Done.
| |
| 1969 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | |
| 1970 if (number_of_own_descriptors == 0) return kNotFound; | |
| 1955 | 1971 |
| 1956 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); | 1972 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); |
| 1957 int number = cache->Lookup(this, name); | 1973 int number = cache->Lookup(map, name); |
| 1958 | 1974 |
| 1959 if (number == DescriptorLookupCache::kAbsent) { | 1975 if (number == DescriptorLookupCache::kAbsent) { |
| 1960 number = Search(name); | 1976 number = Search(name, number_of_own_descriptors); |
| 1961 cache->Update(this, name, number); | 1977 cache->Update(map, name, number); |
| 1962 } | 1978 } |
| 1963 | 1979 |
| 1964 return number; | 1980 return number; |
| 1965 } | 1981 } |
| 1966 | 1982 |
| 1967 | 1983 |
| 1968 void Map::LookupDescriptor(JSObject* holder, | 1984 void Map::LookupDescriptor(JSObject* holder, |
| 1969 String* name, | 1985 String* name, |
| 1970 LookupResult* result) { | 1986 LookupResult* result) { |
| 1971 DescriptorArray* descriptors = this->instance_descriptors(); | 1987 DescriptorArray* descriptors = this->instance_descriptors(); |
| 1972 int number = descriptors->SearchWithCache(name); | 1988 int number = descriptors->SearchWithCache(name, this); |
| 1973 if (number == DescriptorArray::kNotFound) return result->NotFound(); | 1989 if (number == DescriptorArray::kNotFound) return result->NotFound(); |
| 1974 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1990 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 1975 } | 1991 } |
| 1976 | 1992 |
| 1977 | 1993 |
| 1978 void Map::LookupTransition(JSObject* holder, | 1994 void Map::LookupTransition(JSObject* holder, |
| 1979 String* name, | 1995 String* name, |
| 1980 LookupResult* result) { | 1996 LookupResult* result) { |
| 1981 if (HasTransitionArray()) { | 1997 if (HasTransitionArray()) { |
| 1982 TransitionArray* transition_array = transitions(); | 1998 TransitionArray* transition_array = transitions(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2006 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { | 2022 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { |
| 2007 return GetDetails(descriptor_number).pointer(); | 2023 return GetDetails(descriptor_number).pointer(); |
| 2008 } | 2024 } |
| 2009 | 2025 |
| 2010 | 2026 |
| 2011 String* DescriptorArray::GetSortedKey(int descriptor_number) { | 2027 String* DescriptorArray::GetSortedKey(int descriptor_number) { |
| 2012 return GetKey(GetSortedKeyIndex(descriptor_number)); | 2028 return GetKey(GetSortedKeyIndex(descriptor_number)); |
| 2013 } | 2029 } |
| 2014 | 2030 |
| 2015 | 2031 |
| 2016 void DescriptorArray::SetSortedKey(int pointer, int descriptor_number) { | 2032 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { |
| 2017 int details_index = ToDetailsIndex(pointer); | 2033 PropertyDetails details = GetDetails(descriptor_index); |
| 2018 PropertyDetails details = PropertyDetails(Smi::cast(get(details_index))); | 2034 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); |
| 2019 set_unchecked(details_index, details.set_pointer(descriptor_number).AsSmi()); | |
| 2020 } | 2035 } |
| 2021 | 2036 |
| 2022 | 2037 |
| 2023 Object** DescriptorArray::GetValueSlot(int descriptor_number) { | 2038 Object** DescriptorArray::GetValueSlot(int descriptor_number) { |
| 2024 ASSERT(descriptor_number < number_of_descriptors()); | 2039 ASSERT(descriptor_number < number_of_descriptors()); |
| 2025 return HeapObject::RawField( | 2040 return HeapObject::RawField( |
| 2026 reinterpret_cast<HeapObject*>(this), | 2041 reinterpret_cast<HeapObject*>(this), |
| 2027 OffsetOfElementAt(ToValueIndex(descriptor_number))); | 2042 OffsetOfElementAt(ToValueIndex(descriptor_number))); |
| 2028 } | 2043 } |
| 2029 | 2044 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2093 desc->GetValue()); | 2108 desc->GetValue()); |
| 2094 NoIncrementalWriteBarrierSet(this, | 2109 NoIncrementalWriteBarrierSet(this, |
| 2095 ToDetailsIndex(descriptor_number), | 2110 ToDetailsIndex(descriptor_number), |
| 2096 desc->GetDetails().AsSmi()); | 2111 desc->GetDetails().AsSmi()); |
| 2097 } | 2112 } |
| 2098 | 2113 |
| 2099 | 2114 |
| 2100 void DescriptorArray::Append(Descriptor* desc, | 2115 void DescriptorArray::Append(Descriptor* desc, |
| 2101 const WhitenessWitness& witness, | 2116 const WhitenessWitness& witness, |
| 2102 int number_of_set_descriptors) { | 2117 int number_of_set_descriptors) { |
| 2103 int enumeration_index = number_of_set_descriptors + 1; | 2118 int descriptor_number = number_of_set_descriptors; |
| 2119 int enumeration_index = descriptor_number + 1; | |
| 2104 desc->SetEnumerationIndex(enumeration_index); | 2120 desc->SetEnumerationIndex(enumeration_index); |
| 2105 Set(number_of_set_descriptors, desc, witness); | 2121 Set(descriptor_number, desc, witness); |
| 2106 | 2122 |
| 2107 uint32_t hash = desc->GetKey()->Hash(); | 2123 uint32_t hash = desc->GetKey()->Hash(); |
| 2108 | 2124 |
| 2109 int insertion; | 2125 int insertion; |
| 2110 | 2126 |
| 2111 for (insertion = number_of_set_descriptors; insertion > 0; --insertion) { | 2127 for (insertion = descriptor_number; insertion > 0; --insertion) { |
| 2112 String* key = GetSortedKey(insertion - 1); | 2128 String* key = GetSortedKey(insertion - 1); |
| 2113 if (key->Hash() <= hash) break; | 2129 if (key->Hash() <= hash) break; |
| 2114 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); | 2130 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); |
| 2115 } | 2131 } |
| 2116 | 2132 |
| 2117 SetSortedKey(insertion, number_of_set_descriptors); | 2133 SetSortedKey(insertion, descriptor_number); |
| 2118 } | 2134 } |
| 2119 | 2135 |
| 2120 | 2136 |
| 2121 void DescriptorArray::SwapSortedKeys(int first, int second) { | 2137 void DescriptorArray::SwapSortedKeys(int first, int second) { |
| 2122 int first_key = GetSortedKeyIndex(first); | 2138 int first_key = GetSortedKeyIndex(first); |
| 2123 SetSortedKey(first, GetSortedKeyIndex(second)); | 2139 SetSortedKey(first, GetSortedKeyIndex(second)); |
| 2124 SetSortedKey(second, first_key); | 2140 SetSortedKey(second, first_key); |
| 2125 } | 2141 } |
| 2126 | 2142 |
| 2127 | 2143 |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3006 JSFunction* Map::unchecked_constructor() { | 3022 JSFunction* Map::unchecked_constructor() { |
| 3007 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); | 3023 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); |
| 3008 } | 3024 } |
| 3009 | 3025 |
| 3010 | 3026 |
| 3011 Code::Flags Code::flags() { | 3027 Code::Flags Code::flags() { |
| 3012 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); | 3028 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); |
| 3013 } | 3029 } |
| 3014 | 3030 |
| 3015 | 3031 |
| 3032 void Map::SetOwnsDescriptors(bool is_shared) { | |
|
Jakob Kummerow
2012/09/11 14:24:25
nit: for consistency, these two methods should be
Toon Verwaest
2012/09/11 14:49:23
Done.
| |
| 3033 set_bit_field3(OwnsDescriptors::update(bit_field3(), is_shared)); | |
| 3034 } | |
| 3035 | |
| 3036 | |
| 3037 bool Map::OwnsDescriptors() { | |
| 3038 return OwnsDescriptors::decode(bit_field3()); | |
| 3039 } | |
| 3040 | |
| 3041 | |
| 3016 void Code::set_flags(Code::Flags flags) { | 3042 void Code::set_flags(Code::Flags flags) { |
| 3017 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); | 3043 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); |
| 3018 // Make sure that all call stubs have an arguments count. | 3044 // Make sure that all call stubs have an arguments count. |
| 3019 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && | 3045 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && |
| 3020 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || | 3046 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || |
| 3021 ExtractArgumentsCountFromFlags(flags) >= 0); | 3047 ExtractArgumentsCountFromFlags(flags) >= 0); |
| 3022 WRITE_INT_FIELD(this, kFlagsOffset, flags); | 3048 WRITE_INT_FIELD(this, kFlagsOffset, flags); |
| 3023 } | 3049 } |
| 3024 | 3050 |
| 3025 | 3051 |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3442 | 3468 |
| 3443 | 3469 |
| 3444 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 3470 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
| 3445 ASSERT(value->IsNull() || value->IsJSReceiver()); | 3471 ASSERT(value->IsNull() || value->IsJSReceiver()); |
| 3446 WRITE_FIELD(this, kPrototypeOffset, value); | 3472 WRITE_FIELD(this, kPrototypeOffset, value); |
| 3447 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); | 3473 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); |
| 3448 } | 3474 } |
| 3449 | 3475 |
| 3450 | 3476 |
| 3451 DescriptorArray* Map::instance_descriptors() { | 3477 DescriptorArray* Map::instance_descriptors() { |
| 3452 if (!HasTransitionArray()) return GetHeap()->empty_descriptor_array(); | 3478 if (HasTransitionArray()) return transitions()->descriptors(); |
| 3453 return transitions()->descriptors(); | 3479 Object* back_pointer = GetBackPointer(); |
| 3480 if (!back_pointer->IsMap()) return GetHeap()->empty_descriptor_array(); | |
| 3481 return Map::cast(back_pointer)->instance_descriptors(); | |
| 3454 } | 3482 } |
| 3455 | 3483 |
| 3456 | 3484 |
| 3457 // If the descriptor is using the empty transition array, install a new empty | 3485 // If the descriptor is using the empty transition array, install a new empty |
| 3458 // transition array that will have place for an element transition. | 3486 // transition array that will have place for an element transition. |
| 3459 static MaybeObject* EnsureHasTransitionArray(Map* map) { | 3487 static MaybeObject* EnsureHasTransitionArray(Map* map) { |
| 3460 if (map->HasTransitionArray()) return map; | 3488 if (map->HasTransitionArray()) return map; |
| 3461 | 3489 |
| 3462 TransitionArray* transitions; | 3490 TransitionArray* transitions; |
| 3463 MaybeObject* maybe_transitions = TransitionArray::Allocate(0); | 3491 JSGlobalPropertyCell* pointer = map->RetrieveDescriptorsPointer(); |
| 3492 MaybeObject* maybe_transitions = TransitionArray::Allocate(0, pointer); | |
| 3464 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 3493 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
| 3494 | |
| 3495 transitions->set_back_pointer_storage(map->GetBackPointer()); | |
| 3465 map->set_transitions(transitions); | 3496 map->set_transitions(transitions); |
| 3466 return transitions; | 3497 return transitions; |
| 3467 } | 3498 } |
| 3468 | 3499 |
| 3469 | 3500 |
| 3470 MaybeObject* Map::SetDescriptors(DescriptorArray* value, | 3501 MaybeObject* Map::SetDescriptors(DescriptorArray* value) { |
| 3471 WriteBarrierMode mode) { | |
| 3472 ASSERT(!is_shared()); | 3502 ASSERT(!is_shared()); |
| 3473 MaybeObject* maybe_failure = EnsureHasTransitionArray(this); | 3503 MaybeObject* maybe_failure = EnsureHasTransitionArray(this); |
| 3474 if (maybe_failure->IsFailure()) return maybe_failure; | 3504 if (maybe_failure->IsFailure()) return maybe_failure; |
| 3475 | 3505 |
| 3476 transitions()->set_descriptors(value, mode); | 3506 ASSERT(NumberOfOwnDescriptors() <= value->number_of_descriptors()); |
| 3507 transitions()->set_descriptors(value); | |
| 3477 return this; | 3508 return this; |
| 3478 } | 3509 } |
| 3479 | 3510 |
| 3480 | 3511 |
| 3481 MaybeObject* Map::InitializeDescriptors(DescriptorArray* descriptors) { | 3512 MaybeObject* Map::InitializeDescriptors(DescriptorArray* descriptors) { |
| 3513 int len = descriptors->number_of_descriptors(); | |
| 3482 #ifdef DEBUG | 3514 #ifdef DEBUG |
| 3483 int len = descriptors->number_of_descriptors(); | |
| 3484 ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors); | 3515 ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors); |
| 3485 SLOW_ASSERT(descriptors->IsSortedNoDuplicates()); | |
| 3486 | 3516 |
| 3487 bool used_indices[DescriptorArray::kMaxNumberOfDescriptors]; | 3517 bool used_indices[DescriptorArray::kMaxNumberOfDescriptors]; |
| 3488 for (int i = 0; i < len; ++i) used_indices[i] = false; | 3518 for (int i = 0; i < len; ++i) used_indices[i] = false; |
| 3489 | 3519 |
| 3490 // Ensure that all enumeration indexes between 1 and length occur uniquely in | 3520 // Ensure that all enumeration indexes between 1 and length occur uniquely in |
| 3491 // the descriptor array. | 3521 // the descriptor array. |
| 3492 for (int i = 0; i < len; ++i) { | 3522 for (int i = 0; i < len; ++i) { |
| 3493 int enum_index = descriptors->GetDetails(i).descriptor_index() - | 3523 int enum_index = descriptors->GetDetails(i).descriptor_index() - |
| 3494 PropertyDetails::kInitialIndex; | 3524 PropertyDetails::kInitialIndex; |
| 3495 ASSERT(0 <= enum_index && enum_index < len); | 3525 ASSERT(0 <= enum_index && enum_index < len); |
| 3496 ASSERT(!used_indices[enum_index]); | 3526 ASSERT(!used_indices[enum_index]); |
| 3497 used_indices[enum_index] = true; | 3527 used_indices[enum_index] = true; |
| 3498 } | 3528 } |
| 3499 #endif | 3529 #endif |
| 3500 | 3530 |
| 3501 MaybeObject* maybe_failure = SetDescriptors(descriptors); | 3531 MaybeObject* maybe_failure = SetDescriptors(descriptors); |
| 3502 if (maybe_failure->IsFailure()) return maybe_failure; | 3532 if (maybe_failure->IsFailure()) return maybe_failure; |
| 3503 | 3533 |
| 3504 SetNumberOfOwnDescriptors(descriptors->number_of_descriptors()); | 3534 SetNumberOfOwnDescriptors(len); |
| 3505 | |
| 3506 return this; | 3535 return this; |
| 3507 } | 3536 } |
| 3508 | 3537 |
| 3509 | 3538 |
| 3510 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset) | 3539 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset) |
| 3511 | 3540 |
| 3512 | 3541 |
| 3513 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { | 3542 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { |
| 3514 Object* back_pointer = GetBackPointer(); | 3543 Object* back_pointer = GetBackPointer(); |
| 3515 #ifdef DEBUG | 3544 #ifdef DEBUG |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3564 | 3593 |
| 3565 | 3594 |
| 3566 bool Map::CanHaveMoreTransitions() { | 3595 bool Map::CanHaveMoreTransitions() { |
| 3567 if (!HasTransitionArray()) return true; | 3596 if (!HasTransitionArray()) return true; |
| 3568 return FixedArray::SizeFor(transitions()->length() + | 3597 return FixedArray::SizeFor(transitions()->length() + |
| 3569 TransitionArray::kTransitionSize) | 3598 TransitionArray::kTransitionSize) |
| 3570 <= Page::kMaxNonCodeHeapObjectSize; | 3599 <= Page::kMaxNonCodeHeapObjectSize; |
| 3571 } | 3600 } |
| 3572 | 3601 |
| 3573 | 3602 |
| 3603 JSGlobalPropertyCell* Map::RetrieveDescriptorsPointer() { | |
| 3604 if (!OwnsDescriptors()) return NULL; | |
| 3605 Object* back_pointer = GetBackPointer(); | |
| 3606 if (back_pointer->IsUndefined()) return NULL; | |
| 3607 Map* map = Map::cast(back_pointer); | |
| 3608 ASSERT(map->HasTransitionArray()); | |
| 3609 return map->transitions()->descriptors_pointer(); | |
| 3610 } | |
| 3611 | |
| 3612 | |
| 3574 MaybeObject* Map::AddTransition(String* key, Map* target) { | 3613 MaybeObject* Map::AddTransition(String* key, Map* target) { |
| 3575 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); | 3614 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); |
| 3576 return TransitionArray::NewWith(key, target); | 3615 JSGlobalPropertyCell* descriptors_pointer = RetrieveDescriptorsPointer(); |
| 3616 return TransitionArray::NewWith( | |
| 3617 key, target, descriptors_pointer, GetBackPointer()); | |
| 3577 } | 3618 } |
| 3578 | 3619 |
| 3579 | 3620 |
| 3580 void Map::SetTransition(int transition_index, Map* target) { | 3621 void Map::SetTransition(int transition_index, Map* target) { |
| 3581 transitions()->SetTarget(transition_index, target); | 3622 transitions()->SetTarget(transition_index, target); |
| 3582 } | 3623 } |
| 3583 | 3624 |
| 3584 | 3625 |
| 3585 MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) { | 3626 MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) { |
| 3586 MaybeObject* allow_elements = EnsureHasTransitionArray(this); | 3627 MaybeObject* allow_elements = EnsureHasTransitionArray(this); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3620 | 3661 |
| 3621 TransitionArray* Map::transitions() { | 3662 TransitionArray* Map::transitions() { |
| 3622 ASSERT(HasTransitionArray()); | 3663 ASSERT(HasTransitionArray()); |
| 3623 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 3664 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
| 3624 return TransitionArray::cast(object); | 3665 return TransitionArray::cast(object); |
| 3625 } | 3666 } |
| 3626 | 3667 |
| 3627 | 3668 |
| 3628 void Map::set_transitions(TransitionArray* transition_array, | 3669 void Map::set_transitions(TransitionArray* transition_array, |
| 3629 WriteBarrierMode mode) { | 3670 WriteBarrierMode mode) { |
| 3630 transition_array->set_descriptors(instance_descriptors()); | |
| 3631 transition_array->set_back_pointer_storage(GetBackPointer()); | |
| 3632 #ifdef DEBUG | 3671 #ifdef DEBUG |
| 3633 if (HasTransitionArray()) { | 3672 if (HasTransitionArray()) { |
| 3634 ASSERT(transitions() != transition_array); | 3673 ASSERT(transitions() != transition_array); |
| 3635 ZapTransitions(); | 3674 ZapTransitions(); |
| 3636 } | 3675 } |
| 3637 #endif | 3676 #endif |
| 3638 | 3677 |
| 3639 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); | 3678 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); |
| 3640 CONDITIONAL_WRITE_BARRIER( | 3679 CONDITIONAL_WRITE_BARRIER( |
| 3641 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); | 3680 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5409 #undef WRITE_UINT32_FIELD | 5448 #undef WRITE_UINT32_FIELD |
| 5410 #undef READ_SHORT_FIELD | 5449 #undef READ_SHORT_FIELD |
| 5411 #undef WRITE_SHORT_FIELD | 5450 #undef WRITE_SHORT_FIELD |
| 5412 #undef READ_BYTE_FIELD | 5451 #undef READ_BYTE_FIELD |
| 5413 #undef WRITE_BYTE_FIELD | 5452 #undef WRITE_BYTE_FIELD |
| 5414 | 5453 |
| 5415 | 5454 |
| 5416 } } // namespace v8::internal | 5455 } } // namespace v8::internal |
| 5417 | 5456 |
| 5418 #endif // V8_OBJECTS_INL_H_ | 5457 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |