| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); | 223 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); |
| 224 | 224 |
| 225 LargePage* lop = heap_->lo_space()->first_page(); | 225 LargePage* lop = heap_->lo_space()->first_page(); |
| 226 while (lop->is_valid()) { | 226 while (lop->is_valid()) { |
| 227 SetOldSpacePageFlags(lop, false); | 227 SetOldSpacePageFlags(lop, false); |
| 228 lop = lop->next_page(); | 228 lop = lop->next_page(); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 void IncrementalMarking::ClearMarkbits(PagedSpace* space) { | 233 void IncrementalMarking::ActivateIncrementalWriteBarrier(PagedSpace* space) { |
| 234 PageIterator it(space); | 234 PageIterator it(space); |
| 235 while (it.has_next()) { | 235 while (it.has_next()) { |
| 236 Page* p = it.next(); | 236 Page* p = it.next(); |
| 237 Bitmap::Clear(p); | |
| 238 SetOldSpacePageFlags(p, true); | 237 SetOldSpacePageFlags(p, true); |
| 239 } | 238 } |
| 240 } | 239 } |
| 241 | 240 |
| 242 | 241 |
| 243 void IncrementalMarking::ClearMarkbits(NewSpace* space) { | 242 void IncrementalMarking::ActivateIncrementalWriteBarrier(NewSpace* space) { |
| 244 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | 243 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); |
| 245 while (it.has_next()) { | 244 while (it.has_next()) { |
| 246 NewSpacePage* p = it.next(); | 245 NewSpacePage* p = it.next(); |
| 247 Bitmap::Clear(p); | |
| 248 SetNewSpacePageFlags(p, true); | 246 SetNewSpacePageFlags(p, true); |
| 249 } | 247 } |
| 250 } | 248 } |
| 251 | 249 |
| 252 | 250 |
| 253 void IncrementalMarking::ClearMarkbits() { | 251 void IncrementalMarking::ActivateIncrementalWriteBarrier() { |
| 254 // TODO(gc): Clear the mark bits in the sweeper. | 252 ActivateIncrementalWriteBarrier(heap_->old_pointer_space()); |
| 255 ClearMarkbits(heap_->old_pointer_space()); | 253 ActivateIncrementalWriteBarrier(heap_->old_data_space()); |
| 256 ClearMarkbits(heap_->old_data_space()); | 254 ActivateIncrementalWriteBarrier(heap_->cell_space()); |
| 257 ClearMarkbits(heap_->cell_space()); | 255 ActivateIncrementalWriteBarrier(heap_->map_space()); |
| 258 ClearMarkbits(heap_->map_space()); | 256 ActivateIncrementalWriteBarrier(heap_->code_space()); |
| 259 ClearMarkbits(heap_->code_space()); | 257 ActivateIncrementalWriteBarrier(heap_->new_space()); |
| 260 ClearMarkbits(heap_->new_space()); | |
| 261 | 258 |
| 262 LargePage* lop = heap_->lo_space()->first_page(); | 259 LargePage* lop = heap_->lo_space()->first_page(); |
| 263 while (lop->is_valid()) { | 260 while (lop->is_valid()) { |
| 264 SetOldSpacePageFlags(lop, true); | 261 SetOldSpacePageFlags(lop, true); |
| 265 lop = lop->next_page(); | 262 lop = lop->next_page(); |
| 266 } | 263 } |
| 267 } | 264 } |
| 268 | 265 |
| 269 | 266 |
| 270 #ifdef DEBUG | |
| 271 void IncrementalMarking::VerifyMarkbitsAreClean(PagedSpace* space) { | |
| 272 PageIterator it(space); | |
| 273 | |
| 274 while (it.has_next()) { | |
| 275 Page* p = it.next(); | |
| 276 ASSERT(p->markbits()->IsClean()); | |
| 277 } | |
| 278 } | |
| 279 | |
| 280 | |
| 281 void IncrementalMarking::VerifyMarkbitsAreClean(NewSpace* space) { | |
| 282 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | |
| 283 | |
| 284 while (it.has_next()) { | |
| 285 NewSpacePage* p = it.next(); | |
| 286 ASSERT(p->markbits()->IsClean()); | |
| 287 } | |
| 288 } | |
| 289 | |
| 290 | |
| 291 void IncrementalMarking::VerifyMarkbitsAreClean() { | |
| 292 VerifyMarkbitsAreClean(heap_->old_pointer_space()); | |
| 293 VerifyMarkbitsAreClean(heap_->old_data_space()); | |
| 294 VerifyMarkbitsAreClean(heap_->code_space()); | |
| 295 VerifyMarkbitsAreClean(heap_->cell_space()); | |
| 296 VerifyMarkbitsAreClean(heap_->map_space()); | |
| 297 VerifyMarkbitsAreClean(heap_->new_space()); | |
| 298 } | |
| 299 #endif | |
| 300 | |
| 301 | |
| 302 bool IncrementalMarking::WorthActivating() { | 267 bool IncrementalMarking::WorthActivating() { |
| 303 #ifndef DEBUG | 268 #ifndef DEBUG |
| 304 static const intptr_t kActivationThreshold = 8 * MB; | 269 static const intptr_t kActivationThreshold = 8 * MB; |
| 305 #else | 270 #else |
| 306 // TODO(gc) consider setting this to some low level so that some | 271 // TODO(gc) consider setting this to some low level so that some |
| 307 // debug tests run with incremental marking and some without. | 272 // debug tests run with incremental marking and some without. |
| 308 static const intptr_t kActivationThreshold = 0; | 273 static const intptr_t kActivationThreshold = 0; |
| 309 #endif | 274 #endif |
| 310 | 275 |
| 311 return FLAG_incremental_marking && | 276 return FLAG_incremental_marking && |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); | 366 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); |
| 402 | 367 |
| 403 EnsureMarkingDequeIsCommitted(); | 368 EnsureMarkingDequeIsCommitted(); |
| 404 | 369 |
| 405 // Initialize marking stack. | 370 // Initialize marking stack. |
| 406 Address addr = static_cast<Address>(marking_deque_memory_->address()); | 371 Address addr = static_cast<Address>(marking_deque_memory_->address()); |
| 407 size_t size = marking_deque_memory_->size(); | 372 size_t size = marking_deque_memory_->size(); |
| 408 if (FLAG_force_marking_deque_overflows) size = 64 * kPointerSize; | 373 if (FLAG_force_marking_deque_overflows) size = 64 * kPointerSize; |
| 409 marking_deque_.Initialize(addr, addr + size); | 374 marking_deque_.Initialize(addr, addr + size); |
| 410 | 375 |
| 411 // Clear markbits. | 376 ActivateIncrementalWriteBarrier(); |
| 412 ClearMarkbits(); | |
| 413 | 377 |
| 414 #ifdef DEBUG | 378 #ifdef DEBUG |
| 415 VerifyMarkbitsAreClean(); | 379 // Marking bits are cleared by the sweeper. |
| 380 heap_->mark_compact_collector()->VerifyMarkbitsAreClean(); |
| 416 #endif | 381 #endif |
| 417 | 382 |
| 418 // Mark strong roots grey. | 383 // Mark strong roots grey. |
| 419 IncrementalMarkingRootMarkingVisitor visitor(heap_, this); | 384 IncrementalMarkingRootMarkingVisitor visitor(heap_, this); |
| 420 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 385 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
| 421 | 386 |
| 422 // Ready to start incremental marking. | 387 // Ready to start incremental marking. |
| 423 if (FLAG_trace_incremental_marking) { | 388 if (FLAG_trace_incremental_marking) { |
| 424 PrintF("[IncrementalMarking] Running\n"); | 389 PrintF("[IncrementalMarking] Running\n"); |
| 425 } | 390 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 double end = OS::TimeCurrentMillis(); | 596 double end = OS::TimeCurrentMillis(); |
| 632 double delta = (end - start); | 597 double delta = (end - start); |
| 633 longest_step_ = Max(longest_step_, delta); | 598 longest_step_ = Max(longest_step_, delta); |
| 634 steps_took_ += delta; | 599 steps_took_ += delta; |
| 635 steps_took_since_last_gc_ += delta; | 600 steps_took_since_last_gc_ += delta; |
| 636 } | 601 } |
| 637 } | 602 } |
| 638 | 603 |
| 639 | 604 |
| 640 } } // namespace v8::internal | 605 } } // namespace v8::internal |
| OLD | NEW |