592aee4838
The change was already reverted and I accidentally relanded this. Change-Id: I62ff3367db7aaaf3a470727fdb587830a23fe53c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98566 Reviewed-by: Martin Kustermann <kustermann@google.com>
68 lines
1.8 KiB
C++
68 lines
1.8 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_HEAP_COMPACTOR_H_
|
|
#define RUNTIME_VM_HEAP_COMPACTOR_H_
|
|
|
|
#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 {
|
|
public:
|
|
GCCompactor(Thread* thread, Heap* heap)
|
|
: HandleVisitor(thread),
|
|
ObjectPointerVisitor(thread->isolate()),
|
|
heap_(heap) {}
|
|
~GCCompactor() {}
|
|
|
|
void Compact(HeapPage* pages, FreeList* freelist, Mutex* mutex);
|
|
|
|
private:
|
|
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
|
|
|
|
#endif // RUNTIME_VM_HEAP_COMPACTOR_H_
|