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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 for (Object** current = start; current < end; current++) { | 78 for (Object** current = start; current < end; current++) { |
79 if ((*current)->IsHeapObject()) { | 79 if ((*current)->IsHeapObject()) { |
80 HeapObject* object = HeapObject::cast(*current); | 80 HeapObject* object = HeapObject::cast(*current); |
81 CHECK(HEAP->mark_compact_collector()->IsMarked(object)); | 81 CHECK(HEAP->mark_compact_collector()->IsMarked(object)); |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 void VisitEmbeddedPointer(RelocInfo* rinfo) { | 86 void VisitEmbeddedPointer(RelocInfo* rinfo) { |
87 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 87 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
88 if (!FLAG_weak_embedded_maps_in_optimized_code || | 88 if (!FLAG_weak_embedded_maps_in_optimized_code || !FLAG_collect_maps || |
89 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || | 89 rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || |
90 !rinfo->target_object()->IsMap() || | 90 !rinfo->target_object()->IsMap() || |
91 !Map::cast(rinfo->target_object())->CanTransition()) { | 91 !Map::cast(rinfo->target_object())->CanTransition()) { |
92 VisitPointer(rinfo->target_object_address()); | 92 VisitPointer(rinfo->target_object_address()); |
93 } | 93 } |
94 } | 94 } |
95 }; | 95 }; |
96 | 96 |
97 | 97 |
98 static void VerifyMarking(Address bottom, Address top) { | 98 static void VerifyMarking(Address bottom, Address top) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 SweepSpaces(); | 405 SweepSpaces(); |
406 | 406 |
407 if (!FLAG_collect_maps) ReattachInitialMaps(); | 407 if (!FLAG_collect_maps) ReattachInitialMaps(); |
408 | 408 |
409 #ifdef DEBUG | 409 #ifdef DEBUG |
410 if (FLAG_verify_native_context_separation) { | 410 if (FLAG_verify_native_context_separation) { |
411 VerifyNativeContextSeparation(heap_); | 411 VerifyNativeContextSeparation(heap_); |
412 } | 412 } |
413 #endif | 413 #endif |
414 | 414 |
| 415 #ifdef VERIFY_HEAP |
| 416 if (FLAG_collect_maps && FLAG_weak_embedded_maps_in_optimized_code && |
| 417 heap()->weak_embedded_maps_verification_enabled()) { |
| 418 VerifyWeakEmbeddedMapsInOptimizedCode(); |
| 419 } |
| 420 #endif |
| 421 |
415 Finish(); | 422 Finish(); |
416 | 423 |
417 if (marking_parity_ == EVEN_MARKING_PARITY) { | 424 if (marking_parity_ == EVEN_MARKING_PARITY) { |
418 marking_parity_ = ODD_MARKING_PARITY; | 425 marking_parity_ = ODD_MARKING_PARITY; |
419 } else { | 426 } else { |
420 ASSERT(marking_parity_ == ODD_MARKING_PARITY); | 427 ASSERT(marking_parity_ == ODD_MARKING_PARITY); |
421 marking_parity_ = EVEN_MARKING_PARITY; | 428 marking_parity_ = EVEN_MARKING_PARITY; |
422 } | 429 } |
423 | 430 |
424 tracer_ = NULL; | 431 tracer_ = NULL; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 VerifyMarkbitsAreClean(heap_->map_space()); | 463 VerifyMarkbitsAreClean(heap_->map_space()); |
457 VerifyMarkbitsAreClean(heap_->new_space()); | 464 VerifyMarkbitsAreClean(heap_->new_space()); |
458 | 465 |
459 LargeObjectIterator it(heap_->lo_space()); | 466 LargeObjectIterator it(heap_->lo_space()); |
460 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 467 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
461 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 468 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
462 CHECK(Marking::IsWhite(mark_bit)); | 469 CHECK(Marking::IsWhite(mark_bit)); |
463 CHECK_EQ(0, Page::FromAddress(obj->address())->LiveBytes()); | 470 CHECK_EQ(0, Page::FromAddress(obj->address())->LiveBytes()); |
464 } | 471 } |
465 } | 472 } |
| 473 |
| 474 |
| 475 void MarkCompactCollector::VerifyWeakEmbeddedMapsInOptimizedCode() { |
| 476 HeapObjectIterator code_iterator(heap()->code_space()); |
| 477 for (HeapObject* obj = code_iterator.Next(); |
| 478 obj != NULL; |
| 479 obj = code_iterator.Next()) { |
| 480 Code* code = Code::cast(obj); |
| 481 if (code->kind() != Code::OPTIMIZED_FUNCTION) continue; |
| 482 if (code->marked_for_deoptimization()) continue; |
| 483 code->VerifyEmbeddedMapsDependency(); |
| 484 } |
| 485 } |
466 #endif // VERIFY_HEAP | 486 #endif // VERIFY_HEAP |
467 | 487 |
468 | 488 |
469 static void ClearMarkbitsInPagedSpace(PagedSpace* space) { | 489 static void ClearMarkbitsInPagedSpace(PagedSpace* space) { |
470 PageIterator it(space); | 490 PageIterator it(space); |
471 | 491 |
472 while (it.has_next()) { | 492 while (it.has_next()) { |
473 Bitmap::Clear(it.next()); | 493 Bitmap::Clear(it.next()); |
474 } | 494 } |
475 } | 495 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 space->PrepareForMarkCompact(); | 846 space->PrepareForMarkCompact(); |
827 } | 847 } |
828 | 848 |
829 #ifdef VERIFY_HEAP | 849 #ifdef VERIFY_HEAP |
830 if (!was_marked_incrementally_ && FLAG_verify_heap) { | 850 if (!was_marked_incrementally_ && FLAG_verify_heap) { |
831 VerifyMarkbitsAreClean(); | 851 VerifyMarkbitsAreClean(); |
832 } | 852 } |
833 #endif | 853 #endif |
834 } | 854 } |
835 | 855 |
| 856 |
836 class DeoptimizeMarkedCodeFilter : public OptimizedFunctionFilter { | 857 class DeoptimizeMarkedCodeFilter : public OptimizedFunctionFilter { |
837 public: | 858 public: |
838 virtual bool TakeFunction(JSFunction* function) { | 859 virtual bool TakeFunction(JSFunction* function) { |
839 return function->code()->marked_for_deoptimization(); | 860 return function->code()->marked_for_deoptimization(); |
840 } | 861 } |
841 }; | 862 }; |
842 | 863 |
843 | 864 |
844 void MarkCompactCollector::Finish() { | 865 void MarkCompactCollector::Finish() { |
845 #ifdef DEBUG | 866 #ifdef DEBUG |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 AssertNoAllocation no_allocation_scope; | 2324 AssertNoAllocation no_allocation_scope; |
2304 DependentCodes* codes = map->dependent_codes(); | 2325 DependentCodes* codes = map->dependent_codes(); |
2305 int number_of_codes = codes->number_of_codes(); | 2326 int number_of_codes = codes->number_of_codes(); |
2306 if (number_of_codes == 0) return; | 2327 if (number_of_codes == 0) return; |
2307 int new_number_of_codes = 0; | 2328 int new_number_of_codes = 0; |
2308 for (int i = 0; i < number_of_codes; i++) { | 2329 for (int i = 0; i < number_of_codes; i++) { |
2309 Code* code = codes->code_at(i); | 2330 Code* code = codes->code_at(i); |
2310 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2331 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
2311 if (new_number_of_codes != i) { | 2332 if (new_number_of_codes != i) { |
2312 codes->set_code_at(new_number_of_codes, code); | 2333 codes->set_code_at(new_number_of_codes, code); |
2313 Object** slot = codes->code_slot_at(new_number_of_codes); | |
2314 RecordSlot(slot, slot, code); | |
2315 new_number_of_codes++; | |
2316 } | 2334 } |
| 2335 Object** slot = codes->code_slot_at(new_number_of_codes); |
| 2336 RecordSlot(slot, slot, code); |
| 2337 new_number_of_codes++; |
2317 } | 2338 } |
2318 } | 2339 } |
2319 for (int i = new_number_of_codes; i < number_of_codes; i++) { | 2340 for (int i = new_number_of_codes; i < number_of_codes; i++) { |
2320 codes->clear_code_at(i); | 2341 codes->clear_code_at(i); |
2321 } | 2342 } |
2322 codes->set_number_of_codes(new_number_of_codes); | 2343 codes->set_number_of_codes(new_number_of_codes); |
2323 } | 2344 } |
2324 | 2345 |
2325 | 2346 |
2326 void MarkCompactCollector::ProcessWeakMaps() { | 2347 void MarkCompactCollector::ProcessWeakMaps() { |
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3911 while (buffer != NULL) { | 3932 while (buffer != NULL) { |
3912 SlotsBuffer* next_buffer = buffer->next(); | 3933 SlotsBuffer* next_buffer = buffer->next(); |
3913 DeallocateBuffer(buffer); | 3934 DeallocateBuffer(buffer); |
3914 buffer = next_buffer; | 3935 buffer = next_buffer; |
3915 } | 3936 } |
3916 *buffer_address = NULL; | 3937 *buffer_address = NULL; |
3917 } | 3938 } |
3918 | 3939 |
3919 | 3940 |
3920 } } // namespace v8::internal | 3941 } } // namespace v8::internal |
OLD | NEW |