Flutter Engine
The Flutter Engine
allocation.h
Go to the documentation of this file.
1// Copyright (c) 2013, 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_ALLOCATION_H_
6#define RUNTIME_VM_ALLOCATION_H_
7
9#include "platform/assert.h"
10#include "vm/globals.h"
11
12namespace dart {
13
14// Forward declarations.
15class ThreadState;
16class Zone;
17
18// Stack resources subclass from this base class. The VM will ensure that the
19// destructors of these objects are called before the stack is unwound past the
20// objects location on the stack. Use stack resource objects if objects
21// need to be destroyed even in the case of exceptions when a Longjump is done
22// to a stack frame above the frame where these objects were allocated.
24 public:
26 : thread_(nullptr), previous_(nullptr) {
27 Init(thread);
28 }
29
30 virtual ~StackResource();
31
32 // The thread that owns this resource.
33 ThreadState* thread() const { return thread_; }
34
35 // Destroy stack resources of thread until top exit frame.
36 static void Unwind(ThreadState* thread) { UnwindAbove(thread, nullptr); }
37 // Destroy stack resources of thread above new_top, exclusive.
38 static void UnwindAbove(ThreadState* thread, StackResource* new_top);
39
40 private:
41 void Init(ThreadState* thread);
42
43 ThreadState* thread_;
44 StackResource* previous_;
45
46 DISALLOW_ALLOCATION();
47 DISALLOW_IMPLICIT_CONSTRUCTORS(StackResource);
48};
49
50// Zone allocated objects cannot be individually deallocated, but have
51// to rely on the destructor of Zone which is called when the Zone
52// goes out of scope to reclaim memory.
54 public:
56
57 // Implicitly allocate the object in the current zone.
58 void* operator new(size_t size);
59
60 // Allocate the object in the given zone, which must be the current zone.
61 void* operator new(size_t size, Zone* zone);
62
63 // Ideally, the delete operator should be protected instead of
64 // public, but unfortunately the compiler sometimes synthesizes
65 // (unused) destructors for classes derived from ZoneObject, which
66 // require the operator to be visible. MSVC requires the delete
67 // operator to be public.
68
69 // Disallow explicit deallocation of nodes. Nodes can only be
70 // deallocated by invoking DeleteAll() on the zone they live in.
71 void operator delete(void* pointer) { UNREACHABLE(); }
72
73 private:
74 DISALLOW_COPY_AND_ASSIGN(ZoneAllocated);
75};
76
77} // namespace dart
78
79// Prevent use of `new (zone) DoesNotExtendZoneAllocated()`, which places the
80// DoesNotExtendZoneAllocated on top of the Zone.
81void* operator new(size_t size, dart::Zone* zone) = delete;
82
83#endif // RUNTIME_VM_ALLOCATION_H_
#define UNREACHABLE()
Definition: assert.h:248
ThreadState * thread() const
Definition: allocation.h:33
StackResource(ThreadState *thread)
Definition: allocation.h:25
static void UnwindAbove(ThreadState *thread, StackResource *new_top)
Definition: allocation.cc:56
static void Unwind(ThreadState *thread)
Definition: allocation.h:36
virtual ~StackResource()
Definition: allocation.cc:30
Definition: dart_vm.cc:33
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