Bug 197062

Summary: Add option to dump JIT memory
Product: WebKit Reporter: Tadeu Zagallo <tzagallo>
Component: JavaScriptCoreAssignee: Tadeu Zagallo <tzagallo>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ews-watchlist, fpizlo, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Tadeu Zagallo 2019-04-18 09:52:13 PDT
...
Comment 1 Tadeu Zagallo 2019-04-18 14:55:19 PDT
Created attachment 367762 [details]
Patch
Comment 2 Tadeu Zagallo 2019-04-18 14:56:11 PDT
<rdar://problem/49744332>
Comment 3 Saam Barati 2019-04-19 09:55:25 PDT
Comment on attachment 367762 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=367762&action=review

> Source/JavaScriptCore/assembler/LinkBuffer.cpp:264
> +        dumpJITMemory(outData, outData, m_executableMemory->sizeInBytes());

I think you want m_size here

> Source/JavaScriptCore/jit/ExecutableAllocator.cpp:565
> +            ASSERT(fd != -1);

RELEASE_ASSERT

> Source/JavaScriptCore/jit/ExecutableAllocator.cpp:583
> +        if (UNLIKELY(offset + size > bufferSize))

It’s unlikely this would happen, but you should just make the buffer size the size of the jit memory pool. That way you’re guaranteed there is enough space in it. This code here is wrong if a jitmemcpy copies > 32MB
Comment 4 Tadeu Zagallo 2019-04-19 13:56:50 PDT
Comment on attachment 367762 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=367762&action=review

Thanks for the review!

>> Source/JavaScriptCore/jit/ExecutableAllocator.cpp:583
>> +        if (UNLIKELY(offset + size > bufferSize))
> 
> It’s unlikely this would happen, but you should just make the buffer size the size of the jit memory pool. That way you’re guaranteed there is enough space in it. This code here is wrong if a jitmemcpy copies > 32MB

Yeah, I thought it was unlikely enough that it shouldn't matter, but I'll switch it to use `fixedExecutableMemoryPoolSize` instead.
Comment 5 Tadeu Zagallo 2019-04-19 13:58:02 PDT
Created attachment 367821 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2019-04-19 14:47:38 PDT
Comment on attachment 367821 [details]
Patch for landing

Clearing flags on attachment: 367821

Committed r244470: <https://trac.webkit.org/changeset/244470>
Comment 7 WebKit Commit Bot 2019-04-19 14:47:39 PDT
All reviewed patches have been landed.  Closing bug.