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 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
| 1969 if (number_of_own_descriptors == 0) return kNotFound; |
1955 | 1970 |
1956 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); | 1971 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); |
1957 int number = cache->Lookup(this, name); | 1972 int number = cache->Lookup(map, name); |
1958 | 1973 |
1959 if (number == DescriptorLookupCache::kAbsent) { | 1974 if (number == DescriptorLookupCache::kAbsent) { |
1960 number = Search(name); | 1975 number = Search(name, number_of_own_descriptors); |
1961 cache->Update(this, name, number); | 1976 cache->Update(map, name, number); |
1962 } | 1977 } |
1963 | 1978 |
1964 return number; | 1979 return number; |
1965 } | 1980 } |
1966 | 1981 |
1967 | 1982 |
1968 void Map::LookupDescriptor(JSObject* holder, | 1983 void Map::LookupDescriptor(JSObject* holder, |
1969 String* name, | 1984 String* name, |
1970 LookupResult* result) { | 1985 LookupResult* result) { |
1971 DescriptorArray* descriptors = this->instance_descriptors(); | 1986 DescriptorArray* descriptors = this->instance_descriptors(); |
1972 int number = descriptors->SearchWithCache(name); | 1987 int number = descriptors->SearchWithCache(name, this); |
1973 if (number == DescriptorArray::kNotFound) return result->NotFound(); | 1988 if (number == DescriptorArray::kNotFound) return result->NotFound(); |
1974 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1989 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
1975 } | 1990 } |
1976 | 1991 |
1977 | 1992 |
1978 void Map::LookupTransition(JSObject* holder, | 1993 void Map::LookupTransition(JSObject* holder, |
1979 String* name, | 1994 String* name, |
1980 LookupResult* result) { | 1995 LookupResult* result) { |
1981 if (HasTransitionArray()) { | 1996 if (HasTransitionArray()) { |
1982 TransitionArray* transition_array = transitions(); | 1997 TransitionArray* transition_array = transitions(); |
(...skipping 23 matching lines...) Expand all Loading... |
2006 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { | 2021 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { |
2007 return GetDetails(descriptor_number).pointer(); | 2022 return GetDetails(descriptor_number).pointer(); |
2008 } | 2023 } |
2009 | 2024 |
2010 | 2025 |
2011 String* DescriptorArray::GetSortedKey(int descriptor_number) { | 2026 String* DescriptorArray::GetSortedKey(int descriptor_number) { |
2012 return GetKey(GetSortedKeyIndex(descriptor_number)); | 2027 return GetKey(GetSortedKeyIndex(descriptor_number)); |
2013 } | 2028 } |
2014 | 2029 |
2015 | 2030 |
2016 void DescriptorArray::SetSortedKey(int pointer, int descriptor_number) { | 2031 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { |
2017 int details_index = ToDetailsIndex(pointer); | 2032 PropertyDetails details = GetDetails(descriptor_index); |
2018 PropertyDetails details = PropertyDetails(Smi::cast(get(details_index))); | 2033 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); |
2019 set_unchecked(details_index, details.set_pointer(descriptor_number).AsSmi()); | |
2020 } | 2034 } |
2021 | 2035 |
2022 | 2036 |
2023 Object** DescriptorArray::GetValueSlot(int descriptor_number) { | 2037 Object** DescriptorArray::GetValueSlot(int descriptor_number) { |
2024 ASSERT(descriptor_number < number_of_descriptors()); | 2038 ASSERT(descriptor_number < number_of_descriptors()); |
2025 return HeapObject::RawField( | 2039 return HeapObject::RawField( |
2026 reinterpret_cast<HeapObject*>(this), | 2040 reinterpret_cast<HeapObject*>(this), |
2027 OffsetOfElementAt(ToValueIndex(descriptor_number))); | 2041 OffsetOfElementAt(ToValueIndex(descriptor_number))); |
2028 } | 2042 } |
2029 | 2043 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2093 desc->GetValue()); | 2107 desc->GetValue()); |
2094 NoIncrementalWriteBarrierSet(this, | 2108 NoIncrementalWriteBarrierSet(this, |
2095 ToDetailsIndex(descriptor_number), | 2109 ToDetailsIndex(descriptor_number), |
2096 desc->GetDetails().AsSmi()); | 2110 desc->GetDetails().AsSmi()); |
2097 } | 2111 } |
2098 | 2112 |
2099 | 2113 |
2100 void DescriptorArray::Append(Descriptor* desc, | 2114 void DescriptorArray::Append(Descriptor* desc, |
2101 const WhitenessWitness& witness, | 2115 const WhitenessWitness& witness, |
2102 int number_of_set_descriptors) { | 2116 int number_of_set_descriptors) { |
2103 int enumeration_index = number_of_set_descriptors + 1; | 2117 int descriptor_number = number_of_set_descriptors; |
| 2118 int enumeration_index = descriptor_number + 1; |
2104 desc->SetEnumerationIndex(enumeration_index); | 2119 desc->SetEnumerationIndex(enumeration_index); |
2105 Set(number_of_set_descriptors, desc, witness); | 2120 Set(descriptor_number, desc, witness); |
2106 | 2121 |
2107 uint32_t hash = desc->GetKey()->Hash(); | 2122 uint32_t hash = desc->GetKey()->Hash(); |
2108 | 2123 |
2109 int insertion; | 2124 int insertion; |
2110 | 2125 |
2111 for (insertion = number_of_set_descriptors; insertion > 0; --insertion) { | 2126 for (insertion = descriptor_number; insertion > 0; --insertion) { |
2112 String* key = GetSortedKey(insertion - 1); | 2127 String* key = GetSortedKey(insertion - 1); |
2113 if (key->Hash() <= hash) break; | 2128 if (key->Hash() <= hash) break; |
2114 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); | 2129 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); |
2115 } | 2130 } |
2116 | 2131 |
2117 SetSortedKey(insertion, number_of_set_descriptors); | 2132 SetSortedKey(insertion, descriptor_number); |
2118 } | 2133 } |
2119 | 2134 |
2120 | 2135 |
2121 void DescriptorArray::SwapSortedKeys(int first, int second) { | 2136 void DescriptorArray::SwapSortedKeys(int first, int second) { |
2122 int first_key = GetSortedKeyIndex(first); | 2137 int first_key = GetSortedKeyIndex(first); |
2123 SetSortedKey(first, GetSortedKeyIndex(second)); | 2138 SetSortedKey(first, GetSortedKeyIndex(second)); |
2124 SetSortedKey(second, first_key); | 2139 SetSortedKey(second, first_key); |
2125 } | 2140 } |
2126 | 2141 |
2127 | 2142 |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 JSFunction* Map::unchecked_constructor() { | 3021 JSFunction* Map::unchecked_constructor() { |
3007 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); | 3022 return reinterpret_cast<JSFunction*>(READ_FIELD(this, kConstructorOffset)); |
3008 } | 3023 } |
3009 | 3024 |
3010 | 3025 |
3011 Code::Flags Code::flags() { | 3026 Code::Flags Code::flags() { |
3012 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); | 3027 return static_cast<Flags>(READ_INT_FIELD(this, kFlagsOffset)); |
3013 } | 3028 } |
3014 | 3029 |
3015 | 3030 |
| 3031 void Map::set_owns_descriptors(bool is_shared) { |
| 3032 set_bit_field3(OwnsDescriptors::update(bit_field3(), is_shared)); |
| 3033 } |
| 3034 |
| 3035 |
| 3036 bool Map::owns_descriptors() { |
| 3037 return OwnsDescriptors::decode(bit_field3()); |
| 3038 } |
| 3039 |
| 3040 |
3016 void Code::set_flags(Code::Flags flags) { | 3041 void Code::set_flags(Code::Flags flags) { |
3017 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); | 3042 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); |
3018 // Make sure that all call stubs have an arguments count. | 3043 // Make sure that all call stubs have an arguments count. |
3019 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && | 3044 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && |
3020 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || | 3045 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || |
3021 ExtractArgumentsCountFromFlags(flags) >= 0); | 3046 ExtractArgumentsCountFromFlags(flags) >= 0); |
3022 WRITE_INT_FIELD(this, kFlagsOffset, flags); | 3047 WRITE_INT_FIELD(this, kFlagsOffset, flags); |
3023 } | 3048 } |
3024 | 3049 |
3025 | 3050 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 } | 3466 } |
3442 | 3467 |
3443 | 3468 |
3444 void Map::set_prototype(Object* value, WriteBarrierMode mode) { | 3469 void Map::set_prototype(Object* value, WriteBarrierMode mode) { |
3445 ASSERT(value->IsNull() || value->IsJSReceiver()); | 3470 ASSERT(value->IsNull() || value->IsJSReceiver()); |
3446 WRITE_FIELD(this, kPrototypeOffset, value); | 3471 WRITE_FIELD(this, kPrototypeOffset, value); |
3447 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); | 3472 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); |
3448 } | 3473 } |
3449 | 3474 |
3450 | 3475 |
| 3476 JSGlobalPropertyCell* Map::descriptors_pointer() { |
| 3477 ASSERT(HasTransitionArray()); |
| 3478 return transitions()->descriptors_pointer(); |
| 3479 } |
| 3480 |
| 3481 |
3451 DescriptorArray* Map::instance_descriptors() { | 3482 DescriptorArray* Map::instance_descriptors() { |
3452 if (!HasTransitionArray()) return GetHeap()->empty_descriptor_array(); | 3483 if (HasTransitionArray()) return transitions()->descriptors(); |
3453 return transitions()->descriptors(); | 3484 Object* back_pointer = GetBackPointer(); |
| 3485 if (!back_pointer->IsMap()) return GetHeap()->empty_descriptor_array(); |
| 3486 return Map::cast(back_pointer)->instance_descriptors(); |
3454 } | 3487 } |
3455 | 3488 |
3456 | 3489 |
3457 // If the descriptor is using the empty transition array, install a new empty | 3490 // If the descriptor is using the empty transition array, install a new empty |
3458 // transition array that will have place for an element transition. | 3491 // transition array that will have place for an element transition. |
3459 static MaybeObject* EnsureHasTransitionArray(Map* map) { | 3492 static MaybeObject* EnsureHasTransitionArray(Map* map) { |
3460 if (map->HasTransitionArray()) return map; | 3493 if (map->HasTransitionArray()) return map; |
3461 | 3494 |
3462 TransitionArray* transitions; | 3495 TransitionArray* transitions; |
3463 MaybeObject* maybe_transitions = TransitionArray::Allocate(0); | 3496 JSGlobalPropertyCell* pointer = map->RetrieveDescriptorsPointer(); |
| 3497 MaybeObject* maybe_transitions = TransitionArray::Allocate(0, pointer); |
3464 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 3498 if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
| 3499 |
| 3500 transitions->set_back_pointer_storage(map->GetBackPointer()); |
3465 map->set_transitions(transitions); | 3501 map->set_transitions(transitions); |
3466 return transitions; | 3502 return transitions; |
3467 } | 3503 } |
3468 | 3504 |
3469 | 3505 |
3470 MaybeObject* Map::SetDescriptors(DescriptorArray* value, | 3506 MaybeObject* Map::SetDescriptors(DescriptorArray* value) { |
3471 WriteBarrierMode mode) { | |
3472 ASSERT(!is_shared()); | 3507 ASSERT(!is_shared()); |
3473 MaybeObject* maybe_failure = EnsureHasTransitionArray(this); | 3508 MaybeObject* maybe_failure = EnsureHasTransitionArray(this); |
3474 if (maybe_failure->IsFailure()) return maybe_failure; | 3509 if (maybe_failure->IsFailure()) return maybe_failure; |
3475 | 3510 |
3476 transitions()->set_descriptors(value, mode); | 3511 ASSERT(NumberOfOwnDescriptors() <= value->number_of_descriptors()); |
| 3512 transitions()->set_descriptors(value); |
3477 return this; | 3513 return this; |
3478 } | 3514 } |
3479 | 3515 |
3480 | 3516 |
3481 MaybeObject* Map::InitializeDescriptors(DescriptorArray* descriptors) { | 3517 MaybeObject* Map::InitializeDescriptors(DescriptorArray* descriptors) { |
| 3518 int len = descriptors->number_of_descriptors(); |
3482 #ifdef DEBUG | 3519 #ifdef DEBUG |
3483 int len = descriptors->number_of_descriptors(); | |
3484 ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors); | 3520 ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors); |
3485 SLOW_ASSERT(descriptors->IsSortedNoDuplicates()); | |
3486 | 3521 |
3487 bool used_indices[DescriptorArray::kMaxNumberOfDescriptors]; | 3522 bool used_indices[DescriptorArray::kMaxNumberOfDescriptors]; |
3488 for (int i = 0; i < len; ++i) used_indices[i] = false; | 3523 for (int i = 0; i < len; ++i) used_indices[i] = false; |
3489 | 3524 |
3490 // Ensure that all enumeration indexes between 1 and length occur uniquely in | 3525 // Ensure that all enumeration indexes between 1 and length occur uniquely in |
3491 // the descriptor array. | 3526 // the descriptor array. |
3492 for (int i = 0; i < len; ++i) { | 3527 for (int i = 0; i < len; ++i) { |
3493 int enum_index = descriptors->GetDetails(i).descriptor_index() - | 3528 int enum_index = descriptors->GetDetails(i).descriptor_index() - |
3494 PropertyDetails::kInitialIndex; | 3529 PropertyDetails::kInitialIndex; |
3495 ASSERT(0 <= enum_index && enum_index < len); | 3530 ASSERT(0 <= enum_index && enum_index < len); |
3496 ASSERT(!used_indices[enum_index]); | 3531 ASSERT(!used_indices[enum_index]); |
3497 used_indices[enum_index] = true; | 3532 used_indices[enum_index] = true; |
3498 } | 3533 } |
3499 #endif | 3534 #endif |
3500 | 3535 |
3501 MaybeObject* maybe_failure = SetDescriptors(descriptors); | 3536 MaybeObject* maybe_failure = SetDescriptors(descriptors); |
3502 if (maybe_failure->IsFailure()) return maybe_failure; | 3537 if (maybe_failure->IsFailure()) return maybe_failure; |
3503 | 3538 |
3504 SetNumberOfOwnDescriptors(descriptors->number_of_descriptors()); | 3539 SetNumberOfOwnDescriptors(len); |
3505 | |
3506 return this; | 3540 return this; |
3507 } | 3541 } |
3508 | 3542 |
3509 | 3543 |
3510 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset) | 3544 SMI_ACCESSORS(Map, bit_field3, kBitField3Offset) |
3511 | 3545 |
3512 | 3546 |
3513 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { | 3547 void Map::ClearTransitions(Heap* heap, WriteBarrierMode mode) { |
3514 Object* back_pointer = GetBackPointer(); | 3548 Object* back_pointer = GetBackPointer(); |
3515 #ifdef DEBUG | 3549 #ifdef DEBUG |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 | 3598 |
3565 | 3599 |
3566 bool Map::CanHaveMoreTransitions() { | 3600 bool Map::CanHaveMoreTransitions() { |
3567 if (!HasTransitionArray()) return true; | 3601 if (!HasTransitionArray()) return true; |
3568 return FixedArray::SizeFor(transitions()->length() + | 3602 return FixedArray::SizeFor(transitions()->length() + |
3569 TransitionArray::kTransitionSize) | 3603 TransitionArray::kTransitionSize) |
3570 <= Page::kMaxNonCodeHeapObjectSize; | 3604 <= Page::kMaxNonCodeHeapObjectSize; |
3571 } | 3605 } |
3572 | 3606 |
3573 | 3607 |
| 3608 JSGlobalPropertyCell* Map::RetrieveDescriptorsPointer() { |
| 3609 if (!owns_descriptors()) return NULL; |
| 3610 Object* back_pointer = GetBackPointer(); |
| 3611 if (back_pointer->IsUndefined()) return NULL; |
| 3612 Map* map = Map::cast(back_pointer); |
| 3613 ASSERT(map->HasTransitionArray()); |
| 3614 return map->transitions()->descriptors_pointer(); |
| 3615 } |
| 3616 |
| 3617 |
3574 MaybeObject* Map::AddTransition(String* key, Map* target) { | 3618 MaybeObject* Map::AddTransition(String* key, Map* target) { |
3575 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); | 3619 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); |
3576 return TransitionArray::NewWith(key, target); | 3620 JSGlobalPropertyCell* descriptors_pointer = RetrieveDescriptorsPointer(); |
| 3621 return TransitionArray::NewWith( |
| 3622 key, target, descriptors_pointer, GetBackPointer()); |
3577 } | 3623 } |
3578 | 3624 |
3579 | 3625 |
3580 void Map::SetTransition(int transition_index, Map* target) { | 3626 void Map::SetTransition(int transition_index, Map* target) { |
3581 transitions()->SetTarget(transition_index, target); | 3627 transitions()->SetTarget(transition_index, target); |
3582 } | 3628 } |
3583 | 3629 |
3584 | 3630 |
| 3631 Map* Map::GetTransition(int transition_index) { |
| 3632 return transitions()->GetTarget(transition_index); |
| 3633 } |
| 3634 |
| 3635 |
3585 MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) { | 3636 MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) { |
3586 MaybeObject* allow_elements = EnsureHasTransitionArray(this); | 3637 MaybeObject* allow_elements = EnsureHasTransitionArray(this); |
3587 if (allow_elements->IsFailure()) return allow_elements; | 3638 if (allow_elements->IsFailure()) return allow_elements; |
3588 transitions()->set_elements_transition(transitioned_map); | 3639 transitions()->set_elements_transition(transitioned_map); |
3589 return this; | 3640 return this; |
3590 } | 3641 } |
3591 | 3642 |
3592 | 3643 |
3593 FixedArray* Map::GetPrototypeTransitions() { | 3644 FixedArray* Map::GetPrototypeTransitions() { |
3594 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); | 3645 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); |
(...skipping 25 matching lines...) Expand all Loading... |
3620 | 3671 |
3621 TransitionArray* Map::transitions() { | 3672 TransitionArray* Map::transitions() { |
3622 ASSERT(HasTransitionArray()); | 3673 ASSERT(HasTransitionArray()); |
3623 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); | 3674 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); |
3624 return TransitionArray::cast(object); | 3675 return TransitionArray::cast(object); |
3625 } | 3676 } |
3626 | 3677 |
3627 | 3678 |
3628 void Map::set_transitions(TransitionArray* transition_array, | 3679 void Map::set_transitions(TransitionArray* transition_array, |
3629 WriteBarrierMode mode) { | 3680 WriteBarrierMode mode) { |
3630 transition_array->set_descriptors(instance_descriptors()); | |
3631 transition_array->set_back_pointer_storage(GetBackPointer()); | |
3632 #ifdef DEBUG | 3681 #ifdef DEBUG |
3633 if (HasTransitionArray()) { | 3682 if (HasTransitionArray()) { |
3634 ASSERT(transitions() != transition_array); | 3683 ASSERT(transitions() != transition_array); |
3635 ZapTransitions(); | 3684 ZapTransitions(); |
3636 } | 3685 } |
3637 #endif | 3686 #endif |
3638 | 3687 |
3639 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); | 3688 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, transition_array); |
3640 CONDITIONAL_WRITE_BARRIER( | 3689 CONDITIONAL_WRITE_BARRIER( |
3641 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); | 3690 GetHeap(), this, kTransitionsOrBackPointerOffset, transition_array, mode); |
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5409 #undef WRITE_UINT32_FIELD | 5458 #undef WRITE_UINT32_FIELD |
5410 #undef READ_SHORT_FIELD | 5459 #undef READ_SHORT_FIELD |
5411 #undef WRITE_SHORT_FIELD | 5460 #undef WRITE_SHORT_FIELD |
5412 #undef READ_BYTE_FIELD | 5461 #undef READ_BYTE_FIELD |
5413 #undef WRITE_BYTE_FIELD | 5462 #undef WRITE_BYTE_FIELD |
5414 | 5463 |
5415 | 5464 |
5416 } } // namespace v8::internal | 5465 } } // namespace v8::internal |
5417 | 5466 |
5418 #endif // V8_OBJECTS_INL_H_ | 5467 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |