mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 555562 - remove xpctools as no maintainer in 3 years. r=shaver
This commit is contained in:
parent
b404dea59c
commit
c9e150d2ca
@ -113,7 +113,6 @@ MOZ_VTUNE = @MOZ_VTUNE@
|
||||
MOZ_TRACEVIS = @MOZ_TRACEVIS@
|
||||
DEHYDRA_PATH = @DEHYDRA_PATH@
|
||||
|
||||
MOZ_XPCTOOLS = @MOZ_XPCTOOLS@
|
||||
NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
|
||||
USE_ELF_DYNSTR_GC = @USE_ELF_DYNSTR_GC@
|
||||
INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
|
||||
|
10
configure.in
10
configure.in
@ -6530,15 +6530,6 @@ MOZ_ARG_ENABLE_BOOL(leaky,
|
||||
MOZ_LEAKY=)
|
||||
|
||||
|
||||
dnl ========================================================
|
||||
dnl xpctools
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(xpctools,
|
||||
[ --enable-xpctools Build JS profiling tool],
|
||||
MOZ_XPCTOOLS=1,
|
||||
MOZ_XPCTOOLS= )
|
||||
|
||||
|
||||
dnl ========================================================
|
||||
dnl build the tests by default
|
||||
dnl ========================================================
|
||||
@ -8491,7 +8482,6 @@ AC_SUBST(MOZ_JPROF)
|
||||
AC_SUBST(MOZ_SHARK)
|
||||
AC_SUBST(MOZ_CALLGRIND)
|
||||
AC_SUBST(MOZ_VTUNE)
|
||||
AC_SUBST(MOZ_XPCTOOLS)
|
||||
AC_SUBST(MOZ_JSLOADER)
|
||||
AC_SUBST(MOZ_USE_NATIVE_UCONV)
|
||||
AC_SUBST(MOZ_QUANTIFY)
|
||||
|
@ -4999,7 +4999,6 @@ AC_SUBST(MOZ_JPROF)
|
||||
AC_SUBST(MOZ_SHARK)
|
||||
AC_SUBST(MOZ_CALLGRIND)
|
||||
AC_SUBST(MOZ_VTUNE)
|
||||
AC_SUBST(MOZ_XPCTOOLS)
|
||||
AC_SUBST(MOZ_JSLOADER)
|
||||
AC_SUBST(MOZ_QUANTIFY)
|
||||
AC_SUBST(LIBICONV)
|
||||
|
@ -160,10 +160,6 @@ ENABLE_TRACEABLE_FLAGS = --enable-traceables
|
||||
|
||||
endif # ENABLE_JIT
|
||||
|
||||
ifdef MOZ_XPCTOOLS
|
||||
DEFINES += -DXPC_TOOLS_SUPPORT
|
||||
endif
|
||||
|
||||
ifdef XPC_IDISPATCH_SUPPORT
|
||||
DEFINES += -DXPC_IDISPATCH_SUPPORT
|
||||
ifdef XPC_COMOBJECT
|
||||
|
@ -97,30 +97,6 @@ nsXPConnect::nsXPConnect()
|
||||
mJSRoots.ops = nsnull;
|
||||
#endif
|
||||
|
||||
#ifdef XPC_TOOLS_SUPPORT
|
||||
{
|
||||
char* filename = PR_GetEnv("MOZILLA_JS_PROFILER_OUTPUT");
|
||||
if(filename && *filename)
|
||||
{
|
||||
mProfilerOutputFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
if(mProfilerOutputFile &&
|
||||
NS_SUCCEEDED(mProfilerOutputFile->InitWithNativePath(nsDependentCString(filename))))
|
||||
{
|
||||
mProfiler = do_GetService(XPCTOOLS_PROFILER_CONTRACTID);
|
||||
if(mProfiler)
|
||||
{
|
||||
if(NS_SUCCEEDED(mProfiler->Start()))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("***** profiling JavaScript. Output to: %s\n",
|
||||
filename);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
char* reportableEnv = PR_GetEnv("MOZ_REPORT_ALL_JS_EXCEPTIONS");
|
||||
if(reportableEnv && *reportableEnv)
|
||||
gReportAllJSExceptions = 1;
|
||||
@ -220,14 +196,6 @@ nsXPConnect::ReleaseXPConnectSingleton()
|
||||
{
|
||||
NS_SetGlobalThreadObserver(nsnull);
|
||||
|
||||
#ifdef XPC_TOOLS_SUPPORT
|
||||
if(xpc->mProfiler)
|
||||
{
|
||||
xpc->mProfiler->Stop();
|
||||
xpc->mProfiler->WriteResults(xpc->mProfilerOutputFile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// force a dump of the JavaScript gc heap if JS is still alive
|
||||
// if requested through XPC_SHUTDOWN_HEAP_DUMP environment variable
|
||||
|
@ -127,10 +127,6 @@
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
#endif
|
||||
|
||||
#ifdef XPC_TOOLS_SUPPORT
|
||||
#include "nsIXPCToolsProfiler.h"
|
||||
#endif
|
||||
|
||||
#include "nsIThreadInternal.h"
|
||||
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
@ -554,11 +550,6 @@ private:
|
||||
#endif
|
||||
PRBool mCycleCollecting;
|
||||
|
||||
#ifdef XPC_TOOLS_SUPPORT
|
||||
nsCOMPtr<nsIXPCToolsProfiler> mProfiler;
|
||||
nsCOMPtr<nsILocalFile> mProfilerOutputFile;
|
||||
#endif
|
||||
|
||||
#ifndef XPCONNECT_STANDALONE
|
||||
typedef nsBaseHashtable<nsVoidPtrHashKey, nsISupports*, nsISupports*> ScopeSet;
|
||||
ScopeSet mScopes;
|
||||
|
@ -1,49 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Communicator client code, released
|
||||
# March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = idl src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,53 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Communicator client code, released
|
||||
# March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1999
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpctools
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIXPCToolsCompiler.idl \
|
||||
nsIXPCToolsProfiler.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,60 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Interface for JS code testing tool which does compile-time checking. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsILocalFile.idl"
|
||||
|
||||
[scriptable, uuid(71151570-e56f-11d3-8f65-0010a4e73d9a)]
|
||||
interface nsIXPCToolsCompiler : nsISupports
|
||||
{
|
||||
/**
|
||||
* XXX temporary hack because there does not seem to be another scriptable
|
||||
* way to get this info.
|
||||
*/
|
||||
readonly attribute nsILocalFile binDir;
|
||||
|
||||
void CompileFile(in nsILocalFile aFile, in PRBool strict);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define XPCTOOLS_COMPILER_CONTRACTID "xpctools.compiler.1"
|
||||
%}
|
@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Interface for JS code testing tool which does code coverage and profiling. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsILocalFile.idl"
|
||||
|
||||
[scriptable, uuid(09ef19b0-e97a-11d3-8f69-0010a4e73d9a)]
|
||||
interface nsIXPCToolsProfiler : nsISupports
|
||||
{
|
||||
void start();
|
||||
void stop();
|
||||
void clear();
|
||||
void writeResults(in nsILocalFile aFile);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define XPCTOOLS_PROFILER_CONTRACTID "xpctools.profiler.1"
|
||||
%}
|
@ -1,28 +0,0 @@
|
||||
const nsIFile = Components.interfaces.nsIFile;
|
||||
var Compiler = new Components.Constructor("xpctools.compiler.1",
|
||||
"nsIXPCToolsCompiler");
|
||||
var c = new Compiler;
|
||||
|
||||
dump("\n");
|
||||
dump("Compiling all .js files under "+c.binDir.path+"\n");
|
||||
dump("Will report any compile-time errors...\n\n");
|
||||
dump( "compiled "+CompileJSFilesInDir(c.binDir)+" files\n\n");
|
||||
|
||||
function CompileJSFilesInDir(dir) {
|
||||
var count = 0;
|
||||
if(!dir.isDirectory())
|
||||
return;
|
||||
var list = dir.directoryEntries;
|
||||
while(list.hasMoreElements()) {
|
||||
file = list.getNext().QueryInterface(nsIFile);
|
||||
if(file.isDirectory())
|
||||
count += CompileJSFilesInDir(file);
|
||||
else if(file.leafName.match(/\.js$/i)) {
|
||||
// dump("compiling... "+file.path+"\n");
|
||||
c.CompileFile(file, false);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
const nsIFile = Components.interfaces.nsIFile;
|
||||
var Compiler = new Components.Constructor("xpctools.compiler.1","nsIXPCToolsCompiler");
|
||||
var c = new Compiler;
|
||||
ListJSFilesInDir(c.binDir);
|
||||
|
||||
function ListJSFilesInDir(dir) {
|
||||
if(!dir.isDirectory())
|
||||
return;
|
||||
var list = dir.directoryEntries;
|
||||
while(list.hasMoreElements()) {
|
||||
file = list.getNext().QueryInterface(nsIFile);
|
||||
if(file.isDirectory())
|
||||
ListJSFilesInDir(file);
|
||||
else if(file.leafName.match(/\.js$/i))
|
||||
dump(file.path+"\n");
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Communicator client code, released
|
||||
# March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# John Bandhauer <jband@netscape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xpctools
|
||||
LIBRARY_NAME = xpctools
|
||||
|
||||
MODULE_NAME = xpctools
|
||||
IS_COMPONENT = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
CPPSRCS = \
|
||||
nsXPCToolsCompiler.cpp \
|
||||
nsXPCToolsProfiler.cpp \
|
||||
nsXPCToolsModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DJSFILE -DJS_THREADSAFE
|
||||
|
@ -1,161 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Implements nsXPCToolsCompiler. */
|
||||
|
||||
#include "xpctools_private.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXPCToolsCompiler, nsIXPCToolsCompiler)
|
||||
|
||||
nsXPCToolsCompiler::nsXPCToolsCompiler()
|
||||
{
|
||||
}
|
||||
|
||||
nsXPCToolsCompiler::~nsXPCToolsCompiler()
|
||||
{
|
||||
}
|
||||
|
||||
/* readonly attribute nsILocalFile binDir; */
|
||||
NS_IMETHODIMP nsXPCToolsCompiler::GetBinDir(nsILocalFile * *aBinDir)
|
||||
{
|
||||
*aBinDir = nsnull;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(file));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
|
||||
NS_ADDREF(*aBinDir = lfile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void ErrorReporter(JSContext *cx, const char *message,
|
||||
JSErrorReport *report)
|
||||
{
|
||||
printf("compile error!\n");
|
||||
}
|
||||
|
||||
static JSClass global_class = {
|
||||
"nsXPCToolsCompiler::global", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nsnull
|
||||
};
|
||||
|
||||
/* void CompileFile (in nsILocalFile aFile, in PRBool strict); */
|
||||
NS_IMETHODIMP nsXPCToolsCompiler::CompileFile(nsILocalFile *aFile, PRBool strict)
|
||||
{
|
||||
// use the xpccallcontext stuff to get the current JSContext
|
||||
|
||||
// get the xpconnect service
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
|
||||
if(NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get the xpconnect native call context
|
||||
nsAXPCNativeCallContext *callContext = nsnull;
|
||||
xpc->GetCurrentNativeCallContext(&callContext);
|
||||
if(!callContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// verify that we are being called from JS (i.e. the current call is
|
||||
// to this object - though we don't verify that it is to this exact method)
|
||||
nsCOMPtr<nsISupports> callee;
|
||||
callContext->GetCallee(getter_AddRefs(callee));
|
||||
if(!callee || callee.get() != (nsISupports*)this)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get JSContext of current call
|
||||
JSContext* cx;
|
||||
rv = callContext->GetJSContext(&cx);
|
||||
if(NS_FAILED(rv) || !cx)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
FILE* handle;
|
||||
if(NS_FAILED(aFile->OpenANSIFileDesc("r", &handle)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSObject* glob = JS_NewObject(cx, &global_class, NULL, NULL);
|
||||
if (!glob)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!JS_InitStandardClasses(cx, glob))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString path;
|
||||
if(NS_FAILED(aFile->GetNativePath(path)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
uint32 oldoptions = JS_GetOptions(cx);
|
||||
JS_SetOptions(cx, JSOPTION_WERROR | (strict ? JSOPTION_STRICT : 0));
|
||||
JSErrorReporter older = JS_SetErrorReporter(cx, ErrorReporter);
|
||||
JSExceptionState *es =JS_SaveExceptionState(cx);
|
||||
|
||||
if(!JS_CompileFileHandle(cx, glob, path.get(), handle))
|
||||
{
|
||||
jsval v;
|
||||
JSErrorReport* report;
|
||||
if(JS_GetPendingException(cx, &v) &&
|
||||
nsnull != (report = JS_ErrorFromException(cx, v)))
|
||||
{
|
||||
JSString* str;
|
||||
const char* msg = "Error";
|
||||
str = JS_ValueToString(cx, v);
|
||||
if(str)
|
||||
msg = JS_GetStringBytes(str);
|
||||
printf("%s [%s,%d]\n\n",
|
||||
msg,
|
||||
report->filename,
|
||||
(int)report->lineno);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("no script and no error report!\n");
|
||||
}
|
||||
|
||||
}
|
||||
JS_RestoreExceptionState(cx, es);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
JS_SetOptions(cx, oldoptions);
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Module code for XPCTools. */
|
||||
|
||||
#include "xpctools_private.h"
|
||||
|
||||
// Module implementation for the xpctools library
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPCToolsCompiler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPCToolsProfiler)
|
||||
|
||||
// {331148C0-E599-11d3-8F65-0010A4E73D9A}
|
||||
#define COMPILER_CID \
|
||||
{ 0x331148c0, 0xe599, 0x11d3, \
|
||||
{ 0x8f, 0x65, 0x0, 0x10, 0xa4, 0xe7, 0x3d, 0x9a } }
|
||||
|
||||
// {7F5D12E0-E97B-11d3-8F69-0010A4E73D9A}
|
||||
#define PROFILER_CID \
|
||||
{ 0x7f5d12e0, 0xe97b, 0x11d3, \
|
||||
{ 0x8f, 0x69, 0x0, 0x10, 0xa4, 0xe7, 0x3d, 0x9a } }
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{nsnull, COMPILER_CID, XPCTOOLS_COMPILER_CONTRACTID, nsXPCToolsCompilerConstructor},
|
||||
{nsnull, PROFILER_CID, XPCTOOLS_PROFILER_CONTRACTID, nsXPCToolsProfilerConstructor}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(xpctools, components)
|
@ -1,370 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Implements nsXPCToolsProfiler. */
|
||||
|
||||
#include "xpctools_private.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
ProfilerFile::ProfilerFile(const char* filename)
|
||||
: mName(filename ? strdup(filename) : nsnull)
|
||||
{
|
||||
mFunctionTable.Init();
|
||||
}
|
||||
|
||||
ProfilerFile::~ProfilerFile()
|
||||
{
|
||||
if(mName)
|
||||
free(mName);
|
||||
}
|
||||
|
||||
ProfilerFunction*
|
||||
ProfilerFile::FindOrAddFunction(const char* aName,
|
||||
uintN aBaseLineNumber,
|
||||
uintN aLineExtent,
|
||||
size_t aTotalSize)
|
||||
{
|
||||
FunctionID key(aBaseLineNumber, aLineExtent);
|
||||
ProfilerFunction* fun;
|
||||
|
||||
if (!mFunctionTable.Get(key, &fun))
|
||||
{
|
||||
fun = new ProfilerFunction(aName, aBaseLineNumber, aLineExtent,
|
||||
aTotalSize, this);
|
||||
if(fun)
|
||||
mFunctionTable.Put(key, fun);
|
||||
}
|
||||
return fun;
|
||||
}
|
||||
|
||||
void
|
||||
ProfilerFile::EnumerateFunctions(EnumeratorType aFunc, void *aClosure) const
|
||||
{
|
||||
mFunctionTable.EnumerateRead(aFunc, aClosure);
|
||||
}
|
||||
|
||||
ProfilerFunction::ProfilerFunction(const char* name,
|
||||
uintN lineno, uintn extent, size_t totalsize,
|
||||
ProfilerFile* file)
|
||||
: mName(name ? strdup(name) : nsnull),
|
||||
mBaseLineNumber(lineno),
|
||||
mLineExtent(extent),
|
||||
mTotalSize(totalsize),
|
||||
mFile(file),
|
||||
mCallCount(0),
|
||||
mCompileCount(0),
|
||||
mQuickTime((PRUint32) -1),
|
||||
mLongTime(0),
|
||||
mStartTime(0),
|
||||
mSum(0)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
ProfilerFunction::~ProfilerFunction()
|
||||
{
|
||||
if(mName)
|
||||
free(mName);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXPCToolsProfiler, nsIXPCToolsProfiler)
|
||||
|
||||
nsXPCToolsProfiler::nsXPCToolsProfiler()
|
||||
: mLock(PR_NewLock()),
|
||||
mRuntime(nsnull)
|
||||
{
|
||||
InitializeRuntime();
|
||||
mFileTable.Init();
|
||||
mScriptTable.Init();
|
||||
}
|
||||
|
||||
nsXPCToolsProfiler::~nsXPCToolsProfiler()
|
||||
{
|
||||
Stop();
|
||||
if(mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// the hooks...
|
||||
|
||||
/* called just after script creation */
|
||||
static void
|
||||
xpctools_JSNewScriptHook(JSContext *cx,
|
||||
const char *filename, /* URL of script */
|
||||
uintN lineno, /* line script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun,
|
||||
void *callerdata)
|
||||
{
|
||||
if(!script)
|
||||
return;
|
||||
if(!filename)
|
||||
filename = "<<<!!! has no name so may represent many different pages !!!>>>";
|
||||
nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) callerdata;
|
||||
|
||||
PR_Lock(self->mLock);
|
||||
|
||||
ProfilerFile* file;
|
||||
if (!self->mFileTable.Get(filename, &file))
|
||||
{
|
||||
file = new ProfilerFile(filename);
|
||||
if (file)
|
||||
self->mFileTable.Put(filename, file);
|
||||
}
|
||||
if(file)
|
||||
{
|
||||
ProfilerFunction* function =
|
||||
file->FindOrAddFunction(fun ? JS_GetFunctionName(fun) : nsnull,
|
||||
JS_GetScriptBaseLineNumber(cx, script),
|
||||
JS_GetScriptLineExtent(cx, script),
|
||||
fun
|
||||
? JS_GetFunctionTotalSize(cx, fun)
|
||||
: JS_GetScriptTotalSize(cx, script));
|
||||
if(function)
|
||||
{
|
||||
function->IncrementCompileCount();
|
||||
self->mScriptTable.Put(script, function);
|
||||
}
|
||||
}
|
||||
PR_Unlock(self->mLock);
|
||||
}
|
||||
|
||||
/* called just before script destruction */
|
||||
static void
|
||||
xpctools_JSDestroyScriptHook(JSContext *cx,
|
||||
JSScript *script,
|
||||
void *callerdata)
|
||||
{
|
||||
if(!script)
|
||||
return;
|
||||
nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) callerdata;
|
||||
|
||||
PR_Lock(self->mLock);
|
||||
self->mScriptTable.Remove(script);
|
||||
PR_Unlock(self->mLock);
|
||||
}
|
||||
|
||||
|
||||
/* called on entry and return of functions and top level scripts */
|
||||
static void*
|
||||
xpctools_InterpreterHook(JSContext *cx, JSStackFrame *fp, JSBool before,
|
||||
JSBool *ok, void *closure)
|
||||
{
|
||||
// ignore returns
|
||||
NS_ASSERTION(fp, "bad frame pointer!");
|
||||
|
||||
JSScript* script = fp->script;
|
||||
if(script)
|
||||
{
|
||||
nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) closure;
|
||||
|
||||
PR_Lock(self->mLock);
|
||||
|
||||
ProfilerFunction* fun;
|
||||
if (self->mScriptTable.Get(script, &fun))
|
||||
{
|
||||
if(before)
|
||||
{
|
||||
fun->IncrementCallCount();
|
||||
fun->SetStartTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
PRUint32 delta = fun->SetEndTime();
|
||||
|
||||
JSStackFrame* down = fp->down;
|
||||
if (down) {
|
||||
JSScript* caller = down->script;
|
||||
if (caller) {
|
||||
ProfilerFunction* callfun;
|
||||
if (self->mScriptTable.Get(caller, &callfun))
|
||||
{
|
||||
callfun->AddNotSelfTime(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(self->mLock);
|
||||
}
|
||||
return closure;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// interface methods
|
||||
|
||||
/* void start (); */
|
||||
NS_IMETHODIMP nsXPCToolsProfiler::Start()
|
||||
{
|
||||
PR_Lock(mLock);
|
||||
|
||||
if(!VerifyRuntime())
|
||||
{
|
||||
PR_Unlock(mLock);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JS_SetNewScriptHook(mRuntime, xpctools_JSNewScriptHook, this);
|
||||
JS_SetDestroyScriptHook(mRuntime, xpctools_JSDestroyScriptHook, this);
|
||||
JS_SetExecuteHook(mRuntime, xpctools_InterpreterHook, this);
|
||||
JS_SetCallHook(mRuntime, xpctools_InterpreterHook, this);
|
||||
|
||||
PR_Unlock(mLock);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void stop (); */
|
||||
NS_IMETHODIMP nsXPCToolsProfiler::Stop()
|
||||
{
|
||||
PR_Lock(mLock);
|
||||
|
||||
if(!VerifyRuntime())
|
||||
{
|
||||
PR_Unlock(mLock);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JS_SetNewScriptHook(mRuntime, nsnull, nsnull);
|
||||
JS_SetDestroyScriptHook(mRuntime, nsnull, nsnull);
|
||||
JS_SetExecuteHook(mRuntime, nsnull, this);
|
||||
JS_SetCallHook(mRuntime, nsnull, this);
|
||||
|
||||
PR_Unlock(mLock);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP nsXPCToolsProfiler::Clear()
|
||||
{
|
||||
// XXX implement me!
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static PLDHashOperator
|
||||
xpctools_FunctionNamePrinter(const FunctionID &aKey,
|
||||
ProfilerFunction* fun, void* closure)
|
||||
{
|
||||
FILE* out = (FILE*) closure;
|
||||
const char* name = fun->GetName();
|
||||
PRUint32 average;
|
||||
PRUint32 count;
|
||||
|
||||
count = fun->GetCallCount();
|
||||
if (count != 0)
|
||||
average = fun->GetSum() / count;
|
||||
if(!name)
|
||||
name = "<top level>";
|
||||
fprintf(out,
|
||||
" [%lu,%lu] %s() {%d-%d} %lu ",
|
||||
(unsigned long) fun->GetCompileCount(),
|
||||
(unsigned long) fun->GetCallCount(),
|
||||
name,
|
||||
(int) fun->GetBaseLineNumber(),
|
||||
(int)(fun->GetBaseLineNumber()+fun->GetLineExtent()-1),
|
||||
(unsigned long) fun->GetTotalSize());
|
||||
if(count != 0)
|
||||
fprintf(out,
|
||||
"{min %lu, max %lu, avg %lu, sum %lu, self %lu}\n",
|
||||
(unsigned long) fun->GetQuickTime(),
|
||||
(unsigned long) fun->GetLongTime(),
|
||||
(unsigned long) average,
|
||||
(unsigned long) fun->GetSum(),
|
||||
(unsigned long) fun->GetSelf());
|
||||
else
|
||||
fprintf(out, "\n" );
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
xpctools_FilenamePrinter(const char *keyname, ProfilerFile* file,
|
||||
void *closure)
|
||||
{
|
||||
FILE* out = (FILE*) closure;
|
||||
fprintf(out, "%s\n", file->GetName());
|
||||
file->EnumerateFunctions(xpctools_FunctionNamePrinter, closure);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
/* void writeResults (in nsILocalFile aFile); */
|
||||
NS_IMETHODIMP nsXPCToolsProfiler::WriteResults(nsILocalFile *aFile)
|
||||
{
|
||||
NS_ENSURE_ARG(aFile);
|
||||
|
||||
FILE* out;
|
||||
if(NS_FAILED(aFile->OpenANSIFileDesc("w", &out)) || ! out)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
fprintf(out, "[CompileCount, CallCount] Name {StartLine, EndLine} TotalSize {MinTime, MaxTime, Average, Total, Self}\n\n");
|
||||
|
||||
PR_Lock(mLock);
|
||||
mFileTable.EnumerateRead(xpctools_FilenamePrinter, out);
|
||||
PR_Unlock(mLock);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// additional utility methods
|
||||
|
||||
JSBool
|
||||
nsXPCToolsProfiler::VerifyRuntime()
|
||||
{
|
||||
JSRuntime* rt;
|
||||
nsCOMPtr<nsIJSRuntimeService> rts = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
||||
return rts && NS_SUCCEEDED(rts->GetRuntime(&rt)) && rt && rt == mRuntime;
|
||||
}
|
||||
|
||||
JSBool
|
||||
nsXPCToolsProfiler::InitializeRuntime()
|
||||
{
|
||||
NS_ASSERTION(!mRuntime, "can't init runtime twice");
|
||||
JSRuntime* rt;
|
||||
nsCOMPtr<nsIJSRuntimeService> rts = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
|
||||
if(rts && NS_SUCCEEDED(rts->GetRuntime(&rt)) && rt)
|
||||
mRuntime = rt;
|
||||
return mRuntime != nsnull;
|
||||
}
|
@ -1,236 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* All the XPCTools private declarations - only include locally. */
|
||||
|
||||
#ifndef xpctoolsprivate_h___
|
||||
#define xpctoolsprivate_h___
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIModule.h"
|
||||
#include "jsapi.h"
|
||||
#include "jshash.h"
|
||||
#include "jsprf.h"
|
||||
#include "jsinterp.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "nsIXPCToolsCompiler.h"
|
||||
#include "nsIXPCToolsProfiler.h"
|
||||
|
||||
class nsXPCToolsCompiler : public nsIXPCToolsCompiler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIXPCTOOLSCOMPILER
|
||||
|
||||
nsXPCToolsCompiler();
|
||||
virtual ~nsXPCToolsCompiler();
|
||||
// XXX add additional members
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class ProfilerFile;
|
||||
|
||||
class ProfilerFunction
|
||||
{
|
||||
public:
|
||||
ProfilerFunction(const char* name,
|
||||
uintN lineno, uintn extent, size_t totalsize,
|
||||
ProfilerFile* file);
|
||||
~ProfilerFunction();
|
||||
|
||||
const char* GetName() const {return mName;}
|
||||
ProfilerFile* GetFile() const {return mFile;}
|
||||
uintN GetBaseLineNumber() const {return mBaseLineNumber;}
|
||||
uintN GetLineExtent() const {return mLineExtent;}
|
||||
size_t GetTotalSize() const { return mTotalSize; }
|
||||
void IncrementCallCount() {++mCallCount;}
|
||||
PRUint32 GetCallCount() {return mCallCount;}
|
||||
PRUint32 GetSum() {return mSum;}
|
||||
void IncrementCompileCount() {++mCompileCount;}
|
||||
PRUint32 GetCompileCount() {return mCompileCount;}
|
||||
PRUint32 NowInMilliSecs()
|
||||
{PRUint64 now64 = LL_INIT(0,1000);
|
||||
PRUint32 now32;
|
||||
LL_DIV(now64,PR_Now(),now64);
|
||||
LL_L2UI(now32, now64);
|
||||
return now32;
|
||||
}
|
||||
void SetStartTime() {mStartTime = NowInMilliSecs();}
|
||||
PRUint32 SetEndTime()
|
||||
{PRUint32 delta = NowInMilliSecs() - mStartTime;
|
||||
if(delta < mQuickTime)
|
||||
mQuickTime = delta;
|
||||
if (delta > mLongTime)
|
||||
mLongTime = delta;
|
||||
mSum += delta;
|
||||
return delta;}
|
||||
PRUint32 GetQuickTime() {return mQuickTime;}
|
||||
PRUint32 GetLongTime() {return mLongTime;}
|
||||
|
||||
void AddNotSelfTime(PRUint32 delta) {mNotSelfSum += delta;}
|
||||
PRUint32 GetSelf() { return mSum - mNotSelfSum;}
|
||||
|
||||
ProfilerFunction(); // not implemented
|
||||
|
||||
private:
|
||||
char* mName;
|
||||
uintN mBaseLineNumber;
|
||||
uintN mLineExtent;
|
||||
size_t mTotalSize; // JSFunction, JSScript, bytecode, &c, size
|
||||
ProfilerFile* mFile;
|
||||
PRUint32 mCallCount;
|
||||
PRUint32 mCompileCount;
|
||||
PRUint32 mQuickTime; // quickest delta in msec
|
||||
PRUint32 mLongTime; // longest delta in msec
|
||||
PRUint32 mStartTime; // time on enter
|
||||
PRUint32 mSum;
|
||||
PRUint32 mNotSelfSum;
|
||||
};
|
||||
|
||||
struct FunctionID
|
||||
{
|
||||
uintN lineno;
|
||||
uintN extent;
|
||||
|
||||
FunctionID(uintN aLineno, uintN aExtent) :
|
||||
lineno(aLineno), extent(aExtent) { }
|
||||
|
||||
PRBool operator==(const FunctionID &aOther) const {
|
||||
return aOther.lineno == this->lineno &&
|
||||
aOther.extent == this->extent;
|
||||
}
|
||||
};
|
||||
|
||||
class FunctionKey : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef const FunctionID &KeyType;
|
||||
typedef const FunctionID *KeyTypePointer;
|
||||
|
||||
FunctionKey(KeyTypePointer aF) : mF(*aF) { }
|
||||
FunctionKey(const FunctionKey &toCopy) : mF(toCopy.mF) { }
|
||||
~FunctionKey() { }
|
||||
|
||||
KeyType GetKey() const { return mF; }
|
||||
PRBool KeyEquals(const KeyTypePointer aKey) const
|
||||
{
|
||||
return mF == *aKey;
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
static PLDHashNumber HashKey(const KeyTypePointer aKey) {
|
||||
return (aKey->lineno * 17) | (aKey->extent * 7);
|
||||
}
|
||||
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
|
||||
private:
|
||||
const FunctionID mF;
|
||||
};
|
||||
|
||||
class ProfilerFile
|
||||
{
|
||||
public:
|
||||
ProfilerFile(const char* filename);
|
||||
~ProfilerFile();
|
||||
|
||||
|
||||
ProfilerFunction* FindOrAddFunction(const char* aName,
|
||||
uintN aBaseLineNumber,
|
||||
uintN aLineExtent,
|
||||
size_t aTotalSize);
|
||||
|
||||
typedef nsClassHashtable<FunctionKey, ProfilerFunction> FunctionTableType;
|
||||
typedef FunctionTableType::EnumReadFunction EnumeratorType;
|
||||
|
||||
void EnumerateFunctions(EnumeratorType aFunc,
|
||||
void *aClosure) const;
|
||||
|
||||
const char* GetName() const {return mName;}
|
||||
|
||||
private:
|
||||
char* mName;
|
||||
FunctionTableType mFunctionTable;
|
||||
};
|
||||
|
||||
class nsXPCToolsProfiler : public nsIXPCToolsProfiler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIXPCTOOLSPROFILER
|
||||
|
||||
nsXPCToolsProfiler();
|
||||
virtual ~nsXPCToolsProfiler();
|
||||
|
||||
private:
|
||||
JSBool InitializeRuntime();
|
||||
JSBool VerifyRuntime();
|
||||
|
||||
/* Taking the unusual step of making all data public to simplify
|
||||
* the implementation of the "C" static debugger hooks.
|
||||
*/
|
||||
|
||||
public:
|
||||
PRLock* mLock;
|
||||
JSRuntime* mRuntime;
|
||||
nsClassHashtable<nsCharPtrHashKey, ProfilerFile> mFileTable;
|
||||
nsDataHashtable<nsVoidPtrHashKey, ProfilerFunction*> mScriptTable;
|
||||
};
|
||||
|
||||
#endif /* xpctoolsprivate_h___ */
|
Loading…
Reference in New Issue
Block a user