Flutter Engine
The Flutter Engine
virtual_memory_compressed.h
Go to the documentation of this file.
1// Copyright (c) 2021, 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_VIRTUAL_MEMORY_COMPRESSED_H_
6#define RUNTIME_VM_VIRTUAL_MEMORY_COMPRESSED_H_
7
8#include "vm/globals.h"
9#include "vm/heap/page.h"
10#include "vm/memory_region.h"
11
12namespace dart {
13
14#if defined(DART_COMPRESSED_POINTERS)
15static constexpr intptr_t kCompressedHeapSize = 4 * GB;
16static constexpr intptr_t kCompressedHeapAlignment = 4 * GB;
17static constexpr intptr_t kCompressedPageSize = kPageSize;
18static constexpr intptr_t kCompressedHeapNumPages =
19 kCompressedHeapSize / kPageSize;
20static constexpr intptr_t kCompressedHeapBitmapSize =
21 kCompressedHeapNumPages / 8;
22
23#if !defined(DART_HOST_OS_FUCHSIA)
24#define DART_COMPRESSED_HEAP
25#endif // !defined(DART_HOST_OS_FUCHSIA)
26#endif // defined(DART_COMPRESSED_POINTERS)
27
28#if defined(DART_COMPRESSED_HEAP)
29
30// Utilities for allocating memory within a contiguous region of memory, for use
31// with compressed pointers.
32class VirtualMemoryCompressedHeap : public AllStatic {
33 public:
34 // Initializes the compressed heap. The callee must allocate a region of
35 // kCompressedHeapSize bytes, aligned to kCompressedHeapSize.
36 static void Init(void* compressed_heap_region, size_t size);
37
38 // Cleans up the compressed heap. The callee is responsible for freeing the
39 // region's memory.
40 static void Cleanup();
41
42 // Allocates a segment of the compressed heap with the given size. Returns a
43 // heap memory region if a large enough free segment can't be found.
44 static MemoryRegion Allocate(intptr_t size, intptr_t alignment);
45
46 // Frees a segment.
47 static void Free(void* address, intptr_t size);
48
49 // Returns whether the address is within the compressed heap.
50 static bool Contains(void* address);
51
52 // Returns a pointer to the compressed heap region.
53 static void* GetRegion();
54
55 private:
56 static bool IsPageUsed(uword page_id);
57 static void SetPageUsed(uword page_id);
58 static void ClearPageUsed(uword page_id);
59
60 static uword base_;
61 static uword size_;
62 static uint8_t* pages_;
63 static uword minimum_free_page_id_;
64 static Mutex* mutex_;
65};
66
67#endif // defined(DART_COMPRESSED_HEAP)
68
69} // namespace dart
70
71#endif // RUNTIME_VM_VIRTUAL_MEMORY_COMPRESSED_H_
void Init()
bool Contains(const Container &container, const Value &value)
Definition: dart_vm.cc:33
static constexpr intptr_t kPageSize
Definition: page.h:27
static void * Allocate(uword size, Zone *zone)
Definition: allocation.cc:14
uintptr_t uword
Definition: globals.h:501
static void Free(FreeList *free_list, uword address, intptr_t size, bool is_protected)
constexpr intptr_t GB
Definition: globals.h:532
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259