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 "vm/dart.h" | 7 #include "vm/dart.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 survivor_end_ = top_; | 917 survivor_end_ = top_; |
918 | 918 |
919 Scavenge(); | 919 Scavenge(); |
920 | 920 |
921 // It is possible for objects to stay in the new space | 921 // It is possible for objects to stay in the new space |
922 // if the VM cannot create more pages for these objects. | 922 // if the VM cannot create more pages for these objects. |
923 ASSERT((UsedInWords() == 0) || failed_to_promote_); | 923 ASSERT((UsedInWords() == 0) || failed_to_promote_); |
924 } | 924 } |
925 | 925 |
926 int64_t Scavenger::UsedInWords() const { | 926 int64_t Scavenger::UsedInWords() const { |
927 int64_t used_in_words = (top_ - FirstObjectStart()) >> kWordSizeLog2; | 927 int64_t free_space_in_tlab = 0; |
928 return used_in_words; | 928 if (heap_->isolate()->IsMutatorThreadScheduled()) { |
| 929 Thread* mutator_thread = heap_->isolate()->mutator_thread(); |
| 930 if (mutator_thread->HasActiveTLAB()) { |
| 931 free_space_in_tlab = |
| 932 (mutator_thread->end() - mutator_thread->top()) >> kWordSizeLog2; |
| 933 } |
| 934 } |
| 935 int64_t max_space_used = (top_ - FirstObjectStart()) >> kWordSizeLog2; |
| 936 return max_space_used - free_space_in_tlab; |
929 } | 937 } |
930 | 938 |
931 } // namespace dart | 939 } // namespace dart |
OLD | NEW |