| 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 19 matching lines...) Expand all Loading... |
| 30 #include "accessors.h" | 30 #include "accessors.h" |
| 31 #include "api.h" | 31 #include "api.h" |
| 32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
| 33 #include "codegen.h" | 33 #include "codegen.h" |
| 34 #include "compilation-cache.h" | 34 #include "compilation-cache.h" |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "deoptimizer.h" | 36 #include "deoptimizer.h" |
| 37 #include "global-handles.h" | 37 #include "global-handles.h" |
| 38 #include "heap-profiler.h" | 38 #include "heap-profiler.h" |
| 39 #include "incremental-marking.h" | 39 #include "incremental-marking.h" |
| 40 #include "liveobjectlist-inl.h" | |
| 41 #include "mark-compact.h" | 40 #include "mark-compact.h" |
| 42 #include "natives.h" | 41 #include "natives.h" |
| 43 #include "objects-visiting.h" | 42 #include "objects-visiting.h" |
| 44 #include "objects-visiting-inl.h" | 43 #include "objects-visiting-inl.h" |
| 45 #include "once.h" | 44 #include "once.h" |
| 46 #include "runtime-profiler.h" | 45 #include "runtime-profiler.h" |
| 47 #include "scopeinfo.h" | 46 #include "scopeinfo.h" |
| 48 #include "snapshot.h" | 47 #include "snapshot.h" |
| 49 #include "store-buffer.h" | 48 #include "store-buffer.h" |
| 50 #include "v8threads.h" | 49 #include "v8threads.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 431 |
| 433 #ifdef DEBUG | 432 #ifdef DEBUG |
| 434 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 433 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
| 435 allow_allocation(false); | 434 allow_allocation(false); |
| 436 | 435 |
| 437 if (FLAG_gc_verbose) Print(); | 436 if (FLAG_gc_verbose) Print(); |
| 438 | 437 |
| 439 ReportStatisticsBeforeGC(); | 438 ReportStatisticsBeforeGC(); |
| 440 #endif // DEBUG | 439 #endif // DEBUG |
| 441 | 440 |
| 442 LiveObjectList::GCPrologue(); | |
| 443 store_buffer()->GCPrologue(); | 441 store_buffer()->GCPrologue(); |
| 444 } | 442 } |
| 445 | 443 |
| 446 | 444 |
| 447 intptr_t Heap::SizeOfObjects() { | 445 intptr_t Heap::SizeOfObjects() { |
| 448 intptr_t total = 0; | 446 intptr_t total = 0; |
| 449 AllSpaces spaces; | 447 AllSpaces spaces; |
| 450 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 448 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
| 451 total += space->SizeOfObjects(); | 449 total += space->SizeOfObjects(); |
| 452 } | 450 } |
| 453 return total; | 451 return total; |
| 454 } | 452 } |
| 455 | 453 |
| 456 | 454 |
| 457 void Heap::RepairFreeListsAfterBoot() { | 455 void Heap::RepairFreeListsAfterBoot() { |
| 458 PagedSpaces spaces; | 456 PagedSpaces spaces; |
| 459 for (PagedSpace* space = spaces.next(); | 457 for (PagedSpace* space = spaces.next(); |
| 460 space != NULL; | 458 space != NULL; |
| 461 space = spaces.next()) { | 459 space = spaces.next()) { |
| 462 space->RepairFreeListsAfterBoot(); | 460 space->RepairFreeListsAfterBoot(); |
| 463 } | 461 } |
| 464 } | 462 } |
| 465 | 463 |
| 466 | 464 |
| 467 void Heap::GarbageCollectionEpilogue() { | 465 void Heap::GarbageCollectionEpilogue() { |
| 468 store_buffer()->GCEpilogue(); | 466 store_buffer()->GCEpilogue(); |
| 469 LiveObjectList::GCEpilogue(); | |
| 470 | 467 |
| 471 // In release mode, we only zap the from space under heap verification. | 468 // In release mode, we only zap the from space under heap verification. |
| 472 if (Heap::ShouldZapGarbage()) { | 469 if (Heap::ShouldZapGarbage()) { |
| 473 ZapFromSpace(); | 470 ZapFromSpace(); |
| 474 } | 471 } |
| 475 | 472 |
| 476 #ifdef VERIFY_HEAP | 473 #ifdef VERIFY_HEAP |
| 477 if (FLAG_verify_heap) { | 474 if (FLAG_verify_heap) { |
| 478 Verify(); | 475 Verify(); |
| 479 } | 476 } |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 &scavenge_visitor); | 1379 &scavenge_visitor); |
| 1383 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1380 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| 1384 | 1381 |
| 1385 UpdateNewSpaceReferencesInExternalStringTable( | 1382 UpdateNewSpaceReferencesInExternalStringTable( |
| 1386 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1383 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
| 1387 | 1384 |
| 1388 error_object_list_.UpdateReferencesInNewSpace(this); | 1385 error_object_list_.UpdateReferencesInNewSpace(this); |
| 1389 | 1386 |
| 1390 promotion_queue_.Destroy(); | 1387 promotion_queue_.Destroy(); |
| 1391 | 1388 |
| 1392 LiveObjectList::UpdateReferencesForScavengeGC(); | |
| 1393 if (!FLAG_watch_ic_patching) { | 1389 if (!FLAG_watch_ic_patching) { |
| 1394 isolate()->runtime_profiler()->UpdateSamplesAfterScavenge(); | 1390 isolate()->runtime_profiler()->UpdateSamplesAfterScavenge(); |
| 1395 } | 1391 } |
| 1396 incremental_marking()->UpdateMarkingDequeAfterScavenge(); | 1392 incremental_marking()->UpdateMarkingDequeAfterScavenge(); |
| 1397 | 1393 |
| 1398 ScavengeWeakObjectRetainer weak_object_retainer(this); | 1394 ScavengeWeakObjectRetainer weak_object_retainer(this); |
| 1399 ProcessWeakReferences(&weak_object_retainer); | 1395 ProcessWeakReferences(&weak_object_retainer); |
| 1400 | 1396 |
| 1401 ASSERT(new_space_front == new_space_.top()); | 1397 ASSERT(new_space_front == new_space_.top()); |
| 1402 | 1398 |
| (...skipping 5334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6737 } | 6733 } |
| 6738 | 6734 |
| 6739 | 6735 |
| 6740 void HeapIterator::reset() { | 6736 void HeapIterator::reset() { |
| 6741 // Restart the iterator. | 6737 // Restart the iterator. |
| 6742 Shutdown(); | 6738 Shutdown(); |
| 6743 Init(); | 6739 Init(); |
| 6744 } | 6740 } |
| 6745 | 6741 |
| 6746 | 6742 |
| 6747 #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) | 6743 #ifdef DEBUG |
| 6748 | 6744 |
| 6749 Object* const PathTracer::kAnyGlobalObject = reinterpret_cast<Object*>(NULL); | 6745 Object* const PathTracer::kAnyGlobalObject = reinterpret_cast<Object*>(NULL); |
| 6750 | 6746 |
| 6751 class PathTracer::MarkVisitor: public ObjectVisitor { | 6747 class PathTracer::MarkVisitor: public ObjectVisitor { |
| 6752 public: | 6748 public: |
| 6753 explicit MarkVisitor(PathTracer* tracer) : tracer_(tracer) {} | 6749 explicit MarkVisitor(PathTracer* tracer) : tracer_(tracer) {} |
| 6754 void VisitPointers(Object** start, Object** end) { | 6750 void VisitPointers(Object** start, Object** end) { |
| 6755 // Scan all HeapObject pointers in [start, end) | 6751 // Scan all HeapObject pointers in [start, end) |
| 6756 for (Object** p = start; !tracer_->found() && (p < end); p++) { | 6752 for (Object** p = start; !tracer_->found() && (p < end); p++) { |
| 6757 if ((*p)->IsHeapObject()) | 6753 if ((*p)->IsHeapObject()) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6904 | 6900 |
| 6905 ASSERT(!object_stack_.is_empty()); | 6901 ASSERT(!object_stack_.is_empty()); |
| 6906 for (int i = 0; i < object_stack_.length(); i++) { | 6902 for (int i = 0; i < object_stack_.length(); i++) { |
| 6907 if (i > 0) PrintF("\n |\n |\n V\n\n"); | 6903 if (i > 0) PrintF("\n |\n |\n V\n\n"); |
| 6908 Object* obj = object_stack_[i]; | 6904 Object* obj = object_stack_[i]; |
| 6909 obj->Print(); | 6905 obj->Print(); |
| 6910 } | 6906 } |
| 6911 PrintF("=====================================\n"); | 6907 PrintF("=====================================\n"); |
| 6912 } | 6908 } |
| 6913 } | 6909 } |
| 6914 #endif // DEBUG || LIVE_OBJECT_LIST | |
| 6915 | 6910 |
| 6916 | 6911 |
| 6917 #ifdef DEBUG | |
| 6918 // Triggers a depth-first traversal of reachable objects from one | 6912 // Triggers a depth-first traversal of reachable objects from one |
| 6919 // given root object and finds a path to a specific heap object and | 6913 // given root object and finds a path to a specific heap object and |
| 6920 // prints it. | 6914 // prints it. |
| 6921 void Heap::TracePathToObjectFrom(Object* target, Object* root) { | 6915 void Heap::TracePathToObjectFrom(Object* target, Object* root) { |
| 6922 PathTracer tracer(target, PathTracer::FIND_ALL, VISIT_ALL); | 6916 PathTracer tracer(target, PathTracer::FIND_ALL, VISIT_ALL); |
| 6923 tracer.VisitPointer(&root); | 6917 tracer.VisitPointer(&root); |
| 6924 } | 6918 } |
| 6925 | 6919 |
| 6926 | 6920 |
| 6927 // Triggers a depth-first traversal of reachable objects from roots | 6921 // Triggers a depth-first traversal of reachable objects from roots |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7510 static_cast<int>(object_sizes_last_time_[index])); | 7504 static_cast<int>(object_sizes_last_time_[index])); |
| 7511 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7505 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7512 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7506 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7513 | 7507 |
| 7514 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7508 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7515 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7509 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7516 ClearObjectStats(); | 7510 ClearObjectStats(); |
| 7517 } | 7511 } |
| 7518 | 7512 |
| 7519 } } // namespace v8::internal | 7513 } } // namespace v8::internal |
| OLD | NEW |