OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 // Initialize compilation cache. | 2252 // Initialize compilation cache. |
2253 isolate_->compilation_cache()->Clear(); | 2253 isolate_->compilation_cache()->Clear(); |
2254 | 2254 |
2255 return true; | 2255 return true; |
2256 } | 2256 } |
2257 | 2257 |
2258 | 2258 |
2259 Object* StringSplitCache::Lookup( | 2259 Object* StringSplitCache::Lookup( |
2260 FixedArray* cache, String* string, String* pattern) { | 2260 FixedArray* cache, String* string, String* pattern) { |
2261 if (!string->IsSymbol() || !pattern->IsSymbol()) return Smi::FromInt(0); | 2261 if (!string->IsSymbol() || !pattern->IsSymbol()) return Smi::FromInt(0); |
2262 uintptr_t hash = string->Hash(); | 2262 uint32_t hash = string->Hash(); |
2263 uintptr_t index = ((hash & (kStringSplitCacheSize - 1)) & | 2263 uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & |
2264 ~(kArrayEntriesPerCacheEntry - 1)); | 2264 ~(kArrayEntriesPerCacheEntry - 1)); |
2265 if (cache->get(index + kStringOffset) == string && | 2265 if (cache->get(index + kStringOffset) == string && |
2266 cache->get(index + kPatternOffset) == pattern) { | 2266 cache->get(index + kPatternOffset) == pattern) { |
2267 return cache->get(index + kArrayOffset); | 2267 return cache->get(index + kArrayOffset); |
2268 } | 2268 } |
2269 index = ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); | 2269 index = ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); |
2270 if (cache->get(index + kStringOffset) == string && | 2270 if (cache->get(index + kStringOffset) == string && |
2271 cache->get(index + kPatternOffset) == pattern) { | 2271 cache->get(index + kPatternOffset) == pattern) { |
2272 return cache->get(index + kArrayOffset); | 2272 return cache->get(index + kArrayOffset); |
2273 } | 2273 } |
2274 return Smi::FromInt(0); | 2274 return Smi::FromInt(0); |
2275 } | 2275 } |
2276 | 2276 |
2277 | 2277 |
2278 void StringSplitCache::Enter(Heap* heap, | 2278 void StringSplitCache::Enter(Heap* heap, |
2279 FixedArray* cache, | 2279 FixedArray* cache, |
2280 String* string, | 2280 String* string, |
2281 String* pattern, | 2281 String* pattern, |
2282 FixedArray* array) { | 2282 FixedArray* array) { |
2283 if (!string->IsSymbol() || !pattern->IsSymbol()) return; | 2283 if (!string->IsSymbol() || !pattern->IsSymbol()) return; |
2284 uintptr_t hash = string->Hash(); | 2284 uint32_t hash = string->Hash(); |
2285 uintptr_t index = ((hash & (kStringSplitCacheSize - 1)) & | 2285 uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & |
2286 ~(kArrayEntriesPerCacheEntry - 1)); | 2286 ~(kArrayEntriesPerCacheEntry - 1)); |
2287 if (cache->get(index + kStringOffset) == Smi::FromInt(0)) { | 2287 if (cache->get(index + kStringOffset) == Smi::FromInt(0)) { |
2288 cache->set(index + kStringOffset, string); | 2288 cache->set(index + kStringOffset, string); |
2289 cache->set(index + kPatternOffset, pattern); | 2289 cache->set(index + kPatternOffset, pattern); |
2290 cache->set(index + kArrayOffset, array); | 2290 cache->set(index + kArrayOffset, array); |
2291 return; | 2291 return; |
2292 } | 2292 } |
2293 uintptr_t index2 = | 2293 uint32_t index2 = |
2294 ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); | 2294 ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); |
2295 if (cache->get(index2 + kStringOffset) == Smi::FromInt(0)) { | 2295 if (cache->get(index2 + kStringOffset) == Smi::FromInt(0)) { |
2296 cache->set(index2 + kStringOffset, string); | 2296 cache->set(index2 + kStringOffset, string); |
2297 cache->set(index2 + kPatternOffset, pattern); | 2297 cache->set(index2 + kPatternOffset, pattern); |
2298 cache->set(index2 + kArrayOffset, array); | 2298 cache->set(index2 + kArrayOffset, array); |
2299 return; | 2299 return; |
2300 } | 2300 } |
2301 cache->set(index2 + kStringOffset, Smi::FromInt(0)); | 2301 cache->set(index2 + kStringOffset, Smi::FromInt(0)); |
2302 cache->set(index2 + kPatternOffset, Smi::FromInt(0)); | 2302 cache->set(index2 + kPatternOffset, Smi::FromInt(0)); |
2303 cache->set(index2 + kArrayOffset, Smi::FromInt(0)); | 2303 cache->set(index2 + kArrayOffset, Smi::FromInt(0)); |
(...skipping 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6226 } | 6226 } |
6227 | 6227 |
6228 | 6228 |
6229 void ExternalStringTable::TearDown() { | 6229 void ExternalStringTable::TearDown() { |
6230 new_space_strings_.Free(); | 6230 new_space_strings_.Free(); |
6231 old_space_strings_.Free(); | 6231 old_space_strings_.Free(); |
6232 } | 6232 } |
6233 | 6233 |
6234 | 6234 |
6235 } } // namespace v8::internal | 6235 } } // namespace v8::internal |
OLD | NEW |