| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 external_size_(0) { | 340 external_size_(0) { |
| 341 // Verify assumptions about the first word in objects which the scavenger is | 341 // Verify assumptions about the first word in objects which the scavenger is |
| 342 // going to use for forwarding pointers. | 342 // going to use for forwarding pointers. |
| 343 ASSERT(Object::tags_offset() == 0); | 343 ASSERT(Object::tags_offset() == 0); |
| 344 | 344 |
| 345 // Set initial size resulting in a total of three different levels. | 345 // Set initial size resulting in a total of three different levels. |
| 346 const intptr_t initial_semi_capacity_in_words = max_semi_capacity_in_words / | 346 const intptr_t initial_semi_capacity_in_words = max_semi_capacity_in_words / |
| 347 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor); | 347 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor); |
| 348 to_ = SemiSpace::New(initial_semi_capacity_in_words); | 348 to_ = SemiSpace::New(initial_semi_capacity_in_words); |
| 349 if (to_ == NULL) { | 349 if (to_ == NULL) { |
| 350 FATAL("Out of memory.\n"); | 350 OUT_OF_MEMORY(); |
| 351 } | 351 } |
| 352 // Setup local fields. | 352 // Setup local fields. |
| 353 top_ = FirstObjectStart(); | 353 top_ = FirstObjectStart(); |
| 354 resolved_top_ = top_; | 354 resolved_top_ = top_; |
| 355 end_ = to_->end(); | 355 end_ = to_->end(); |
| 356 | 356 |
| 357 survivor_end_ = FirstObjectStart(); | 357 survivor_end_ = FirstObjectStart(); |
| 358 | 358 |
| 359 UpdateMaxHeapCapacity(); | 359 UpdateMaxHeapCapacity(); |
| 360 UpdateMaxHeapUsage(); | 360 UpdateMaxHeapUsage(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 386 (isolate->gc_prologue_callback())(); | 386 (isolate->gc_prologue_callback())(); |
| 387 } | 387 } |
| 388 isolate->PrepareForGC(); | 388 isolate->PrepareForGC(); |
| 389 // Flip the two semi-spaces so that to_ is always the space for allocating | 389 // Flip the two semi-spaces so that to_ is always the space for allocating |
| 390 // objects. | 390 // objects. |
| 391 SemiSpace* from = to_; | 391 SemiSpace* from = to_; |
| 392 to_ = SemiSpace::New(NewSizeInWords(from->size_in_words())); | 392 to_ = SemiSpace::New(NewSizeInWords(from->size_in_words())); |
| 393 if (to_ == NULL) { | 393 if (to_ == NULL) { |
| 394 // TODO(koda): We could try to recover (collect old space, wait for another | 394 // TODO(koda): We could try to recover (collect old space, wait for another |
| 395 // isolate to finish scavenge, etc.). | 395 // isolate to finish scavenge, etc.). |
| 396 FATAL("Out of memory.\n"); | 396 OUT_OF_MEMORY(); |
| 397 } | 397 } |
| 398 UpdateMaxHeapCapacity(); | 398 UpdateMaxHeapCapacity(); |
| 399 top_ = FirstObjectStart(); | 399 top_ = FirstObjectStart(); |
| 400 resolved_top_ = top_; | 400 resolved_top_ = top_; |
| 401 end_ = to_->end(); | 401 end_ = to_->end(); |
| 402 return from; | 402 return from; |
| 403 } | 403 } |
| 404 | 404 |
| 405 | 405 |
| 406 void Scavenger::Epilogue(Isolate* isolate, | 406 void Scavenger::Epilogue(Isolate* isolate, |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 } | 900 } |
| 901 | 901 |
| 902 | 902 |
| 903 void Scavenger::FreeExternal(intptr_t size) { | 903 void Scavenger::FreeExternal(intptr_t size) { |
| 904 ASSERT(size >= 0); | 904 ASSERT(size >= 0); |
| 905 external_size_ -= size; | 905 external_size_ -= size; |
| 906 ASSERT(external_size_ >= 0); | 906 ASSERT(external_size_ >= 0); |
| 907 } | 907 } |
| 908 | 908 |
| 909 } // namespace dart | 909 } // namespace dart |
| OLD | NEW |