| 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 3695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3706 | 3706 |
| 3707 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { | 3707 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { |
| 3708 // No GC is supposed to happen between a call to IndexInCodeCache and | 3708 // No GC is supposed to happen between a call to IndexInCodeCache and |
| 3709 // RemoveFromCodeCache so the code cache must be there. | 3709 // RemoveFromCodeCache so the code cache must be there. |
| 3710 ASSERT(!code_cache()->IsFixedArray()); | 3710 ASSERT(!code_cache()->IsFixedArray()); |
| 3711 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); | 3711 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); |
| 3712 } | 3712 } |
| 3713 | 3713 |
| 3714 | 3714 |
| 3715 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { | 3715 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { |
| 3716 // Traverse the transition tree without using a stack. We do this by |
| 3717 // reversing the pointers in the maps and descriptor arrays. |
| 3716 Map* current = this; | 3718 Map* current = this; |
| 3717 Map* meta_map = heap()->meta_map(); | 3719 Map* meta_map = heap()->meta_map(); |
| 3720 Object** map_or_index_field = NULL; |
| 3718 while (current != meta_map) { | 3721 while (current != meta_map) { |
| 3719 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( | 3722 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( |
| 3720 *RawField(current, Map::kInstanceDescriptorsOffset)); | 3723 *RawField(current, Map::kInstanceDescriptorsOffset)); |
| 3721 if (d == heap()->empty_descriptor_array()) { | 3724 if (!d->IsEmpty()) { |
| 3722 Map* prev = current->map(); | 3725 FixedArray* contents = reinterpret_cast<FixedArray*>( |
| 3723 current->set_map(meta_map); | 3726 d->get(DescriptorArray::kContentArrayIndex)); |
| 3724 callback(current, data); | 3727 map_or_index_field = RawField(contents, HeapObject::kMapOffset); |
| 3725 current = prev; | 3728 Object* map_or_index = *map_or_index_field; |
| 3726 continue; | 3729 bool map_done = true; // Controls a nested continue statement. |
| 3730 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; |
| 3731 i < contents->length(); |
| 3732 i += 2) { |
| 3733 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
| 3734 if (details.IsTransition()) { |
| 3735 // Found a map in the transition array. We record our progress in |
| 3736 // the transition array by recording the current map in the map field |
| 3737 // of the next map and recording the index in the transition array in |
| 3738 // the map field of the array. |
| 3739 Map* next = Map::cast(contents->get(i)); |
| 3740 next->set_map(current); |
| 3741 *map_or_index_field = Smi::FromInt(i + 2); |
| 3742 current = next; |
| 3743 map_done = false; |
| 3744 break; |
| 3745 } |
| 3746 } |
| 3747 if (!map_done) continue; |
| 3748 } |
| 3749 // That was the regular transitions, now for the prototype transitions. |
| 3750 FixedArray* prototype_transitions = |
| 3751 current->unchecked_prototype_transitions(); |
| 3752 Object** proto_map_or_index_field = |
| 3753 RawField(prototype_transitions, HeapObject::kMapOffset); |
| 3754 Object* map_or_index = *proto_map_or_index_field; |
| 3755 const int start = 2; |
| 3756 int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : start; |
| 3757 if (i < prototype_transitions->length()) { |
| 3758 // Found a map in the prototype transition array. Record progress in |
| 3759 // an analogous way to the regular transitions array above. |
| 3760 Object* perhaps_map = prototype_transitions->get(i); |
| 3761 if (perhaps_map->IsMap()) { |
| 3762 Map* next = Map::cast(perhaps_map); |
| 3763 next->set_map(current); |
| 3764 *proto_map_or_index_field = |
| 3765 Smi::FromInt(i + 2); |
| 3766 current = next; |
| 3767 continue; |
| 3768 } |
| 3769 } |
| 3770 *proto_map_or_index_field = heap()->fixed_array_map(); |
| 3771 if (map_or_index_field != NULL) { |
| 3772 *map_or_index_field = heap()->fixed_array_map(); |
| 3727 } | 3773 } |
| 3728 | 3774 |
| 3729 FixedArray* contents = reinterpret_cast<FixedArray*>( | 3775 // The callback expects a map to have a real map as its map, so we save |
| 3730 d->get(DescriptorArray::kContentArrayIndex)); | 3776 // the map field, which is being used to track the traversal and put the |
| 3731 Object** map_or_index_field = RawField(contents, HeapObject::kMapOffset); | 3777 // correct map (the meta_map) in place while we do the callback. |
| 3732 Object* map_or_index = *map_or_index_field; | |
| 3733 bool map_done = true; | |
| 3734 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; | |
| 3735 i < contents->length(); | |
| 3736 i += 2) { | |
| 3737 PropertyDetails details(Smi::cast(contents->get(i + 1))); | |
| 3738 if (details.IsTransition()) { | |
| 3739 Map* next = reinterpret_cast<Map*>(contents->get(i)); | |
| 3740 next->set_map(current); | |
| 3741 *map_or_index_field = Smi::FromInt(i + 2); | |
| 3742 current = next; | |
| 3743 map_done = false; | |
| 3744 break; | |
| 3745 } | |
| 3746 } | |
| 3747 if (!map_done) continue; | |
| 3748 *map_or_index_field = heap()->fixed_array_map(); | |
| 3749 Map* prev = current->map(); | 3778 Map* prev = current->map(); |
| 3750 current->set_map(meta_map); | 3779 current->set_map(meta_map); |
| 3751 callback(current, data); | 3780 callback(current, data); |
| 3752 current = prev; | 3781 current = prev; |
| 3753 } | 3782 } |
| 3754 } | 3783 } |
| 3755 | 3784 |
| 3756 | 3785 |
| 3757 MaybeObject* CodeCache::Update(String* name, Code* code) { | 3786 MaybeObject* CodeCache::Update(String* name, Code* code) { |
| 3758 ASSERT(code->ic_state() == MONOMORPHIC); | 3787 ASSERT(code->ic_state() == MONOMORPHIC); |
| (...skipping 6615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10374 if (break_point_objects()->IsUndefined()) return 0; | 10403 if (break_point_objects()->IsUndefined()) return 0; |
| 10375 // Single beak point. | 10404 // Single beak point. |
| 10376 if (!break_point_objects()->IsFixedArray()) return 1; | 10405 if (!break_point_objects()->IsFixedArray()) return 1; |
| 10377 // Multiple break points. | 10406 // Multiple break points. |
| 10378 return FixedArray::cast(break_point_objects())->length(); | 10407 return FixedArray::cast(break_point_objects())->length(); |
| 10379 } | 10408 } |
| 10380 #endif | 10409 #endif |
| 10381 | 10410 |
| 10382 | 10411 |
| 10383 } } // namespace v8::internal | 10412 } } // namespace v8::internal |
| OLD | NEW |