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 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 // Additionally, we need to make sure that we do not cache results | 2626 // Additionally, we need to make sure that we do not cache results |
2627 // for objects that require access checks. | 2627 // for objects that require access checks. |
2628 if (args[0]->IsJSObject() && | 2628 if (args[0]->IsJSObject() && |
2629 !args[0]->IsJSGlobalProxy() && | 2629 !args[0]->IsJSGlobalProxy() && |
2630 !args[0]->IsAccessCheckNeeded() && | 2630 !args[0]->IsAccessCheckNeeded() && |
2631 args[1]->IsString()) { | 2631 args[1]->IsString()) { |
2632 JSObject* receiver = JSObject::cast(args[0]); | 2632 JSObject* receiver = JSObject::cast(args[0]); |
2633 String* key = String::cast(args[1]); | 2633 String* key = String::cast(args[1]); |
2634 if (receiver->HasFastProperties()) { | 2634 if (receiver->HasFastProperties()) { |
2635 // Attempt to use lookup cache. | 2635 // Attempt to use lookup cache. |
2636 Object* obj = Heap::GetKeyedLookupCache(); | |
2637 if (obj->IsFailure()) return obj; | |
2638 LookupCache* cache = LookupCache::cast(obj); | |
2639 Map* receiver_map = receiver->map(); | 2636 Map* receiver_map = receiver->map(); |
2640 int offset = cache->Lookup(receiver_map, key); | 2637 int offset = KeyedLookupCache::Lookup(receiver_map, key); |
2641 if (offset != LookupCache::kNotFound) { | 2638 if (offset != -1) { |
2642 Object* value = receiver->FastPropertyAt(offset); | 2639 Object* value = receiver->FastPropertyAt(offset); |
2643 return value->IsTheHole() ? Heap::undefined_value() : value; | 2640 return value->IsTheHole() ? Heap::undefined_value() : value; |
2644 } | 2641 } |
2645 // Lookup cache miss. Perform lookup and update the cache if | 2642 // Lookup cache miss. Perform lookup and update the cache if |
2646 // appropriate. | 2643 // appropriate. |
2647 LookupResult result; | 2644 LookupResult result; |
2648 receiver->LocalLookup(key, &result); | 2645 receiver->LocalLookup(key, &result); |
2649 if (result.IsProperty() && result.IsLoaded() && result.type() == FIELD) { | 2646 if (result.IsProperty() && result.IsLoaded() && result.type() == FIELD) { |
2650 int offset = result.GetFieldIndex(); | 2647 int offset = result.GetFieldIndex(); |
2651 Object* obj = cache->Put(receiver_map, key, offset); | 2648 KeyedLookupCache::Update(receiver_map, key, offset); |
2652 if (obj->IsFailure()) return obj; | |
2653 Heap::SetKeyedLookupCache(LookupCache::cast(obj)); | |
2654 Object* value = receiver->FastPropertyAt(offset); | 2649 Object* value = receiver->FastPropertyAt(offset); |
2655 return value->IsTheHole() ? Heap::undefined_value() : value; | 2650 return value->IsTheHole() ? Heap::undefined_value() : value; |
2656 } | 2651 } |
2657 } else { | 2652 } else { |
2658 // Attempt dictionary lookup. | 2653 // Attempt dictionary lookup. |
2659 Dictionary* dictionary = receiver->property_dictionary(); | 2654 Dictionary* dictionary = receiver->property_dictionary(); |
2660 int entry = dictionary->FindStringEntry(key); | 2655 int entry = dictionary->FindStringEntry(key); |
2661 if ((entry != DescriptorArray::kNotFound) && | 2656 if ((entry != DescriptorArray::kNotFound) && |
2662 (dictionary->DetailsAt(entry).type() == NORMAL)) { | 2657 (dictionary->DetailsAt(entry).type() == NORMAL)) { |
2663 return dictionary->ValueAt(entry); | 2658 return dictionary->ValueAt(entry); |
(...skipping 4804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7468 } else { | 7463 } else { |
7469 // Handle last resort GC and make sure to allow future allocations | 7464 // Handle last resort GC and make sure to allow future allocations |
7470 // to grow the heap without causing GCs (if possible). | 7465 // to grow the heap without causing GCs (if possible). |
7471 Counters::gc_last_resort_from_js.Increment(); | 7466 Counters::gc_last_resort_from_js.Increment(); |
7472 Heap::CollectAllGarbage(); | 7467 Heap::CollectAllGarbage(); |
7473 } | 7468 } |
7474 } | 7469 } |
7475 | 7470 |
7476 | 7471 |
7477 } } // namespace v8::internal | 7472 } } // namespace v8::internal |
OLD | NEW |