| 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 890 |
| 891 Object* Object::GetElementNoExceptionThrown(uint32_t index) { | 891 Object* Object::GetElementNoExceptionThrown(uint32_t index) { |
| 892 MaybeObject* maybe = GetElementWithReceiver(this, index); | 892 MaybeObject* maybe = GetElementWithReceiver(this, index); |
| 893 ASSERT(!maybe->IsFailure()); | 893 ASSERT(!maybe->IsFailure()); |
| 894 Object* result = NULL; // Initialization to please compiler. | 894 Object* result = NULL; // Initialization to please compiler. |
| 895 maybe->ToObject(&result); | 895 maybe->ToObject(&result); |
| 896 return result; | 896 return result; |
| 897 } | 897 } |
| 898 | 898 |
| 899 | 899 |
| 900 MaybeObject* Object::GetProperty(String* key) { | 900 MaybeObject* Object::GetProperty(Name* key) { |
| 901 PropertyAttributes attributes; | 901 PropertyAttributes attributes; |
| 902 return GetPropertyWithReceiver(this, key, &attributes); | 902 return GetPropertyWithReceiver(this, key, &attributes); |
| 903 } | 903 } |
| 904 | 904 |
| 905 | 905 |
| 906 MaybeObject* Object::GetProperty(String* key, PropertyAttributes* attributes) { | 906 MaybeObject* Object::GetProperty(Name* key, PropertyAttributes* attributes) { |
| 907 return GetPropertyWithReceiver(this, key, attributes); | 907 return GetPropertyWithReceiver(this, key, attributes); |
| 908 } | 908 } |
| 909 | 909 |
| 910 | 910 |
| 911 #define FIELD_ADDR(p, offset) \ | 911 #define FIELD_ADDR(p, offset) \ |
| 912 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) | 912 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) |
| 913 | 913 |
| 914 #define READ_FIELD(p, offset) \ | 914 #define READ_FIELD(p, offset) \ |
| 915 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) | 915 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) |
| 916 | 916 |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 MaybeObject* maybe_properties = properties()->CopySize(new_size); | 1481 MaybeObject* maybe_properties = properties()->CopySize(new_size); |
| 1482 if (!maybe_properties->To(&new_properties)) return maybe_properties; | 1482 if (!maybe_properties->To(&new_properties)) return maybe_properties; |
| 1483 set_properties(new_properties); | 1483 set_properties(new_properties); |
| 1484 } | 1484 } |
| 1485 set_map(map); | 1485 set_map(map); |
| 1486 return this; | 1486 return this; |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 | 1489 |
| 1490 bool JSObject::TryTransitionToField(Handle<JSObject> object, | 1490 bool JSObject::TryTransitionToField(Handle<JSObject> object, |
| 1491 Handle<String> key) { | 1491 Handle<Name> key) { |
| 1492 if (!object->map()->HasTransitionArray()) return false; | 1492 if (!object->map()->HasTransitionArray()) return false; |
| 1493 Handle<TransitionArray> transitions(object->map()->transitions()); | 1493 Handle<TransitionArray> transitions(object->map()->transitions()); |
| 1494 int transition = transitions->Search(*key); | 1494 int transition = transitions->Search(*key); |
| 1495 if (transition == TransitionArray::kNotFound) return false; | 1495 if (transition == TransitionArray::kNotFound) return false; |
| 1496 PropertyDetails target_details = transitions->GetTargetDetails(transition); | 1496 PropertyDetails target_details = transitions->GetTargetDetails(transition); |
| 1497 if (target_details.type() != FIELD) return false; | 1497 if (target_details.type() != FIELD) return false; |
| 1498 if (target_details.attributes() != NONE) return false; | 1498 if (target_details.attributes() != NONE) return false; |
| 1499 Handle<Map> target(transitions->GetTarget(transition)); | 1499 Handle<Map> target(transitions->GetTarget(transition)); |
| 1500 JSObject::AddFastPropertyUsingMap(object, target); | 1500 JSObject::AddFastPropertyUsingMap(object, target); |
| 1501 return true; | 1501 return true; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { | 2009 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { |
| 2010 WRITE_FIELD( | 2010 WRITE_FIELD( |
| 2011 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); | 2011 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 | 2014 |
| 2015 // Perform a binary search in a fixed array. Low and high are entry indices. If | 2015 // Perform a binary search in a fixed array. Low and high are entry indices. If |
| 2016 // there are three entries in this array it should be called with low=0 and | 2016 // there are three entries in this array it should be called with low=0 and |
| 2017 // high=2. | 2017 // high=2. |
| 2018 template<SearchMode search_mode, typename T> | 2018 template<SearchMode search_mode, typename T> |
| 2019 int BinarySearch(T* array, String* name, int low, int high, int valid_entries) { | 2019 int BinarySearch(T* array, Name* name, int low, int high, int valid_entries) { |
| 2020 uint32_t hash = name->Hash(); | 2020 uint32_t hash = name->Hash(); |
| 2021 int limit = high; | 2021 int limit = high; |
| 2022 | 2022 |
| 2023 ASSERT(low <= high); | 2023 ASSERT(low <= high); |
| 2024 | 2024 |
| 2025 while (low != high) { | 2025 while (low != high) { |
| 2026 int mid = (low + high) / 2; | 2026 int mid = (low + high) / 2; |
| 2027 String* mid_name = array->GetSortedKey(mid); | 2027 Name* mid_name = array->GetSortedKey(mid); |
| 2028 uint32_t mid_hash = mid_name->Hash(); | 2028 uint32_t mid_hash = mid_name->Hash(); |
| 2029 | 2029 |
| 2030 if (mid_hash >= hash) { | 2030 if (mid_hash >= hash) { |
| 2031 high = mid; | 2031 high = mid; |
| 2032 } else { | 2032 } else { |
| 2033 low = mid + 1; | 2033 low = mid + 1; |
| 2034 } | 2034 } |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 for (; low <= limit; ++low) { | 2037 for (; low <= limit; ++low) { |
| 2038 int sort_index = array->GetSortedKeyIndex(low); | 2038 int sort_index = array->GetSortedKeyIndex(low); |
| 2039 String* entry = array->GetKey(sort_index); | 2039 Name* entry = array->GetKey(sort_index); |
| 2040 if (entry->Hash() != hash) break; | 2040 if (entry->Hash() != hash) break; |
| 2041 if (entry->Equals(name)) { | 2041 if (entry->Equals(name)) { |
| 2042 if (search_mode == ALL_ENTRIES || sort_index < valid_entries) { | 2042 if (search_mode == ALL_ENTRIES || sort_index < valid_entries) { |
| 2043 return sort_index; | 2043 return sort_index; |
| 2044 } | 2044 } |
| 2045 return T::kNotFound; | 2045 return T::kNotFound; |
| 2046 } | 2046 } |
| 2047 } | 2047 } |
| 2048 | 2048 |
| 2049 return T::kNotFound; | 2049 return T::kNotFound; |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 | 2052 |
| 2053 // Perform a linear search in this fixed array. len is the number of entry | 2053 // Perform a linear search in this fixed array. len is the number of entry |
| 2054 // indices that are valid. | 2054 // indices that are valid. |
| 2055 template<SearchMode search_mode, typename T> | 2055 template<SearchMode search_mode, typename T> |
| 2056 int LinearSearch(T* array, String* name, int len, int valid_entries) { | 2056 int LinearSearch(T* array, Name* name, int len, int valid_entries) { |
| 2057 uint32_t hash = name->Hash(); | 2057 uint32_t hash = name->Hash(); |
| 2058 if (search_mode == ALL_ENTRIES) { | 2058 if (search_mode == ALL_ENTRIES) { |
| 2059 for (int number = 0; number < len; number++) { | 2059 for (int number = 0; number < len; number++) { |
| 2060 int sorted_index = array->GetSortedKeyIndex(number); | 2060 int sorted_index = array->GetSortedKeyIndex(number); |
| 2061 String* entry = array->GetKey(sorted_index); | 2061 Name* entry = array->GetKey(sorted_index); |
| 2062 uint32_t current_hash = entry->Hash(); | 2062 uint32_t current_hash = entry->Hash(); |
| 2063 if (current_hash > hash) break; | 2063 if (current_hash > hash) break; |
| 2064 if (current_hash == hash && entry->Equals(name)) return sorted_index; | 2064 if (current_hash == hash && entry->Equals(name)) return sorted_index; |
| 2065 } | 2065 } |
| 2066 } else { | 2066 } else { |
| 2067 ASSERT(len >= valid_entries); | 2067 ASSERT(len >= valid_entries); |
| 2068 for (int number = 0; number < valid_entries; number++) { | 2068 for (int number = 0; number < valid_entries; number++) { |
| 2069 String* entry = array->GetKey(number); | 2069 Name* entry = array->GetKey(number); |
| 2070 uint32_t current_hash = entry->Hash(); | 2070 uint32_t current_hash = entry->Hash(); |
| 2071 if (current_hash == hash && entry->Equals(name)) return number; | 2071 if (current_hash == hash && entry->Equals(name)) return number; |
| 2072 } | 2072 } |
| 2073 } | 2073 } |
| 2074 return T::kNotFound; | 2074 return T::kNotFound; |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 | 2077 |
| 2078 template<SearchMode search_mode, typename T> | 2078 template<SearchMode search_mode, typename T> |
| 2079 int Search(T* array, String* name, int valid_entries) { | 2079 int Search(T* array, Name* name, int valid_entries) { |
| 2080 if (search_mode == VALID_ENTRIES) { | 2080 if (search_mode == VALID_ENTRIES) { |
| 2081 SLOW_ASSERT(array->IsSortedNoDuplicates(valid_entries)); | 2081 SLOW_ASSERT(array->IsSortedNoDuplicates(valid_entries)); |
| 2082 } else { | 2082 } else { |
| 2083 SLOW_ASSERT(array->IsSortedNoDuplicates()); | 2083 SLOW_ASSERT(array->IsSortedNoDuplicates()); |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 int nof = array->number_of_entries(); | 2086 int nof = array->number_of_entries(); |
| 2087 if (nof == 0) return T::kNotFound; | 2087 if (nof == 0) return T::kNotFound; |
| 2088 | 2088 |
| 2089 // Fast case: do linear search for small arrays. | 2089 // Fast case: do linear search for small arrays. |
| 2090 const int kMaxElementsForLinearSearch = 8; | 2090 const int kMaxElementsForLinearSearch = 8; |
| 2091 if ((search_mode == ALL_ENTRIES && | 2091 if ((search_mode == ALL_ENTRIES && |
| 2092 nof <= kMaxElementsForLinearSearch) || | 2092 nof <= kMaxElementsForLinearSearch) || |
| 2093 (search_mode == VALID_ENTRIES && | 2093 (search_mode == VALID_ENTRIES && |
| 2094 valid_entries <= (kMaxElementsForLinearSearch * 3))) { | 2094 valid_entries <= (kMaxElementsForLinearSearch * 3))) { |
| 2095 return LinearSearch<search_mode>(array, name, nof, valid_entries); | 2095 return LinearSearch<search_mode>(array, name, nof, valid_entries); |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 // Slow case: perform binary search. | 2098 // Slow case: perform binary search. |
| 2099 return BinarySearch<search_mode>(array, name, 0, nof - 1, valid_entries); | 2099 return BinarySearch<search_mode>(array, name, 0, nof - 1, valid_entries); |
| 2100 } | 2100 } |
| 2101 | 2101 |
| 2102 | 2102 |
| 2103 int DescriptorArray::Search(String* name, int valid_descriptors) { | 2103 int DescriptorArray::Search(Name* name, int valid_descriptors) { |
| 2104 return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors); | 2104 return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 | 2107 |
| 2108 int DescriptorArray::SearchWithCache(String* name, Map* map) { | 2108 int DescriptorArray::SearchWithCache(Name* name, Map* map) { |
| 2109 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 2109 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
| 2110 if (number_of_own_descriptors == 0) return kNotFound; | 2110 if (number_of_own_descriptors == 0) return kNotFound; |
| 2111 | 2111 |
| 2112 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); | 2112 DescriptorLookupCache* cache = GetIsolate()->descriptor_lookup_cache(); |
| 2113 int number = cache->Lookup(map, name); | 2113 int number = cache->Lookup(map, name); |
| 2114 | 2114 |
| 2115 if (number == DescriptorLookupCache::kAbsent) { | 2115 if (number == DescriptorLookupCache::kAbsent) { |
| 2116 number = Search(name, number_of_own_descriptors); | 2116 number = Search(name, number_of_own_descriptors); |
| 2117 cache->Update(map, name, number); | 2117 cache->Update(map, name, number); |
| 2118 } | 2118 } |
| 2119 | 2119 |
| 2120 return number; | 2120 return number; |
| 2121 } | 2121 } |
| 2122 | 2122 |
| 2123 | 2123 |
| 2124 void Map::LookupDescriptor(JSObject* holder, | 2124 void Map::LookupDescriptor(JSObject* holder, |
| 2125 String* name, | 2125 Name* name, |
| 2126 LookupResult* result) { | 2126 LookupResult* result) { |
| 2127 DescriptorArray* descriptors = this->instance_descriptors(); | 2127 DescriptorArray* descriptors = this->instance_descriptors(); |
| 2128 int number = descriptors->SearchWithCache(name, this); | 2128 int number = descriptors->SearchWithCache(name, this); |
| 2129 if (number == DescriptorArray::kNotFound) return result->NotFound(); | 2129 if (number == DescriptorArray::kNotFound) return result->NotFound(); |
| 2130 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 2130 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 2131 } | 2131 } |
| 2132 | 2132 |
| 2133 | 2133 |
| 2134 void Map::LookupTransition(JSObject* holder, | 2134 void Map::LookupTransition(JSObject* holder, |
| 2135 String* name, | 2135 Name* name, |
| 2136 LookupResult* result) { | 2136 LookupResult* result) { |
| 2137 if (HasTransitionArray()) { | 2137 if (HasTransitionArray()) { |
| 2138 TransitionArray* transition_array = transitions(); | 2138 TransitionArray* transition_array = transitions(); |
| 2139 int number = transition_array->Search(name); | 2139 int number = transition_array->Search(name); |
| 2140 if (number != TransitionArray::kNotFound) { | 2140 if (number != TransitionArray::kNotFound) { |
| 2141 return result->TransitionResult(holder, number); | 2141 return result->TransitionResult(holder, number); |
| 2142 } | 2142 } |
| 2143 } | 2143 } |
| 2144 result->NotFound(); | 2144 result->NotFound(); |
| 2145 } | 2145 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2156 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { | 2156 Object** DescriptorArray::GetDescriptorStartSlot(int descriptor_number) { |
| 2157 return GetKeySlot(descriptor_number); | 2157 return GetKeySlot(descriptor_number); |
| 2158 } | 2158 } |
| 2159 | 2159 |
| 2160 | 2160 |
| 2161 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { | 2161 Object** DescriptorArray::GetDescriptorEndSlot(int descriptor_number) { |
| 2162 return GetValueSlot(descriptor_number - 1) + 1; | 2162 return GetValueSlot(descriptor_number - 1) + 1; |
| 2163 } | 2163 } |
| 2164 | 2164 |
| 2165 | 2165 |
| 2166 String* DescriptorArray::GetKey(int descriptor_number) { | 2166 Name* DescriptorArray::GetKey(int descriptor_number) { |
| 2167 ASSERT(descriptor_number < number_of_descriptors()); | 2167 ASSERT(descriptor_number < number_of_descriptors()); |
| 2168 return String::cast(get(ToKeyIndex(descriptor_number))); | 2168 return Name::cast(get(ToKeyIndex(descriptor_number))); |
| 2169 } | 2169 } |
| 2170 | 2170 |
| 2171 | 2171 |
| 2172 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { | 2172 int DescriptorArray::GetSortedKeyIndex(int descriptor_number) { |
| 2173 return GetDetails(descriptor_number).pointer(); | 2173 return GetDetails(descriptor_number).pointer(); |
| 2174 } | 2174 } |
| 2175 | 2175 |
| 2176 | 2176 |
| 2177 String* DescriptorArray::GetSortedKey(int descriptor_number) { | 2177 Name* DescriptorArray::GetSortedKey(int descriptor_number) { |
| 2178 return GetKey(GetSortedKeyIndex(descriptor_number)); | 2178 return GetKey(GetSortedKeyIndex(descriptor_number)); |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 | 2181 |
| 2182 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { | 2182 void DescriptorArray::SetSortedKey(int descriptor_index, int pointer) { |
| 2183 PropertyDetails details = GetDetails(descriptor_index); | 2183 PropertyDetails details = GetDetails(descriptor_index); |
| 2184 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); | 2184 set(ToDetailsIndex(descriptor_index), details.set_pointer(pointer).AsSmi()); |
| 2185 } | 2185 } |
| 2186 | 2186 |
| 2187 | 2187 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 int enumeration_index = descriptor_number + 1; | 2281 int enumeration_index = descriptor_number + 1; |
| 2282 SetNumberOfDescriptors(descriptor_number + 1); | 2282 SetNumberOfDescriptors(descriptor_number + 1); |
| 2283 desc->SetEnumerationIndex(enumeration_index); | 2283 desc->SetEnumerationIndex(enumeration_index); |
| 2284 Set(descriptor_number, desc, witness); | 2284 Set(descriptor_number, desc, witness); |
| 2285 | 2285 |
| 2286 uint32_t hash = desc->GetKey()->Hash(); | 2286 uint32_t hash = desc->GetKey()->Hash(); |
| 2287 | 2287 |
| 2288 int insertion; | 2288 int insertion; |
| 2289 | 2289 |
| 2290 for (insertion = descriptor_number; insertion > 0; --insertion) { | 2290 for (insertion = descriptor_number; insertion > 0; --insertion) { |
| 2291 String* key = GetSortedKey(insertion - 1); | 2291 Name* key = GetSortedKey(insertion - 1); |
| 2292 if (key->Hash() <= hash) break; | 2292 if (key->Hash() <= hash) break; |
| 2293 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); | 2293 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 SetSortedKey(insertion, descriptor_number); | 2296 SetSortedKey(insertion, descriptor_number); |
| 2297 } | 2297 } |
| 2298 | 2298 |
| 2299 | 2299 |
| 2300 void DescriptorArray::Append(Descriptor* desc) { | 2300 void DescriptorArray::Append(Descriptor* desc) { |
| 2301 int descriptor_number = number_of_descriptors(); | 2301 int descriptor_number = number_of_descriptors(); |
| 2302 int enumeration_index = descriptor_number + 1; | 2302 int enumeration_index = descriptor_number + 1; |
| 2303 SetNumberOfDescriptors(descriptor_number + 1); | 2303 SetNumberOfDescriptors(descriptor_number + 1); |
| 2304 desc->SetEnumerationIndex(enumeration_index); | 2304 desc->SetEnumerationIndex(enumeration_index); |
| 2305 Set(descriptor_number, desc); | 2305 Set(descriptor_number, desc); |
| 2306 | 2306 |
| 2307 uint32_t hash = desc->GetKey()->Hash(); | 2307 uint32_t hash = desc->GetKey()->Hash(); |
| 2308 | 2308 |
| 2309 int insertion; | 2309 int insertion; |
| 2310 | 2310 |
| 2311 for (insertion = descriptor_number; insertion > 0; --insertion) { | 2311 for (insertion = descriptor_number; insertion > 0; --insertion) { |
| 2312 String* key = GetSortedKey(insertion - 1); | 2312 Name* key = GetSortedKey(insertion - 1); |
| 2313 if (key->Hash() <= hash) break; | 2313 if (key->Hash() <= hash) break; |
| 2314 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); | 2314 SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); |
| 2315 } | 2315 } |
| 2316 | 2316 |
| 2317 SetSortedKey(insertion, descriptor_number); | 2317 SetSortedKey(insertion, descriptor_number); |
| 2318 } | 2318 } |
| 2319 | 2319 |
| 2320 | 2320 |
| 2321 void DescriptorArray::SwapSortedKeys(int first, int second) { | 2321 void DescriptorArray::SwapSortedKeys(int first, int second) { |
| 2322 int first_key = GetSortedKeyIndex(first); | 2322 int first_key = GetSortedKeyIndex(first); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 CAST_ACCESSOR(String) | 2416 CAST_ACCESSOR(String) |
| 2417 CAST_ACCESSOR(SeqString) | 2417 CAST_ACCESSOR(SeqString) |
| 2418 CAST_ACCESSOR(SeqOneByteString) | 2418 CAST_ACCESSOR(SeqOneByteString) |
| 2419 CAST_ACCESSOR(SeqTwoByteString) | 2419 CAST_ACCESSOR(SeqTwoByteString) |
| 2420 CAST_ACCESSOR(SlicedString) | 2420 CAST_ACCESSOR(SlicedString) |
| 2421 CAST_ACCESSOR(ConsString) | 2421 CAST_ACCESSOR(ConsString) |
| 2422 CAST_ACCESSOR(ExternalString) | 2422 CAST_ACCESSOR(ExternalString) |
| 2423 CAST_ACCESSOR(ExternalAsciiString) | 2423 CAST_ACCESSOR(ExternalAsciiString) |
| 2424 CAST_ACCESSOR(ExternalTwoByteString) | 2424 CAST_ACCESSOR(ExternalTwoByteString) |
| 2425 CAST_ACCESSOR(Symbol) | 2425 CAST_ACCESSOR(Symbol) |
| 2426 CAST_ACCESSOR(Name) |
| 2426 CAST_ACCESSOR(JSReceiver) | 2427 CAST_ACCESSOR(JSReceiver) |
| 2427 CAST_ACCESSOR(JSObject) | 2428 CAST_ACCESSOR(JSObject) |
| 2428 CAST_ACCESSOR(Smi) | 2429 CAST_ACCESSOR(Smi) |
| 2429 CAST_ACCESSOR(HeapObject) | 2430 CAST_ACCESSOR(HeapObject) |
| 2430 CAST_ACCESSOR(HeapNumber) | 2431 CAST_ACCESSOR(HeapNumber) |
| 2431 CAST_ACCESSOR(Oddball) | 2432 CAST_ACCESSOR(Oddball) |
| 2432 CAST_ACCESSOR(JSGlobalPropertyCell) | 2433 CAST_ACCESSOR(JSGlobalPropertyCell) |
| 2433 CAST_ACCESSOR(SharedFunctionInfo) | 2434 CAST_ACCESSOR(SharedFunctionInfo) |
| 2434 CAST_ACCESSOR(Map) | 2435 CAST_ACCESSOR(Map) |
| 2435 CAST_ACCESSOR(JSFunction) | 2436 CAST_ACCESSOR(JSFunction) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 | 2486 |
| 2486 | 2487 |
| 2487 void Name::set_hash_field(uint32_t value) { | 2488 void Name::set_hash_field(uint32_t value) { |
| 2488 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); | 2489 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); |
| 2489 #if V8_HOST_ARCH_64_BIT | 2490 #if V8_HOST_ARCH_64_BIT |
| 2490 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); | 2491 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); |
| 2491 #endif | 2492 #endif |
| 2492 } | 2493 } |
| 2493 | 2494 |
| 2494 | 2495 |
| 2496 bool Name::Equals(Name* other) { |
| 2497 if (other == this) return true; |
| 2498 if (this->IsUniqueName() && other->IsUniqueName()) return false; |
| 2499 return String::cast(this)->SlowEquals(String::cast(other)); |
| 2500 } |
| 2501 |
| 2502 |
| 2495 bool String::Equals(String* other) { | 2503 bool String::Equals(String* other) { |
| 2496 if (other == this) return true; | 2504 if (other == this) return true; |
| 2497 if (StringShape(this).IsInternalized() && | 2505 if (this->IsInternalizedString() && other->IsInternalizedString()) { |
| 2498 StringShape(other).IsInternalized()) { | |
| 2499 return false; | 2506 return false; |
| 2500 } | 2507 } |
| 2501 return SlowEquals(other); | 2508 return SlowEquals(other); |
| 2502 } | 2509 } |
| 2503 | 2510 |
| 2504 | 2511 |
| 2505 MaybeObject* String::TryFlatten(PretenureFlag pretenure) { | 2512 MaybeObject* String::TryFlatten(PretenureFlag pretenure) { |
| 2506 if (!StringShape(this).IsCons()) return this; | 2513 if (!StringShape(this).IsCons()) return this; |
| 2507 ConsString* cons = ConsString::cast(this); | 2514 ConsString* cons = ConsString::cast(this); |
| 2508 if (cons->IsFlat()) return cons->first(); | 2515 if (cons->IsFlat()) return cons->first(); |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 | 3224 |
| 3218 | 3225 |
| 3219 int Map::pre_allocated_property_fields() { | 3226 int Map::pre_allocated_property_fields() { |
| 3220 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 3227 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
| 3221 } | 3228 } |
| 3222 | 3229 |
| 3223 | 3230 |
| 3224 int HeapObject::SizeFromMap(Map* map) { | 3231 int HeapObject::SizeFromMap(Map* map) { |
| 3225 int instance_size = map->instance_size(); | 3232 int instance_size = map->instance_size(); |
| 3226 if (instance_size != kVariableSizeSentinel) return instance_size; | 3233 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 3227 // We can ignore the "internalized" bit becase it is only set for strings | 3234 // We can ignore the "internalized" bit because it is only set for strings |
| 3228 // and thus implies a string type. | 3235 // and thus implies a string type. |
| 3229 int instance_type = | 3236 int instance_type = |
| 3230 static_cast<int>(map->instance_type()) & ~kIsInternalizedMask; | 3237 static_cast<int>(map->instance_type()) & ~kIsInternalizedMask; |
| 3231 // Only inline the most frequent cases. | 3238 // Only inline the most frequent cases. |
| 3232 if (instance_type == FIXED_ARRAY_TYPE) { | 3239 if (instance_type == FIXED_ARRAY_TYPE) { |
| 3233 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3240 return FixedArray::BodyDescriptor::SizeOf(map, this); |
| 3234 } | 3241 } |
| 3235 if (instance_type == ASCII_STRING_TYPE) { | 3242 if (instance_type == ASCII_STRING_TYPE) { |
| 3236 return SeqOneByteString::SizeFor( | 3243 return SeqOneByteString::SizeFor( |
| 3237 reinterpret_cast<SeqOneByteString*>(this)->length()); | 3244 reinterpret_cast<SeqOneByteString*>(this)->length()); |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3981 | 3988 |
| 3982 | 3989 |
| 3983 bool Map::CanHaveMoreTransitions() { | 3990 bool Map::CanHaveMoreTransitions() { |
| 3984 if (!HasTransitionArray()) return true; | 3991 if (!HasTransitionArray()) return true; |
| 3985 return FixedArray::SizeFor(transitions()->length() + | 3992 return FixedArray::SizeFor(transitions()->length() + |
| 3986 TransitionArray::kTransitionSize) | 3993 TransitionArray::kTransitionSize) |
| 3987 <= Page::kMaxNonCodeHeapObjectSize; | 3994 <= Page::kMaxNonCodeHeapObjectSize; |
| 3988 } | 3995 } |
| 3989 | 3996 |
| 3990 | 3997 |
| 3991 MaybeObject* Map::AddTransition(String* key, | 3998 MaybeObject* Map::AddTransition(Name* key, |
| 3992 Map* target, | 3999 Map* target, |
| 3993 SimpleTransitionFlag flag) { | 4000 SimpleTransitionFlag flag) { |
| 3994 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); | 4001 if (HasTransitionArray()) return transitions()->CopyInsert(key, target); |
| 3995 return TransitionArray::NewWith(flag, key, target, GetBackPointer()); | 4002 return TransitionArray::NewWith(flag, key, target, GetBackPointer()); |
| 3996 } | 4003 } |
| 3997 | 4004 |
| 3998 | 4005 |
| 3999 void Map::SetTransition(int transition_index, Map* target) { | 4006 void Map::SetTransition(int transition_index, Map* target) { |
| 4000 transitions()->SetTarget(transition_index, target); | 4007 transitions()->SetTarget(transition_index, target); |
| 4001 } | 4008 } |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5224 if (!maybe_writable_elems->ToObject(&writable_elems)) { | 5231 if (!maybe_writable_elems->ToObject(&writable_elems)) { |
| 5225 return maybe_writable_elems; | 5232 return maybe_writable_elems; |
| 5226 } | 5233 } |
| 5227 } | 5234 } |
| 5228 set_elements(FixedArray::cast(writable_elems)); | 5235 set_elements(FixedArray::cast(writable_elems)); |
| 5229 isolate->counters()->cow_arrays_converted()->Increment(); | 5236 isolate->counters()->cow_arrays_converted()->Increment(); |
| 5230 return writable_elems; | 5237 return writable_elems; |
| 5231 } | 5238 } |
| 5232 | 5239 |
| 5233 | 5240 |
| 5234 StringDictionary* JSObject::property_dictionary() { | 5241 NameDictionary* JSObject::property_dictionary() { |
| 5235 ASSERT(!HasFastProperties()); | 5242 ASSERT(!HasFastProperties()); |
| 5236 return StringDictionary::cast(properties()); | 5243 return NameDictionary::cast(properties()); |
| 5237 } | 5244 } |
| 5238 | 5245 |
| 5239 | 5246 |
| 5240 SeededNumberDictionary* JSObject::element_dictionary() { | 5247 SeededNumberDictionary* JSObject::element_dictionary() { |
| 5241 ASSERT(HasDictionaryElements()); | 5248 ASSERT(HasDictionaryElements()); |
| 5242 return SeededNumberDictionary::cast(elements()); | 5249 return SeededNumberDictionary::cast(elements()); |
| 5243 } | 5250 } |
| 5244 | 5251 |
| 5245 | 5252 |
| 5246 bool Name::IsHashFieldComputed(uint32_t field) { | 5253 bool Name::IsHashFieldComputed(uint32_t field) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5349 template <typename schar> | 5356 template <typename schar> |
| 5350 uint32_t StringHasher::HashSequentialString(const schar* chars, | 5357 uint32_t StringHasher::HashSequentialString(const schar* chars, |
| 5351 int length, | 5358 int length, |
| 5352 uint32_t seed) { | 5359 uint32_t seed) { |
| 5353 StringHasher hasher(length, seed); | 5360 StringHasher hasher(length, seed); |
| 5354 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); | 5361 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); |
| 5355 return hasher.GetHashField(); | 5362 return hasher.GetHashField(); |
| 5356 } | 5363 } |
| 5357 | 5364 |
| 5358 | 5365 |
| 5366 bool Name::AsArrayIndex(uint32_t* index) { |
| 5367 return IsString() && String::cast(this)->AsArrayIndex(index); |
| 5368 } |
| 5369 |
| 5370 |
| 5359 bool String::AsArrayIndex(uint32_t* index) { | 5371 bool String::AsArrayIndex(uint32_t* index) { |
| 5360 uint32_t field = hash_field(); | 5372 uint32_t field = hash_field(); |
| 5361 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { | 5373 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { |
| 5362 return false; | 5374 return false; |
| 5363 } | 5375 } |
| 5364 return SlowAsArrayIndex(index); | 5376 return SlowAsArrayIndex(index); |
| 5365 } | 5377 } |
| 5366 | 5378 |
| 5367 | 5379 |
| 5368 Object* JSReceiver::GetPrototype() { | 5380 Object* JSReceiver::GetPrototype() { |
| 5369 return map()->prototype(); | 5381 return map()->prototype(); |
| 5370 } | 5382 } |
| 5371 | 5383 |
| 5372 | 5384 |
| 5373 Object* JSReceiver::GetConstructor() { | 5385 Object* JSReceiver::GetConstructor() { |
| 5374 return map()->constructor(); | 5386 return map()->constructor(); |
| 5375 } | 5387 } |
| 5376 | 5388 |
| 5377 | 5389 |
| 5378 bool JSReceiver::HasProperty(String* name) { | 5390 bool JSReceiver::HasProperty(Name* name) { |
| 5379 if (IsJSProxy()) { | 5391 if (IsJSProxy()) { |
| 5380 return JSProxy::cast(this)->HasPropertyWithHandler(name); | 5392 return JSProxy::cast(this)->HasPropertyWithHandler(name); |
| 5381 } | 5393 } |
| 5382 return GetPropertyAttribute(name) != ABSENT; | 5394 return GetPropertyAttribute(name) != ABSENT; |
| 5383 } | 5395 } |
| 5384 | 5396 |
| 5385 | 5397 |
| 5386 bool JSReceiver::HasLocalProperty(String* name) { | 5398 bool JSReceiver::HasLocalProperty(Name* name) { |
| 5387 if (IsJSProxy()) { | 5399 if (IsJSProxy()) { |
| 5388 return JSProxy::cast(this)->HasPropertyWithHandler(name); | 5400 return JSProxy::cast(this)->HasPropertyWithHandler(name); |
| 5389 } | 5401 } |
| 5390 return GetLocalPropertyAttribute(name) != ABSENT; | 5402 return GetLocalPropertyAttribute(name) != ABSENT; |
| 5391 } | 5403 } |
| 5392 | 5404 |
| 5393 | 5405 |
| 5394 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) { | 5406 PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) { |
| 5395 uint32_t index; | 5407 uint32_t index; |
| 5396 if (IsJSObject() && key->AsArrayIndex(&index)) { | 5408 if (IsJSObject() && key->AsArrayIndex(&index)) { |
| 5397 return GetElementAttribute(index); | 5409 return GetElementAttribute(index); |
| 5398 } | 5410 } |
| 5399 return GetPropertyAttributeWithReceiver(this, key); | 5411 return GetPropertyAttributeWithReceiver(this, key); |
| 5400 } | 5412 } |
| 5401 | 5413 |
| 5402 | 5414 |
| 5403 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) { | 5415 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) { |
| 5404 if (IsJSProxy()) { | 5416 if (IsJSProxy()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5509 Object* value) { | 5521 Object* value) { |
| 5510 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 5522 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
| 5511 } | 5523 } |
| 5512 | 5524 |
| 5513 | 5525 |
| 5514 template<typename Shape, typename Key> | 5526 template<typename Shape, typename Key> |
| 5515 void Dictionary<Shape, Key>::SetEntry(int entry, | 5527 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 5516 Object* key, | 5528 Object* key, |
| 5517 Object* value, | 5529 Object* value, |
| 5518 PropertyDetails details) { | 5530 PropertyDetails details) { |
| 5519 ASSERT(!key->IsString() || | 5531 ASSERT(!key->IsName() || |
| 5520 details.IsDeleted() || | 5532 details.IsDeleted() || |
| 5521 details.dictionary_index() > 0); | 5533 details.dictionary_index() > 0); |
| 5522 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 5534 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 5523 AssertNoAllocation no_gc; | 5535 AssertNoAllocation no_gc; |
| 5524 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 5536 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 5525 FixedArray::set(index, key, mode); | 5537 FixedArray::set(index, key, mode); |
| 5526 FixedArray::set(index+1, value, mode); | 5538 FixedArray::set(index+1, value, mode); |
| 5527 FixedArray::set(index+2, details.AsSmi()); | 5539 FixedArray::set(index+2, details.AsSmi()); |
| 5528 } | 5540 } |
| 5529 | 5541 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5554 Object* other) { | 5566 Object* other) { |
| 5555 ASSERT(other->IsNumber()); | 5567 ASSERT(other->IsNumber()); |
| 5556 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 5568 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
| 5557 } | 5569 } |
| 5558 | 5570 |
| 5559 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { | 5571 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { |
| 5560 return Isolate::Current()->heap()->NumberFromUint32(key); | 5572 return Isolate::Current()->heap()->NumberFromUint32(key); |
| 5561 } | 5573 } |
| 5562 | 5574 |
| 5563 | 5575 |
| 5564 bool StringDictionaryShape::IsMatch(String* key, Object* other) { | 5576 bool NameDictionaryShape::IsMatch(Name* key, Object* other) { |
| 5565 // We know that all entries in a hash table had their hash keys created. | 5577 // We know that all entries in a hash table had their hash keys created. |
| 5566 // Use that knowledge to have fast failure. | 5578 // Use that knowledge to have fast failure. |
| 5567 if (key->Hash() != String::cast(other)->Hash()) return false; | 5579 if (key->Hash() != Name::cast(other)->Hash()) return false; |
| 5568 return key->Equals(String::cast(other)); | 5580 return key->Equals(Name::cast(other)); |
| 5569 } | 5581 } |
| 5570 | 5582 |
| 5571 | 5583 |
| 5572 uint32_t StringDictionaryShape::Hash(String* key) { | 5584 uint32_t NameDictionaryShape::Hash(Name* key) { |
| 5573 return key->Hash(); | 5585 return key->Hash(); |
| 5574 } | 5586 } |
| 5575 | 5587 |
| 5576 | 5588 |
| 5577 uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) { | 5589 uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) { |
| 5578 return String::cast(other)->Hash(); | 5590 return Name::cast(other)->Hash(); |
| 5579 } | 5591 } |
| 5580 | 5592 |
| 5581 | 5593 |
| 5582 MaybeObject* StringDictionaryShape::AsObject(String* key) { | 5594 MaybeObject* NameDictionaryShape::AsObject(Name* key) { |
| 5583 return key; | 5595 return key; |
| 5584 } | 5596 } |
| 5585 | 5597 |
| 5586 | 5598 |
| 5587 template <int entrysize> | 5599 template <int entrysize> |
| 5588 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { | 5600 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { |
| 5589 return key->SameValue(other); | 5601 return key->SameValue(other); |
| 5590 } | 5602 } |
| 5591 | 5603 |
| 5592 | 5604 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5904 #undef WRITE_UINT32_FIELD | 5916 #undef WRITE_UINT32_FIELD |
| 5905 #undef READ_SHORT_FIELD | 5917 #undef READ_SHORT_FIELD |
| 5906 #undef WRITE_SHORT_FIELD | 5918 #undef WRITE_SHORT_FIELD |
| 5907 #undef READ_BYTE_FIELD | 5919 #undef READ_BYTE_FIELD |
| 5908 #undef WRITE_BYTE_FIELD | 5920 #undef WRITE_BYTE_FIELD |
| 5909 | 5921 |
| 5910 | 5922 |
| 5911 } } // namespace v8::internal | 5923 } } // namespace v8::internal |
| 5912 | 5924 |
| 5913 #endif // V8_OBJECTS_INL_H_ | 5925 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |