Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 407216 - DOM quick stubs - faster paths for top N DOM methods (r+…
Browse files Browse the repository at this point in the history
…sr=jst, security r=mrbkap, build r=bsmedberg)

* * *
* * *
* * *
  • Loading branch information
Jason Orendorff committed Aug 20, 2008
1 parent 8cf7eb0 commit 4e49790
Show file tree
Hide file tree
Showing 27 changed files with 8,903 additions and 30 deletions.
1 change: 0 additions & 1 deletion accessible/src/msaa/nsAccessNodeWrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
#ifndef WINABLEAPI
#include <winable.h>
#endif
#undef ERROR /// Otherwise we can't include nsIDOMNSEvent.h if we include this
#ifdef MOZ_CRASHREPORTER
#include "nsICrashReporter.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion dom/public/idl/events/nsIDOMNSEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "domstubs.idl"

%{C++
#ifdef WINCE
#ifdef ERROR
#undef ERROR
#endif
%}
Expand Down
22 changes: 21 additions & 1 deletion dom/src/base/nsDOMClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3845,7 +3845,8 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
// be calling nsWindowSH::GlobalResolve directly.
JSObject *global = ::JS_GetGlobalForObject(cx, obj);
jsval val;
if (!::JS_LookupProperty(cx, global, mData->mName, &val)) {
if (!::JS_LookupPropertyWithFlags(cx, global, mData->mName,
JSRESOLVE_CLASSNAME, &val)) {
return NS_ERROR_UNEXPECTED;
}

Expand Down Expand Up @@ -4081,6 +4082,25 @@ nsDOMClassInfo::InnerObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
return NS_ERROR_UNEXPECTED;
}

NS_IMETHODIMP
nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
{
PRUint32 flags = (mData->mScriptableFlags & DONT_ENUM_STATIC_PROPS)
? 0
: JSPROP_ENUMERATE;

PRUint32 count = 0;
while (mData->mInterfaces[count]) {
count++;
}

if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
count, mData->mInterfaces)) {
JS_ClearPendingException(cx);
}
return NS_OK;
}

// static
nsIClassInfo *
NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
Expand Down
2 changes: 1 addition & 1 deletion js/src/jscntxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ typedef enum JSErrNum {
JSErr_Limit
} JSErrNum;

extern const JSErrorFormatString *
extern JS_FRIEND_API(const JSErrorFormatString *)
js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);

#ifdef va_start
Expand Down
6 changes: 5 additions & 1 deletion js/src/xpconnect/idl/nsIXPCScriptable.idl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* to *_retval unless they want to return PR_FALSE.
*/

[uuid(1455f6fe-6de9-4b62-a2b3-d1aee82dd829)]
[uuid(5d309b93-e9b4-4374-bcd5-44245c83408f)]
interface nsIXPCScriptable : nsISupports
{
/* bitflags used for 'flags' (only 32 bits available!) */
Expand Down Expand Up @@ -174,4 +174,8 @@ interface nsIXPCScriptable : nsISupports

JSObjectPtr innerObject(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj);

// This method is called if the WANT_POSTCREATE bit is set in
// scriptableFlags.
void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);
};
26 changes: 25 additions & 1 deletion js/src/xpconnect/idl/nsIXPConnect.idl
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}

[uuid(c1d4a482-1beb-4c82-9c0b-d2ab93acc7ef)]
[uuid(d4c6bc06-2a4f-4315-90ec-d12904aca046)]
interface nsIXPConnect : nsISupports
{
%{ C++
Expand Down Expand Up @@ -747,4 +747,28 @@ interface nsIXPConnect : nsISupports
* passed here.
*/
void setReportAllJSExceptions(in boolean reportAllJSExceptions);

/**
* Define quick stubs on the given object, @a proto.
*
* @param cx
* A context. Requires request.
* @param proto
* The (newly created) prototype object for a DOM class. The JS half
* of an XPCWrappedNativeProto.
* @param flags
* Property flags for the quick stub properties--should be either
* JSPROP_ENUMERATE or 0.
* @param interfaceCount
* The number of interfaces the class implements.
* @param interfaceArray
* The interfaces the class implements; interfaceArray and
* interfaceCount are like what nsIClassInfo.getInterfaces returns.
*/
[noscript,notxpcom] PRBool defineDOMQuickStubs(
in JSContextPtr cx,
in JSObjectPtr proto,
in PRUint32 flags,
in PRUint32 interfaceCount,
[array, size_is(interfaceCount)] in nsIIDPtr interfaceArray);
};
9 changes: 9 additions & 0 deletions js/src/xpconnect/public/xpc_map_end.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::InnerObject(nsIXPConnectWrappedNative *wrapper,
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
#endif

#ifndef XPC_MAP_WANT_POST_CREATE_PROTOTYPE
NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreatePrototype(JSContext *cx, JSObject *proto)
{return NS_OK;}
#endif

/**************************************************************/

#undef XPC_MAP_CLASSNAME
Expand Down Expand Up @@ -313,6 +318,10 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::InnerObject(nsIXPConnectWrappedNative *wrapper,
#undef XPC_MAP_WANT_OUTER_OBJECT
#endif

#ifdef XPC_MAP_WANT_POST_CREATE_PROTOTYPE
#undef XPC_MAP_WANT_POST_CREATE_PROTOTYPE
#endif

#ifdef XPC_MAP_FLAGS
#undef XPC_MAP_FLAGS
#endif
36 changes: 36 additions & 0 deletions js/src/xpconnect/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ REQUIRES = xpcom \
dom \
$(NULL)

# These modules are required because the auto-generated file
# dom_quickstubs.cpp #includes header files from many places.
REQUIRES += content \
editor \
layout \
rdf \
svg \
xuldoc \
xultmpl \
$(NULL)


CPPSRCS = \
nsScriptError.cpp \
nsXPConnect.cpp \
Expand Down Expand Up @@ -99,6 +111,8 @@ CPPSRCS = \
XPCSafeJSObjectWrapper.cpp \
XPCCrossOriginWrapper.cpp \
XPCWrapper.cpp \
xpcquickstubs.cpp \
dom_quickstubs.cpp \
$(NULL)
ifdef XPC_IDISPATCH_SUPPORT
CPPSRCS += XPCDispObject.cpp \
Expand Down Expand Up @@ -168,3 +182,25 @@ endif
endif
endif

nsXPConnect.$(OBJ_SUFFIX): dom_quickstubs.h

dom_quickstubs.h dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
$(srcdir)/qsgen.py \
$(topsrcdir)/xpcom/idl-parser/header.py \
$(topsrcdir)/xpcom/idl-parser/xpidl.py
PYTHONPATH=$(topsrcdir)/xpcom/idl-parser \
$(PYTHON) $(srcdir)/qsgen.py \
--idlpath=$(DEPTH)/dist/idl \
--cachedir=$(DEPTH)/xpcom/idl-parser \
--header-output dom_quickstubs.h \
--stub-output dom_quickstubs.cpp \
--makedepend-output dom_quickstubs.depends \
$(srcdir)/dom_quickstubs.qsconf

GARBAGE += \
dom_quickstubs.h \
dom_quickstubs.cpp \
dom_quickstubs.depends \
$(NULL)

-include dom_quickstubs.depends
Loading

0 comments on commit 4e49790

Please sign in to comment.