Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: runtime/vm/virtual_memory.h

Issue 2929203002: [Fuchsia] Give VMOs names (Closed)
Patch Set: Fix tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/scavenger.cc ('k') | runtime/vm/virtual_memory_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_VIRTUAL_MEMORY_H_ 5 #ifndef RUNTIME_VM_VIRTUAL_MEMORY_H_
6 #define RUNTIME_VM_VIRTUAL_MEMORY_H_ 6 #define RUNTIME_VM_VIRTUAL_MEMORY_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/memory_region.h" 10 #include "vm/memory_region.h"
(...skipping 17 matching lines...) Expand all
28 uword start() const { return region_.start(); } 28 uword start() const { return region_.start(); }
29 uword end() const { return region_.end(); } 29 uword end() const { return region_.end(); }
30 void* address() const { return region_.pointer(); } 30 void* address() const { return region_.pointer(); }
31 intptr_t size() const { return region_.size(); } 31 intptr_t size() const { return region_.size(); }
32 32
33 static void InitOnce(); 33 static void InitOnce();
34 34
35 bool Contains(uword addr) const { return region_.Contains(addr); } 35 bool Contains(uword addr) const { return region_.Contains(addr); }
36 36
37 // Commits the virtual memory area, which is guaranteed to be zeroed. Returns 37 // Commits the virtual memory area, which is guaranteed to be zeroed. Returns
38 // true on success and false on failure (e.g., out-of-memory). 38 // true on success and false on failure (e.g., out-of-memory). The name
39 bool Commit(bool is_executable) { 39 // parameter is optional. On systems that support it, it is used to give the
40 return Commit(start(), size(), is_executable); 40 // OS a name for the committed memory region.
41 bool Commit(bool is_executable, const char* name) {
42 return Commit(start(), size(), is_executable, name);
41 } 43 }
42 44
43 // Changes the protection of the virtual memory area. 45 // Changes the protection of the virtual memory area.
44 static bool Protect(void* address, intptr_t size, Protection mode); 46 static bool Protect(void* address, intptr_t size, Protection mode);
45 bool Protect(Protection mode) { return Protect(address(), size(), mode); } 47 bool Protect(Protection mode) { return Protect(address(), size(), mode); }
46 48
47 // Reserves a virtual memory segment with size. If a segment of the requested 49 // Reserves a virtual memory segment with size. If a segment of the requested
48 // size cannot be allocated NULL is returned. 50 // size cannot be allocated NULL is returned.
49 static VirtualMemory* Reserve(intptr_t size) { return ReserveInternal(size); } 51 static VirtualMemory* Reserve(intptr_t size) { return ReserveInternal(size); }
50 52
51 static intptr_t PageSize() { 53 static intptr_t PageSize() {
52 ASSERT(page_size_ != 0); 54 ASSERT(page_size_ != 0);
53 ASSERT(Utils::IsPowerOfTwo(page_size_)); 55 ASSERT(Utils::IsPowerOfTwo(page_size_));
54 return page_size_; 56 return page_size_;
55 } 57 }
56 58
57 static bool InSamePage(uword address0, uword address1); 59 static bool InSamePage(uword address0, uword address1);
58 60
59 // Truncate this virtual memory segment. If try_unmap is false, the 61 // Truncate this virtual memory segment. If try_unmap is false, the
60 // memory beyond the new end is still accessible, but will be returned 62 // memory beyond the new end is still accessible, but will be returned
61 // upon destruction. 63 // upon destruction.
62 void Truncate(intptr_t new_size, bool try_unmap = true); 64 void Truncate(intptr_t new_size, bool try_unmap = true);
63 65
64 // Commit a reserved memory area, so that the memory can be accessed. 66 // Commit a reserved memory area, so that the memory can be accessed. The name
65 bool Commit(uword addr, intptr_t size, bool is_executable); 67 // parameter is optional. On systems that support it, it is used to give the
68 // OS a name for the committed memory region.
69 bool Commit(uword addr, intptr_t size, bool is_executable, const char* name);
66 70
67 bool vm_owns_region() const { return vm_owns_region_; } 71 bool vm_owns_region() const { return vm_owns_region_; }
68 72
69 static VirtualMemory* ForImagePage(void* pointer, uword size); 73 static VirtualMemory* ForImagePage(void* pointer, uword size);
70 74
71 private: 75 private:
72 static VirtualMemory* ReserveInternal(intptr_t size); 76 static VirtualMemory* ReserveInternal(intptr_t size);
73 77
74 // Free a sub segment. On operating systems that support it this 78 // Free a sub segment. On operating systems that support it this
75 // can give back the virtual memory to the system. Returns true on success. 79 // can give back the virtual memory to the system. Returns true on success.
(...skipping 21 matching lines...) Expand all
97 // belongs to the embedder and must not be deallocated or have its 101 // belongs to the embedder and must not be deallocated or have its
98 // protection status changed by the VM. 102 // protection status changed by the VM.
99 bool vm_owns_region_; 103 bool vm_owns_region_;
100 104
101 DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory); 105 DISALLOW_IMPLICIT_CONSTRUCTORS(VirtualMemory);
102 }; 106 };
103 107
104 } // namespace dart 108 } // namespace dart
105 109
106 #endif // RUNTIME_VM_VIRTUAL_MEMORY_H_ 110 #endif // RUNTIME_VM_VIRTUAL_MEMORY_H_
OLDNEW
« no previous file with comments | « runtime/vm/scavenger.cc ('k') | runtime/vm/virtual_memory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698