blob: c55eb9aada32899d4e244a688d9673b9cbf7d586 [file] [log] [blame]
// 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.
#include "platform/growable_array.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,
public HandleVisitor,
public ObjectPointerVisitor {
GCCompactor(Thread* thread, Heap* heap)
: HandleVisitor(thread),
heap_(heap) {}
~GCCompactor() {}
void Compact(HeapPage* pages, FreeList* freelist, Mutex* mutex);
friend class CompactorTask;
void SetupImagePageBoundaries();
void ForwardStackPointers();
void ForwardPointer(RawObject** ptr);
void VisitTypedDataViewPointers(RawTypedDataView* view,
RawObject** first,
RawObject** last);
void VisitPointers(RawObject** first, RawObject** last);
void VisitHandle(uword addr);
Heap* heap_;
struct ImagePageRange {
uword base;
uword size;
// There are up to 6 images to consider:
// {instructions, data} x {vm isolate, current isolate, shared}
static const intptr_t kMaxImagePages = 6;
ImagePageRange image_page_ranges_[kMaxImagePages];
// The typed data views whose inner pointer must be updated after sliding is
// complete.
Mutex typed_data_view_mutex_;
MallocGrowableArray<RawTypedDataView*> typed_data_views_;
} // namespace dart