| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 *p = first_word.ToForwardingAddress(); | 806 *p = first_word.ToForwardingAddress(); |
| 807 return; | 807 return; |
| 808 } | 808 } |
| 809 | 809 |
| 810 // Call the slow part of scavenge object. | 810 // Call the slow part of scavenge object. |
| 811 return ScavengeObjectSlow(p, object); | 811 return ScavengeObjectSlow(p, object); |
| 812 } | 812 } |
| 813 | 813 |
| 814 | 814 |
| 815 static inline bool IsShortcutCandidate(HeapObject* object, Map* map) { | 815 static inline bool IsShortcutCandidate(HeapObject* object, Map* map) { |
| 816 // A ConsString object with Heap::empty_string() as the right side | 816 // A ConsString with an empty string as the right side is a |
| 817 // is a candidate for being shortcut by the scavenger. | 817 // candidate for being shortcut by the scavenger unless it is a |
| 818 // symbol. It's not common to have non-flat symbols, so we do not |
| 819 // shortcut them thereby avoiding turning symbols into strings. |
| 820 ASSERT(kNotStringTag != 0 && kSymbolTag != 0); |
| 821 static const uint32_t kShortcutTypeMask = |
| 822 kIsNotStringMask | |
| 823 kIsSymbolMask | |
| 824 kStringRepresentationMask; |
| 818 ASSERT(object->map() == map); | 825 ASSERT(object->map() == map); |
| 819 if (map->instance_type() >= FIRST_NONSTRING_TYPE) return false; | 826 InstanceType type = map->instance_type(); |
| 820 return (StringShape(map).representation_tag() == kConsStringTag) && | 827 if ((type & kShortcutTypeMask) != kConsStringTag) return false; |
| 821 (ConsString::cast(object)->unchecked_second() == Heap::empty_string()); | 828 ASSERT(object->IsString() && !object->IsSymbol()); |
| 829 return ConsString::cast(object)->unchecked_second() == Heap::empty_string(); |
| 822 } | 830 } |
| 823 | 831 |
| 824 | 832 |
| 825 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { | 833 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { |
| 826 ASSERT(InFromSpace(object)); | 834 ASSERT(InFromSpace(object)); |
| 827 MapWord first_word = object->map_word(); | 835 MapWord first_word = object->map_word(); |
| 828 ASSERT(!first_word.IsForwardingAddress()); | 836 ASSERT(!first_word.IsForwardingAddress()); |
| 829 | 837 |
| 830 // Optimization: Bypass flattened ConsString objects. | 838 // Optimization: Bypass flattened ConsString objects. |
| 831 if (IsShortcutCandidate(object, first_word.ToMap())) { | 839 if (IsShortcutCandidate(object, first_word.ToMap())) { |
| (...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3355 #ifdef DEBUG | 3363 #ifdef DEBUG |
| 3356 bool Heap::GarbageCollectionGreedyCheck() { | 3364 bool Heap::GarbageCollectionGreedyCheck() { |
| 3357 ASSERT(FLAG_gc_greedy); | 3365 ASSERT(FLAG_gc_greedy); |
| 3358 if (Bootstrapper::IsActive()) return true; | 3366 if (Bootstrapper::IsActive()) return true; |
| 3359 if (disallow_allocation_failure()) return true; | 3367 if (disallow_allocation_failure()) return true; |
| 3360 return CollectGarbage(0, NEW_SPACE); | 3368 return CollectGarbage(0, NEW_SPACE); |
| 3361 } | 3369 } |
| 3362 #endif | 3370 #endif |
| 3363 | 3371 |
| 3364 } } // namespace v8::internal | 3372 } } // namespace v8::internal |
| OLD | NEW |