| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 2970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 Object* Map::FindInCodeCache(String* name, Code::Flags flags) { | 2981 Object* Map::FindInCodeCache(String* name, Code::Flags flags) { |
| 2982 // Do a lookup if a code cache exists. | 2982 // Do a lookup if a code cache exists. |
| 2983 if (!code_cache()->IsFixedArray()) { | 2983 if (!code_cache()->IsFixedArray()) { |
| 2984 return CodeCache::cast(code_cache())->Lookup(name, flags); | 2984 return CodeCache::cast(code_cache())->Lookup(name, flags); |
| 2985 } else { | 2985 } else { |
| 2986 return Heap::undefined_value(); | 2986 return Heap::undefined_value(); |
| 2987 } | 2987 } |
| 2988 } | 2988 } |
| 2989 | 2989 |
| 2990 | 2990 |
| 2991 int Map::IndexInCodeCache(String* name, Code* code) { | 2991 int Map::IndexInCodeCache(Object* name, Code* code) { |
| 2992 // Get the internal index if a code cache exists. | 2992 // Get the internal index if a code cache exists. |
| 2993 if (!code_cache()->IsFixedArray()) { | 2993 if (!code_cache()->IsFixedArray()) { |
| 2994 return CodeCache::cast(code_cache())->GetIndex(name, code); | 2994 return CodeCache::cast(code_cache())->GetIndex(name, code); |
| 2995 } | 2995 } |
| 2996 return -1; | 2996 return -1; |
| 2997 } | 2997 } |
| 2998 | 2998 |
| 2999 | 2999 |
| 3000 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { | 3000 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { |
| 3001 // No GC is supposed to happen between a call to IndexInCodeCache and | 3001 // No GC is supposed to happen between a call to IndexInCodeCache and |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) { | 3126 Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) { |
| 3127 if (!normal_type_cache()->IsUndefined()) { | 3127 if (!normal_type_cache()->IsUndefined()) { |
| 3128 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 3128 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
| 3129 return cache->Lookup(name, flags); | 3129 return cache->Lookup(name, flags); |
| 3130 } else { | 3130 } else { |
| 3131 return Heap::undefined_value(); | 3131 return Heap::undefined_value(); |
| 3132 } | 3132 } |
| 3133 } | 3133 } |
| 3134 | 3134 |
| 3135 | 3135 |
| 3136 int CodeCache::GetIndex(String* name, Code* code) { | 3136 int CodeCache::GetIndex(Object* name, Code* code) { |
| 3137 // This is not used for normal load/store/call IC's. | |
| 3138 if (code->type() == NORMAL) { | 3137 if (code->type() == NORMAL) { |
| 3139 if (normal_type_cache()->IsUndefined()) return -1; | 3138 if (normal_type_cache()->IsUndefined()) return -1; |
| 3140 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 3139 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
| 3141 return cache->GetIndex(name, code->flags()); | 3140 return cache->GetIndex(String::cast(name), code->flags()); |
| 3142 } | 3141 } |
| 3143 | 3142 |
| 3144 FixedArray* array = default_cache(); | 3143 FixedArray* array = default_cache(); |
| 3145 int len = array->length(); | 3144 int len = array->length(); |
| 3146 for (int i = 0; i < len; i += kCodeCacheEntrySize) { | 3145 for (int i = 0; i < len; i += kCodeCacheEntrySize) { |
| 3147 if (array->get(i + kCodeCacheEntryCodeOffset) == code) return i + 1; | 3146 if (array->get(i + kCodeCacheEntryCodeOffset) == code) return i + 1; |
| 3148 } | 3147 } |
| 3149 return -1; | 3148 return -1; |
| 3150 } | 3149 } |
| 3151 | 3150 |
| 3152 | 3151 |
| 3153 void CodeCache::RemoveByIndex(String* name, Code* code, int index) { | 3152 void CodeCache::RemoveByIndex(Object* name, Code* code, int index) { |
| 3154 if (code->type() == NORMAL) { | 3153 if (code->type() == NORMAL) { |
| 3155 ASSERT(!normal_type_cache()->IsUndefined()); | 3154 ASSERT(!normal_type_cache()->IsUndefined()); |
| 3156 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); | 3155 CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache()); |
| 3157 ASSERT(cache->GetIndex(name, code->flags()) == index); | 3156 ASSERT(cache->GetIndex(String::cast(name), code->flags()) == index); |
| 3158 cache->RemoveByIndex(index); | 3157 cache->RemoveByIndex(index); |
| 3159 } else { | 3158 } else { |
| 3160 FixedArray* array = default_cache(); | 3159 FixedArray* array = default_cache(); |
| 3161 ASSERT(array->length() >= index && array->get(index)->IsCode()); | 3160 ASSERT(array->length() >= index && array->get(index)->IsCode()); |
| 3162 // Use null instead of undefined for deleted elements to distinguish | 3161 // Use null instead of undefined for deleted elements to distinguish |
| 3163 // deleted elements from unused elements. This distinction is used | 3162 // deleted elements from unused elements. This distinction is used |
| 3164 // when looking up in the cache and when updating the cache. | 3163 // when looking up in the cache and when updating the cache. |
| 3165 ASSERT_EQ(1, kCodeCacheEntryCodeOffset - kCodeCacheEntryNameOffset); | 3164 ASSERT_EQ(1, kCodeCacheEntryCodeOffset - kCodeCacheEntryNameOffset); |
| 3166 array->set_null(index - 1); // Name. | 3165 array->set_null(index - 1); // Name. |
| 3167 array->set_null(index); // Code. | 3166 array->set_null(index); // Code. |
| (...skipping 5345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8513 if (break_point_objects()->IsUndefined()) return 0; | 8512 if (break_point_objects()->IsUndefined()) return 0; |
| 8514 // Single beak point. | 8513 // Single beak point. |
| 8515 if (!break_point_objects()->IsFixedArray()) return 1; | 8514 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8516 // Multiple break points. | 8515 // Multiple break points. |
| 8517 return FixedArray::cast(break_point_objects())->length(); | 8516 return FixedArray::cast(break_point_objects())->length(); |
| 8518 } | 8517 } |
| 8519 #endif | 8518 #endif |
| 8520 | 8519 |
| 8521 | 8520 |
| 8522 } } // namespace v8::internal | 8521 } } // namespace v8::internal |
| OLD | NEW |