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

Side by Side Diff: runtime/vm/virtual_memory_fuchsia.cc

Issue 2583543004: Fuchsia: Switch to new virtual memory syscalls (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_FUCHSIA) 6 #if defined(TARGET_OS_FUCHSIA)
7 7
8 #include "vm/virtual_memory.h" 8 #include "vm/virtual_memory.h"
9 9
10 #include <magenta/syscalls.h> 10 #include <magenta/syscalls.h>
(...skipping 19 matching lines...) Expand all
30 if (status != NO_ERROR) { 30 if (status != NO_ERROR) {
31 return NULL; 31 return NULL;
32 } 32 }
33 33
34 // TODO(zra): map with PERM_NONE, when that works, and relax with 34 // TODO(zra): map with PERM_NONE, when that works, and relax with
35 // Commit and Protect when they are implemented. 35 // Commit and Protect when they are implemented.
36 // Issue MG-161. 36 // Issue MG-161.
37 const int prot = 37 const int prot =
38 MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_WRITE | MX_VM_FLAG_PERM_EXECUTE; 38 MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_WRITE | MX_VM_FLAG_PERM_EXECUTE;
39 uintptr_t addr; 39 uintptr_t addr;
40 status = mx_process_map_vm(mx_process_self(), vmo, 0, size, &addr, prot); 40 status = mx_vmar_map(mx_vmar_root_self(), 0, vmo, 0, size, prot, &addr);
41 if (status != NO_ERROR) { 41 if (status != NO_ERROR) {
42 mx_handle_close(vmo); 42 mx_handle_close(vmo);
43 FATAL("VirtualMemory::ReserveInternal FAILED"); 43 FATAL("VirtualMemory::ReserveInternal FAILED");
44 return NULL; 44 return NULL;
45 } 45 }
46 46
47 MemoryRegion region(reinterpret_cast<void*>(addr), size); 47 MemoryRegion region(reinterpret_cast<void*>(addr), size);
48 return new VirtualMemory(region, vmo); 48 return new VirtualMemory(region, vmo);
49 } 49 }
50 50
51 51
52 VirtualMemory::~VirtualMemory() { 52 VirtualMemory::~VirtualMemory() {
53 if (!embedder_allocated()) { 53 if (!embedder_allocated()) {
54 // TODO(zra): Use reserved_size_. 54 // TODO(zra): Use reserved_size_.
55 // Issue MG-162. 55 // Issue MG-162.
56 uintptr_t addr = reinterpret_cast<uintptr_t>(address()); 56 uintptr_t addr = reinterpret_cast<uintptr_t>(address());
57 mx_status_t status = 57 mx_status_t status =
58 mx_process_unmap_vm(mx_process_self(), addr, 0 /*reserved_size_*/); 58 mx_vmar_unmap(mx_vmar_root_self(), addr, 0 /*reserved_size_*/);
59 if (status != NO_ERROR) { 59 if (status != NO_ERROR) {
60 FATAL("VirtualMemory::~VirtualMemory: unamp FAILED"); 60 FATAL("VirtualMemory::~VirtualMemory: unamp FAILED");
61 } 61 }
62 62
63 status = mx_handle_close(handle()); 63 status = mx_handle_close(handle());
64 if (status != NO_ERROR) { 64 if (status != NO_ERROR) {
65 FATAL("VirtualMemory::~VirtualMemory: handle_close FAILED"); 65 FATAL("VirtualMemory::~VirtualMemory: handle_close FAILED");
66 } 66 }
67 } 67 }
68 } 68 }
(...skipping 14 matching lines...) Expand all
83 83
84 84
85 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { 85 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
86 // TODO(zra): Implement when Fuchsia has an mprotect-like call. 86 // TODO(zra): Implement when Fuchsia has an mprotect-like call.
87 return true; 87 return true;
88 } 88 }
89 89
90 } // namespace dart 90 } // namespace dart
91 91
92 #endif // defined(TARGET_OS_FUCHSIA) 92 #endif // defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698