Skip to content

Commit 1920b51

Browse files
committed
Fix Titzer bench on iOS.
https://bugs.webkit.org/show_bug.cgi?id=175917 Reviewed by Ryosuke Niwa. Currently, Titzer bench doesn't run on iOS since the benchmark allocates lots of physical pages that it never actually writes to. We limited the total number wasm physical pages to the ram size of the phone, which caused us to fail a memory allocation. This patch changes it so we will allocate up to 3x ram size, which seems to fix the problem. * wasm/WasmMemory.cpp: Canonical link: https://commits.webkit.org/192578@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f139c79 commit 1920b51

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

Source/JavaScriptCore/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2017-08-23 Keith Miller <keith_miller@apple.com>
2+
3+
Fix Titzer bench on iOS.
4+
https://bugs.webkit.org/show_bug.cgi?id=175917
5+
6+
Reviewed by Ryosuke Niwa.
7+
8+
Currently, Titzer bench doesn't run on iOS since the benchmark
9+
allocates lots of physical pages that it never actually writes
10+
to. We limited the total number wasm physical pages to the ram
11+
size of the phone, which caused us to fail a memory
12+
allocation. This patch changes it so we will allocate up to 3x ram
13+
size, which seems to fix the problem.
14+
15+
* wasm/WasmMemory.cpp:
16+
117
2017-08-23 Yusuke Suzuki <utatane.tea@gmail.com>
218

319
Unreviewed, fix for test262

Source/JavaScriptCore/wasm/WasmMemory.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,24 @@ class MemoryManager {
140140
}
141141
return false;
142142
}
143-
143+
144+
// We allow people to "commit" more wasm memory than there is on the system since most of the time
145+
// people don't actually write to most of that memory. There is some chance that this gets us
146+
// JetSammed but that's possible anyway.
147+
inline size_t memoryLimit() const { return ramSize() * 3; }
148+
144149
// FIXME: Ideally, bmalloc would have this kind of mechanism. Then, we would just forward to that
145150
// mechanism here.
146151
MemoryResult::Kind tryAllocatePhysicalBytes(size_t bytes)
147152
{
148153
MemoryResult::Kind result = [&] {
149154
auto holder = holdLock(m_lock);
150-
if (m_physicalBytes + bytes > ramSize())
155+
if (m_physicalBytes + bytes > memoryLimit())
151156
return MemoryResult::SyncGCAndRetry;
152157

153158
m_physicalBytes += bytes;
154159

155-
if (m_physicalBytes >= ramSize() / 2)
160+
if (m_physicalBytes >= memoryLimit() / 2)
156161
return MemoryResult::SuccessAndAsyncGC;
157162

158163
return MemoryResult::Success;
@@ -177,7 +182,7 @@ class MemoryManager {
177182

178183
void dump(PrintStream& out) const
179184
{
180-
out.print("memories = ", m_memories.size(), "/", m_maxCount, ", bytes = ", m_physicalBytes, "/", ramSize());
185+
out.print("virtual memories = ", m_memories.size(), "/", m_maxCount, ", bytes = ", m_physicalBytes, "/", memoryLimit());
181186
}
182187

183188
private:

0 commit comments

Comments
 (0)