| 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 28 matching lines...) Expand all  Loading... | 
| 39 | 39 | 
| 40 class IncrementalMarking { | 40 class IncrementalMarking { | 
| 41  public: | 41  public: | 
| 42   enum State { | 42   enum State { | 
| 43     STOPPED, | 43     STOPPED, | 
| 44     SWEEPING, | 44     SWEEPING, | 
| 45     MARKING, | 45     MARKING, | 
| 46     COMPLETE | 46     COMPLETE | 
| 47   }; | 47   }; | 
| 48 | 48 | 
|  | 49   enum CompletionAction { | 
|  | 50     GC_VIA_STACK_GUARD, | 
|  | 51     NO_GC_VIA_STACK_GUARD | 
|  | 52   }; | 
|  | 53 | 
| 49   explicit IncrementalMarking(Heap* heap); | 54   explicit IncrementalMarking(Heap* heap); | 
| 50 | 55 | 
| 51   void TearDown(); | 56   void TearDown(); | 
| 52 | 57 | 
| 53   State state() { | 58   State state() { | 
| 54     ASSERT(state_ == STOPPED || FLAG_incremental_marking); | 59     ASSERT(state_ == STOPPED || FLAG_incremental_marking); | 
| 55     return state_; | 60     return state_; | 
| 56   } | 61   } | 
| 57 | 62 | 
| 58   bool should_hurry() { return should_hurry_; } | 63   bool should_hurry() { return should_hurry_; } | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 75   void PrepareForScavenge(); | 80   void PrepareForScavenge(); | 
| 76 | 81 | 
| 77   void UpdateMarkingDequeAfterScavenge(); | 82   void UpdateMarkingDequeAfterScavenge(); | 
| 78 | 83 | 
| 79   void Hurry(); | 84   void Hurry(); | 
| 80 | 85 | 
| 81   void Finalize(); | 86   void Finalize(); | 
| 82 | 87 | 
| 83   void Abort(); | 88   void Abort(); | 
| 84 | 89 | 
| 85   void MarkingComplete(); | 90   void MarkingComplete(CompletionAction action); | 
| 86 | 91 | 
| 87   // It's hard to know how much work the incremental marker should do to make | 92   // It's hard to know how much work the incremental marker should do to make | 
| 88   // progress in the face of the mutator creating new work for it.  We start | 93   // progress in the face of the mutator creating new work for it.  We start | 
| 89   // of at a moderate rate of work and gradually increase the speed of the | 94   // of at a moderate rate of work and gradually increase the speed of the | 
| 90   // incremental marker until it completes. | 95   // incremental marker until it completes. | 
| 91   // Do some marking every time this much memory has been allocated. | 96   // Do some marking every time this much memory has been allocated. | 
| 92   static const intptr_t kAllocatedThreshold = 65536; | 97   static const intptr_t kAllocatedThreshold = 65536; | 
| 93   // Start off by marking this many times more memory than has been allocated. | 98   // Start off by marking this many times more memory than has been allocated. | 
| 94   static const intptr_t kInitialAllocationMarkingFactor = 1; | 99   static const intptr_t kInitialAllocationMarkingFactor = 1; | 
| 95   // But if we are promoting a lot of data we need to mark faster to keep up | 100   // But if we are promoting a lot of data we need to mark faster to keep up | 
| 96   // with the data that is entering the old space through promotion. | 101   // with the data that is entering the old space through promotion. | 
| 97   static const intptr_t kFastMarking = 3; | 102   static const intptr_t kFastMarking = 3; | 
| 98   // After this many steps we increase the marking/allocating factor. | 103   // After this many steps we increase the marking/allocating factor. | 
| 99   static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; | 104   static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; | 
| 100   // This is how much we increase the marking/allocating factor by. | 105   // This is how much we increase the marking/allocating factor by. | 
| 101   static const intptr_t kAllocationMarkingFactorSpeedup = 2; | 106   static const intptr_t kAllocationMarkingFactorSpeedup = 2; | 
| 102   static const intptr_t kMaxAllocationMarkingFactor = 1000; | 107   static const intptr_t kMaxAllocationMarkingFactor = 1000; | 
| 103 | 108 | 
| 104   void OldSpaceStep(intptr_t allocated) { | 109   void OldSpaceStep(intptr_t allocated) { | 
| 105     Step(allocated * kFastMarking / kInitialAllocationMarkingFactor); | 110     Step(allocated * kFastMarking / kInitialAllocationMarkingFactor, | 
|  | 111          GC_VIA_STACK_GUARD); | 
| 106   } | 112   } | 
| 107 | 113 | 
| 108   void Step(intptr_t allocated); | 114   void Step(intptr_t allocated, CompletionAction action); | 
| 109 | 115 | 
| 110   inline void RestartIfNotMarking() { | 116   inline void RestartIfNotMarking() { | 
| 111     if (state_ == COMPLETE) { | 117     if (state_ == COMPLETE) { | 
| 112       state_ = MARKING; | 118       state_ = MARKING; | 
| 113       if (FLAG_trace_incremental_marking) { | 119       if (FLAG_trace_incremental_marking) { | 
| 114         PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 120         PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 
| 115       } | 121       } | 
| 116     } | 122     } | 
| 117   } | 123   } | 
| 118 | 124 | 
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 269   intptr_t allocated_; | 275   intptr_t allocated_; | 
| 270 | 276 | 
| 271   int no_marking_scope_depth_; | 277   int no_marking_scope_depth_; | 
| 272 | 278 | 
| 273   DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 279   DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 
| 274 }; | 280 }; | 
| 275 | 281 | 
| 276 } }  // namespace v8::internal | 282 } }  // namespace v8::internal | 
| 277 | 283 | 
| 278 #endif  // V8_INCREMENTAL_MARKING_H_ | 284 #endif  // V8_INCREMENTAL_MARKING_H_ | 
| OLD | NEW | 
|---|