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

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

Issue 2929203002: [Fuchsia] Give VMOs names (Closed)
Patch Set: 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/virtual_memory_android.cc ('k') | runtime/vm/virtual_memory_linux.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) 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(HOST_OS_FUCHSIA) 6 #if defined(HOST_OS_FUCHSIA)
7 7
8 #include "vm/virtual_memory.h" 8 #include "vm/virtual_memory.h"
9 9
10 #include <magenta/process.h> 10 #include <magenta/process.h>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 mx_status_t status = 194 mx_status_t status =
195 mx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size); 195 mx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size);
196 if (status != NO_ERROR) { 196 if (status != NO_ERROR) {
197 LOG_ERR("mx_vmar_unmap failed: %s\n", mx_status_get_string(status)); 197 LOG_ERR("mx_vmar_unmap failed: %s\n", mx_status_get_string(status));
198 return false; 198 return false;
199 } 199 }
200 return true; 200 return true;
201 } 201 }
202 202
203 203
204 bool VirtualMemory::Commit(uword addr, intptr_t size, bool executable) { 204 bool VirtualMemory::Commit(uword addr,
205 intptr_t size,
206 bool executable,
207 const char* name) {
205 ASSERT(Contains(addr)); 208 ASSERT(Contains(addr));
206 ASSERT(Contains(addr + size) || (addr + size == end())); 209 ASSERT(Contains(addr + size) || (addr + size == end()));
207 mx_handle_t vmo = MX_HANDLE_INVALID; 210 mx_handle_t vmo = MX_HANDLE_INVALID;
208 mx_status_t status = mx_vmo_create(size, 0u, &vmo); 211 mx_status_t status = mx_vmo_create(size, 0u, &vmo);
209 if (status != NO_ERROR) { 212 if (status != NO_ERROR) {
210 LOG_ERR("mx_vmo_create(%ld) failed: %s\n", size, 213 LOG_ERR("mx_vmo_create(%ld) failed: %s\n", size,
211 mx_status_get_string(status)); 214 mx_status_get_string(status));
212 return false; 215 return false;
213 } 216 }
214 217
218 if (name != NULL) {
219 status = mx_object_set_property(vmo, MX_PROP_NAME, name, strlen(name));
220 if (status != NO_ERROR) {
abarth 2017/06/09 19:46:40 The pattern we've been using is to ignore errors o
zra 2017/06/09 20:10:22 Done.
221 mx_handle_close(vmo);
222 LOG_ERR("mx_object_set_property on vmo failed: %s\n",
223 mx_status_get_string(status));
224 }
225 }
226
215 mx_handle_t vmar = static_cast<mx_handle_t>(handle()); 227 mx_handle_t vmar = static_cast<mx_handle_t>(handle());
216 const size_t offset = addr - start(); 228 const size_t offset = addr - start();
217 const uint32_t flags = MX_VM_FLAG_SPECIFIC | MX_VM_FLAG_PERM_READ | 229 const uint32_t flags = MX_VM_FLAG_SPECIFIC | MX_VM_FLAG_PERM_READ |
218 MX_VM_FLAG_PERM_WRITE | 230 MX_VM_FLAG_PERM_WRITE |
219 (executable ? MX_VM_FLAG_PERM_EXECUTE : 0); 231 (executable ? MX_VM_FLAG_PERM_EXECUTE : 0);
220 uintptr_t mapped_addr; 232 uintptr_t mapped_addr;
221 status = mx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr); 233 status = mx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr);
222 if (status != NO_ERROR) { 234 if (status != NO_ERROR) {
223 mx_handle_close(vmo); 235 mx_handle_close(vmo);
224 LOG_ERR("mx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags, 236 LOG_ERR("mx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return false; 286 return false;
275 } 287 }
276 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address, 288 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address,
277 end_address - page_address, prot); 289 end_address - page_address, prot);
278 return true; 290 return true;
279 } 291 }
280 292
281 } // namespace dart 293 } // namespace dart
282 294
283 #endif // defined(HOST_OS_FUCHSIA) 295 #endif // defined(HOST_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/vm/virtual_memory_android.cc ('k') | runtime/vm/virtual_memory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698