Commit a900e53f authored by Scott Graham's avatar Scott Graham Committed by Commit Bot

fuchsia: Remove scaffolding for 3-sided roll

Chromium has rolled the Fuchsia SDK, so this can be removed now, and
the new zx_, etc. names used exclusively.

Bug: chromium:765754
Change-Id: I8bd60239da7a05e62d3b8d5209e1cfe898d8052a
Reviewed-on: https://chromium-review.googlesource.com/671769Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48071}
parent af1c9de9
......@@ -2,28 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(scottmg): Temporary during 3-sided roll, see https://crbug.com/765754.
#if defined(CHROMIUM_ROLLING_MAGENTA_TO_ZIRCON)
#include <zircon/process.h>
#include <zircon/syscalls.h>
#define MX_OK ZX_OK
#define MX_PROP_NAME ZX_PROP_NAME
#define MX_VM_FLAG_PERM_EXECUTE ZX_VM_FLAG_PERM_EXECUTE
#define MX_VM_FLAG_PERM_READ ZX_VM_FLAG_PERM_READ
#define MX_VM_FLAG_PERM_WRITE ZX_VM_FLAG_PERM_WRITE
#define mx_handle_close zx_handle_close
#define mx_handle_t zx_handle_t
#define mx_object_set_property zx_object_set_property
#define mx_status_t zx_status_t
#define mx_vmar_map zx_vmar_map
#define mx_vmar_protect zx_vmar_protect
#define mx_vmar_root_self zx_vmar_root_self
#define mx_vmar_unmap zx_vmar_unmap
#define mx_vmo_create zx_vmo_create
#else
#include <magenta/process.h>
#include <magenta/syscalls.h>
#endif
#include "src/base/macros.h"
#include "src/base/platform/platform-posix-time.h"
......@@ -64,18 +44,18 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment, void* hint)
size_t request_size =
RoundUp(size + alignment, static_cast<intptr_t>(OS::AllocateAlignment()));
mx_handle_t vmo;
if (mx_vmo_create(request_size, 0, &vmo) != MX_OK) return;
zx_handle_t vmo;
if (zx_vmo_create(request_size, 0, &vmo) != ZX_OK) return;
static const char kVirtualMemoryName[] = "v8-virtualmem";
mx_object_set_property(vmo, MX_PROP_NAME, kVirtualMemoryName,
zx_object_set_property(vmo, ZX_PROP_NAME, kVirtualMemoryName,
strlen(kVirtualMemoryName));
uintptr_t reservation;
mx_status_t status = mx_vmar_map(mx_vmar_root_self(), 0, vmo, 0, request_size,
zx_status_t status = zx_vmar_map(zx_vmar_root_self(), 0, vmo, 0, request_size,
0 /*no permissions*/, &reservation);
// Either the vmo is now referenced by the vmar, or we failed and are bailing,
// so close the vmo either way.
mx_handle_close(vmo);
if (status != MX_OK) return;
zx_handle_close(vmo);
if (status != ZX_OK) return;
uint8_t* base = reinterpret_cast<uint8_t*>(reservation);
uint8_t* aligned_base = RoundUp(base, alignment);
......@@ -84,7 +64,7 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment, void* hint)
// Unmap extra memory reserved before and after the desired block.
if (aligned_base != base) {
size_t prefix_size = static_cast<size_t>(aligned_base - base);
mx_vmar_unmap(mx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
zx_vmar_unmap(zx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
prefix_size);
request_size -= prefix_size;
}
......@@ -94,7 +74,7 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment, void* hint)
if (aligned_size != request_size) {
size_t suffix_size = request_size - aligned_size;
mx_vmar_unmap(mx_vmar_root_self(),
zx_vmar_unmap(zx_vmar_root_self(),
reinterpret_cast<uintptr_t>(aligned_base + aligned_size),
suffix_size);
request_size -= suffix_size;
......@@ -129,49 +109,49 @@ bool VirtualMemory::Uncommit(void* address, size_t size) {
}
bool VirtualMemory::Guard(void* address) {
return mx_vmar_protect(mx_vmar_root_self(),
return zx_vmar_protect(zx_vmar_root_self(),
reinterpret_cast<uintptr_t>(address),
OS::CommitPageSize(), 0 /*no permissions*/) == MX_OK;
OS::CommitPageSize(), 0 /*no permissions*/) == ZX_OK;
}
// static
void* VirtualMemory::ReserveRegion(size_t size, void* hint) {
mx_handle_t vmo;
if (mx_vmo_create(size, 0, &vmo) != MX_OK) return nullptr;
zx_handle_t vmo;
if (zx_vmo_create(size, 0, &vmo) != ZX_OK) return nullptr;
uintptr_t result;
mx_status_t status = mx_vmar_map(mx_vmar_root_self(), 0, vmo, 0, size,
zx_status_t status = zx_vmar_map(zx_vmar_root_self(), 0, vmo, 0, size,
0 /*no permissions*/, &result);
mx_handle_close(vmo);
if (status != MX_OK) return nullptr;
zx_handle_close(vmo);
if (status != ZX_OK) return nullptr;
return reinterpret_cast<void*>(result);
}
// static
bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
uint32_t prot = MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_WRITE |
(is_executable ? MX_VM_FLAG_PERM_EXECUTE : 0);
return mx_vmar_protect(mx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size, prot) == MX_OK;
uint32_t prot = ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE |
(is_executable ? ZX_VM_FLAG_PERM_EXECUTE : 0);
return zx_vmar_protect(zx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size, prot) == ZX_OK;
}
// static
bool VirtualMemory::UncommitRegion(void* base, size_t size) {
return mx_vmar_protect(mx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size, 0 /*no permissions*/) == MX_OK;
return zx_vmar_protect(zx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size, 0 /*no permissions*/) == ZX_OK;
}
// static
bool VirtualMemory::ReleasePartialRegion(void* base, size_t size,
void* free_start, size_t free_size) {
return mx_vmar_unmap(mx_vmar_root_self(),
return zx_vmar_unmap(zx_vmar_root_self(),
reinterpret_cast<uintptr_t>(free_start),
free_size) == MX_OK;
free_size) == ZX_OK;
}
// static
bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
return mx_vmar_unmap(mx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size) == MX_OK;
return zx_vmar_unmap(zx_vmar_root_self(), reinterpret_cast<uintptr_t>(base),
size) == ZX_OK;
}
// static
......@@ -182,20 +162,3 @@ bool VirtualMemory::HasLazyCommits() {
} // namespace base
} // namespace v8
#if defined(CHROMIUM_ROLLING_MAGENTA_TO_ZIRCON)
#undef MX_OK ZX_OK
#undef MX_PROP_NAME ZX_PROP_NAME
#undef MX_VM_FLAG_PERM_EXECUTE ZX_VM_FLAG_PERM_EXECUTE
#undef MX_VM_FLAG_PERM_READ ZX_VM_FLAG_PERM_READ
#undef MX_VM_FLAG_PERM_WRITE ZX_VM_FLAG_PERM_WRITE
#undef mx_handle_close zx_handle_close
#undef mx_handle_t zx_handle_t
#undef mx_object_set_property zx_object_set_property
#undef mx_status_t zx_status_t
#undef mx_vmar_map zx_vmar_map
#undef mx_vmar_protect zx_vmar_protect
#undef mx_vmar_root_self zx_vmar_root_self
#undef mx_vmar_unmap zx_vmar_unmap
#undef mx_vmo_create zx_vmo_create
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment