OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1058 RecordSlot(code_slot, code_slot, *code_slot); | 1058 RecordSlot(code_slot, code_slot, *code_slot); |
1059 | 1059 |
1060 candidate = next_candidate; | 1060 candidate = next_candidate; |
1061 } | 1061 } |
1062 | 1062 |
1063 shared_function_info_candidates_head_ = NULL; | 1063 shared_function_info_candidates_head_ = NULL; |
1064 } | 1064 } |
1065 | 1065 |
1066 | 1066 |
1067 void CodeFlusher::ProcessOptimizedCodeMaps() { | 1067 void CodeFlusher::ProcessOptimizedCodeMaps() { |
1068 static const int kEntriesStart = SharedFunctionInfo::kEntriesStart; | 1068 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4); |
1069 static const int kEntryLength = SharedFunctionInfo::kEntryLength; | |
1070 static const int kContextOffset = 0; | |
1071 static const int kCodeOffset = 1; | |
1072 static const int kLiteralsOffset = 2; | |
1073 STATIC_ASSERT(kEntryLength == 3); | |
1074 | 1069 |
1075 SharedFunctionInfo* holder = optimized_code_map_holder_head_; | 1070 SharedFunctionInfo* holder = optimized_code_map_holder_head_; |
1076 SharedFunctionInfo* next_holder; | 1071 SharedFunctionInfo* next_holder; |
1072 | |
1077 while (holder != NULL) { | 1073 while (holder != NULL) { |
1078 next_holder = GetNextCodeMap(holder); | 1074 next_holder = GetNextCodeMap(holder); |
1079 ClearNextCodeMap(holder); | 1075 ClearNextCodeMap(holder); |
1080 | 1076 |
1081 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); | 1077 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); |
1082 int new_length = kEntriesStart; | 1078 int new_length = SharedFunctionInfo::kEntriesStart; |
1083 int old_length = code_map->length(); | 1079 int old_length = code_map->length(); |
1084 for (int i = kEntriesStart; i < old_length; i += kEntryLength) { | 1080 for (int i = SharedFunctionInfo::kEntriesStart; |
1085 Code* code = Code::cast(code_map->get(i + kCodeOffset)); | 1081 i < old_length; |
1086 MarkBit code_mark = Marking::MarkBitFrom(code); | 1082 i += SharedFunctionInfo::kEntryLength) { |
1087 if (!code_mark.Get()) { | 1083 Code* code = |
1088 continue; | 1084 Code::cast(code_map->get(i + SharedFunctionInfo::kCachedCodeOffset)); |
1085 if (!Marking::MarkBitFrom(code).Get()) continue; | |
1086 | |
1087 // Move every slot in the entry. | |
1088 for (int j = 0; j < SharedFunctionInfo::kEntryLength; j++) { | |
titzer
2013/12/17 08:31:43
Much better.
| |
1089 int dst_index = new_length++; | |
1090 Object** slot = code_map->RawFieldOfElementAt(dst_index); | |
1091 Object* object = code_map->get(i + j); | |
1092 code_map->set(dst_index, object); | |
1093 if (j == SharedFunctionInfo::kOsrAstIdOffset) { | |
1094 ASSERT(object->IsSmi()); | |
1095 } else { | |
1096 ASSERT(Marking::IsBlack( | |
1097 Marking::MarkBitFrom(HeapObject::cast(*slot)))); | |
1098 isolate_->heap()->mark_compact_collector()-> | |
1099 RecordSlot(slot, slot, *slot); | |
1100 } | |
1089 } | 1101 } |
1090 | |
1091 // Update and record the context slot in the optimized code map. | |
1092 Object** context_slot = HeapObject::RawField(code_map, | |
1093 FixedArray::OffsetOfElementAt(new_length)); | |
1094 code_map->set(new_length++, code_map->get(i + kContextOffset)); | |
1095 ASSERT(Marking::IsBlack( | |
1096 Marking::MarkBitFrom(HeapObject::cast(*context_slot)))); | |
1097 isolate_->heap()->mark_compact_collector()-> | |
1098 RecordSlot(context_slot, context_slot, *context_slot); | |
1099 | |
1100 // Update and record the code slot in the optimized code map. | |
1101 Object** code_slot = HeapObject::RawField(code_map, | |
1102 FixedArray::OffsetOfElementAt(new_length)); | |
1103 code_map->set(new_length++, code_map->get(i + kCodeOffset)); | |
1104 ASSERT(Marking::IsBlack( | |
1105 Marking::MarkBitFrom(HeapObject::cast(*code_slot)))); | |
1106 isolate_->heap()->mark_compact_collector()-> | |
1107 RecordSlot(code_slot, code_slot, *code_slot); | |
1108 | |
1109 // Update and record the literals slot in the optimized code map. | |
1110 Object** literals_slot = HeapObject::RawField(code_map, | |
1111 FixedArray::OffsetOfElementAt(new_length)); | |
1112 code_map->set(new_length++, code_map->get(i + kLiteralsOffset)); | |
1113 ASSERT(Marking::IsBlack( | |
1114 Marking::MarkBitFrom(HeapObject::cast(*literals_slot)))); | |
1115 isolate_->heap()->mark_compact_collector()-> | |
1116 RecordSlot(literals_slot, literals_slot, *literals_slot); | |
1117 } | 1102 } |
1118 | 1103 |
1119 // Trim the optimized code map if entries have been removed. | 1104 // Trim the optimized code map if entries have been removed. |
1120 if (new_length < old_length) { | 1105 if (new_length < old_length) { |
1121 holder->TrimOptimizedCodeMap(old_length - new_length); | 1106 holder->TrimOptimizedCodeMap(old_length - new_length); |
1122 } | 1107 } |
1123 | 1108 |
1124 holder = next_holder; | 1109 holder = next_holder; |
1125 } | 1110 } |
1126 | 1111 |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2601 if (new_number_of_transitions != i) { | 2586 if (new_number_of_transitions != i) { |
2602 prototype_transitions->set( | 2587 prototype_transitions->set( |
2603 proto_index, | 2588 proto_index, |
2604 prototype, | 2589 prototype, |
2605 UPDATE_WRITE_BARRIER); | 2590 UPDATE_WRITE_BARRIER); |
2606 prototype_transitions->set( | 2591 prototype_transitions->set( |
2607 map_index, | 2592 map_index, |
2608 cached_map, | 2593 cached_map, |
2609 SKIP_WRITE_BARRIER); | 2594 SKIP_WRITE_BARRIER); |
2610 } | 2595 } |
2611 Object** slot = | 2596 Object** slot = prototype_transitions->RawFieldOfElementAt(proto_index); |
2612 HeapObject::RawField(prototype_transitions, | |
2613 FixedArray::OffsetOfElementAt(proto_index)); | |
2614 RecordSlot(slot, slot, prototype); | 2597 RecordSlot(slot, slot, prototype); |
2615 new_number_of_transitions++; | 2598 new_number_of_transitions++; |
2616 } | 2599 } |
2617 } | 2600 } |
2618 | 2601 |
2619 if (new_number_of_transitions != number_of_transitions) { | 2602 if (new_number_of_transitions != number_of_transitions) { |
2620 map->SetNumberOfProtoTransitions(new_number_of_transitions); | 2603 map->SetNumberOfProtoTransitions(new_number_of_transitions); |
2621 } | 2604 } |
2622 | 2605 |
2623 // Fill slots that became free with undefined value. | 2606 // Fill slots that became free with undefined value. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2708 while (weak_collection_obj != Smi::FromInt(0)) { | 2691 while (weak_collection_obj != Smi::FromInt(0)) { |
2709 ASSERT(MarkCompactCollector::IsMarked( | 2692 ASSERT(MarkCompactCollector::IsMarked( |
2710 HeapObject::cast(weak_collection_obj))); | 2693 HeapObject::cast(weak_collection_obj))); |
2711 JSWeakCollection* weak_collection = | 2694 JSWeakCollection* weak_collection = |
2712 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); | 2695 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); |
2713 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); | 2696 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); |
2714 Object** anchor = reinterpret_cast<Object**>(table->address()); | 2697 Object** anchor = reinterpret_cast<Object**>(table->address()); |
2715 for (int i = 0; i < table->Capacity(); i++) { | 2698 for (int i = 0; i < table->Capacity(); i++) { |
2716 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2699 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
2717 Object** key_slot = | 2700 Object** key_slot = |
2718 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( | 2701 table->RawFieldOfElementAt(ObjectHashTable::EntryToIndex(i)); |
2719 ObjectHashTable::EntryToIndex(i))); | |
2720 RecordSlot(anchor, key_slot, *key_slot); | 2702 RecordSlot(anchor, key_slot, *key_slot); |
2721 Object** value_slot = | 2703 Object** value_slot = |
2722 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( | 2704 table->RawFieldOfElementAt(ObjectHashTable::EntryToValueIndex(i)); |
2723 ObjectHashTable::EntryToValueIndex(i))); | |
2724 MarkCompactMarkingVisitor::MarkObjectByPointer( | 2705 MarkCompactMarkingVisitor::MarkObjectByPointer( |
2725 this, anchor, value_slot); | 2706 this, anchor, value_slot); |
2726 } | 2707 } |
2727 } | 2708 } |
2728 weak_collection_obj = weak_collection->next(); | 2709 weak_collection_obj = weak_collection->next(); |
2729 } | 2710 } |
2730 } | 2711 } |
2731 | 2712 |
2732 | 2713 |
2733 void MarkCompactCollector::ClearWeakCollections() { | 2714 void MarkCompactCollector::ClearWeakCollections() { |
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4363 while (buffer != NULL) { | 4344 while (buffer != NULL) { |
4364 SlotsBuffer* next_buffer = buffer->next(); | 4345 SlotsBuffer* next_buffer = buffer->next(); |
4365 DeallocateBuffer(buffer); | 4346 DeallocateBuffer(buffer); |
4366 buffer = next_buffer; | 4347 buffer = next_buffer; |
4367 } | 4348 } |
4368 *buffer_address = NULL; | 4349 *buffer_address = NULL; |
4369 } | 4350 } |
4370 | 4351 |
4371 | 4352 |
4372 } } // namespace v8::internal | 4353 } } // namespace v8::internal |
OLD | NEW |