mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Backout cb50e96dbee0 (Bug 677079) for Win PGO mochitests failures.
This commit is contained in:
parent
3c4b80c685
commit
36e97f68a2
@ -38,7 +38,7 @@
|
||||
|
||||
#include "ContentChild.h"
|
||||
#include "ContentParent.h"
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
@ -41,8 +41,7 @@
|
||||
* A class that handles loading and evaluation of <script> elements.
|
||||
*/
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsParserUtils.h"
|
||||
@ -498,7 +497,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||
// We re-use our knowledge of the implementation to reuse
|
||||
// JSVERSION_HAS_XML as a safe version flag.
|
||||
// If version has JSVERSION_UNKNOWN (-1), then this is still OK.
|
||||
version = JS_VersionSetXML(JSVersion(version), true);
|
||||
version |= js::VersionFlags::HAS_XML;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jstypedarray.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -47,8 +47,7 @@
|
||||
* see http://developer.mozilla.org/en/docs/XUL
|
||||
*/
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h" // for JSVERSION_HAS_XML
|
||||
#include "nsXULContentSink.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsForwardReference.h"
|
||||
@ -1061,7 +1060,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
||||
// our implementation knowledge to reuse JSVERSION_HAS_XML as a
|
||||
// safe version flag. This is still OK if version is
|
||||
// JSVERSION_UNKNOWN (-1),
|
||||
version = JS_VersionSetXML(JSVersion(version), true);
|
||||
version |= js::VersionFlags::HAS_XML;
|
||||
|
||||
nsAutoString value;
|
||||
rv = parser.GetParameter("e4x", value);
|
||||
@ -1070,7 +1069,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
||||
return rv;
|
||||
} else {
|
||||
if (value.Length() == 1 && value[0] == '0')
|
||||
version = JS_VersionSetXML(JSVersion(version), false);
|
||||
version &= ~js::VersionFlags::HAS_XML;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1084,7 +1083,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
||||
|
||||
// Even when JS version < 1.6 is specified, E4X is
|
||||
// turned on in XUL.
|
||||
version = JS_VersionSetXML(JSVersion(version), true);
|
||||
version |= js::VersionFlags::HAS_XML;
|
||||
}
|
||||
}
|
||||
aAttributes += 2;
|
||||
|
@ -43,6 +43,7 @@
|
||||
// JavaScript includes
|
||||
#include "jsapi.h"
|
||||
#include "jsprvtd.h" // we are using private JS typedefs...
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "AccessCheck.h"
|
||||
@ -5242,7 +5243,7 @@ nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
}
|
||||
|
||||
if (id == sWrappedJSObject_id &&
|
||||
xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
|
||||
xpc::AccessCheck::isChrome(cx->compartment)) {
|
||||
obj = JS_ObjectToOuterObject(cx, obj);
|
||||
*vp = OBJECT_TO_JSVAL(obj);
|
||||
return NS_SUCCESS_I_DID_SOMETHING;
|
||||
|
@ -6092,7 +6092,7 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
}
|
||||
|
||||
const JSStructuredCloneCallbacks* runtimeCallbacks =
|
||||
js::GetRuntimeStructuredCloneCallbacks(js::GetContextRuntime(cx));
|
||||
cx->runtime->structuredCloneCallbacks;
|
||||
|
||||
if (runtimeCallbacks) {
|
||||
return runtimeCallbacks->read(cx, reader, tag, data, nsnull);
|
||||
@ -6132,7 +6132,7 @@ PostMessageWriteStructuredClone(JSContext* cx,
|
||||
}
|
||||
|
||||
const JSStructuredCloneCallbacks* runtimeCallbacks =
|
||||
js::GetRuntimeStructuredCloneCallbacks(js::GetContextRuntime(cx));
|
||||
cx->runtime->structuredCloneCallbacks;
|
||||
|
||||
if (runtimeCallbacks) {
|
||||
return runtimeCallbacks->write(cx, writer, obj, nsnull);
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
@ -224,7 +224,7 @@ private:
|
||||
}
|
||||
|
||||
nsAutoTArray<jsval, 16> vals;
|
||||
JS::AutoArrayRooter avr;
|
||||
js::AutoArrayRooter avr;
|
||||
};
|
||||
|
||||
/****************************************************************
|
||||
@ -720,8 +720,8 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
|
||||
|
||||
// Check if we should offer the option to debug
|
||||
JSStackFrame* fp = ::JS_GetScriptedCaller(cx, NULL);
|
||||
bool debugPossible = (fp != nsnull && js::GetContextDebugHooks(cx) &&
|
||||
js::GetContextDebugHooks(cx)->debuggerHandler != nsnull);
|
||||
bool debugPossible = (fp != nsnull && cx->debugHooks &&
|
||||
cx->debugHooks->debuggerHandler != nsnull);
|
||||
#ifdef MOZ_JSDEBUGGER
|
||||
// Get the debugger service if necessary.
|
||||
if (debugPossible) {
|
||||
@ -850,10 +850,10 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
|
||||
else if ((buttonPressed == 2) && debugPossible) {
|
||||
// Debug the script
|
||||
jsval rval;
|
||||
JSDebugHooks *hooks = js::GetContextDebugHooks(cx);
|
||||
switch(hooks->debuggerHandler(cx, script, ::JS_GetFramePC(cx, fp),
|
||||
&rval,
|
||||
hooks->debuggerHandlerData)) {
|
||||
switch(cx->debugHooks->debuggerHandler(cx, script, ::JS_GetFramePC(cx, fp),
|
||||
&rval,
|
||||
cx->debugHooks->
|
||||
debuggerHandlerData)) {
|
||||
case JSTRAP_RETURN:
|
||||
JS_SetFrameReturnValue(cx, fp, rval);
|
||||
return JS_TRUE;
|
||||
@ -1152,7 +1152,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
|
||||
NS_ASSERTION(!tmp->mContext || js::GetContextOutstandingRequests(tmp->mContext) == 0,
|
||||
NS_ASSERTION(!tmp->mContext || tmp->mContext->outstandingRequests == 0,
|
||||
"Trying to unlink a context with outstanding requests.");
|
||||
tmp->mIsInitialized = false;
|
||||
tmp->mGCOnDestruction = false;
|
||||
@ -1182,7 +1182,7 @@ nsJSContext::GetCCRefcnt()
|
||||
{
|
||||
nsrefcnt refcnt = mRefCnt.get();
|
||||
if (NS_LIKELY(mContext))
|
||||
refcnt += js::GetContextOutstandingRequests(mContext);
|
||||
refcnt += mContext->outstandingRequests;
|
||||
return refcnt;
|
||||
}
|
||||
|
||||
@ -3373,7 +3373,6 @@ static JSBool
|
||||
DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
{
|
||||
static PRTime start;
|
||||
JSBool compartmental = JS_WasLastGCCompartmental(cx);
|
||||
|
||||
if (sPostGCEventsToConsole && NS_IsMainThread()) {
|
||||
if (status == JSGC_BEGIN) {
|
||||
@ -3383,7 +3382,7 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
NS_NAMED_LITERAL_STRING(kFmt, "GC mode: %s, timestamp: %lld, duration: %llu ms.");
|
||||
nsString msg;
|
||||
msg.Adopt(nsTextFormatter::smprintf(kFmt.get(),
|
||||
compartmental ? "compartment" : "full",
|
||||
cx->runtime->gcTriggerCompartment ? "compartment" : "full",
|
||||
now,
|
||||
(now - start) / PR_USEC_PER_MSEC));
|
||||
nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
@ -3404,7 +3403,7 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
// result of last-ditch or MaybeGC. In both cases its
|
||||
// probably a time of heavy activity and we want to delay
|
||||
// the full GC, but we do want it to happen eventually.
|
||||
if (compartmental) {
|
||||
if (cx->runtime->gcTriggerCompartment) {
|
||||
nsJSContext::PokeGC();
|
||||
|
||||
// We poked the GC, so we can kill any pending CC here.
|
||||
@ -3412,7 +3411,7 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
}
|
||||
} else {
|
||||
// If this was a full GC, poke the CC to run soon.
|
||||
if (!compartmental) {
|
||||
if (!cx->runtime->gcTriggerCompartment) {
|
||||
sGCHasRun = true;
|
||||
nsJSContext::PokeCC();
|
||||
}
|
||||
@ -3420,7 +3419,7 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
|
||||
// If we didn't end up scheduling a GC, and there are unused
|
||||
// chunks waiting to expire, make sure we will GC again soon.
|
||||
if (!sGCTimer && JS_GetGCParameter(JS_GetRuntime(cx), JSGC_UNUSED_CHUNKS) > 0) {
|
||||
if (!sGCTimer && JS_GetGCParameter(cx->runtime, JSGC_UNUSED_CHUNKS) > 0) {
|
||||
nsJSContext::PokeGC();
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,7 @@
|
||||
|
||||
#include "nsIVariant.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -39,8 +39,7 @@
|
||||
|
||||
#include "IDBDatabase.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
@ -42,8 +42,7 @@
|
||||
#include "nsIIDBDatabaseException.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMException.h"
|
||||
|
@ -41,8 +41,7 @@
|
||||
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
@ -42,8 +42,8 @@
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIVariant.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsclone.h"
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
@ -449,7 +449,7 @@ StructuredCloneWriteDummyProp(JSContext* aCx,
|
||||
PRUint64* closure = reinterpret_cast<PRUint64*>(aClosure);
|
||||
|
||||
NS_ASSERTION(*closure == 0, "We should not have been here before!");
|
||||
*closure = JS_GetSCOffset(aWriter);
|
||||
*closure = js_GetSCOffset(aWriter);
|
||||
|
||||
PRUint64 value = 0;
|
||||
return JS_WriteBytes(aWriter, &value, sizeof(value));
|
||||
@ -457,7 +457,7 @@ StructuredCloneWriteDummyProp(JSContext* aCx,
|
||||
|
||||
// try using the runtime callbacks
|
||||
const JSStructuredCloneCallbacks* runtimeCallbacks =
|
||||
js::GetRuntimeStructuredCloneCallbacks(js::GetContextRuntime(aCx));
|
||||
aCx->runtime->structuredCloneCallbacks;
|
||||
if (runtimeCallbacks) {
|
||||
return runtimeCallbacks->write(aCx, aWriter, aObj, nsnull);
|
||||
}
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
// FIXME(bug 332648): Give me a real API please!
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsJSNPRuntime.h"
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "prenv.h"
|
||||
#include "prclist.h"
|
||||
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "nsPluginHost.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "ChromeWorkerScope.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "EventTarget.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
||||
#include "WorkerInlines.h"
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "Events.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "Exceptions.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsprf.h"
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jstypedarray.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "xpcprivate.h"
|
||||
|
@ -41,12 +41,11 @@
|
||||
#include "ListenerManager.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "js/Vector.h"
|
||||
|
||||
#include "Events.h"
|
||||
|
||||
#include "nsTArray.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using dom::workers::events::ListenerManager;
|
||||
|
||||
@ -368,7 +367,8 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||
return true;
|
||||
}
|
||||
|
||||
InfallibleTArray<jsval> listeners;
|
||||
js::ContextAllocPolicy ap(aCx);
|
||||
js::Vector<jsval, 10, js::ContextAllocPolicy> listeners(ap);
|
||||
|
||||
for (PRCList* elem = PR_NEXT_LINK(&collection->mListenerHead);
|
||||
elem != &collection->mListenerHead;
|
||||
@ -377,12 +377,13 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||
|
||||
// Listeners that don't want untrusted events will be skipped if this is an
|
||||
// untrusted event.
|
||||
if (eventIsTrusted || listener->mWantsUntrusted) {
|
||||
listeners.AppendElement(listener->mListenerVal);
|
||||
if ((eventIsTrusted || listener->mWantsUntrusted) &&
|
||||
!listeners.append(listener->mListenerVal)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (listeners.IsEmpty()) {
|
||||
if (listeners.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -390,7 +391,7 @@ ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < listeners.Length(); index++) {
|
||||
for (size_t index = 0; index < listeners.length(); index++) {
|
||||
// If anything fails in here we want to report the exception and continue on
|
||||
// to the next listener rather than bailing out. If something fails and
|
||||
// does not set an exception then we bail out entirely as we've either run
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "Location.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "Navigator.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "Worker.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "EventTarget.h"
|
||||
#include "RuntimeService.h"
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsprf.h"
|
||||
#include "nsAlgorithm.h"
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "WorkerScope.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "xpcprivate.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "XMLHttpRequest.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "WorkerPrivate.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "mozilla/jsipc/ContextWrapperChild.h"
|
||||
#include "mozilla/jsipc/ObjectWrapperChild.h"
|
||||
@ -454,7 +455,7 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
|
||||
proto;
|
||||
proto = JS_GetPrototype(cx, proto))
|
||||
{
|
||||
JS::AutoIdArray ids(cx, JS_Enumerate(cx, proto));
|
||||
AutoIdArray ids(cx, JS_Enumerate(cx, proto));
|
||||
for (uint i = 0; i < ids.length(); ++i)
|
||||
JS_DefinePropertyById(cx, state, ids[i], JSVAL_VOID,
|
||||
NULL, NULL, JSPROP_ENUMERATE | JSPROP_SHARED);
|
||||
@ -462,7 +463,7 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
|
||||
|
||||
InfallibleTArray<nsString>* strIds;
|
||||
{
|
||||
JS::AutoIdArray ids(cx, JS_Enumerate(cx, state));
|
||||
AutoIdArray ids(cx, JS_Enumerate(cx, state));
|
||||
if (!ids)
|
||||
return false;
|
||||
strIds = new InfallibleTArray<nsString>(ids.length());
|
||||
@ -600,7 +601,7 @@ ObjectWrapperChild::AnswerCall(PObjectWrapperChild* receiver, const InfallibleTA
|
||||
jsval *jsargs = args.AppendElements(argc);
|
||||
if (!jsargs)
|
||||
return false;
|
||||
JS::AutoArrayRooter tvr(cx, argc, jsargs);
|
||||
AutoArrayRooter tvr(cx, argc, jsargs);
|
||||
|
||||
for (PRUint32 i = 0; i < argc; ++i)
|
||||
if (!jsval_from_JSVariant(cx, argv.ElementAt(i), jsargs + i))
|
||||
@ -626,7 +627,7 @@ ObjectWrapperChild::AnswerConstruct(const InfallibleTArray<JSVariant>& argv,
|
||||
jsval* jsargs = args.AppendElements(argc);
|
||||
if (!jsargs)
|
||||
return false;
|
||||
JS::AutoArrayRooter tvr(cx, argc, jsargs);
|
||||
AutoArrayRooter tvr(cx, argc, jsargs);
|
||||
|
||||
for (PRUint32 i = 0; i < argc; ++i)
|
||||
if (!jsval_from_JSVariant(cx, argv.ElementAt(i), jsargs + i))
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsclass.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "mozilla/unused.h"
|
||||
@ -125,7 +126,7 @@ public:
|
||||
JSObject* obj = JS_NewObject(cx, clasp, NULL, NULL);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
JS::AutoObjectRooter root(cx, obj);
|
||||
js::AutoObjectRooter root(cx, obj);
|
||||
|
||||
JSPropertySpec* ps = const_cast<JSPropertySpec*>(sHandle_Properties);
|
||||
JSFunctionSpec* fs = const_cast<JSFunctionSpec*>(sHandle_Functions);
|
||||
@ -159,7 +160,7 @@ private:
|
||||
if (mObj) {
|
||||
JS_SetPrivate(mCx, mObj, NULL);
|
||||
|
||||
JS::AutoObjectRooter obj(mCx, mObj);
|
||||
js::AutoObjectRooter obj(mCx, mObj);
|
||||
mObj = NULL;
|
||||
|
||||
// If we can't enter the compartment, we won't run onInvalidate().
|
||||
@ -168,7 +169,7 @@ private:
|
||||
JSBool hasOnInvalidate;
|
||||
if (JS_HasProperty(mCx, obj.object(), "onInvalidate",
|
||||
&hasOnInvalidate) && hasOnInvalidate) {
|
||||
JS::AutoValueRooter r(mCx);
|
||||
js::AutoValueRooter r(mCx);
|
||||
JSBool ok = JS_CallFunctionName(mCx, obj.object(), "onInvalidate", 0,
|
||||
NULL, r.jsval_addr());
|
||||
if (!ok)
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "js/HashTable.h"
|
||||
|
||||
#include "mozilla/jetpack/JetpackActorCommon.h"
|
||||
@ -341,7 +342,7 @@ JetpackActorCommon::jsval_from_CompVariant(JSContext* cx,
|
||||
case CompVariant::TArrayOfKeyValue: {
|
||||
if (!(obj = JS_NewObject(cx, NULL, NULL, NULL)))
|
||||
return false;
|
||||
JS::AutoObjectRooter root(cx, obj);
|
||||
js::AutoObjectRooter root(cx, obj);
|
||||
|
||||
OpaqueSeenType::IdType ignored;
|
||||
if (!seen->add(obj, &ignored))
|
||||
@ -350,7 +351,7 @@ JetpackActorCommon::jsval_from_CompVariant(JSContext* cx,
|
||||
const nsTArray<KeyValue>& kvs = from.get_ArrayOfKeyValue();
|
||||
for (PRUint32 i = 0; i < kvs.Length(); ++i) {
|
||||
const KeyValue& kv = kvs.ElementAt(i);
|
||||
JS::AutoValueRooter toSet(cx);
|
||||
js::AutoValueRooter toSet(cx);
|
||||
if (!jsval_from_Variant(cx, kv.value(), toSet.jsval_addr(), seen) ||
|
||||
!JS_SetUCProperty(cx, obj,
|
||||
kv.key().get(),
|
||||
@ -370,7 +371,7 @@ JetpackActorCommon::jsval_from_CompVariant(JSContext* cx,
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < vs.Length(); ++i)
|
||||
elems[i] = JSVAL_VOID;
|
||||
JS::AutoArrayRooter root(cx, vs.Length(), elems);
|
||||
js::AutoArrayRooter root(cx, vs.Length(), elems);
|
||||
|
||||
OpaqueSeenType::IdType ignored;
|
||||
if (!seen->add(obj, &ignored))
|
||||
@ -445,7 +446,7 @@ JetpackActorCommon::RecvMessage(JSContext* cx,
|
||||
return false;
|
||||
for (PRUint32 i = 0; i < argc; ++i)
|
||||
argv[i] = JSVAL_VOID;
|
||||
JS::AutoArrayRooter argvRooter(cx, argc, argv);
|
||||
js::AutoArrayRooter argvRooter(cx, argc, argv);
|
||||
|
||||
JSString* msgNameStr =
|
||||
JS_NewUCStringCopyN(cx,
|
||||
@ -459,7 +460,7 @@ JetpackActorCommon::RecvMessage(JSContext* cx,
|
||||
if (!jsval_from_Variant(cx, data.ElementAt(i), argv + i + 1))
|
||||
return false;
|
||||
|
||||
JS::AutoValueRooter rval(cx);
|
||||
js::AutoValueRooter rval(cx);
|
||||
for (PRUint32 i = 0; i < snapshot.Length(); ++i) {
|
||||
Variant* vp = results ? results->AppendElement() : NULL;
|
||||
rval.set(JSVAL_VOID);
|
||||
|
@ -36,6 +36,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jswrapper.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
@ -310,7 +311,7 @@ JetpackChild::CallMessage(JSContext* cx, uintN argc, jsval* vp)
|
||||
}
|
||||
for (PRUint32 i = 0; i < results.Length(); ++i)
|
||||
rvals[i] = JSVAL_VOID;
|
||||
JS::AutoArrayRooter root(cx, results.Length(), rvals);
|
||||
js::AutoArrayRooter root(cx, results.Length(), rvals);
|
||||
|
||||
for (PRUint32 i = 0; i < results.Length(); ++i)
|
||||
if (!jsval_from_Variant(cx, results.ElementAt(i), rvals + i)) {
|
||||
@ -511,7 +512,7 @@ JetpackChild::EvalInSandbox(JSContext* cx, uintN argc, jsval* vp)
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
|
||||
JS::AutoValueRooter ignored(cx);
|
||||
js::AutoValueRooter ignored(cx);
|
||||
return JS_EvaluateUCScript(cx, obj, chars, length, "", 1, ignored.jsval_addr());
|
||||
}
|
||||
|
||||
@ -528,7 +529,7 @@ JetpackChild::ReportError(JSContext* cx, const char* message,
|
||||
|
||||
sReportingError = true;
|
||||
|
||||
JS::AutoObjectRooter obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
js::AutoObjectRooter obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||
|
||||
if (report && report->filename) {
|
||||
jsval filename = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, report->filename));
|
||||
|
@ -191,7 +191,10 @@ INSTALLED_HEADERS = \
|
||||
jsclass.h \
|
||||
jsclist.h \
|
||||
jsclone.h \
|
||||
jscntxt.h \
|
||||
jscompat.h \
|
||||
jscrashreport.h \
|
||||
jsdate.h \
|
||||
jsdbgapi.h \
|
||||
jsdhash.h \
|
||||
jsfriendapi.h \
|
||||
@ -208,11 +211,15 @@ INSTALLED_HEADERS = \
|
||||
jsotypes.h \
|
||||
jsproxy.h \
|
||||
jsprf.h \
|
||||
jspropertycache.h \
|
||||
jspropertytree.h \
|
||||
jsproto.tbl \
|
||||
jsprvtd.h \
|
||||
jspubtd.h \
|
||||
jsreflect.h \
|
||||
jsstdint.h \
|
||||
jsstr.h \
|
||||
jstracer.h \
|
||||
jstypedarray.h \
|
||||
jstypes.h \
|
||||
jsutil.h \
|
||||
|
@ -117,7 +117,7 @@ using namespace js::frontend;
|
||||
#define MUST_MATCH_TOKEN(tt, errno) MUST_MATCH_TOKEN_WITH_FLAGS(tt, errno, 0)
|
||||
|
||||
Parser::Parser(JSContext *cx, JSPrincipals *prin, StackFrame *cfp, bool foldConstants)
|
||||
: js::AutoGCRooter(cx),
|
||||
: AutoGCRooter(cx, PARSER),
|
||||
context(cx),
|
||||
tokenStream(cx),
|
||||
principals(NULL),
|
||||
|
@ -120,6 +120,7 @@ struct Parser : private AutoGCRooter
|
||||
Parser(JSContext *cx, JSPrincipals *prin = NULL, StackFrame *cfp = NULL, bool fold = true);
|
||||
~Parser();
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
friend struct TreeContext;
|
||||
friend struct BytecodeCompiler;
|
||||
|
||||
@ -174,7 +175,7 @@ struct Parser : private AutoGCRooter
|
||||
void markExtensibleScopeDescendants(FunctionBox *funbox, bool hasExtensibleParent);
|
||||
void setFunctionKinds(FunctionBox *funbox, uint32 *tcflags);
|
||||
|
||||
virtual void trace(JSTracer *trc);
|
||||
void trace(JSTracer *trc);
|
||||
|
||||
/*
|
||||
* Report a parse (compile) error.
|
||||
|
@ -635,7 +635,6 @@ static JSBool js_NewRuntimeWasCalled = JS_FALSE;
|
||||
|
||||
JSRuntime::JSRuntime()
|
||||
: atomsCompartment(NULL),
|
||||
structuredCloneCallbacks(NULL),
|
||||
#ifdef JS_THREADSAFE
|
||||
atomsCompartmentIsLocked(false),
|
||||
#endif
|
||||
@ -704,6 +703,7 @@ JSRuntime::JSRuntime()
|
||||
#endif
|
||||
debuggerMutations(0),
|
||||
securityCallbacks(NULL),
|
||||
structuredCloneCallbacks(NULL),
|
||||
telemetryCallback(NULL),
|
||||
propertyRemovals(0),
|
||||
scriptFilenameTable(NULL),
|
||||
@ -5889,12 +5889,6 @@ JS_ReportAllocationOverflow(JSContext *cx)
|
||||
js_ReportAllocationOverflow(cx);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSErrorReporter)
|
||||
JS_GetErrorReporter(JSContext *cx)
|
||||
{
|
||||
return cx->errorReporter;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSErrorReporter)
|
||||
JS_SetErrorReporter(JSContext *cx, JSErrorReporter er)
|
||||
{
|
||||
|
222
js/src/jsapi.h
222
js/src/jsapi.h
@ -4646,8 +4646,6 @@ struct JSErrorReport {
|
||||
#define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0)
|
||||
#define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \
|
||||
JSREPORT_STRICT_MODE_ERROR) != 0)
|
||||
extern JS_PUBLIC_API(JSErrorReporter)
|
||||
JS_GetErrorReporter(JSContext *cx);
|
||||
|
||||
extern JS_PUBLIC_API(JSErrorReporter)
|
||||
JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
|
||||
@ -4891,224 +4889,4 @@ JS_ScheduleGC(JSContext *cx, uint32 count, JSBool compartment);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace JS {
|
||||
|
||||
class AutoGCRooter;
|
||||
|
||||
namespace shadow {
|
||||
|
||||
struct Context {
|
||||
JS::AutoGCRooter *autoGCRooters;
|
||||
};
|
||||
|
||||
} /* namespace shadow */
|
||||
|
||||
class AutoGCRooter {
|
||||
public:
|
||||
AutoGCRooter(JSContext *cx)
|
||||
: down(reinterpret_cast<shadow::Context *>(cx)->autoGCRooters), context(cx)
|
||||
{
|
||||
JS_ASSERT(this != reinterpret_cast<shadow::Context *>(cx)->autoGCRooters);
|
||||
reinterpret_cast<shadow::Context *>(cx)->autoGCRooters = this;
|
||||
}
|
||||
|
||||
virtual ~AutoGCRooter() {
|
||||
JS_ASSERT(this == reinterpret_cast<shadow::Context *>(context)->autoGCRooters);
|
||||
reinterpret_cast<shadow::Context *>(context)->autoGCRooters = down;
|
||||
}
|
||||
|
||||
/* Implemented in jsgc.cpp. */
|
||||
void traceAll(JSTracer *trc);
|
||||
|
||||
protected:
|
||||
virtual void trace(JSTracer *trc) = 0;
|
||||
|
||||
AutoGCRooter * const down;
|
||||
JSContext * const context;
|
||||
|
||||
private:
|
||||
/* No copy or assignment semantics. */
|
||||
AutoGCRooter(AutoGCRooter &ida);
|
||||
void operator=(AutoGCRooter &ida);
|
||||
};
|
||||
|
||||
class AutoValueRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoValueRooter(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), val(js::NullValue())
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
AutoValueRooter(JSContext *cx, const Value &v
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), val(v)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
/*
|
||||
* If you are looking for Object* overloads, use AutoObjectRooter instead;
|
||||
* rooting Object*s as a js::Value requires discerning whether or not it is
|
||||
* a function object. Also, AutoObjectRooter is smaller.
|
||||
*/
|
||||
|
||||
void set(Value v) {
|
||||
val = v;
|
||||
}
|
||||
|
||||
const Value &value() const {
|
||||
return val;
|
||||
}
|
||||
|
||||
Value *addr() {
|
||||
return &val;
|
||||
}
|
||||
|
||||
const jsval &jsval_value() const {
|
||||
return val;
|
||||
}
|
||||
|
||||
jsval *jsval_addr() {
|
||||
return &val;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual JS_PUBLIC_API(void) trace(JSTracer *trc);
|
||||
|
||||
Value val;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoObjectRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoObjectRooter(JSContext *cx, JSObject *obj = NULL
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), obj(obj)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
void setObject(JSObject *obj) {
|
||||
this->obj = obj;
|
||||
}
|
||||
|
||||
JSObject * object() const {
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSObject ** addr() {
|
||||
return &obj;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual JS_PUBLIC_API(void) trace(JSTracer *trc);
|
||||
|
||||
JSObject *obj;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoArrayRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoArrayRooter(JSContext *cx, size_t len, Value *vec
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), array(vec), length(len)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
void changeLength(size_t newLength) {
|
||||
length = newLength;
|
||||
}
|
||||
|
||||
void changeArray(Value *newArray, size_t newLength) {
|
||||
changeLength(newLength);
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
Value *array;
|
||||
size_t length;
|
||||
|
||||
private:
|
||||
virtual JS_PUBLIC_API(void) trace(JSTracer *trc);
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0)
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), id_(id)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
jsid id() {
|
||||
return id_;
|
||||
}
|
||||
|
||||
jsid * addr() {
|
||||
return &id_;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual JS_PUBLIC_API(void) trace(JSTracer *trc);
|
||||
|
||||
jsid id_;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdArray : private AutoGCRooter {
|
||||
public:
|
||||
AutoIdArray(JSContext *cx, JSIdArray *ida
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), idArray(ida)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
~AutoIdArray() {
|
||||
if (idArray)
|
||||
JS_DestroyIdArray(context, idArray);
|
||||
}
|
||||
bool operator!() {
|
||||
return idArray == NULL;
|
||||
}
|
||||
jsid operator[](size_t i) const {
|
||||
JS_ASSERT(idArray);
|
||||
JS_ASSERT(i < size_t(idArray->length));
|
||||
return idArray->vector[i];
|
||||
}
|
||||
size_t length() const {
|
||||
return idArray->length;
|
||||
}
|
||||
|
||||
JSIdArray *steal() {
|
||||
JSIdArray *copy = idArray;
|
||||
idArray = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual JS_PUBLIC_API(void) trace(JSTracer *trc);
|
||||
|
||||
JSIdArray * idArray;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
/* No copy or assignment semantics. */
|
||||
AutoIdArray(AutoIdArray &ida);
|
||||
void operator=(AutoIdArray &ida);
|
||||
};
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* jsapi_h___ */
|
||||
|
@ -46,8 +46,8 @@
|
||||
|
||||
using namespace js;
|
||||
|
||||
JS_FRIEND_API(JSUint64)
|
||||
JS_GetSCOffset(JSStructuredCloneWriter* writer)
|
||||
JS_FRIEND_API(uint64_t)
|
||||
js_GetSCOffset(JSStructuredCloneWriter* writer)
|
||||
{
|
||||
JS_ASSERT(writer);
|
||||
return writer->output().count() * sizeof(uint64_t);
|
||||
|
@ -46,6 +46,9 @@
|
||||
#include "js/HashTable.h"
|
||||
#include "js/Vector.h"
|
||||
|
||||
JS_FRIEND_API(uint64_t)
|
||||
js_GetSCOffset(JSStructuredCloneWriter* writer);
|
||||
|
||||
namespace js {
|
||||
|
||||
bool
|
||||
|
@ -1333,25 +1333,7 @@ DSTOffsetCache::DSTOffsetCache()
|
||||
}
|
||||
|
||||
JSContext::JSContext(JSRuntime *rt)
|
||||
: autoGCRooters(NULL),
|
||||
data(NULL),
|
||||
data2(NULL),
|
||||
#ifdef JS_THREADSAFE
|
||||
thread_(NULL),
|
||||
#endif
|
||||
compartment(NULL),
|
||||
globalObject(NULL),
|
||||
runtime(rt),
|
||||
#if JS_STACK_GROWTH_DIRECTION > 0
|
||||
stackLimit((jsuword)-1),
|
||||
#else
|
||||
stackLimit(0),
|
||||
#endif
|
||||
#ifdef JS_THREADSAFE
|
||||
outstandingRequests(0),
|
||||
#endif
|
||||
debugHooks(&rt->globalDebugHooks),
|
||||
defaultVersion(JSVERSION_DEFAULT),
|
||||
: defaultVersion(JSVERSION_DEFAULT),
|
||||
hasVersionOverride(false),
|
||||
throwing(false),
|
||||
exception(UndefinedValue()),
|
||||
@ -1360,12 +1342,30 @@ JSContext::JSContext(JSRuntime *rt)
|
||||
localeCallbacks(NULL),
|
||||
resolvingList(NULL),
|
||||
generatingError(false),
|
||||
#if JS_STACK_GROWTH_DIRECTION > 0
|
||||
stackLimit((jsuword)-1),
|
||||
#else
|
||||
stackLimit(0),
|
||||
#endif
|
||||
runtime(rt),
|
||||
compartment(NULL),
|
||||
#ifdef JS_THREADSAFE
|
||||
thread_(NULL),
|
||||
#endif
|
||||
stack(thisDuringConstruction()), /* depends on cx->thread_ */
|
||||
parseMapPool_(NULL),
|
||||
globalObject(NULL),
|
||||
argumentFormatMap(NULL),
|
||||
lastMessage(NULL),
|
||||
errorReporter(NULL),
|
||||
operationCallback(NULL),
|
||||
data(NULL),
|
||||
data2(NULL),
|
||||
#ifdef JS_THREADSAFE
|
||||
outstandingRequests(0),
|
||||
#endif
|
||||
autoGCRooters(NULL),
|
||||
debugHooks(&rt->globalDebugHooks),
|
||||
securityCallbacks(NULL),
|
||||
resolveFlags(0),
|
||||
rngSeed(0),
|
||||
|
596
js/src/jscntxt.h
596
js/src/jscntxt.h
@ -45,7 +45,6 @@
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsprvtd.h"
|
||||
#include "jsatom.h"
|
||||
@ -263,16 +262,12 @@ struct JSThread {
|
||||
js::DefaultHasher<void *>,
|
||||
js::SystemAllocPolicy> Map;
|
||||
|
||||
/* Opaque thread-id, from NSPR's PR_GetCurrentThread(). */
|
||||
void *id;
|
||||
|
||||
void staticAsserts() {
|
||||
JS_STATIC_ASSERT(offsetof(JSThread, id) == offsetof(js::shadow::Thread, id));
|
||||
}
|
||||
|
||||
/* Linked list of all contexts in use on this thread. */
|
||||
JSCList contextList;
|
||||
|
||||
/* Opaque thread-id, from NSPR's PR_GetCurrentThread(). */
|
||||
void *id;
|
||||
|
||||
/* Number of JS_SuspendRequest calls withot JS_ResumeRequest. */
|
||||
unsigned suspendCount;
|
||||
|
||||
@ -353,33 +348,15 @@ typedef js::Vector<JSCompartment *, 0, js::SystemAllocPolicy> CompartmentVector;
|
||||
}
|
||||
|
||||
struct JSRuntime {
|
||||
/* Literal table maintained by jsatom.cpp functions. */
|
||||
JSAtomState atomState;
|
||||
|
||||
/* Default compartment. */
|
||||
JSCompartment *atomsCompartment;
|
||||
|
||||
/* List of compartments (protected by the GC lock). */
|
||||
js::CompartmentVector compartments;
|
||||
|
||||
/* Structured data callbacks are runtime-wide. */
|
||||
const JSStructuredCloneCallbacks *structuredCloneCallbacks;
|
||||
|
||||
void staticAsserts() {
|
||||
JS_STATIC_ASSERT(offsetof(JSRuntime, atomState) ==
|
||||
offsetof(js::shadow::Runtime, atomState));
|
||||
JS_STATIC_ASSERT(offsetof(JSRuntime, atomsCompartment) ==
|
||||
offsetof(js::shadow::Runtime, atomsCompartment));
|
||||
JS_STATIC_ASSERT(offsetof(JSRuntime, compartments) ==
|
||||
offsetof(js::shadow::Runtime, compartments));
|
||||
JS_STATIC_ASSERT(offsetof(JSRuntime, structuredCloneCallbacks) ==
|
||||
offsetof(js::shadow::Runtime, structuredCloneCallbacks));
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
bool atomsCompartmentIsLocked;
|
||||
#endif
|
||||
|
||||
/* List of compartments (protected by the GC lock). */
|
||||
js::CompartmentVector compartments;
|
||||
|
||||
/* Runtime state, synchronized by the stateChange/gcLock condvar/lock. */
|
||||
JSRuntimeState state;
|
||||
|
||||
@ -466,9 +443,6 @@ struct JSRuntime {
|
||||
void *gcMarkStackXMLs[js::XML_MARK_STACK_SIZE / sizeof(void *)];
|
||||
void *gcMarkStackLarges[js::LARGE_MARK_STACK_SIZE / sizeof(void *)];
|
||||
|
||||
/* Was the most recent GC compartmental or full? */
|
||||
bool wasCompartmentGC;
|
||||
|
||||
/*
|
||||
* Compartment that triggered GC. If more than one Compatment need GC,
|
||||
* gcTriggerCompartment is reset to NULL and a global GC is performed.
|
||||
@ -627,6 +601,9 @@ struct JSRuntime {
|
||||
*/
|
||||
JSSecurityCallbacks *securityCallbacks;
|
||||
|
||||
/* Structured data callbacks are runtime-wide. */
|
||||
const JSStructuredCloneCallbacks *structuredCloneCallbacks;
|
||||
|
||||
/* Call this to accumulate telemetry data. */
|
||||
JSAccumulateTelemetryDataCallback telemetryCallback;
|
||||
|
||||
@ -688,6 +665,9 @@ struct JSRuntime {
|
||||
*/
|
||||
volatile uint32 shapeGen;
|
||||
|
||||
/* Literal table maintained by jsatom.c functions. */
|
||||
JSAtomState atomState;
|
||||
|
||||
/* Tables of strings that are pre-allocated in the atomsCompartment. */
|
||||
js::StaticStrings staticStrings;
|
||||
|
||||
@ -826,6 +806,7 @@ extern const JSDebugHooks js_NullDebugHooks; /* defined in jsdbgapi.cpp */
|
||||
|
||||
namespace js {
|
||||
|
||||
class AutoGCRooter;
|
||||
struct AutoResolving;
|
||||
|
||||
static inline bool
|
||||
@ -934,71 +915,6 @@ struct JSContext
|
||||
JSContext *thisDuringConstruction() { return this; }
|
||||
~JSContext();
|
||||
|
||||
/* Stack of thread-stack-allocated GC roots. */
|
||||
js::AutoGCRooter *autoGCRooters;
|
||||
|
||||
/* Client opaque pointers. */
|
||||
void *data;
|
||||
void *data2;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
private:
|
||||
JSThread *thread_;
|
||||
public:
|
||||
JSThread *thread() const { return thread_; }
|
||||
|
||||
void setThread(JSThread *thread);
|
||||
static const size_t threadOffset() { return offsetof(JSContext, thread_); }
|
||||
#endif
|
||||
|
||||
/* GC heap compartment. */
|
||||
JSCompartment *compartment;
|
||||
|
||||
/* Top-level object and pointer to top stack frame's scope chain. */
|
||||
JSObject *globalObject;
|
||||
|
||||
/* Data shared by threads in an address space. */
|
||||
JSRuntime *const runtime;
|
||||
|
||||
/* Limit pointer for checking native stack consumption during recursion. */
|
||||
jsuword stackLimit;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
unsigned outstandingRequests;/* number of JS_BeginRequest calls
|
||||
without the corresponding
|
||||
JS_EndRequest. */
|
||||
#endif
|
||||
|
||||
/* Debug hooks associated with the current context. */
|
||||
const JSDebugHooks *debugHooks;
|
||||
|
||||
void staticAsserts() {
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, autoGCRooters) ==
|
||||
offsetof(JS::shadow::Context, autoGCRooters));
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, data) ==
|
||||
offsetof(js::shadow::Context, data));
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, data2) ==
|
||||
offsetof(js::shadow::Context, data2));
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, thread_) ==
|
||||
offsetof(js::shadow::Context, thread_));
|
||||
#endif
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, compartment) ==
|
||||
offsetof(js::shadow::Context, compartment));
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, runtime) ==
|
||||
offsetof(js::shadow::Context, runtime));
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, stackLimit) ==
|
||||
offsetof(js::shadow::Context, stackLimit));
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, outstandingRequests) ==
|
||||
offsetof(js::shadow::Context, outstandingRequests));
|
||||
#endif
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, globalObject) ==
|
||||
offsetof(js::shadow::Context, globalObject));
|
||||
JS_STATIC_ASSERT(offsetof(JSContext, debugHooks) ==
|
||||
offsetof(js::shadow::Context, debugHooks));
|
||||
}
|
||||
|
||||
/* JSRuntime contextList linkage. */
|
||||
JSCList link;
|
||||
|
||||
@ -1029,8 +945,27 @@ struct JSContext
|
||||
*/
|
||||
JSPackedBool generatingError;
|
||||
|
||||
/* Limit pointer for checking native stack consumption during recursion. */
|
||||
jsuword stackLimit;
|
||||
|
||||
/* Data shared by threads in an address space. */
|
||||
JSRuntime *const runtime;
|
||||
|
||||
/* GC heap compartment. */
|
||||
JSCompartment *compartment;
|
||||
|
||||
inline void setCompartment(JSCompartment *compartment);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
private:
|
||||
JSThread *thread_;
|
||||
public:
|
||||
JSThread *thread() const { return thread_; }
|
||||
|
||||
void setThread(JSThread *thread);
|
||||
static const size_t threadOffset() { return offsetof(JSContext, thread_); }
|
||||
#endif
|
||||
|
||||
/* Current execution stack. */
|
||||
js::ContextStack stack;
|
||||
|
||||
@ -1052,6 +987,9 @@ struct JSContext
|
||||
js::ParseMapPool *parseMapPool_;
|
||||
|
||||
public:
|
||||
/* Top-level object and pointer to top stack frame's scope chain. */
|
||||
JSObject *globalObject;
|
||||
|
||||
/* State for object and array toSource conversion. */
|
||||
JSSharpObjectMap sharpObjectMap;
|
||||
js::BusyArraysSet busyArrays;
|
||||
@ -1068,6 +1006,10 @@ struct JSContext
|
||||
/* Branch callback. */
|
||||
JSOperationCallback operationCallback;
|
||||
|
||||
/* Client opaque pointers. */
|
||||
void *data;
|
||||
void *data2;
|
||||
|
||||
inline js::RegExpStatics *regExpStatics();
|
||||
|
||||
public:
|
||||
@ -1154,9 +1096,18 @@ struct JSContext
|
||||
inline js::LifoAlloc &typeLifoAlloc();
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
unsigned outstandingRequests;/* number of JS_BeginRequest calls
|
||||
without the corresponding
|
||||
JS_EndRequest. */
|
||||
JSCList threadLinks; /* JSThread contextList linkage */
|
||||
#endif
|
||||
|
||||
/* Stack of thread-stack-allocated GC roots. */
|
||||
js::AutoGCRooter *autoGCRooters;
|
||||
|
||||
/* Debug hooks associated with the current context. */
|
||||
const JSDebugHooks *debugHooks;
|
||||
|
||||
/* Security callbacks that override any defined on the runtime. */
|
||||
JSSecurityCallbacks *securityCallbacks;
|
||||
|
||||
@ -1412,11 +1363,164 @@ struct AutoResolving {
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoGCRooter {
|
||||
public:
|
||||
AutoGCRooter(JSContext *cx, ptrdiff_t tag)
|
||||
: down(cx->autoGCRooters), tag(tag), context(cx)
|
||||
{
|
||||
JS_ASSERT(this != cx->autoGCRooters);
|
||||
CHECK_REQUEST(cx);
|
||||
cx->autoGCRooters = this;
|
||||
}
|
||||
|
||||
~AutoGCRooter() {
|
||||
JS_ASSERT(this == context->autoGCRooters);
|
||||
CHECK_REQUEST(context);
|
||||
context->autoGCRooters = down;
|
||||
}
|
||||
|
||||
/* Implemented in jsgc.cpp. */
|
||||
inline void trace(JSTracer *trc);
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC visibility push(default)
|
||||
#endif
|
||||
friend JS_FRIEND_API(void) MarkContext(JSTracer *trc, JSContext *acx);
|
||||
friend void MarkRuntime(JSTracer *trc);
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
protected:
|
||||
AutoGCRooter * const down;
|
||||
|
||||
/*
|
||||
* Discriminates actual subclass of this being used. If non-negative, the
|
||||
* subclass roots an array of values of the length stored in this field.
|
||||
* If negative, meaning is indicated by the corresponding value in the enum
|
||||
* below. Any other negative value indicates some deeper problem such as
|
||||
* memory corruption.
|
||||
*/
|
||||
ptrdiff_t tag;
|
||||
|
||||
JSContext * const context;
|
||||
|
||||
enum {
|
||||
JSVAL = -1, /* js::AutoValueRooter */
|
||||
VALARRAY = -2, /* js::AutoValueArrayRooter */
|
||||
PARSER = -3, /* js::Parser */
|
||||
SHAPEVECTOR = -4, /* js::AutoShapeVector */
|
||||
ENUMERATOR = -5, /* js::AutoEnumStateRooter */
|
||||
IDARRAY = -6, /* js::AutoIdArray */
|
||||
DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */
|
||||
NAMESPACES = -8, /* js::AutoNamespaceArray */
|
||||
XML = -9, /* js::AutoXMLRooter */
|
||||
OBJECT = -10, /* js::AutoObjectRooter */
|
||||
ID = -11, /* js::AutoIdRooter */
|
||||
VALVECTOR = -12, /* js::AutoValueVector */
|
||||
DESCRIPTOR = -13, /* js::AutoPropertyDescriptorRooter */
|
||||
STRING = -14, /* js::AutoStringRooter */
|
||||
IDVECTOR = -15, /* js::AutoIdVector */
|
||||
OBJVECTOR = -16 /* js::AutoObjectVector */
|
||||
};
|
||||
|
||||
private:
|
||||
/* No copy or assignment semantics. */
|
||||
AutoGCRooter(AutoGCRooter &ida);
|
||||
void operator=(AutoGCRooter &ida);
|
||||
};
|
||||
|
||||
/* FIXME(bug 332648): Move this into a public header. */
|
||||
class AutoValueRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoValueRooter(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, JSVAL), val(js::NullValue())
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
AutoValueRooter(JSContext *cx, const Value &v
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, JSVAL), val(v)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
/*
|
||||
* If you are looking for Object* overloads, use AutoObjectRooter instead;
|
||||
* rooting Object*s as a js::Value requires discerning whether or not it is
|
||||
* a function object. Also, AutoObjectRooter is smaller.
|
||||
*/
|
||||
|
||||
void set(Value v) {
|
||||
JS_ASSERT(tag == JSVAL);
|
||||
val = v;
|
||||
}
|
||||
|
||||
const Value &value() const {
|
||||
JS_ASSERT(tag == JSVAL);
|
||||
return val;
|
||||
}
|
||||
|
||||
Value *addr() {
|
||||
JS_ASSERT(tag == JSVAL);
|
||||
return &val;
|
||||
}
|
||||
|
||||
const jsval &jsval_value() const {
|
||||
JS_ASSERT(tag == JSVAL);
|
||||
return val;
|
||||
}
|
||||
|
||||
jsval *jsval_addr() {
|
||||
JS_ASSERT(tag == JSVAL);
|
||||
return &val;
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
friend void MarkRuntime(JSTracer *trc);
|
||||
|
||||
private:
|
||||
Value val;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoObjectRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoObjectRooter(JSContext *cx, JSObject *obj = NULL
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, OBJECT), obj(obj)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
void setObject(JSObject *obj) {
|
||||
this->obj = obj;
|
||||
}
|
||||
|
||||
JSObject * object() const {
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSObject ** addr() {
|
||||
return &obj;
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
friend void MarkRuntime(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JSObject *obj;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoStringRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoStringRooter(JSContext *cx, JSString *str = NULL
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), str(str)
|
||||
: AutoGCRooter(cx, STRING), str(str)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
@ -1433,20 +1537,117 @@ class AutoStringRooter : private AutoGCRooter {
|
||||
return &str;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void trace(JSTracer *trc);
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JSString *str;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoArrayRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoArrayRooter(JSContext *cx, size_t len, Value *vec
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, len), array(vec)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeLength(size_t newLength) {
|
||||
tag = ptrdiff_t(newLength);
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeArray(Value *newArray, size_t newLength) {
|
||||
changeLength(newLength);
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
Value *array;
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0)
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, ID), id_(id)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
jsid id() {
|
||||
return id_;
|
||||
}
|
||||
|
||||
jsid * addr() {
|
||||
return &id_;
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
friend void MarkRuntime(JSTracer *trc);
|
||||
|
||||
private:
|
||||
jsid id_;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdArray : private AutoGCRooter {
|
||||
public:
|
||||
AutoIdArray(JSContext *cx, JSIdArray *ida JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, IDARRAY), idArray(ida)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
~AutoIdArray() {
|
||||
if (idArray)
|
||||
JS_DestroyIdArray(context, idArray);
|
||||
}
|
||||
bool operator!() {
|
||||
return idArray == NULL;
|
||||
}
|
||||
jsid operator[](size_t i) const {
|
||||
JS_ASSERT(idArray);
|
||||
JS_ASSERT(i < size_t(idArray->length));
|
||||
return idArray->vector[i];
|
||||
}
|
||||
size_t length() const {
|
||||
return idArray->length;
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
JSIdArray *steal() {
|
||||
JSIdArray *copy = idArray;
|
||||
idArray = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JSIdArray * idArray;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
/* No copy or assignment semantics. */
|
||||
AutoIdArray(AutoIdArray &ida);
|
||||
void operator=(AutoIdArray &ida);
|
||||
};
|
||||
|
||||
/* The auto-root for enumeration object and its state. */
|
||||
class AutoEnumStateRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
AutoEnumStateRooter(JSContext *cx, JSObject *obj
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), obj(obj), stateValue()
|
||||
: AutoGCRooter(cx, ENUMERATOR), obj(obj), stateValue()
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(obj);
|
||||
@ -1454,15 +1655,17 @@ class AutoEnumStateRooter : private AutoGCRooter
|
||||
|
||||
~AutoEnumStateRooter();
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
const Value &state() const { return stateValue; }
|
||||
Value *addr() { return &stateValue; }
|
||||
|
||||
protected:
|
||||
void trace(JSTracer *trc);
|
||||
|
||||
JSObject * const obj;
|
||||
|
||||
private:
|
||||
virtual void trace(JSTracer *trc);
|
||||
|
||||
Value stateValue;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
@ -1472,15 +1675,16 @@ class AutoXMLRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoXMLRooter(JSContext *cx, JSXML *xml
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), xml(xml)
|
||||
: AutoGCRooter(cx, XML), xml(xml)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(xml);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void trace(JSTracer *trc);
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
friend void MarkRuntime(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JSXML * const xml;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
@ -1769,6 +1973,21 @@ js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp);
|
||||
extern JS_FRIEND_API(JSContext *)
|
||||
js_NextActiveContext(JSRuntime *, JSContext *);
|
||||
|
||||
/*
|
||||
* Report an exception, which is currently realized as a printf-style format
|
||||
* string and its arguments.
|
||||
*/
|
||||
typedef enum JSErrNum {
|
||||
#define MSG_DEF(name, number, count, exception, format) \
|
||||
name = number,
|
||||
#include "js.msg"
|
||||
#undef MSG_DEF
|
||||
JSErr_Limit
|
||||
} JSErrNum;
|
||||
|
||||
extern JS_FRIEND_API(const JSErrorFormatString *)
|
||||
js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);
|
||||
|
||||
#ifdef va_start
|
||||
extern JSBool
|
||||
js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap);
|
||||
@ -1788,9 +2007,23 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
extern void
|
||||
js_ReportOutOfMemory(JSContext *cx);
|
||||
|
||||
/* JS_CHECK_RECURSION is used outside JS, so JS_FRIEND_API. */
|
||||
JS_FRIEND_API(void)
|
||||
js_ReportOverRecursed(JSContext *maybecx);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
js_ReportAllocationOverflow(JSContext *cx);
|
||||
|
||||
#define JS_CHECK_RECURSION(cx, onerror) \
|
||||
JS_BEGIN_MACRO \
|
||||
int stackDummy_; \
|
||||
\
|
||||
if (!JS_CHECK_STACK_SIZE(cx->stackLimit, &stackDummy_)) { \
|
||||
js_ReportOverRecursed(cx); \
|
||||
onerror; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
/*
|
||||
* Report an exception using a previously composed JSErrorReport.
|
||||
* XXXbe remove from "friend" API
|
||||
@ -1892,6 +2125,9 @@ js_CurrentPCIsInImacro(JSContext *cx);
|
||||
|
||||
namespace js {
|
||||
|
||||
extern JS_FORCES_STACK JS_FRIEND_API(void)
|
||||
LeaveTrace(JSContext *cx);
|
||||
|
||||
extern bool
|
||||
CanLeaveTrace(JSContext *cx);
|
||||
|
||||
@ -1948,6 +2184,31 @@ ClearValueRange(Value *vec, uintN len, bool useHoles)
|
||||
}
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(Value *vec, size_t len)
|
||||
{
|
||||
PodZero(vec, len);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(Value *beg, Value *end)
|
||||
{
|
||||
PodZero(beg, end - beg);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(jsid *beg, jsid *end)
|
||||
{
|
||||
for (jsid *id = beg; id != end; ++id)
|
||||
*id = INT_TO_JSID(0);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(jsid *vec, size_t len)
|
||||
{
|
||||
MakeRangeGCSafe(vec, vec + len);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(const Shape **beg, const Shape **end)
|
||||
{
|
||||
@ -1986,20 +2247,128 @@ SetValueRangeToNull(Value *vec, size_t len)
|
||||
SetValueRangeToNull(vec, vec + len);
|
||||
}
|
||||
|
||||
class AutoShapeVector : public AutoVectorRooter<const Shape *>
|
||||
template<class T>
|
||||
class AutoVectorRooter : protected AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoShapeVector(JSContext *cx
|
||||
explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, tag), vector(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
size_t length() const { return vector.length(); }
|
||||
|
||||
bool append(const T &v) { return vector.append(v); }
|
||||
|
||||
/* For use when space has already been reserved. */
|
||||
void infallibleAppend(const T &v) { vector.infallibleAppend(v); }
|
||||
|
||||
void popBack() { vector.popBack(); }
|
||||
T popCopy() { return vector.popCopy(); }
|
||||
|
||||
bool growBy(size_t inc) {
|
||||
size_t oldLength = vector.length();
|
||||
if (!vector.growByUninitialized(inc))
|
||||
return false;
|
||||
MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool resize(size_t newLength) {
|
||||
size_t oldLength = vector.length();
|
||||
if (newLength <= oldLength) {
|
||||
vector.shrinkBy(oldLength - newLength);
|
||||
return true;
|
||||
}
|
||||
if (!vector.growByUninitialized(newLength - oldLength))
|
||||
return false;
|
||||
MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
void clear() { vector.clear(); }
|
||||
|
||||
bool reserve(size_t newLength) {
|
||||
return vector.reserve(newLength);
|
||||
}
|
||||
|
||||
T &operator[](size_t i) { return vector[i]; }
|
||||
const T &operator[](size_t i) const { return vector[i]; }
|
||||
|
||||
const T *begin() const { return vector.begin(); }
|
||||
T *begin() { return vector.begin(); }
|
||||
|
||||
const T *end() const { return vector.end(); }
|
||||
T *end() { return vector.end(); }
|
||||
|
||||
const T &back() const { return vector.back(); }
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
typedef Vector<T, 8> VectorImpl;
|
||||
VectorImpl vector;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoValueVector : public AutoVectorRooter<Value>
|
||||
{
|
||||
public:
|
||||
explicit AutoValueVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<const Shape *>(cx)
|
||||
: AutoVectorRooter<Value>(cx, VALVECTOR)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
const jsval *jsval_begin() const { return begin(); }
|
||||
jsval *jsval_begin() { return begin(); }
|
||||
|
||||
const jsval *jsval_end() const { return end(); }
|
||||
jsval *jsval_end() { return end(); }
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoObjectVector : public AutoVectorRooter<JSObject *>
|
||||
{
|
||||
public:
|
||||
explicit AutoObjectVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<JSObject *>(cx, OBJVECTOR)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void trace(JSTracer *trc);
|
||||
class AutoIdVector : public AutoVectorRooter<jsid>
|
||||
{
|
||||
public:
|
||||
explicit AutoIdVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<jsid>(cx, IDVECTOR)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoShapeVector : public AutoVectorRooter<const Shape *>
|
||||
{
|
||||
public:
|
||||
explicit AutoShapeVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<const Shape *>(cx, SHAPEVECTOR)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoValueArray : public AutoGCRooter
|
||||
@ -2010,7 +2379,7 @@ class AutoValueArray : public AutoGCRooter
|
||||
public:
|
||||
AutoValueArray(JSContext *cx, js::Value *start, unsigned length
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), start_(start), length_(length)
|
||||
: AutoGCRooter(cx, VALARRAY), start_(start), length_(length)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
@ -2019,9 +2388,6 @@ class AutoValueArray : public AutoGCRooter
|
||||
unsigned length() const { return length_; }
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
protected:
|
||||
virtual void trace(JSTracer *trc);
|
||||
};
|
||||
|
||||
JSIdArray *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=78:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
@ -102,7 +102,7 @@ GetGSNCache(JSContext *cx)
|
||||
|
||||
class AutoNamespaceArray : protected AutoGCRooter {
|
||||
public:
|
||||
AutoNamespaceArray(JSContext *cx) : AutoGCRooter(cx) {
|
||||
AutoNamespaceArray(JSContext *cx) : AutoGCRooter(cx, NAMESPACES) {
|
||||
array.init();
|
||||
}
|
||||
|
||||
@ -112,10 +112,9 @@ class AutoNamespaceArray : protected AutoGCRooter {
|
||||
|
||||
uint32 length() const { return array.length; }
|
||||
|
||||
protected:
|
||||
virtual void trace(JSTracer *trc);
|
||||
|
||||
public:
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
JSXMLArray array;
|
||||
};
|
||||
|
||||
|
@ -319,56 +319,3 @@ js::DumpHeapComplete(JSContext *cx, FILE *fp)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
JS_DateIsValid(JSContext *cx, JSObject* obj)
|
||||
{
|
||||
return js_DateIsValid(cx, obj);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(jsdouble)
|
||||
JS_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return js_DateGetMsecSinceEpoch(cx, obj);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
JS_WasLastGCCompartmental(JSContext *cx)
|
||||
{
|
||||
return cx->runtime->wasCompartmentGC;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSVersion)
|
||||
JS_VersionSetXML(JSVersion version, JSBool enable)
|
||||
{
|
||||
js::VersionSetXML(&version, enable);
|
||||
return version;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
JS_IsContextRunningJS(JSContext *cx)
|
||||
{
|
||||
return !cx->stack.empty();
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
AutoSkipConservativeScan::AutoSkipConservativeScan(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
|
||||
: context(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
||||
js::ThreadData &threadData = context->thread()->data;
|
||||
JS_ASSERT(threadData.requestDepth >= 1);
|
||||
JS_ASSERT(!threadData.conservativeGC.requestThreshold);
|
||||
if(threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 1;
|
||||
}
|
||||
|
||||
AutoSkipConservativeScan::~AutoSkipConservativeScan()
|
||||
{
|
||||
js::ThreadData &threadData = context->thread()->data;
|
||||
if(threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -44,11 +44,6 @@
|
||||
#include "jspubtd.h"
|
||||
#include "jsprvtd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "jsatom.h"
|
||||
#include "js/Vector.h"
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
@ -137,9 +132,6 @@ JS_CloneObject(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent);
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js_ReportOverRecursed(JSContext *maybecx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
@ -205,8 +197,6 @@ JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp)
|
||||
extern JS_FRIEND_API(bool)
|
||||
CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname);
|
||||
|
||||
typedef js::Vector<JSCompartment *, 0, js::SystemAllocPolicy> CompartmentVector;
|
||||
|
||||
/*
|
||||
* Shadow declarations of JS internal structures, for access by inline access
|
||||
* functions below. Do not use these structures in any other way. When adding
|
||||
@ -241,34 +231,6 @@ struct Object {
|
||||
}
|
||||
};
|
||||
|
||||
struct Context {
|
||||
JS::AutoGCRooter *autoGCRooters;
|
||||
void *data;
|
||||
void *data2;
|
||||
#ifdef JS_THREADSAFE
|
||||
JSThread *thread_;
|
||||
#endif
|
||||
JSCompartment *compartment;
|
||||
JSObject *globalObject;
|
||||
JSRuntime *runtime;
|
||||
jsuword stackLimit;
|
||||
#ifdef JS_THREADSAFE
|
||||
unsigned outstandingRequests;
|
||||
#endif
|
||||
JSDebugHooks *debugHooks;
|
||||
};
|
||||
|
||||
struct Thread {
|
||||
void *id;
|
||||
};
|
||||
|
||||
struct Runtime {
|
||||
JSAtomState atomState;
|
||||
JSCompartment *atomsCompartment;
|
||||
js::CompartmentVector compartments;
|
||||
JSStructuredCloneCallbacks *structuredCloneCallbacks;
|
||||
};
|
||||
|
||||
} /* namespace shadow */
|
||||
|
||||
extern JS_FRIEND_DATA(js::Class) AnyNameClass;
|
||||
@ -399,312 +361,7 @@ StringIsArrayIndex(JSLinearString *str, jsuint *indexp);
|
||||
/* When defining functions, JSFunctionSpec::call points to a JSNativeTraceInfo. */
|
||||
#define JSFUN_TRCINFO 0x2000
|
||||
|
||||
static inline void *
|
||||
GetContextPrivate(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->data;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
GetContextPrivate2(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->data2;
|
||||
}
|
||||
|
||||
static inline void
|
||||
SetContextPrivate2(JSContext *cx, void *data)
|
||||
{
|
||||
reinterpret_cast<js::shadow::Context *>(cx)->data2 = data;
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
static inline JSThread *
|
||||
GetContextThread(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->thread_;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
GetContextThreadId(JSContext *cx)
|
||||
{
|
||||
JSThread *th = GetContextThread(cx);
|
||||
return reinterpret_cast<js::shadow::Thread *>(th)->id;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline JSCompartment *
|
||||
GetContextCompartment(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->compartment;
|
||||
}
|
||||
|
||||
static inline JSObject *
|
||||
GetContextGlobalObject(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->globalObject;
|
||||
}
|
||||
|
||||
static inline void
|
||||
SetContextGlobalObject(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
reinterpret_cast<js::shadow::Context *>(cx)->globalObject = obj;
|
||||
}
|
||||
|
||||
static inline JSRuntime *
|
||||
GetContextRuntime(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->runtime;
|
||||
}
|
||||
|
||||
static inline jsuword
|
||||
GetContextStackLimit(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->stackLimit;
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
static inline unsigned
|
||||
GetContextOutstandingRequests(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->outstandingRequests;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline JSDebugHooks *
|
||||
GetContextDebugHooks(JSContext *cx)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Context *>(cx)->debugHooks;
|
||||
}
|
||||
|
||||
static inline JSString *
|
||||
GetEmptyAtom(JSContext *cx)
|
||||
{
|
||||
JSRuntime *rt = js::GetContextRuntime(cx);
|
||||
return (JSString *)reinterpret_cast<js::shadow::Runtime *>(rt)->atomState.emptyAtom;
|
||||
}
|
||||
|
||||
static inline CompartmentVector &
|
||||
GetRuntimeCompartments(JSRuntime *rt)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Runtime *>(rt)->compartments;
|
||||
}
|
||||
|
||||
static inline JSStructuredCloneCallbacks *
|
||||
GetRuntimeStructuredCloneCallbacks(JSRuntime *rt)
|
||||
{
|
||||
return reinterpret_cast<js::shadow::Runtime *>(rt)->structuredCloneCallbacks;
|
||||
}
|
||||
|
||||
#define JS_CHECK_RECURSION(cx, onerror) \
|
||||
JS_BEGIN_MACRO \
|
||||
int stackDummy_; \
|
||||
\
|
||||
if (!JS_CHECK_STACK_SIZE(js::GetContextStackLimit(cx), &stackDummy_)) { \
|
||||
js_ReportOverRecursed(cx); \
|
||||
onerror; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(Value *vec, size_t len)
|
||||
{
|
||||
JS_ASSERT(vec <= vec + len);
|
||||
PodZero(vec, len);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(Value *beg, Value *end)
|
||||
{
|
||||
JS_ASSERT(beg <= end);
|
||||
PodZero(beg, end - beg);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(jsid *beg, jsid *end)
|
||||
{
|
||||
JS_ASSERT(beg <= end);
|
||||
for (jsid *id = beg; id < end; ++id)
|
||||
*id = INT_TO_JSID(0);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void
|
||||
MakeRangeGCSafe(jsid *vec, size_t len)
|
||||
{
|
||||
MakeRangeGCSafe(vec, vec + len);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class AutoVectorRooter : protected AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoVectorRooter(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx), vector(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
size_t length() const { return vector.length(); }
|
||||
|
||||
bool append(const T &v) { return vector.append(v); }
|
||||
|
||||
/* For use when space has already been reserved. */
|
||||
void infallibleAppend(const T &v) { vector.infallibleAppend(v); }
|
||||
|
||||
void popBack() { vector.popBack(); }
|
||||
T popCopy() { return vector.popCopy(); }
|
||||
|
||||
bool growBy(size_t inc) {
|
||||
size_t oldLength = vector.length();
|
||||
if (!vector.growByUninitialized(inc))
|
||||
return false;
|
||||
MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool resize(size_t newLength) {
|
||||
size_t oldLength = vector.length();
|
||||
if (newLength <= oldLength) {
|
||||
vector.shrinkBy(oldLength - newLength);
|
||||
return true;
|
||||
}
|
||||
if (!vector.growByUninitialized(newLength - oldLength))
|
||||
return false;
|
||||
MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
void clear() { vector.clear(); }
|
||||
|
||||
bool reserve(size_t newLength) {
|
||||
return vector.reserve(newLength);
|
||||
}
|
||||
|
||||
T &operator[](size_t i) { return vector[i]; }
|
||||
const T &operator[](size_t i) const { return vector[i]; }
|
||||
|
||||
const T *begin() const { return vector.begin(); }
|
||||
T *begin() { return vector.begin(); }
|
||||
|
||||
const T *end() const { return vector.end(); }
|
||||
T *end() { return vector.end(); }
|
||||
|
||||
const T &back() const { return vector.back(); }
|
||||
|
||||
protected:
|
||||
typedef Vector<T, 8> VectorImpl;
|
||||
VectorImpl vector;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoValueVector : public AutoVectorRooter<Value>
|
||||
{
|
||||
public:
|
||||
explicit AutoValueVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<Value>(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
const jsval *jsval_begin() const { return begin(); }
|
||||
jsval *jsval_begin() { return begin(); }
|
||||
|
||||
const jsval *jsval_end() const { return end(); }
|
||||
jsval *jsval_end() { return end(); }
|
||||
|
||||
protected:
|
||||
virtual JS_FRIEND_API(void) trace(JSTracer *trc);
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoObjectVector : public AutoVectorRooter<JSObject *>
|
||||
{
|
||||
public:
|
||||
explicit AutoObjectVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<JSObject *>(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual JS_FRIEND_API(void) trace(JSTracer *trc);
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdVector : public AutoVectorRooter<jsid>
|
||||
{
|
||||
public:
|
||||
explicit AutoIdVector(JSContext *cx
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<jsid>(cx)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual JS_FRIEND_API(void) trace(JSTracer *trc);
|
||||
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
class JS_FRIEND_API(AutoSkipConservativeScan)
|
||||
{
|
||||
public:
|
||||
AutoSkipConservativeScan(JSContext *cx JS_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
~AutoSkipConservativeScan();
|
||||
|
||||
private:
|
||||
JSContext *context;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
#endif
|
||||
|
||||
extern JS_FORCES_STACK JS_FRIEND_API(void)
|
||||
LeaveTrace(JSContext *cx);
|
||||
|
||||
} /* namespace js */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Report an exception, which is currently realized as a printf-style format
|
||||
* string and its arguments.
|
||||
*/
|
||||
typedef enum JSErrNum {
|
||||
#define MSG_DEF(name, number, count, exception, format) \
|
||||
name = number,
|
||||
#include "js.msg"
|
||||
#undef MSG_DEF
|
||||
JSErr_Limit
|
||||
} JSErrNum;
|
||||
|
||||
extern JS_FRIEND_API(const JSErrorFormatString *)
|
||||
js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);
|
||||
|
||||
/*
|
||||
* Detect whether the internal date value is NaN. (Because failure is
|
||||
* out-of-band for js_DateGet*)
|
||||
*/
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
JS_DateIsValid(JSContext *cx, JSObject* obj);
|
||||
|
||||
extern JS_FRIEND_API(jsdouble)
|
||||
JS_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
JS_WasLastGCCompartmental(JSContext *cx);
|
||||
|
||||
extern JS_FRIEND_API(JSUint64)
|
||||
JS_GetSCOffset(JSStructuredCloneWriter* writer);
|
||||
|
||||
extern JS_FRIEND_API(JSVersion)
|
||||
JS_VersionSetXML(JSVersion version, JSBool enable);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
JS_IsContextRunningJS(JSContext *cx);
|
||||
|
||||
#endif /* jsfriendapi_h___ */
|
||||
|
210
js/src/jsgc.cpp
210
js/src/jsgc.cpp
@ -1791,6 +1791,7 @@ js_TraceStackFrame(JSTracer *trc, StackFrame *fp)
|
||||
void
|
||||
AutoIdArray::trace(JSTracer *trc)
|
||||
{
|
||||
JS_ASSERT(tag == IDARRAY);
|
||||
gc::MarkIdRange(trc, idArray->length, idArray->vector, "JSAutoIdArray.idArray");
|
||||
}
|
||||
|
||||
@ -1800,112 +1801,112 @@ AutoEnumStateRooter::trace(JSTracer *trc)
|
||||
gc::MarkObject(trc, *obj, "js::AutoEnumStateRooter.obj");
|
||||
}
|
||||
|
||||
void
|
||||
AutoValueRooter::trace(JSTracer *trc)
|
||||
inline void
|
||||
AutoGCRooter::trace(JSTracer *trc)
|
||||
{
|
||||
MarkValue(trc, val, "js::AutoValueRooter.val");
|
||||
}
|
||||
switch (tag) {
|
||||
case JSVAL:
|
||||
MarkValue(trc, static_cast<AutoValueRooter *>(this)->val, "js::AutoValueRooter.val");
|
||||
return;
|
||||
|
||||
void
|
||||
AutoPropDescArrayRooter::trace(JSTracer *trc)
|
||||
{
|
||||
for (size_t i = 0, len = descriptors.length(); i < len; i++) {
|
||||
PropDesc &desc = descriptors[i];
|
||||
MarkValue(trc, desc.pd, "PropDesc::pd");
|
||||
MarkValue(trc, desc.value, "PropDesc::value");
|
||||
MarkValue(trc, desc.get, "PropDesc::get");
|
||||
MarkValue(trc, desc.set, "PropDesc::set");
|
||||
case PARSER:
|
||||
static_cast<Parser *>(this)->trace(trc);
|
||||
return;
|
||||
|
||||
case ENUMERATOR:
|
||||
static_cast<AutoEnumStateRooter *>(this)->trace(trc);
|
||||
return;
|
||||
|
||||
case IDARRAY: {
|
||||
JSIdArray *ida = static_cast<AutoIdArray *>(this)->idArray;
|
||||
MarkIdRange(trc, ida->length, ida->vector, "js::AutoIdArray.idArray");
|
||||
return;
|
||||
}
|
||||
|
||||
case DESCRIPTORS: {
|
||||
PropDescArray &descriptors =
|
||||
static_cast<AutoPropDescArrayRooter *>(this)->descriptors;
|
||||
for (size_t i = 0, len = descriptors.length(); i < len; i++) {
|
||||
PropDesc &desc = descriptors[i];
|
||||
MarkValue(trc, desc.pd, "PropDesc::pd");
|
||||
MarkValue(trc, desc.value, "PropDesc::value");
|
||||
MarkValue(trc, desc.get, "PropDesc::get");
|
||||
MarkValue(trc, desc.set, "PropDesc::set");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case DESCRIPTOR : {
|
||||
PropertyDescriptor &desc = *static_cast<AutoPropertyDescriptorRooter *>(this);
|
||||
if (desc.obj)
|
||||
MarkObject(trc, *desc.obj, "Descriptor::obj");
|
||||
MarkValue(trc, desc.value, "Descriptor::value");
|
||||
if ((desc.attrs & JSPROP_GETTER) && desc.getter)
|
||||
MarkObject(trc, *CastAsObject(desc.getter), "Descriptor::get");
|
||||
if (desc.attrs & JSPROP_SETTER && desc.setter)
|
||||
MarkObject(trc, *CastAsObject(desc.setter), "Descriptor::set");
|
||||
return;
|
||||
}
|
||||
|
||||
case NAMESPACES: {
|
||||
JSXMLArray &array = static_cast<AutoNamespaceArray *>(this)->array;
|
||||
MarkObjectRange(trc, array.length, reinterpret_cast<JSObject **>(array.vector),
|
||||
"JSXMLArray.vector");
|
||||
array.cursors->trace(trc);
|
||||
return;
|
||||
}
|
||||
|
||||
case XML:
|
||||
js_TraceXML(trc, static_cast<AutoXMLRooter *>(this)->xml);
|
||||
return;
|
||||
|
||||
case OBJECT:
|
||||
if (JSObject *obj = static_cast<AutoObjectRooter *>(this)->obj)
|
||||
MarkObject(trc, *obj, "js::AutoObjectRooter.obj");
|
||||
return;
|
||||
|
||||
case ID:
|
||||
MarkId(trc, static_cast<AutoIdRooter *>(this)->id_, "js::AutoIdRooter.val");
|
||||
return;
|
||||
|
||||
case VALVECTOR: {
|
||||
AutoValueVector::VectorImpl &vector = static_cast<AutoValueVector *>(this)->vector;
|
||||
MarkValueRange(trc, vector.length(), vector.begin(), "js::AutoValueVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case STRING:
|
||||
if (JSString *str = static_cast<AutoStringRooter *>(this)->str)
|
||||
MarkString(trc, str, "js::AutoStringRooter.str");
|
||||
return;
|
||||
|
||||
case IDVECTOR: {
|
||||
AutoIdVector::VectorImpl &vector = static_cast<AutoIdVector *>(this)->vector;
|
||||
MarkIdRange(trc, vector.length(), vector.begin(), "js::AutoIdVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case SHAPEVECTOR: {
|
||||
AutoShapeVector::VectorImpl &vector = static_cast<js::AutoShapeVector *>(this)->vector;
|
||||
MarkShapeRange(trc, vector.length(), vector.begin(), "js::AutoShapeVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case OBJVECTOR: {
|
||||
AutoObjectVector::VectorImpl &vector = static_cast<AutoObjectVector *>(this)->vector;
|
||||
MarkObjectRange(trc, vector.length(), vector.begin(), "js::AutoObjectVector.vector");
|
||||
return;
|
||||
}
|
||||
|
||||
case VALARRAY: {
|
||||
AutoValueArray *array = static_cast<AutoValueArray *>(this);
|
||||
MarkValueRange(trc, array->length(), array->start(), "js::AutoValueArray");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AutoPropertyDescriptorRooter::trace(JSTracer *trc)
|
||||
{
|
||||
if (obj)
|
||||
MarkObject(trc, *obj, "Descriptor::obj");
|
||||
MarkValue(trc, value, "Descriptor::value");
|
||||
if ((attrs & JSPROP_GETTER) && getter)
|
||||
MarkObject(trc, *CastAsObject(getter), "Descriptor::get");
|
||||
if (attrs & JSPROP_SETTER && setter)
|
||||
MarkObject(trc, *CastAsObject(setter), "Descriptor::set");
|
||||
}
|
||||
|
||||
void
|
||||
AutoNamespaceArray::trace(JSTracer *trc)
|
||||
{
|
||||
MarkObjectRange(trc, array.length, reinterpret_cast<JSObject **>(array.vector),
|
||||
"JSXMLArray.vector");
|
||||
array.cursors->trace(trc);
|
||||
}
|
||||
|
||||
void
|
||||
AutoXMLRooter::trace(JSTracer *trc)
|
||||
{
|
||||
js_TraceXML(trc, xml);
|
||||
}
|
||||
|
||||
void
|
||||
AutoObjectRooter::trace(JSTracer *trc)
|
||||
{
|
||||
if (obj)
|
||||
MarkObject(trc, *obj, "js::AutoObjectRooter.obj");
|
||||
}
|
||||
|
||||
void
|
||||
AutoIdRooter::trace(JSTracer *trc)
|
||||
{
|
||||
MarkId(trc, id_, "js::AutoIdRooter.val");
|
||||
}
|
||||
|
||||
void
|
||||
AutoValueVector::trace(JSTracer *trc)
|
||||
{
|
||||
MarkValueRange(trc, vector.length(), vector.begin(), "js::AutoValueVector.vector");
|
||||
}
|
||||
|
||||
void
|
||||
AutoStringRooter::trace(JSTracer *trc)
|
||||
{
|
||||
if (str)
|
||||
MarkString(trc, str, "js::AutoStringRooter.str");
|
||||
}
|
||||
|
||||
void
|
||||
AutoIdVector::trace(JSTracer *trc)
|
||||
{
|
||||
MarkIdRange(trc, vector.length(), vector.begin(), "js::AutoIdVector.vector");
|
||||
}
|
||||
|
||||
void
|
||||
AutoShapeVector::trace(JSTracer *trc)
|
||||
{
|
||||
MarkShapeRange(trc, vector.length(), vector.begin(), "js::AutoShapeVector.vector");
|
||||
}
|
||||
|
||||
void
|
||||
AutoObjectVector::trace(JSTracer *trc)
|
||||
{
|
||||
MarkObjectRange(trc, vector.length(), vector.begin(), "js::AutoObjectVector.vector");
|
||||
}
|
||||
|
||||
void
|
||||
AutoValueArray::trace(JSTracer *trc)
|
||||
{
|
||||
MarkValueRange(trc, length(), start(), "js::AutoValueArray");
|
||||
}
|
||||
|
||||
void
|
||||
AutoArrayRooter::trace(JSTracer *trc)
|
||||
{
|
||||
MarkValueRange(trc, length, array, "js::AutoArrayRooter.array");
|
||||
}
|
||||
|
||||
void
|
||||
AutoGCRooter::traceAll(JSTracer *trc)
|
||||
{
|
||||
trace(trc);
|
||||
if (down)
|
||||
down->traceAll(trc);
|
||||
JS_ASSERT(tag >= 0);
|
||||
MarkValueRange(trc, tag, static_cast<AutoArrayRooter *>(this)->array, "js::AutoArrayRooter.array");
|
||||
}
|
||||
|
||||
namespace js {
|
||||
@ -1921,8 +1922,8 @@ MarkContext(JSTracer *trc, JSContext *acx)
|
||||
if (acx->isExceptionPending())
|
||||
MarkValue(trc, acx->getPendingException(), "exception");
|
||||
|
||||
if (acx->autoGCRooters)
|
||||
acx->autoGCRooters->traceAll(trc);
|
||||
for (js::AutoGCRooter *gcr = acx->autoGCRooters; gcr; gcr = gcr->down)
|
||||
gcr->trace(trc);
|
||||
|
||||
if (acx->sharpObjectMap.depth > 0)
|
||||
js_TraceSharpMap(trc, &acx->sharpObjectMap);
|
||||
@ -2777,7 +2778,6 @@ GCCycle(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind)
|
||||
|
||||
JS_ASSERT(!rt->gcCurrentCompartment);
|
||||
rt->gcCurrentCompartment = comp;
|
||||
rt->wasCompartmentGC = !!comp;
|
||||
|
||||
rt->gcMarkAndSweep = true;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
@ -1324,7 +1324,7 @@ class AutoPropDescArrayRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
AutoPropDescArrayRooter(JSContext *cx)
|
||||
: AutoGCRooter(cx), descriptors(cx)
|
||||
: AutoGCRooter(cx, DESCRIPTORS), descriptors(cx)
|
||||
{ }
|
||||
|
||||
PropDesc *append() {
|
||||
@ -1338,16 +1338,16 @@ class AutoPropDescArrayRooter : private AutoGCRooter
|
||||
return descriptors[i];
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void trace(JSTracer *trc);
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
PropDescArray descriptors;
|
||||
};
|
||||
|
||||
class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescriptor
|
||||
{
|
||||
public:
|
||||
AutoPropertyDescriptorRooter(JSContext *cx) : AutoGCRooter(cx) {
|
||||
AutoPropertyDescriptorRooter(JSContext *cx) : AutoGCRooter(cx, DESCRIPTOR) {
|
||||
obj = NULL;
|
||||
attrs = 0;
|
||||
getter = (PropertyOp) NULL;
|
||||
@ -1356,7 +1356,7 @@ class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescri
|
||||
}
|
||||
|
||||
AutoPropertyDescriptorRooter(JSContext *cx, PropertyDescriptor *desc)
|
||||
: AutoGCRooter(cx)
|
||||
: AutoGCRooter(cx, DESCRIPTOR)
|
||||
{
|
||||
obj = desc->obj;
|
||||
attrs = desc->attrs;
|
||||
@ -1365,8 +1365,7 @@ class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescri
|
||||
value = desc->value;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void trace(JSTracer *trc);
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
};
|
||||
|
||||
static inline bool
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define jsproxy_h___
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
namespace js {
|
||||
|
@ -47,8 +47,6 @@
|
||||
|
||||
namespace js {
|
||||
|
||||
class DummyFrameGuard;
|
||||
|
||||
/* No-op wrapper handler base class. */
|
||||
class JS_FRIEND_API(Wrapper) : public ProxyHandler
|
||||
{
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsScriptLoader.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsprf.h"
|
||||
@ -544,9 +545,12 @@ DumpXPC(JSContext *cx, uintN argc, jsval *vp)
|
||||
static JSBool
|
||||
GC(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
|
||||
rt = cx->runtime;
|
||||
JS_GC(cx);
|
||||
#ifdef JS_GCMETER
|
||||
js_DumpGCStats(JS_GetRuntime(cx), stdout);
|
||||
js_DumpGCStats(rt, stdout);
|
||||
#endif
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
@ -1001,9 +1005,9 @@ static const JSErrorFormatString *
|
||||
my_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber)
|
||||
{
|
||||
if ((errorNumber > 0) && (errorNumber < JSShellErr_Limit))
|
||||
return &jsShell_ErrorFormatString[errorNumber];
|
||||
JS_NOT_REACHED("invalid error number");
|
||||
return NULL;
|
||||
return &jsShell_ErrorFormatString[errorNumber];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -59,15 +59,15 @@ XPCContext::XPCContext(XPCJSRuntime* aRuntime,
|
||||
|
||||
PR_INIT_CLIST(&mScopes);
|
||||
|
||||
NS_ASSERTION(!js::GetContextPrivate2(mJSContext), "Must be null");
|
||||
js::SetContextPrivate2(mJSContext, this);
|
||||
NS_ASSERTION(!mJSContext->data2, "Must be null");
|
||||
mJSContext->data2 = this;
|
||||
}
|
||||
|
||||
XPCContext::~XPCContext()
|
||||
{
|
||||
MOZ_COUNT_DTOR(XPCContext);
|
||||
NS_ASSERTION(js::GetContextPrivate2(mJSContext) == this, "Must match this");
|
||||
js::SetContextPrivate2(mJSContext, nsnull);
|
||||
NS_ASSERTION(mJSContext->data2 == this, "Must match this");
|
||||
mJSContext->data2 = nsnull;
|
||||
NS_IF_RELEASE(mException);
|
||||
NS_IF_RELEASE(mSecurityManager);
|
||||
|
||||
|
@ -253,7 +253,7 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
|
||||
// Allow wrong compartment or unset ScopeForNewObject when the caller knows
|
||||
// the value is primitive (viz., XPCNativeMember::GetConstantValue).
|
||||
NS_ABORT_IF_FALSE(type.IsArithmetic() ||
|
||||
js::GetContextCompartment(cx) == js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()),
|
||||
cx->compartment == js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()),
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
if (pErr)
|
||||
@ -1061,8 +1061,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
|
||||
// optimal -- we could detect this and roll the functionality into a
|
||||
// single wrapper, but the current solution is good enough for now.
|
||||
JSContext* cx = lccx.GetJSContext();
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) ==
|
||||
js::GetContextCompartment(cx),
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) == cx->compartment,
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
JSObject *jsscope = lccx.GetScopeForNewJSObjects();
|
||||
@ -1108,7 +1107,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
|
||||
if (!flat) {
|
||||
tryConstructSlimWrapper = true;
|
||||
} else if (IS_SLIM_WRAPPER_OBJECT(flat)) {
|
||||
if (js::GetObjectCompartment(flat) == js::GetContextCompartment(cx)) {
|
||||
if (js::GetObjectCompartment(flat) == cx->compartment) {
|
||||
*d = OBJECT_TO_JSVAL(flat);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -1258,7 +1257,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
|
||||
|
||||
flat = locationWrapper;
|
||||
} else if (wrapper->NeedsSOW() &&
|
||||
!xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
|
||||
!xpc::AccessCheck::isChrome(cx->compartment)) {
|
||||
JSObject *sowWrapper = wrapper->GetWrapper();
|
||||
if (!sowWrapper) {
|
||||
sowWrapper = xpc::WrapperFactory::WrapSOWObject(cx, flat);
|
||||
@ -1274,7 +1273,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
|
||||
} else {
|
||||
flat = JS_ObjectToOuterObject(cx, flat);
|
||||
NS_ASSERTION(flat, "bad outer object hook!");
|
||||
NS_ASSERTION(js::GetObjectCompartment(flat) == js::GetContextCompartment(cx),
|
||||
NS_ASSERTION(js::GetObjectCompartment(flat) == cx->compartment,
|
||||
"bad compartment");
|
||||
}
|
||||
}
|
||||
@ -1705,8 +1704,7 @@ XPCConvert::NativeArray2JS(XPCLazyCallContext& lccx,
|
||||
return JS_FALSE;
|
||||
|
||||
JSContext* cx = ccx.GetJSContext();
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) ==
|
||||
js::GetContextCompartment(cx),
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) == cx->compartment,
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
// XXX add support for putting chars in a string rather than an array
|
||||
|
@ -164,8 +164,7 @@ inline void
|
||||
XPCCallContext::SetScopeForNewJSObjects(JSObject *scope)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mState == HAVE_CONTEXT, "wrong call context state");
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(scope) == js::GetContextCompartment(mJSContext),
|
||||
"wrong compartment");
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(scope) == mJSContext->compartment, "wrong compartment");
|
||||
mScopeForNewJSObjects = scope;
|
||||
mState = HAVE_SCOPE;
|
||||
}
|
||||
|
@ -87,8 +87,10 @@ XPCStringConvert::ReadableToJSVal(JSContext *cx,
|
||||
|
||||
PRUint32 length = readable.Length();
|
||||
|
||||
if (length == 0)
|
||||
return STRING_TO_JSVAL(js::GetEmptyAtom(cx));
|
||||
JSAtom *atom;
|
||||
if (length == 0 && (atom = cx->runtime->atomState.emptyAtom)) {
|
||||
return STRING_TO_JSVAL(atom);
|
||||
}
|
||||
|
||||
nsStringBuffer *buf = nsStringBuffer::FromString(readable);
|
||||
if (buf) {
|
||||
|
@ -135,7 +135,7 @@ GetPrincipalFromCx(JSContext *cx)
|
||||
NS_IMETHODIMP
|
||||
XPCJSContextStack::Push(JSContext * cx)
|
||||
{
|
||||
JS_ASSERT_IF(cx, js::GetContextThread(cx));
|
||||
JS_ASSERT_IF(cx, JS_GetContextThread(cx));
|
||||
if (mStack.Length() > 0) {
|
||||
XPCJSContextInfo & e = mStack[mStack.Length() - 1];
|
||||
if (e.cx) {
|
||||
@ -439,7 +439,7 @@ XPCPerThreadData::GetDataImpl(JSContext *cx)
|
||||
}
|
||||
|
||||
if (cx && !sMainJSThread && NS_IsMainThread()) {
|
||||
sMainJSThread = js::GetContextThread(cx);
|
||||
sMainJSThread = cx->thread();
|
||||
|
||||
sMainThreadData = data;
|
||||
|
||||
|
@ -467,8 +467,7 @@ XPCVariant::VariantDataToJS(XPCLazyCallContext& lccx,
|
||||
JSBool success;
|
||||
|
||||
JSContext* cx = lccx.GetJSContext();
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) ==
|
||||
js::GetContextCompartment(cx),
|
||||
NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) == cx->compartment,
|
||||
"bad scope for new JSObjects");
|
||||
|
||||
switch (type) {
|
||||
|
@ -62,7 +62,7 @@ bool AutoScriptEvaluate::StartEvaluating(JSObject *scope, JSErrorReporter errorR
|
||||
return true;
|
||||
|
||||
mEvaluated = true;
|
||||
if (!JS_GetErrorReporter(mJSContext)) {
|
||||
if (!mJSContext->errorReporter) {
|
||||
JS_SetErrorReporter(mJSContext, errorReporter);
|
||||
mErrorReporterSet = true;
|
||||
}
|
||||
@ -553,7 +553,7 @@ GetContextFromObject(JSObject *obj)
|
||||
|
||||
if (xpcc) {
|
||||
JSContext *cx = xpcc->GetJSContext();
|
||||
if (js::GetContextThreadId(cx) == js_CurrentThreadId())
|
||||
if (cx->thread()->id == js_CurrentThreadId())
|
||||
return cx;
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||
// Try to use the error reporter set on the context to handle this
|
||||
// error if it came from a JS exception.
|
||||
if (reportable && is_js_exception &&
|
||||
JS_GetErrorReporter(cx) != xpcWrappedJSErrorReporter) {
|
||||
cx->errorReporter != xpcWrappedJSErrorReporter) {
|
||||
reportable = !JS_ReportPendingException(cx);
|
||||
}
|
||||
|
||||
|
@ -3671,7 +3671,7 @@ ConstructSlimWrapper(XPCCallContext &ccx,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (js::GetContextCompartment(ccx.GetJSContext()) != js::GetObjectCompartment(parent)) {
|
||||
if (ccx.GetJSContext()->compartment != js::GetObjectCompartment(parent)) {
|
||||
SLIM_LOG_NOT_CREATED(ccx, identityObj, "wrong compartment");
|
||||
|
||||
return JS_FALSE;
|
||||
|
@ -401,8 +401,14 @@ nsXPConnect::Collect()
|
||||
// cycle collection. So to compensate for JS_BeginRequest in
|
||||
// XPCCallContext::Init we disable the conservative scanner if that call
|
||||
// has started the request on this thread.
|
||||
js::AutoSkipConservativeScan ascs(cx);
|
||||
js::ThreadData &threadData = cx->thread()->data;
|
||||
JS_ASSERT(threadData.requestDepth >= 1);
|
||||
JS_ASSERT(!threadData.conservativeGC.requestThreshold);
|
||||
if (threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 1;
|
||||
JS_GC(cx);
|
||||
if (threadData.requestDepth == 1)
|
||||
threadData.conservativeGC.requestThreshold = 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -604,7 +610,7 @@ static void
|
||||
UnmarkGrayChildren(JSTracer *trc, void *thing, JSGCTraceKind kind)
|
||||
{
|
||||
int stackDummy;
|
||||
if (!JS_CHECK_STACK_SIZE(js::GetContextStackLimit(trc->context), &stackDummy)) {
|
||||
if (!JS_CHECK_STACK_SIZE(trc->context->stackLimit, &stackDummy)) {
|
||||
/*
|
||||
* If we run out of stack, we take a more drastic measure: require that
|
||||
* we GC again before the next CC.
|
||||
@ -871,7 +877,7 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
|
||||
unsigned
|
||||
nsXPConnect::GetOutstandingRequests(JSContext* cx)
|
||||
{
|
||||
unsigned n = js::GetContextOutstandingRequests(cx);
|
||||
unsigned n = cx->outstandingRequests;
|
||||
XPCCallContext* context = mCycleCollectionContext;
|
||||
// Ignore the contribution from the XPCCallContext we created for cycle
|
||||
// collection.
|
||||
@ -892,8 +898,8 @@ public:
|
||||
NS_IMETHOD Unlink(void *n)
|
||||
{
|
||||
JSContext *cx = static_cast<JSContext*>(n);
|
||||
NS_ASSERTION(js::GetContextGlobalObject(cx), "global object NULL before unlinking");
|
||||
js::SetContextGlobalObject(cx, nsnull);
|
||||
NS_ASSERTION(cx->globalObject, "global object NULL before unlinking");
|
||||
cx->globalObject = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD Unroot(void *n)
|
||||
@ -909,10 +915,12 @@ public:
|
||||
// edges will ensure that any cycles this context is in won't be
|
||||
// collected.
|
||||
unsigned refCount = nsXPConnect::GetXPConnect()->GetOutstandingRequests(cx) + 1;
|
||||
cb.DescribeRefCountedNode(refCount, 0, "JSContext");
|
||||
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(JSContext, refCount)
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]");
|
||||
if (JSObject *global = js::GetContextGlobalObject(cx))
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, global);
|
||||
if (cx->globalObject) {
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
cx->globalObject);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2520,7 +2528,7 @@ nsXPConnect::CheckForDebugMode(JSRuntime *rt) {
|
||||
} adc(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
js::CompartmentVector &vector = js::GetRuntimeCompartments(rt);
|
||||
js::CompartmentVector &vector = rt->compartments;
|
||||
for (JSCompartment **p = vector.begin(); p != vector.end(); ++p) {
|
||||
JSCompartment *comp = *p;
|
||||
if (!JS_GetCompartmentPrincipals(comp)) {
|
||||
@ -2590,7 +2598,7 @@ nsXPConnect::Push(JSContext * cx)
|
||||
bool runningJS = false;
|
||||
for (PRUint32 i = 0; i < stack->Length(); ++i) {
|
||||
JSContext *cx = (*stack)[i].cx;
|
||||
if (cx && JS_IsContextRunningJS(cx)) {
|
||||
if (cx && !cx->stack.empty()) {
|
||||
runningJS = true;
|
||||
break;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "jsdhash.h"
|
||||
#include "jsprf.h"
|
||||
#include "prprf.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsgc.h"
|
||||
@ -854,8 +855,8 @@ class XPCContext
|
||||
public:
|
||||
static XPCContext* GetXPCContext(JSContext* aJSContext)
|
||||
{
|
||||
NS_ASSERTION(js::GetContextPrivate2(aJSContext), "should already have XPCContext");
|
||||
return static_cast<XPCContext *>(js::GetContextPrivate2(aJSContext));
|
||||
NS_ASSERTION(aJSContext->data2, "should already have XPCContext");
|
||||
return static_cast<XPCContext *>(aJSContext->data2);
|
||||
}
|
||||
|
||||
XPCJSRuntime* GetRuntime() const {return mRuntime;}
|
||||
@ -3638,9 +3639,9 @@ public:
|
||||
static inline XPCPerThreadData* GetData(JSContext *cx)
|
||||
{
|
||||
if (cx) {
|
||||
NS_ASSERTION(js::GetContextThread(cx), "Uh, JS context w/o a thread?");
|
||||
NS_ASSERTION(cx->thread(), "Uh, JS context w/o a thread?");
|
||||
|
||||
if(js::GetContextThread(cx) == sMainJSThread)
|
||||
if (cx->thread() == sMainJSThread)
|
||||
return sMainThreadData;
|
||||
} else if (sMainThreadData && sMainThreadData->mThread == PR_GetCurrentThread()) {
|
||||
return sMainThreadData;
|
||||
@ -3743,7 +3744,7 @@ public:
|
||||
{sMainJSThread = nsnull; sMainThreadData = nsnull;}
|
||||
|
||||
static bool IsMainThread(JSContext *cx)
|
||||
{ return js::GetContextThread(cx) == sMainJSThread; }
|
||||
{ return cx->thread() == sMainJSThread; }
|
||||
|
||||
private:
|
||||
XPCPerThreadData();
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsstr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace js;
|
||||
@ -198,7 +197,7 @@ IsFrameId(JSContext *cx, JSObject *obj, jsid id)
|
||||
|
||||
if (JSID_IS_INT(id)) {
|
||||
col->Item(JSID_TO_INT(id), getter_AddRefs(domwin));
|
||||
} else if (JSID_IS_STRING(id)) {
|
||||
} else if (JSID_IS_ATOM(id)) {
|
||||
nsAutoString str(JS_GetInternedStringChars(JSID_TO_STRING(id)));
|
||||
col->NamedItem(str, getter_AddRefs(domwin));
|
||||
} else {
|
||||
@ -305,7 +304,7 @@ AccessCheck::isCrossOriginAccessPermitted(JSContext *cx, JSObject *wrapper, jsid
|
||||
else
|
||||
name = clasp->name;
|
||||
|
||||
if (JSID_IS_STRING(id)) {
|
||||
if (JSID_IS_ATOM(id)) {
|
||||
if (IsPermitted(name, JSID_TO_FLAT_STRING(id), act == Wrapper::SET))
|
||||
return true;
|
||||
}
|
||||
@ -498,7 +497,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
|
||||
// Always permit access to "length" and indexed properties of arrays.
|
||||
if (JS_IsArrayObject(cx, wrappedObject) &&
|
||||
((JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) ||
|
||||
(JSID_IS_STRING(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "length")))) {
|
||||
(JSID_IS_ATOM(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "length")))) {
|
||||
perm = PermitPropertyAccess;
|
||||
return true; // Allow
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
|
||||
NS_ASSERTION(JS_GET_CLASS(cx, obj) != &XrayUtils::HolderClass, "trying to wrap a holder");
|
||||
|
||||
JSCompartment *origin = js::GetObjectCompartment(obj);
|
||||
JSCompartment *target = js::GetContextCompartment(cx);
|
||||
JSCompartment *target = cx->compartment;
|
||||
JSObject *xrayHolder = nsnull;
|
||||
|
||||
Wrapper *wrapper;
|
||||
@ -439,7 +439,7 @@ WrapperFactory::WaiveXrayAndWrap(JSContext *cx, jsval *vp)
|
||||
|
||||
JSObject *obj = js::UnwrapObject(JSVAL_TO_OBJECT(*vp));
|
||||
obj = GetCurrentOuter(cx, obj);
|
||||
if (js::GetObjectCompartment(obj) == js::GetContextCompartment(cx)) {
|
||||
if (js::GetObjectCompartment(obj) == cx->compartment) {
|
||||
*vp = OBJECT_TO_JSVAL(obj);
|
||||
return true;
|
||||
}
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "CrossOriginWrapper.h"
|
||||
#include "WrapperFactory.h"
|
||||
|
||||
#include "jscntxt.h"
|
||||
|
||||
#include "nsINode.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
@ -259,7 +261,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid i
|
||||
|
||||
// There are no native numeric properties, so we can shortcut here. We will not
|
||||
// find the property.
|
||||
if (!JSID_IS_STRING(id)) {
|
||||
if (!JSID_IS_ATOM(id)) {
|
||||
/* Not found */
|
||||
return true;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "sqlite3.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsdate.h"
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsString.h"
|
||||
@ -172,10 +172,10 @@ convertJSValToVariant(
|
||||
if (JSVAL_IS_OBJECT(aValue)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(aValue);
|
||||
// We only support Date instances, all others fail.
|
||||
if (!::JS_DateIsValid(aCtx, obj))
|
||||
if (!::js_DateIsValid(aCtx, obj))
|
||||
return nsnull;
|
||||
|
||||
double msecd = ::JS_DateGetMsecSinceEpoch(aCtx, obj);
|
||||
double msecd = ::js_DateGetMsecSinceEpoch(aCtx, obj);
|
||||
msecd *= 1000.0;
|
||||
PRInt64 msec;
|
||||
LL_D2L(msec, msecd);
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsdate.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
@ -707,7 +708,7 @@ MaybeDefineProperty(JSContext *cx, JSObject *obj, const char *name, PRTime times
|
||||
{
|
||||
if (!timestamp)
|
||||
return;
|
||||
JSObject *date = JS_NewDateObjectMsec(cx, timestamp / PR_USEC_PER_MSEC);
|
||||
JSObject *date = js_NewDateObjectMsec(cx, timestamp/PR_USEC_PER_MSEC);
|
||||
JS_DefineProperty(cx, obj, name, OBJECT_TO_JSVAL(date), NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user