Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
compactor.h
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5#ifndef RUNTIME_VM_HEAP_COMPACTOR_H_
6#define RUNTIME_VM_HEAP_COMPACTOR_H_
7
9
10#include "vm/allocation.h"
11#include "vm/dart_api_state.h"
12#include "vm/globals.h"
13#include "vm/visitor.h"
14
15namespace dart {
16
17// Forward declarations.
18class FreeList;
19class Heap;
20class Page;
21
22// Implements a sliding compactor.
23class GCCompactor : public ValueObject,
24 public HandleVisitor,
26 public:
31 ~GCCompactor() { free(image_page_ranges_); }
32
33 void Compact(Page* pages, FreeList* freelist, Mutex* mutex);
34
35 private:
36 friend class CompactorTask;
37
38 void SetupImagePageBoundaries();
39 void SetupLargePages();
40 void ForwardLargePages();
41 void ForwardStackPointers();
42 void ForwardPointer(ObjectPtr* ptr);
43 void ForwardCompressedPointer(uword heap_base, CompressedObjectPtr* ptr);
44 void VisitTypedDataViewPointers(TypedDataViewPtr view,
46 CompressedObjectPtr* last) override;
47 void VisitPointers(ObjectPtr* first, ObjectPtr* last) override;
48#if defined(DART_COMPRESSED_POINTERS)
49 void VisitCompressedPointers(uword heap_base,
51 CompressedObjectPtr* last) override;
52#endif
53 bool CanVisitSuspendStatePointers(SuspendStatePtr suspend_state) override;
54 void VisitHandle(uword addr) override;
55
56 Heap* heap_;
57
58 struct ImagePageRange {
60 uword end;
61 };
62 static int CompareImagePageRanges(const ImagePageRange* a,
63 const ImagePageRange* b) {
64 if (a->start < b->start) {
65 return -1;
66 } else if (a->start == b->start) {
67 return 0;
68 } else {
69 return 1;
70 }
71 }
72 intptr_t image_page_hi_ = 0;
73 ImagePageRange* image_page_ranges_ = nullptr;
74
75 Mutex large_pages_mutex_;
76 Page* large_pages_ = nullptr;
77
78 // The typed data views whose inner pointer must be updated after sliding is
79 // complete.
80 Mutex typed_data_view_mutex_;
81 MallocGrowableArray<TypedDataViewPtr> typed_data_views_;
82
83 // SuspendState objects with copied frame must be updated after sliding is
84 // complete.
85 bool can_visit_stack_frames_ = false;
86 Mutex postponed_suspend_states_mutex_;
87 MallocGrowableArray<SuspendStatePtr> postponed_suspend_states_;
88};
89
90} // namespace dart
91
92#endif // RUNTIME_VM_HEAP_COMPACTOR_H_
void Compact(Page *pages, FreeList *freelist, Mutex *mutex)
Definition compactor.cc:184
void VisitTypedDataViewPointers(TypedDataViewPtr view, CompressedObjectPtr *first, CompressedObjectPtr *last) override
Definition compactor.cc:713
void VisitHandle(uword addr) override
Definition compactor.cc:780
void VisitPointers(ObjectPtr *first, ObjectPtr *last) override
Definition compactor.cc:749
GCCompactor(Thread *thread, Heap *heap)
Definition compactor.h:27
bool CanVisitSuspendStatePointers(SuspendStatePtr suspend_state) override
Definition compactor.cc:765
Thread * thread() const
IsolateGroup * isolate_group() const
Definition visitor.h:25
void VisitCompressedPointers(uword heap_base, CompressedObjectPtr *first, CompressedObjectPtr *last)
Definition visitor.h:43
static bool b
struct MyStruct a[10]
glong glong end
uintptr_t uword
Definition globals.h:501