48 {
51
52#if defined(DART_HOST_OS_MACOS) && defined(DART_PRECOMPILED_RUNTIME)
53
54
55
56
57 const mach_port_t task = mach_task_self();
58 const vm_address_t source_address =
reinterpret_cast<vm_address_t
>(
address());
59 const vm_size_t mem_size = aligned_size;
60 const vm_prot_t read_execute = VM_PROT_READ | VM_PROT_EXECUTE;
61 vm_prot_t current_protection = read_execute;
63 vm_address_t target_address =
64 reinterpret_cast<vm_address_t
>(
target->address());
65 kern_return_t status = vm_remap(
66 task, &target_address, mem_size,
67 0,
68 VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE, task, source_address,
69 true, ¤t_protection, &max_protection,
70 VM_INHERIT_NONE);
71 if (status != KERN_SUCCESS) {
72 return false;
73 }
74 ASSERT(
reinterpret_cast<void*
>(target_address) ==
target->address());
75 ASSERT_EQUAL(current_protection & read_execute, read_execute);
76 ASSERT_EQUAL(max_protection & read_execute, read_execute);
77 return true;
78
79#else
80
81
85 return true;
86#endif
87}
#define ASSERT_LESS_OR_EQUAL(expected, actual)
#define ASSERT_EQUAL(expected, actual)
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
static void Protect(void *address, intptr_t size, Protection mode)