From 63dc378eac88be2da11255b61d7af140bb89ba55 Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Tue, 19 Oct 2010 19:09:30 +0000 Subject: Drop allocator dependency from base library. This will fix libnpapi_test_plugin from loading TCMalloc. This undoes the bad dependency from base to allocator added in http://src.chromium.org/viewvc/chrome/trunk/src/base/base.gyp?revision=43477&view=markup, which was required to fix the linux shared build, due to http://src.chromium.org/viewvc/chrome?view=rev&revision=41218 which added the base/profiler.cc compile-time dependency on TCMalloc (rather than a link-time dependency injection, relying on something like weak symbols) The purify/quantify dependency is indeed compile-time, and is appropriately done in profiler.cc. But, to simply this change, I've killed profiler.cc and only used it in the profiler extension. We can add it back if needed, but it's only been used in that one place for a long time anyway. BUG=59317,40467 TEST=make -j15 npapi_test_plugin && nm out/Debug/libnpapi_test_plugin.so | grep TCMalloc. Should be empty. Review URL: http://codereview.chromium.org/3783009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63082 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/extensions/v8/profiler_extension.cc | 42 +++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'webkit/extensions') diff --git a/webkit/extensions/v8/profiler_extension.cc b/webkit/extensions/v8/profiler_extension.cc index 8f393d4..487649a 100644 --- a/webkit/extensions/v8/profiler_extension.cc +++ b/webkit/extensions/v8/profiler_extension.cc @@ -4,11 +4,22 @@ #include "webkit/extensions/v8/profiler_extension.h" -#include "base/profiler.h" +#include "build/build_config.h" + +#if defined(QUANTIFY) +// this #define is used to prevent people from directly using pure.h +// instead of profiler.h +#define PURIFY_PRIVATE_INCLUDE +#include "base/third_party/purify/pure.h" +#endif // QUANTIFY + +#if defined(USE_TCMALLOC) && defined(OS_LINUX) +#include "third_party/tcmalloc/chromium/src/google/profiler.h" +#endif namespace extensions_v8 { -const char* kProfilerExtensionName = "v8/Profiler"; +const char kProfilerExtensionName[] = "v8/Profiler"; class ProfilerWrapper : public v8::Extension { public: @@ -58,25 +69,37 @@ class ProfilerWrapper : public v8::Extension { static v8::Handle ProfilerStart( const v8::Arguments& args) { - base::Profiler::StartRecording(); +#if defined(QUANTIFY) + QuantifyStartRecordingData(); +#elif defined(USE_TCMALLOC) && defined(OS_LINUX) + ::ProfilerStart("chrome-profile"); +#endif return v8::Undefined(); } static v8::Handle ProfilerStop( const v8::Arguments& args) { - base::Profiler::StopRecording(); +#if defined(QUANTIFY) + QuantifyStopRecordingData(); +#elif defined(USE_TCMALLOC) && defined(OS_LINUX) + ::ProfilerStop(); +#endif return v8::Undefined(); } static v8::Handle ProfilerClearData( const v8::Arguments& args) { - base::Profiler::ClearData(); +#if defined(QUANTIFY) + QuantifyClearData(); +#endif return v8::Undefined(); } static v8::Handle ProfilerFlush( const v8::Arguments& args) { - base::Profiler::Flush(); +#if defined(USE_TCMALLOC) && defined(OS_LINUX) + ::ProfilerFlush(); +#endif return v8::Undefined(); } @@ -87,7 +110,12 @@ class ProfilerWrapper : public v8::Extension { v8::Local inputString = args[0]->ToString(); char nameBuffer[256]; inputString->WriteAscii(nameBuffer, 0, sizeof(nameBuffer)-1); - base::Profiler::SetThreadName(nameBuffer); +#if defined(QUANTIFY) + // make a copy since the Quantify function takes a char*, not const char* + char buffer[512]; + base::snprintf(buffer, arraysize(buffer)-1, "%s", name); + QuantifySetThreadName(buffer); +#endif } return v8::Undefined(); } -- cgit v1.1