| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 482 } |
| 483 | 483 |
| 484 | 484 |
| 485 void Heap::WriteProtect(bool read_only) { | 485 void Heap::WriteProtect(bool read_only) { |
| 486 read_only_ = read_only; | 486 read_only_ = read_only; |
| 487 new_space_.WriteProtect(read_only); | 487 new_space_.WriteProtect(read_only); |
| 488 old_space_.WriteProtect(read_only); | 488 old_space_.WriteProtect(read_only); |
| 489 } | 489 } |
| 490 | 490 |
| 491 | 491 |
| 492 intptr_t Heap::TopOffset(Heap::Space space) { | |
| 493 if (space == kNew) { | |
| 494 return OFFSET_OF(Heap, new_space_) + Scavenger::top_offset(); | |
| 495 } else { | |
| 496 ASSERT(space == kOld); | |
| 497 return OFFSET_OF(Heap, old_space_) + PageSpace::top_offset(); | |
| 498 } | |
| 499 } | |
| 500 | |
| 501 | |
| 502 intptr_t Heap::EndOffset(Heap::Space space) { | |
| 503 if (space == kNew) { | |
| 504 return OFFSET_OF(Heap, new_space_) + Scavenger::end_offset(); | |
| 505 } else { | |
| 506 ASSERT(space == kOld); | |
| 507 return OFFSET_OF(Heap, old_space_) + PageSpace::end_offset(); | |
| 508 } | |
| 509 } | |
| 510 | |
| 511 | |
| 512 void Heap::Init(Isolate* isolate, | 492 void Heap::Init(Isolate* isolate, |
| 513 intptr_t max_new_gen_words, | 493 intptr_t max_new_gen_words, |
| 514 intptr_t max_old_gen_words, | 494 intptr_t max_old_gen_words, |
| 515 intptr_t max_external_words) { | 495 intptr_t max_external_words) { |
| 516 ASSERT(isolate->heap() == NULL); | 496 ASSERT(isolate->heap() == NULL); |
| 517 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, | 497 Heap* heap = new Heap(isolate, max_new_gen_words, max_old_gen_words, |
| 518 max_external_words); | 498 max_external_words); |
| 519 isolate->set_heap(heap); | 499 isolate->set_heap(heap); |
| 520 } | 500 } |
| 521 | 501 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 Dart::vm_isolate()->heap()->WriteProtect(false); | 857 Dart::vm_isolate()->heap()->WriteProtect(false); |
| 878 } | 858 } |
| 879 | 859 |
| 880 | 860 |
| 881 WritableVMIsolateScope::~WritableVMIsolateScope() { | 861 WritableVMIsolateScope::~WritableVMIsolateScope() { |
| 882 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); | 862 ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0); |
| 883 Dart::vm_isolate()->heap()->WriteProtect(true); | 863 Dart::vm_isolate()->heap()->WriteProtect(true); |
| 884 } | 864 } |
| 885 | 865 |
| 886 } // namespace dart | 866 } // namespace dart |
| OLD | NEW |