dart-sdk/runtime/vm/gc_compactor.h
Ryan Macnak e4d01aa323 [vm, gc] Remove the evacuating compactor.
This was a temporary measure to verify the VM could handle moving old-space objects before we had the sliding compactor.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I4ffec413918481c0af4828d126930455f620935d
Reviewed-on: https://dart-review.googlesource.com/22663
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-11-22 18:12:02 +00:00

64 lines
1.7 KiB
C++

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_GC_COMPACTOR_H_
#define RUNTIME_VM_GC_COMPACTOR_H_
#include "vm/allocation.h"
#include "vm/dart_api_state.h"
#include "vm/globals.h"
#include "vm/visitor.h"
namespace dart {
// Forward declarations.
class FreeList;
class Heap;
class HeapPage;
class RawObject;
// Implements a sliding compactor.
class GCCompactor : public ValueObject,
private HandleVisitor,
private ObjectPointerVisitor {
public:
GCCompactor(Thread* thread, Heap* heap)
: HandleVisitor(thread),
ObjectPointerVisitor(thread->isolate()),
heap_(heap) {}
~GCCompactor() {}
void CompactBySliding(HeapPage* pages, FreeList* freelist, Mutex* mutex);
private:
void SlidePage(HeapPage* page);
uword SlideBlock(uword first_object, ForwardingPage* forwarding_page);
void MoveToExactAddress(uword addr);
void MoveToContiguousSize(intptr_t size);
void ForwardPointersForSliding();
void ForwardPointerForSliding(RawObject** ptr);
void VisitPointers(RawObject** first, RawObject** last);
void VisitHandle(uword addr);
Heap* heap_;
HeapPage* free_page_;
uword free_current_;
uword free_end_;
FreeList* freelist_;
struct ImagePageRange {
uword base;
uword size;
};
// There are up to 4 images to consider:
// {instructions, data} x {vm isolate, current isolate}
static const intptr_t kMaxImagePages = 4;
ImagePageRange image_page_ranges_[kMaxImagePages];
};
} // namespace dart
#endif // RUNTIME_VM_GC_COMPACTOR_H_