зеркало из https://github.com/mozilla/gecko-dev.git
Fix bugs 296772 and 262948 (r=shaver, sr=jst, a=me).
This commit is contained in:
Родитель
9f51bec4e3
Коммит
b2dc882824
|
@ -39,6 +39,7 @@
|
|||
#include "nsIScriptContextOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIDOMChromeWindow.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -87,6 +88,10 @@
|
|||
#include "nsICollation.h"
|
||||
#include "nsCollationCID.h"
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#include "jsgc.h" // for WAY_TOO_MUCH_GC, if defined for GC debugging
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
|
||||
|
||||
#include "nsIStringBundle.h"
|
||||
|
@ -666,10 +671,10 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
|
|||
|
||||
++sContextCount;
|
||||
|
||||
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS |
|
||||
JSOPTION_NATIVE_BRANCH_CALLBACK
|
||||
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS
|
||||
| JSOPTION_NATIVE_BRANCH_CALLBACK
|
||||
#ifdef DEBUG
|
||||
| JSOPTION_STRICT // lint catching for development
|
||||
| JSOPTION_STRICT // lint catching for development
|
||||
#endif
|
||||
;
|
||||
|
||||
|
@ -1294,7 +1299,8 @@ nsJSContext::CompileEventHandler(void *aTarget, nsIAtom *aName,
|
|||
const char *argList[] = { aEventName };
|
||||
|
||||
JSFunction* fun =
|
||||
::JS_CompileUCFunctionForPrincipals(mContext, target, jsprin,
|
||||
::JS_CompileUCFunctionForPrincipals(mContext,
|
||||
aShared ? nsnull : target, jsprin,
|
||||
charName, 1, argList,
|
||||
(jschar*)PromiseFlatString(aBody).get(),
|
||||
aBody.Length(),
|
||||
|
@ -1310,11 +1316,6 @@ nsJSContext::CompileEventHandler(void *aTarget, nsIAtom *aName,
|
|||
JSObject *handler = ::JS_GetFunctionObject(fun);
|
||||
if (aHandler)
|
||||
*aHandler = (void*) handler;
|
||||
|
||||
if (aShared) {
|
||||
/* Break scope link to avoid entraining shared compilation scope. */
|
||||
::JS_SetParent(mContext, handler, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1345,7 +1346,8 @@ nsJSContext::CompileFunction(void* aTarget,
|
|||
|
||||
JSObject *target = (JSObject*)aTarget;
|
||||
JSFunction* fun =
|
||||
::JS_CompileUCFunctionForPrincipals(mContext, target, jsprin,
|
||||
::JS_CompileUCFunctionForPrincipals(mContext,
|
||||
aShared ? nsnull : target, jsprin,
|
||||
PromiseFlatCString(aName).get(),
|
||||
aArgCount, aArgArray,
|
||||
(jschar*)PromiseFlatString(aBody).get(),
|
||||
|
@ -1360,12 +1362,6 @@ nsJSContext::CompileFunction(void* aTarget,
|
|||
JSObject *handler = ::JS_GetFunctionObject(fun);
|
||||
if (aFunctionObject)
|
||||
*aFunctionObject = (void*) handler;
|
||||
|
||||
// Prevent entraining just like CompileEventHandler does?
|
||||
if (aShared) {
|
||||
/* Break scope link to avoid entraining shared compilation scope. */
|
||||
::JS_SetParent(mContext, handler, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1917,10 +1913,14 @@ nsJSContext::ScriptEvaluated(PRBool aTerminated)
|
|||
|
||||
mNumEvaluations++;
|
||||
|
||||
#ifdef WAY_TOO_MUCH_GC
|
||||
::JS_MaybeGC(mContext);
|
||||
#else
|
||||
if (mNumEvaluations > 20) {
|
||||
mNumEvaluations = 0;
|
||||
::JS_MaybeGC(mContext);
|
||||
}
|
||||
#endif
|
||||
|
||||
mBranchCallbackCount = 0;
|
||||
mBranchCallbackTime = LL_ZERO;
|
||||
|
|
|
@ -1758,6 +1758,9 @@ JS_GC(JSContext *cx)
|
|||
JS_PUBLIC_API(void)
|
||||
JS_MaybeGC(JSContext *cx)
|
||||
{
|
||||
#ifdef WAY_TOO_MUCH_GC
|
||||
JS_GC(cx);
|
||||
#else
|
||||
JSRuntime *rt;
|
||||
uint32 bytes, lastBytes;
|
||||
|
||||
|
@ -1773,6 +1776,7 @@ JS_MaybeGC(JSContext *cx)
|
|||
*/
|
||||
JS_GC(cx);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSGCCallback)
|
||||
|
|
|
@ -555,13 +555,6 @@ js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes)
|
|||
JSLocalRootStack *lrs;
|
||||
uint32 *bytesptr;
|
||||
|
||||
#ifdef TOO_MUCH_GC
|
||||
js_GC(cx, GC_KEEP_ATOMS);
|
||||
tried_gc = JS_TRUE;
|
||||
#else
|
||||
tried_gc = JS_FALSE;
|
||||
#endif
|
||||
|
||||
rt = cx->runtime;
|
||||
JS_LOCK_GC(rt);
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
@ -570,6 +563,17 @@ js_NewGCThing(JSContext *cx, uintN flags, size_t nbytes)
|
|||
JS_UNLOCK_GC(rt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TOO_MUCH_GC
|
||||
#ifdef WAY_TOO_MUCH_GC
|
||||
rt->gcPoke = JS_TRUE;
|
||||
#endif
|
||||
js_GC(cx, GC_KEEP_ATOMS | GC_ALREADY_LOCKED);
|
||||
tried_gc = JS_TRUE;
|
||||
#else
|
||||
tried_gc = JS_FALSE;
|
||||
#endif
|
||||
|
||||
METER(rt->gcStats.alloc++);
|
||||
nbytes = JS_ROUNDUP(nbytes, sizeof(JSGCThing));
|
||||
nflags = nbytes / sizeof(JSGCThing);
|
||||
|
|
|
@ -256,6 +256,14 @@ js_DumpGCStats(JSRuntime *rt, FILE *fp);
|
|||
|
||||
#endif /* JS_GCMETER */
|
||||
|
||||
#ifdef DEBUG_notme
|
||||
#define TOO_MUCH_GC 1
|
||||
#endif
|
||||
|
||||
#ifdef WAY_TOO_MUCH_GC
|
||||
#define TOO_MUCH_GC 1
|
||||
#endif
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsgc_h___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче