Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 | 33 |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 | 37 |
| 38 IncrementalMarking::IncrementalMarking(Heap* heap) | 38 IncrementalMarking::IncrementalMarking(Heap* heap) |
| 39 : heap_(heap), | 39 : heap_(heap), |
| 40 state_(STOPPED), | 40 state_(STOPPED), |
| 41 marking_deque_memory_(NULL), | |
| 41 steps_count_(0), | 42 steps_count_(0), |
| 42 steps_took_(0), | 43 steps_took_(0), |
| 43 should_hurry_(false), | 44 should_hurry_(false), |
| 44 allocation_marking_factor_(0), | 45 allocation_marking_factor_(0), |
| 45 allocated_(0) { | 46 allocated_(0) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 | 49 |
| 50 void IncrementalMarking::TearDown() { | |
| 51 delete marking_deque_memory_; | |
| 52 } | |
| 53 | |
| 54 | |
| 49 void IncrementalMarking::RecordWriteFromCode(HeapObject* obj, | 55 void IncrementalMarking::RecordWriteFromCode(HeapObject* obj, |
| 50 Object* value, | 56 Object* value, |
| 51 Isolate* isolate) { | 57 Isolate* isolate) { |
| 52 isolate->heap()->incremental_marking()->RecordWrite(obj, value); | 58 isolate->heap()->incremental_marking()->RecordWrite(obj, value); |
| 53 } | 59 } |
| 54 | 60 |
| 55 | 61 |
| 56 class IncrementalMarkingMarkingVisitor : public ObjectVisitor { | 62 class IncrementalMarkingMarkingVisitor : public ObjectVisitor { |
| 57 public: | 63 public: |
| 58 IncrementalMarkingMarkingVisitor(Heap* heap, | 64 IncrementalMarkingMarkingVisitor(Heap* heap, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 Object* e = stubs->ValueAt(i); | 270 Object* e = stubs->ValueAt(i); |
| 265 if (e->IsCode()) { | 271 if (e->IsCode()) { |
| 266 RecordWriteStub::Patch(Code::cast(e), enable); | 272 RecordWriteStub::Patch(Code::cast(e), enable); |
| 267 } | 273 } |
| 268 } | 274 } |
| 269 } | 275 } |
| 270 } | 276 } |
| 271 } | 277 } |
| 272 | 278 |
| 273 | 279 |
| 274 static VirtualMemory* marking_deque_memory = NULL; | 280 void IncrementalMarking::EnsureMarkingDequeIsCommitted() { |
| 275 | 281 if (marking_deque_memory_ == NULL) { |
| 276 | 282 marking_deque_memory_ = new VirtualMemory(4 * MB); |
| 277 static void EnsureMarkingDequeIsCommitted() { | 283 marking_deque_memory_->Commit( |
| 278 if (marking_deque_memory == NULL) { | 284 reinterpret_cast<Address>(marking_deque_memory_->address()), |
| 279 marking_deque_memory = new VirtualMemory(4 * MB); | 285 marking_deque_memory_->size(), |
| 280 marking_deque_memory->Commit( | |
| 281 reinterpret_cast<Address>(marking_deque_memory->address()), | |
| 282 marking_deque_memory->size(), | |
| 283 false); // Not executable. | 286 false); // Not executable. |
| 284 } | 287 } |
| 285 } | 288 } |
| 286 | 289 |
| 287 | 290 |
| 288 void IncrementalMarking::Start() { | 291 void IncrementalMarking::Start() { |
| 289 if (FLAG_trace_incremental_marking) { | 292 if (FLAG_trace_incremental_marking) { |
| 290 PrintF("[IncrementalMarking] Start\n"); | 293 PrintF("[IncrementalMarking] Start\n"); |
| 291 } | 294 } |
| 292 ASSERT(FLAG_incremental_marking); | 295 ASSERT(FLAG_incremental_marking); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 313 PrintF("[IncrementalMarking] Start marking\n"); | 316 PrintF("[IncrementalMarking] Start marking\n"); |
| 314 } | 317 } |
| 315 | 318 |
| 316 state_ = MARKING; | 319 state_ = MARKING; |
| 317 | 320 |
| 318 PatchIncrementalMarkingRecordWriteStubs(true); | 321 PatchIncrementalMarkingRecordWriteStubs(true); |
| 319 | 322 |
| 320 EnsureMarkingDequeIsCommitted(); | 323 EnsureMarkingDequeIsCommitted(); |
| 321 | 324 |
| 322 // Initialize marking stack. | 325 // Initialize marking stack. |
| 323 Address addr = static_cast<Address>(marking_deque_memory->address()); | 326 Address addr = static_cast<Address>(marking_deque_memory_->address()); |
| 324 int size = marking_deque_memory->size(); | 327 int size = marking_deque_memory_->size(); |
| 325 if (FLAG_force_marking_deque_overflows) size = 64 * kPointerSize; | 328 if (FLAG_force_marking_deque_overflows) size = 64 * kPointerSize; |
| 326 marking_deque_.Initialize(addr, addr + size); | 329 marking_deque_.Initialize(addr, addr + size); |
| 327 | 330 |
| 328 // Clear markbits. | 331 // Clear markbits. |
| 329 ClearMarkbits(); | 332 ClearMarkbits(); |
| 330 | 333 |
| 331 #ifdef DEBUG | 334 #ifdef DEBUG |
| 332 VerifyMarkbitsAreClean(); | 335 VerifyMarkbitsAreClean(); |
| 333 #endif | 336 #endif |
| 334 | 337 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 351 | 354 |
| 352 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { | 355 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { |
| 353 if (!IsMarking()) return; | 356 if (!IsMarking()) return; |
| 354 | 357 |
| 355 intptr_t current = marking_deque_.bottom(); | 358 intptr_t current = marking_deque_.bottom(); |
| 356 intptr_t mask = marking_deque_.mask(); | 359 intptr_t mask = marking_deque_.mask(); |
| 357 intptr_t limit = marking_deque_.top(); | 360 intptr_t limit = marking_deque_.top(); |
| 358 HeapObject** array = marking_deque_.array(); | 361 HeapObject** array = marking_deque_.array(); |
| 359 intptr_t new_top = current; | 362 intptr_t new_top = current; |
| 360 | 363 |
| 364 Map* filler_map = heap_->one_pointer_filler_map(); | |
| 365 | |
| 361 while (current != limit) { | 366 while (current != limit) { |
| 362 HeapObject* obj = array[current]; | 367 HeapObject* obj = array[current]; |
| 363 current = ((current + 1) & mask); | 368 current = ((current + 1) & mask); |
| 364 if (heap_->InNewSpace(obj)) { | 369 if (heap_->InNewSpace(obj)) { |
| 365 MapWord map_word = obj->map_word(); | 370 MapWord map_word = obj->map_word(); |
| 366 if (map_word.IsForwardingAddress()) { | 371 if (map_word.IsForwardingAddress()) { |
| 367 HeapObject* dest = map_word.ToForwardingAddress(); | 372 HeapObject* dest = map_word.ToForwardingAddress(); |
| 368 array[new_top] = dest; | 373 array[new_top] = dest; |
| 369 new_top = ((new_top + 1) & mask); | 374 new_top = ((new_top + 1) & mask); |
| 370 ASSERT(new_top != marking_deque_.bottom()); | 375 ASSERT(new_top != marking_deque_.bottom()); |
| 371 ASSERT(Marking::Color(obj) == Marking::Color(dest)); | 376 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj))); |
| 372 } | 377 } |
| 373 } else { | 378 } else if (obj->map() != filler_map) { |
|
Erik Corry
2011/06/06 10:27:39
It would be nice with a comment as to how these gr
| |
| 374 array[new_top] = obj; | 379 array[new_top] = obj; |
| 375 new_top = ((new_top + 1) & mask); | 380 new_top = ((new_top + 1) & mask); |
| 376 ASSERT(new_top != marking_deque_.bottom()); | 381 ASSERT(new_top != marking_deque_.bottom()); |
| 382 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(obj))); | |
| 377 } | 383 } |
| 378 } | 384 } |
| 379 marking_deque_.set_top(new_top); | 385 marking_deque_.set_top(new_top); |
| 380 } | 386 } |
| 381 | 387 |
| 382 | 388 |
| 383 void IncrementalMarking::Hurry() { | 389 void IncrementalMarking::Hurry() { |
| 384 if (state() == MARKING) { | 390 if (state() == MARKING) { |
| 385 double start = 0.0; | 391 double start = 0.0; |
| 386 if (FLAG_trace_incremental_marking) { | 392 if (FLAG_trace_incremental_marking) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 } | 525 } |
| 520 | 526 |
| 521 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { | 527 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { |
| 522 double end = OS::TimeCurrentMillis(); | 528 double end = OS::TimeCurrentMillis(); |
| 523 steps_took_ += (end - start); | 529 steps_took_ += (end - start); |
| 524 } | 530 } |
| 525 } | 531 } |
| 526 | 532 |
| 527 | 533 |
| 528 } } // namespace v8::internal | 534 } } // namespace v8::internal |
| OLD | NEW |