OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/scavenger.h" | 5 #include "vm/scavenger.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 return bits == kForwarded; | 45 return bits == kForwarded; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 static inline uword ForwardedAddr(uword header) { | 49 static inline uword ForwardedAddr(uword header) { |
50 ASSERT(IsForwarding(header)); | 50 ASSERT(IsForwarding(header)); |
51 return header & ~kForwardingMask; | 51 return header & ~kForwardingMask; |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 static inline void ForwardTo(uword orignal, uword target) { | 55 static inline void ForwardTo(uword original, uword target) { |
56 // Make sure forwarding can be encoded. | 56 // Make sure forwarding can be encoded. |
57 ASSERT((target & kForwardingMask) == 0); | 57 ASSERT((target & kForwardingMask) == 0); |
58 *reinterpret_cast<uword*>(orignal) = target | kForwarded; | 58 *reinterpret_cast<uword*>(original) = target | kForwarded; |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 class BoolScope : public ValueObject { | 62 class BoolScope : public ValueObject { |
63 public: | 63 public: |
64 BoolScope(bool* addr, bool value) : _addr(addr), _value(*addr) { | 64 BoolScope(bool* addr, bool value) : _addr(addr), _value(*addr) { |
65 *_addr = value; | 65 *_addr = value; |
66 } | 66 } |
67 ~BoolScope() { | 67 ~BoolScope() { |
68 *_addr = _value; | 68 *_addr = _value; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 if (avg_frac < (FLAG_early_tenuring_threshold / 100.0)) { | 475 if (avg_frac < (FLAG_early_tenuring_threshold / 100.0)) { |
476 // Remember the limit to which objects have been copied. | 476 // Remember the limit to which objects have been copied. |
477 survivor_end_ = top_; | 477 survivor_end_ = top_; |
478 } else { | 478 } else { |
479 // Move survivor end to the end of the to_ space, making all surviving | 479 // Move survivor end to the end of the to_ space, making all surviving |
480 // objects candidates for promotion next time. | 480 // objects candidates for promotion next time. |
481 survivor_end_ = end_; | 481 survivor_end_ = end_; |
482 } | 482 } |
483 | 483 |
484 #if defined(DEBUG) | 484 #if defined(DEBUG) |
485 VerifyStoreBufferPointerVisitor verify_store_buffer_visitor(isolate, to_); | 485 // We can only safely verify the store buffers from old space if there is no |
486 heap_->IterateOldPointers(&verify_store_buffer_visitor); | 486 // concurrent old space task. At the same time we prevent new tasks from |
| 487 // being spawned. |
| 488 { |
| 489 PageSpace* page_space = heap_->old_space(); |
| 490 MonitorLocker ml(page_space->tasks_lock()); |
| 491 if (page_space->tasks() == 0) { |
| 492 VerifyStoreBufferPointerVisitor verify_store_buffer_visitor(isolate, to_); |
| 493 heap_->IterateOldPointers(&verify_store_buffer_visitor); |
| 494 } |
| 495 } |
487 #endif // defined(DEBUG) | 496 #endif // defined(DEBUG) |
488 from_->Delete(); | 497 from_->Delete(); |
489 from_ = NULL; | 498 from_ = NULL; |
490 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { | 499 if (invoke_api_callbacks && (isolate->gc_epilogue_callback() != NULL)) { |
491 (isolate->gc_epilogue_callback())(); | 500 (isolate->gc_epilogue_callback())(); |
492 } | 501 } |
493 } | 502 } |
494 | 503 |
495 | 504 |
496 void Scavenger::IterateStoreBuffers(Isolate* isolate, | 505 void Scavenger::IterateStoreBuffers(Isolate* isolate, |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 } | 882 } |
874 | 883 |
875 | 884 |
876 void Scavenger::FreeExternal(intptr_t size) { | 885 void Scavenger::FreeExternal(intptr_t size) { |
877 ASSERT(size >= 0); | 886 ASSERT(size >= 0); |
878 external_size_ -= size; | 887 external_size_ -= size; |
879 ASSERT(external_size_ >= 0); | 888 ASSERT(external_size_ >= 0); |
880 } | 889 } |
881 | 890 |
882 } // namespace dart | 891 } // namespace dart |
OLD | NEW |