diff --git a/runtime/tools/entitlements/gen_snapshot.plist b/runtime/tools/entitlements/gen_snapshot.plist
index 694b88bfa7e..e4d040d3c73 100644
--- a/runtime/tools/entitlements/gen_snapshot.plist
+++ b/runtime/tools/entitlements/gen_snapshot.plist
@@ -2,7 +2,5 @@
- com.apple.security.cs.allow-jit
-
\ No newline at end of file
diff --git a/runtime/tools/entitlements/gen_snapshot_product.plist b/runtime/tools/entitlements/gen_snapshot_product.plist
index 694b88bfa7e..e4d040d3c73 100644
--- a/runtime/tools/entitlements/gen_snapshot_product.plist
+++ b/runtime/tools/entitlements/gen_snapshot_product.plist
@@ -2,7 +2,5 @@
- com.apple.security.cs.allow-jit
-
\ No newline at end of file
diff --git a/runtime/vm/heap/page.cc b/runtime/vm/heap/page.cc
index d1c507b2aa1..963a03bc564 100644
--- a/runtime/vm/heap/page.cc
+++ b/runtime/vm/heap/page.cc
@@ -69,12 +69,7 @@ static intptr_t CacheIndex(uword flags) {
}
Page* Page::Allocate(intptr_t size, uword flags) {
-#if defined(DART_INCLUDE_SIMULATOR)
- const bool using_simulator = FLAG_use_simulator;
-#else
- const bool using_simulator = false;
-#endif
- const bool executable = (flags & Page::kExecutable) != 0 && !using_simulator;
+ const bool executable = (flags & Page::kExecutable) != 0;
const bool compressed = !executable;
const char* name = executable ? "dart-code" : "dart-heap";
@@ -316,12 +311,7 @@ void Page::ResetProgressBar() {
void Page::WriteProtect(bool read_only) {
ASSERT(!is_image());
-#if defined(DART_INCLUDE_SIMULATOR)
- const bool using_simulator = FLAG_use_simulator;
-#else
- const bool using_simulator = false;
-#endif
- if (is_executable() && read_only && !using_simulator) {
+ if (is_executable() && read_only) {
// Handle making code executable in a special way.
memory_->WriteProtectCode();
} else {
diff --git a/runtime/vm/virtual_memory.h b/runtime/vm/virtual_memory.h
index e2b20c07836..d35c78f7cca 100644
--- a/runtime/vm/virtual_memory.h
+++ b/runtime/vm/virtual_memory.h
@@ -76,10 +76,20 @@ class VirtualMemory {
#endif
}
+ DART_FORCE_INLINE static bool ExecutesGeneratedCode() {
+#if defined(DART_PRECOMPILER) && !defined(TESTING)
+ return false; // I.e., gen_snapshot.
+#else
+ return true;
+#endif
+ }
+
// Write protect a chunk of machine code which is currently writable.
DART_FORCE_INLINE static void WriteProtectCode(void* address, intptr_t size) {
Protect(address, size,
- ShouldDualMapExecutablePages() ? kReadOnly : kReadExecute);
+ ShouldDualMapExecutablePages() || !ExecutesGeneratedCode()
+ ? kReadOnly
+ : kReadExecute);
}
DART_FORCE_INLINE void WriteProtectCode() const {
WriteProtectCode(address(), size());
diff --git a/runtime/vm/virtual_memory_fuchsia.cc b/runtime/vm/virtual_memory_fuchsia.cc
index 48022cbe669..813fd62b3a3 100644
--- a/runtime/vm/virtual_memory_fuchsia.cc
+++ b/runtime/vm/virtual_memory_fuchsia.cc
@@ -151,6 +151,12 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(Utils::IsAligned(alignment, page_size_));
+ // Ignore executable for gen_snapshot/simulator, but still let the heap
+ // track code and data pages separately.
+ if (!VirtualMemory::ExecutesGeneratedCode()) {
+ is_executable = false;
+ }
+
const zx_vm_option_t align_flag = Utils::ShiftForPowerOfTwo(alignment)
<< ZX_VM_ALIGN_BASE;
ASSERT((ZX_VM_ALIGN_1KB <= align_flag) && (align_flag <= ZX_VM_ALIGN_4GB));
diff --git a/runtime/vm/virtual_memory_posix.cc b/runtime/vm/virtual_memory_posix.cc
index f39f79f5e67..f97dcf87b35 100644
--- a/runtime/vm/virtual_memory_posix.cc
+++ b/runtime/vm/virtual_memory_posix.cc
@@ -621,6 +621,12 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
ASSERT(Utils::IsAligned(alignment, PageSize()));
ASSERT(name != nullptr);
+ // Ignore executable for gen_snapshot/simulator, but still let the heap
+ // track code and data pages separately.
+ if (!VirtualMemory::ExecutesGeneratedCode()) {
+ is_executable = false;
+ }
+
#if defined(DART_COMPRESSED_POINTERS)
if (is_compressed) {
RELEASE_ASSERT(!is_executable);
diff --git a/runtime/vm/virtual_memory_win.cc b/runtime/vm/virtual_memory_win.cc
index 0c179de0d83..fd211ab7485 100644
--- a/runtime/vm/virtual_memory_win.cc
+++ b/runtime/vm/virtual_memory_win.cc
@@ -139,6 +139,12 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(Utils::IsAligned(alignment, PageSize()));
+ // Ignore executable for gen_snapshot/simulator, but still let the heap
+ // track code and data pages separately.
+ if (!VirtualMemory::ExecutesGeneratedCode()) {
+ is_executable = false;
+ }
+
#if defined(DART_COMPRESSED_POINTERS)
if (is_compressed) {
RELEASE_ASSERT(!is_executable);