| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 507c2f2 commit 14a87a5
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.22', | ||
| 39 | + 'v8_embedder_string': '-node.23', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,8 @@ STATIC_ASSERT_ENUM(PageAllocator::kReadWriteExecute, | |||
| 21 | 21 | base::OS::MemoryPermission::kReadWriteExecute); | |
| 22 | 22 | STATIC_ASSERT_ENUM(PageAllocator::kReadExecute, | |
| 23 | 23 | base::OS::MemoryPermission::kReadExecute); | |
| 24 | + STATIC_ASSERT_ENUM(PageAllocator::kNoAccessWillJitLater, | ||
| 25 | + base::OS::MemoryPermission::kNoAccessWillJitLater); | ||
| 24 | 26 | ||
| 25 | 27 | #undef STATIC_ASSERT_ENUM | |
| 26 | 28 | ||
@@ -38,6 +40,14 @@ void* PageAllocator::GetRandomMmapAddr() { | |||
| 38 | 40 | ||
| 39 | 41 | void* PageAllocator::AllocatePages(void* hint, size_t size, size_t alignment, | |
| 40 | 42 | PageAllocator::Permission access) { | |
| 43 | + #if !(V8_OS_MACOSX && V8_HOST_ARCH_ARM64 && defined(MAP_JIT)) | ||
| 44 | + // kNoAccessWillJitLater is only used on Apple Silicon. Map it to regular | ||
| 45 | + // kNoAccess on other platforms, so code doesn't have to handle both enum | ||
| 46 | + // values. | ||
| 47 | + if (access == PageAllocator::kNoAccessWillJitLater) { | ||
| 48 | + access = PageAllocator::kNoAccess; | ||
| 49 | + } | ||
| 50 | + #endif | ||
| 41 | 51 | return base::OS::Allocate(hint, size, alignment, | |
| 42 | 52 | static_cast<base::OS::MemoryPermission>(access)); | |
| 43 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ namespace { | |||
| 33 | 33 | DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) { | |
| 34 | 34 | switch (access) { | |
| 35 | 35 | case OS::MemoryPermission::kNoAccess: | |
| 36 | + case OS::MemoryPermission::kNoAccessWillJitLater: | ||
| 36 | 37 | return PAGE_NOACCESS; | |
| 37 | 38 | case OS::MemoryPermission::kRead: | |
| 38 | 39 | return PAGE_READONLY; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ namespace { | |||
| 18 | 18 | uint32_t GetProtectionFromMemoryPermission(OS::MemoryPermission access) { | |
| 19 | 19 | switch (access) { | |
| 20 | 20 | case OS::MemoryPermission::kNoAccess: | |
| 21 | + case OS::MemoryPermission::kNoAccessWillJitLater: | ||
| 21 | 22 | return 0; // no permissions | |
| 22 | 23 | case OS::MemoryPermission::kRead: | |
| 23 | 24 | return ZX_VM_PERM_READ; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -118,6 +118,7 @@ const int kMmapFdOffset = 0; | |||
| 118 | 118 | int GetProtectionFromMemoryPermission(OS::MemoryPermission access) { | |
| 119 | 119 | switch (access) { | |
| 120 | 120 | case OS::MemoryPermission::kNoAccess: | |
| 121 | + case OS::MemoryPermission::kNoAccessWillJitLater: | ||
| 121 | 122 | return PROT_NONE; | |
| 122 | 123 | case OS::MemoryPermission::kRead: | |
| 123 | 124 | return PROT_READ; | |
@@ -140,15 +141,12 @@ int GetFlagsForMemoryPermission(OS::MemoryPermission access) { | |||
| 140 | 141 | #if V8_OS_QNX | |
| 141 | 142 | flags |= MAP_LAZY; | |
| 142 | 143 | #endif // V8_OS_QNX | |
| 143 | - #if V8_OS_MACOSX && V8_HOST_ARCH_ARM64 && defined(MAP_JIT) && \ | ||
| 144 | - !defined(V8_OS_IOS) | ||
| 145 | - // TODO(jkummerow): using the V8_OS_IOS define is a crude approximation | ||
| 146 | - // of the fact that we don't want to set the MAP_JIT flag when | ||
| 147 | - // FLAG_jitless == true, as src/base/ doesn't know any flags. | ||
| 148 | - // TODO(crbug.com/1117591): This is only needed for code spaces. | ||
| 144 | + } | ||
| 145 | + #if V8_OS_MACOSX && V8_HOST_ARCH_ARM64 && defined(MAP_JIT) | ||
| 146 | + if (access == OS::MemoryPermission::kNoAccessWillJitLater) { | ||
| 149 | 147 | flags |= MAP_JIT; | |
| 150 | - #endif | ||
| 151 | 148 | } | |
| 149 | + #endif | ||
| 152 | 150 | return flags; | |
| 153 | 151 | } | |
| 154 | 152 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -753,6 +753,7 @@ namespace { | |||
| 753 | 753 | DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) { | |
| 754 | 754 | switch (access) { | |
| 755 | 755 | case OS::MemoryPermission::kNoAccess: | |
| 756 | + case OS::MemoryPermission::kNoAccessWillJitLater: | ||
| 756 | 757 | return PAGE_NOACCESS; | |
| 757 | 758 | case OS::MemoryPermission::kRead: | |
| 758 | 759 | return PAGE_READONLY; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,7 +167,10 @@ class V8_BASE_EXPORT OS { | |||
| 167 | 167 | kReadWrite, | |
| 168 | 168 | // TODO(hpayer): Remove this flag. Memory should never be rwx. | |
| 169 | 169 | kReadWriteExecute, | |
| 170 | - kReadExecute | ||
| 170 | + kReadExecute, | ||
| 171 | + // TODO(jkummerow): Remove this when Wasm has a platform-independent | ||
| 172 | + // w^x implementation. | ||
| 173 | + kNoAccessWillJitLater | ||
| 171 | 174 | }; | |
| 172 | 175 | ||
| 173 | 176 | static bool HasLazyCommits(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,15 +212,17 @@ bool OnCriticalMemoryPressure(size_t length) { | |||
| 212 | 212 | VirtualMemory::VirtualMemory() = default; | |
| 213 | 213 | ||
| 214 | 214 | VirtualMemory::VirtualMemory(v8::PageAllocator* page_allocator, size_t size, | |
| 215 | - void* hint, size_t alignment) | ||
| 215 | + void* hint, size_t alignment, JitPermission jit) | ||
| 216 | 216 | : page_allocator_(page_allocator) { | |
| 217 | 217 | DCHECK_NOT_NULL(page_allocator); | |
| 218 | 218 | DCHECK(IsAligned(size, page_allocator_->CommitPageSize())); | |
| 219 | 219 | size_t page_size = page_allocator_->AllocatePageSize(); | |
| 220 | 220 | alignment = RoundUp(alignment, page_size); | |
| 221 | - Address address = reinterpret_cast<Address>( | ||
| 222 | - AllocatePages(page_allocator_, hint, RoundUp(size, page_size), alignment, | ||
| 223 | - PageAllocator::kNoAccess)); | ||
| 221 | + PageAllocator::Permission permissions = | ||
| 222 | + jit == kMapAsJittable ? PageAllocator::kNoAccessWillJitLater | ||
| 223 | + : PageAllocator::kNoAccess; | ||
| 224 | + Address address = reinterpret_cast<Address>(AllocatePages( | ||
| 225 | + page_allocator_, hint, RoundUp(size, page_size), alignment, permissions)); | ||
| 224 | 226 | if (address != kNullAddress) { | |
| 225 | 227 | DCHECK(IsAligned(address, alignment)); | |
| 226 | 228 | region_ = base::AddressRegion(address, size); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,6 +150,8 @@ V8_EXPORT_PRIVATE bool OnCriticalMemoryPressure(size_t length); | |||
| 150 | 150 | // Represents and controls an area of reserved memory. | |
| 151 | 151 | class VirtualMemory final { | |
| 152 | 152 | public: | |
| 153 | + enum JitPermission { kNoJit, kMapAsJittable }; | ||
| 154 | + | ||
| 153 | 155 | // Empty VirtualMemory object, controlling no reserved memory. | |
| 154 | 156 | V8_EXPORT_PRIVATE VirtualMemory(); | |
| 155 | 157 | ||
@@ -158,8 +160,8 @@ class VirtualMemory final { | |||
| 158 | 160 | // size. The |size| must be aligned with |page_allocator|'s commit page size. | |
| 159 | 161 | // This may not be at the position returned by address(). | |
| 160 | 162 | V8_EXPORT_PRIVATE VirtualMemory(v8::PageAllocator* page_allocator, | |
| 161 | - size_t size, void* hint, | ||
| 162 | - size_t alignment = 1); | ||
| 163 | + size_t size, void* hint, size_t alignment = 1, | ||
| 164 | + JitPermission jit = kNoJit); | ||
| 163 | 165 | ||
| 164 | 166 | // Construct a virtual memory by assigning it some already mapped address | |
| 165 | 167 | // and size. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1587,7 +1587,11 @@ VirtualMemory WasmCodeManager::TryAllocate(size_t size, void* hint) { | |||
| 1587 | 1587 | if (!BackingStore::ReserveAddressSpace(size)) return {}; | |
| 1588 | 1588 | if (hint == nullptr) hint = page_allocator->GetRandomMmapAddr(); | |
| 1589 | 1589 | ||
| 1590 | - VirtualMemory mem(page_allocator, size, hint, allocate_page_size); | ||
| 1590 | + // When we start exposing Wasm in jitless mode, then the jitless flag | ||
| 1591 | + // will have to determine whether we set kMapAsJittable or not. | ||
| 1592 | + DCHECK(!FLAG_jitless); | ||
| 1593 | + VirtualMemory mem(page_allocator, size, hint, allocate_page_size, | ||
| 1594 | + VirtualMemory::kMapAsJittable); | ||
| 1591 | 1595 | if (!mem.IsReserved()) { | |
| 1592 | 1596 | BackingStore::ReleaseReservation(size); | |
| 1593 | 1597 | return {}; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments