OLD | NEW |
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/status.h> | 10 #include <magenta/status.h> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 mx_status_get_string(status)); | 164 mx_status_get_string(status)); |
165 return NULL; | 165 return NULL; |
166 } | 166 } |
167 VmarList::AddVmar(vmar, addr, size); | 167 VmarList::AddVmar(vmar, addr, size); |
168 MemoryRegion region(reinterpret_cast<void*>(addr), size); | 168 MemoryRegion region(reinterpret_cast<void*>(addr), size); |
169 return new VirtualMemory(region, vmar); | 169 return new VirtualMemory(region, vmar); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 VirtualMemory::~VirtualMemory() { | 173 VirtualMemory::~VirtualMemory() { |
174 if (!embedder_allocated()) { | 174 if (vm_owns_region()) { |
175 mx_handle_t vmar = static_cast<mx_handle_t>(handle()); | 175 mx_handle_t vmar = static_cast<mx_handle_t>(handle()); |
176 mx_status_t status = mx_vmar_destroy(vmar); | 176 mx_status_t status = mx_vmar_destroy(vmar); |
177 if (status != NO_ERROR) { | 177 if (status != NO_ERROR) { |
178 LOG_ERR("mx_vmar_destroy failed: %s\n", mx_status_get_string(status)); | 178 LOG_ERR("mx_vmar_destroy failed: %s\n", mx_status_get_string(status)); |
179 } | 179 } |
180 status = mx_handle_close(vmar); | 180 status = mx_handle_close(vmar); |
181 if (status != NO_ERROR) { | 181 if (status != NO_ERROR) { |
182 LOG_ERR("mx_handle_close failed: %s\n", mx_status_get_string(status)); | 182 LOG_ERR("mx_handle_close failed: %s\n", mx_status_get_string(status)); |
183 } | 183 } |
184 VmarList::RemoveVmar(start()); | 184 VmarList::RemoveVmar(start()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return false; | 273 return false; |
274 } | 274 } |
275 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address, | 275 LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address, |
276 end_address - page_address, prot); | 276 end_address - page_address, prot); |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
280 } // namespace dart | 280 } // namespace dart |
281 | 281 |
282 #endif // defined(TARGET_OS_FUCHSIA) | 282 #endif // defined(TARGET_OS_FUCHSIA) |
OLD | NEW |