Bug 30769 - [gcc/unix] Export WTF::fastMalloc, WTF::fastFree, WTF::fastCalloc, WTF::fastRealloc
Summary: [gcc/unix] Export WTF::fastMalloc, WTF::fastFree, WTF::fastCalloc, WTF::fastR...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-26 04:30 PDT by Holger Freyther
Modified: 2009-10-28 03:35 PDT (History)
1 user (show)

See Also:


Attachments
First attempt to export these symbols (3.34 KB, patch)
2009-10-26 04:38 PDT, Holger Freyther
no flags Details | Formatted Diff | Diff
Export the symbols in libwebkit.so as well (1.65 KB, patch)
2009-10-26 07:08 PDT, Holger Freyther
darin: review+
Details | Formatted Diff | Diff
Export fastMalloc, fastFree, fastRealloc, fastCalloc with normal linkage (3.32 KB, patch)
2009-10-27 06:04 PDT, Holger Freyther
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Freyther 2009-10-26 04:30:16 PDT
All non darwin gcc targets build JSC with -fvisibility=hidden hiding the FastMalloc functions. For malloc analysis it is handy to be able to preload an instrumented version of the above functions. 

The proposed change is to use __attribute__((visibility("default"))) on GCC systems.
Comment 1 Holger Freyther 2009-10-26 04:38:17 PDT
Created attachment 41859 [details]
First attempt to export these symbols

Use __attribute__((visibility("default"))) to export the allocation functions again. On Mac these symbols are exported via the .exp file and available to the WebCore/WebKit library.
Comment 2 Holger Freyther 2009-10-26 07:08:41 PDT
Created attachment 41865 [details]
Export the symbols in libwebkit.so as well

Export the FastMalloc functions in the .so file as well. This is the last step to be able to instrument a TCmalloc enabled libwebkit with memprof.
Comment 3 Darin Adler 2009-10-26 07:49:15 PDT
Comment on attachment 41859 [details]
First attempt to export these symbols

> +#if COMPILER(GCC) && !PLATFORM(DARWIN)
> +#define WTF_FAST_MALLOC_EXPORT __attribute__((visibility("default")))
> +#else
> +#define WTF_FAST_MALLOC_EXPORT
> +#endif

Why ~PLATFORM(DARWIN)"?

If you are using __attribute__ then you should also use __visibility__.

Is it really helpful to do this just for these functions? Doesn't this need to be done consistently across the rest of JavaScriptCore?
Comment 4 Darin Adler 2009-10-26 07:50:14 PDT
Oh, I see now. You're saying this is good "for malloc analysis".

Still, why the !PLATFORM(DARWIN) part? Would this change cause a problem on that platform?
Comment 5 Holger Freyther 2009-10-26 08:00:31 PDT
(In reply to comment #4)
> Oh, I see now. You're saying this is good "for malloc analysis".

Ironically I'm working/using a tool that went from Corel -> Eazel -> GNOME into my hands. I'm using LD_PRELOAD to load my version of malloc and this fails with a release build of WebKit. One option would have been to instrument the mmap/sbrk calls but then I just see calls to TCSystem_Alloc.

> Still, why the !PLATFORM(DARWIN) part? Would this change cause a problem on
> that platform?

My assumption is that it is going to work as visibility should be okay with any gcc4.x release. On a mac build these symbols should have "default" visibility and saying they are default should be harmles. I just tried to minimize the risk of breaking a build on a file that is included by almost everything.
Comment 6 Holger Freyther 2009-10-26 08:01:46 PDT
I'm going to build on Leopard tomorrow and will send an updated patch without the !PLATFORM(DARWIN)
Comment 7 Holger Freyther 2009-10-27 06:04:37 PDT
Created attachment 41945 [details]
Export fastMalloc, fastFree, fastRealloc, fastCalloc with normal linkage

The leopard build was fine, removing the !PLATFORM(DARWIN).
Comment 8 Darin Adler 2009-10-27 10:12:41 PDT
Comment on attachment 41865 [details]
Export the symbols in libwebkit.so as well

rs=me
Comment 9 Holger Freyther 2009-10-28 03:35:55 PDT
Landed in r50204 and r50205.