OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 7321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7332 Object* new_cache; | 7332 Object* new_cache; |
7333 { MaybeObject* maybe_new_cache = cache->Put(name, code); | 7333 { MaybeObject* maybe_new_cache = cache->Put(name, code); |
7334 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; | 7334 if (!maybe_new_cache->ToObject(&new_cache)) return maybe_new_cache; |
7335 } | 7335 } |
7336 set_normal_type_cache(new_cache); | 7336 set_normal_type_cache(new_cache); |
7337 return this; | 7337 return this; |
7338 } | 7338 } |
7339 | 7339 |
7340 | 7340 |
7341 Object* CodeCache::Lookup(Name* name, Code::Flags flags) { | 7341 Object* CodeCache::Lookup(Name* name, Code::Flags flags) { |
7342 if (Code::ExtractTypeFromFlags(flags) == Code::NORMAL) { | 7342 flags = Code::RemoveTypeFromFlags(flags); |
7343 return LookupNormalTypeCache(name, flags); | 7343 Object* result = LookupDefaultCache(name, flags); |
7344 } else { | 7344 if (result->IsCode()) return result; |
7345 return LookupDefaultCache(name, flags); | 7345 return LookupNormalTypeCache(name, flags); |
7346 } | |
7347 } | 7346 } |
7348 | 7347 |
7349 | 7348 |
7350 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { | 7349 Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { |
7351 FixedArray* cache = default_cache(); | 7350 FixedArray* cache = default_cache(); |
7352 int length = cache->length(); | 7351 int length = cache->length(); |
7353 for (int i = 0; i < length; i += kCodeCacheEntrySize) { | 7352 for (int i = 0; i < length; i += kCodeCacheEntrySize) { |
7354 Object* key = cache->get(i + kCodeCacheEntryNameOffset); | 7353 Object* key = cache->get(i + kCodeCacheEntryNameOffset); |
7355 // Skip deleted elements. | 7354 // Skip deleted elements. |
7356 if (key->IsNull()) continue; | 7355 if (key->IsNull()) continue; |
7357 if (key->IsUndefined()) return key; | 7356 if (key->IsUndefined()) return key; |
7358 if (name->Equals(Name::cast(key))) { | 7357 if (name->Equals(Name::cast(key))) { |
7359 Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset)); | 7358 Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset)); |
7360 if (code->flags() == flags) { | 7359 if (Code::RemoveTypeFromFlags(code->flags()) == flags) { |
7361 return code; | 7360 return code; |
7362 } | 7361 } |
7363 } | 7362 } |
7364 } | 7363 } |
7365 return GetHeap()->undefined_value(); | 7364 return GetHeap()->undefined_value(); |
7366 } | 7365 } |
7367 | 7366 |
7368 | 7367 |
7369 Object* CodeCache::LookupNormalTypeCache(Name* name, Code::Flags flags) { | 7368 Object* CodeCache::LookupNormalTypeCache(Name* name, Code::Flags flags) { |
7370 if (!normal_type_cache()->IsUndefined()) { | 7369 if (!normal_type_cache()->IsUndefined()) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7414 // The key in the code cache hash table consists of the property name and the | 7413 // The key in the code cache hash table consists of the property name and the |
7415 // code object. The actual match is on the name and the code flags. If a key | 7414 // code object. The actual match is on the name and the code flags. If a key |
7416 // is created using the flags and not a code object it can only be used for | 7415 // is created using the flags and not a code object it can only be used for |
7417 // lookup not to create a new entry. | 7416 // lookup not to create a new entry. |
7418 class CodeCacheHashTableKey : public HashTableKey { | 7417 class CodeCacheHashTableKey : public HashTableKey { |
7419 public: | 7418 public: |
7420 CodeCacheHashTableKey(Name* name, Code::Flags flags) | 7419 CodeCacheHashTableKey(Name* name, Code::Flags flags) |
7421 : name_(name), flags_(flags), code_(NULL) { } | 7420 : name_(name), flags_(flags), code_(NULL) { } |
7422 | 7421 |
7423 CodeCacheHashTableKey(Name* name, Code* code) | 7422 CodeCacheHashTableKey(Name* name, Code* code) |
7424 : name_(name), | 7423 : name_(name), flags_(code->flags()), code_(code) { } |
7425 flags_(code->flags()), | |
7426 code_(code) { } | |
7427 | 7424 |
7428 | 7425 |
7429 bool IsMatch(Object* other) { | 7426 bool IsMatch(Object* other) { |
7430 if (!other->IsFixedArray()) return false; | 7427 if (!other->IsFixedArray()) return false; |
7431 FixedArray* pair = FixedArray::cast(other); | 7428 FixedArray* pair = FixedArray::cast(other); |
7432 Name* name = Name::cast(pair->get(0)); | 7429 Name* name = Name::cast(pair->get(0)); |
7433 Code::Flags flags = Code::cast(pair->get(1))->flags(); | 7430 Code::Flags flags = Code::cast(pair->get(1))->flags(); |
7434 if (flags != flags_) { | 7431 if (flags != flags_) { |
7435 return false; | 7432 return false; |
7436 } | 7433 } |
(...skipping 8732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16169 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16166 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16170 static const char* error_messages_[] = { | 16167 static const char* error_messages_[] = { |
16171 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16168 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16172 }; | 16169 }; |
16173 #undef ERROR_MESSAGES_TEXTS | 16170 #undef ERROR_MESSAGES_TEXTS |
16174 return error_messages_[reason]; | 16171 return error_messages_[reason]; |
16175 } | 16172 } |
16176 | 16173 |
16177 | 16174 |
16178 } } // namespace v8::internal | 16175 } } // namespace v8::internal |
OLD | NEW |