Merge tracemonkey to mozilla-central.

This commit is contained in:
Robert Sayre 2010-04-05 13:17:29 -04:00
commit 5927f9eed6
467 changed files with 12843 additions and 10611 deletions

View File

@ -202,7 +202,8 @@ function compareJSON(aNodeJSON_1, aNodeJSON_2) {
const SKIP_PROPS = ["dateAdded", "lastModified", "id"];
function compareObjects(obj1, obj2) {
do_check_eq(obj1.__count__, obj2.__count__);
function count(o) { var n = 0; for (let p in o) n++; return n; }
do_check_eq(count(obj1), count(obj2));
for (let prop in obj1) {
// Skip everchanging values.
if (SKIP_PROPS.indexOf(prop) != -1)

View File

@ -6997,6 +6997,17 @@ if test -n "$MOZ_TRACEVIS"; then
AC_DEFINE(MOZ_TRACEVIS)
fi
dnl ========================================================
dnl = Use GCTimer
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(gctimer,
[ --enable-gctimer Enable GC timer (default=no)],
MOZ_GCTIMER=1,
MOZ_GCTIMER= )
if test -n "$MOZ_GCTIMER"; then
AC_DEFINE(MOZ_GCTIMER)
fi
dnl ========================================================
dnl = Use Valgrind
dnl ========================================================
@ -8128,9 +8139,6 @@ if test "$BUILD_CTYPES"; then
if test "$OS_ARCH" = "WINCE" -a `echo $OS_TEST | grep -ic arm` = 1; then
# Disable ctypes for arm/wince.
BUILD_CTYPES=
elif test "$_MSC_VER" && test -z $AS; then
# Disable ctypes if we're on MSVC and MASM is unavailable.
AC_MSG_ERROR([No suitable assembler found. An assembler is required to build js-ctypes. You may --disable-ctypes to avoid this. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK.])
else
AC_DEFINE(BUILD_CTYPES)
fi
@ -8721,6 +8729,10 @@ fi
dist=$MOZ_BUILD_ROOT/dist
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
ac_configure_args="$ac_configure_args --enable-threadsafe"
if test "$BUILD_CTYPES"; then
# Build js-ctypes on the platforms we can.
ac_configure_args="$ac_configure_args --enable-ctypes"
fi
if test -z "$MOZ_NATIVE_NSPR"; then
ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
@ -8737,54 +8749,6 @@ fi
AC_OUTPUT_SUBDIRS(js/src)
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
# Build jsctypes on the platforms we can.
if test "$BUILD_CTYPES"; then
# Run the libffi 'configure' script.
ac_configure_args="--disable-shared --enable-static --disable-raw-api"
if test "$MOZ_DEBUG"; then
ac_configure_args="$ac_configure_args --enable-debug"
fi
if test "$DSO_PIC_CFLAGS"; then
ac_configure_args="$ac_configure_args --with-pic"
fi
if test "$CROSS_COMPILE"; then
case "$target" in
*-mingw*)
ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\" CC=\"$CC\""
;;
*)
ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
;;
esac
fi
if test "$_MSC_VER"; then
# Use a wrapper script for cl and ml that looks more like gcc.
# autotools can't quite handle an MSVC build environment yet.
ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
case "${target_cpu}" in
x86_64)
# Need target since MSYS tools into mozilla-build may be 32bit
ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/js/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
;;
*)
ac_configure_args="$ac_configure_args CC=$_topsrcdir/js/ctypes/libffi/msvcc.sh"
;;
esac
fi
if test "$SOLARIS_SUNPRO_CC"; then
# Always use gcc for libffi on Solaris
ac_configure_args="$ac_configure_args CC=gcc"
fi
# Use a separate cache file for libffi, since it does things differently
# from our configure.
old_cache_file=$cache_file
cache_file=js/ctypes/libffi/config.cache
AC_OUTPUT_SUBDIRS(js/ctypes/libffi)
cache_file=$old_cache_file
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
fi
fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
dnl Prevent the regeneration of autoconf.mk forcing rebuilds of the world

View File

@ -5407,7 +5407,7 @@ public:
jsval source;
jsval clone;
jsval temp;
JSAutoIdArray ids;
js::AutoIdArray ids;
jsuint index;
private:
@ -5425,7 +5425,7 @@ private:
}
CloneStackFrame* prevFrame;
JSAutoTempValueRooter tvrVals;
js::AutoArrayRooter tvrVals;
};
class CloneStack
@ -5691,7 +5691,7 @@ nsContentUtils::CreateStructuredClone(JSContext* cx,
}
jsval output = OBJECT_TO_JSVAL(obj);
JSAutoTempValueRooter tvr(cx, output);
js::AutoValueRooter tvr(cx, output);
CloneStack stack(cx);
if (!stack.Push(val, OBJECT_TO_JSVAL(obj),

View File

@ -50,7 +50,7 @@ Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
XPC_QS_ASSERT_CONTEXT_OK(cx);
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -179,14 +179,14 @@ nsIDOMCanvasRenderingContext2D_CreateImageData(JSContext *cx, uintN argc, jsval
// create the fast typed array; it's initialized to 0 by default
JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8_CLAMPED, len);
JSAutoTempValueRooter rd(cx, darray);
js::AutoValueRooter rd(cx, darray);
if (!darray)
return JS_FALSE;
// Do JS_NewObject after CreateTypedArray, so that gc will get
// triggered here if necessary
JSObject *result = JS_NewObject(cx, NULL, NULL, NULL);
JSAutoTempValueRooter rr(cx, result);
js::AutoValueRooter rr(cx, result);
if (!result)
return JS_FALSE;
@ -212,7 +212,7 @@ nsIDOMCanvasRenderingContext2D_GetImageData(JSContext *cx, uintN argc, jsval *vp
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -246,7 +246,7 @@ nsIDOMCanvasRenderingContext2D_GetImageData(JSContext *cx, uintN argc, jsval *vp
// create the fast typed array
JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8_CLAMPED, len);
JSAutoTempValueRooter rd(cx, darray);
js::AutoValueRooter rd(cx, darray);
if (!darray)
return JS_FALSE;
@ -260,7 +260,7 @@ nsIDOMCanvasRenderingContext2D_GetImageData(JSContext *cx, uintN argc, jsval *vp
// Do JS_NewObject after CreateTypedArray, so that gc will get
// triggered here if necessary
JSObject *result = JS_NewObject(cx, NULL, NULL, NULL);
JSAutoTempValueRooter rr(cx, result);
js::AutoValueRooter rr(cx, result);
if (!result)
return JS_FALSE;
@ -286,7 +286,7 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp
nsIDOMCanvasRenderingContext2D *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -308,7 +308,7 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp
JSObject *darray;
// grab width, height, and the dense array from the dataObject
JSAutoTempValueRooter tv(cx);
js::AutoValueRooter tv(cx);
if (!JS_GetProperty(cx, dataObject, "width", tv.addr()) ||
!JS_ValueToECMAInt32(cx, tv.value(), &wi))
@ -329,7 +329,7 @@ nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp
return JS_FALSE;
darray = JSVAL_TO_OBJECT(tv.value());
JSAutoTempValueRooter tsrc_tvr(cx);
js::AutoValueRooter tsrc_tvr(cx);
js::TypedArray *tsrc = NULL;
if (darray->getClass() == &js::TypedArray::fastClasses[js::TypedArray::TYPE_UINT8] ||

View File

@ -68,7 +68,7 @@ nsICanvasRenderingContextWebGL_BufferData(JSContext *cx, uintN argc, jsval *vp)
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -134,7 +134,7 @@ nsICanvasRenderingContextWebGL_BufferSubData(JSContext *cx, uintN argc, jsval *v
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -204,7 +204,7 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -306,7 +306,7 @@ nsICanvasRenderingContextWebGL_TexSubImage2D(JSContext *cx, uintN argc, jsval *v
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -407,7 +407,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv(JSContext *cx, uintN argc, js
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -427,7 +427,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv(JSContext *cx, uintN argc, js
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -477,7 +477,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv(JSContext *cx, uintN argc, js
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -497,7 +497,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv(JSContext *cx, uintN argc, js
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -547,7 +547,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv(JSContext *cx, uintN ar
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -571,7 +571,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv(JSContext *cx, uintN ar
JSObject *arg2 = JSVAL_TO_OBJECT(argv[2]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -618,7 +618,7 @@ helper_nsICanvasRenderingContextWebGL_VertexAttrib_x_fv(JSContext *cx, uintN arg
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -638,7 +638,7 @@ helper_nsICanvasRenderingContextWebGL_VertexAttrib_x_fv(JSContext *cx, uintN arg
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -780,7 +780,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(JSContext *cx, JSObject *o
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -835,7 +835,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(JSContext *cx, JSObject *o
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -890,7 +890,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(JSContext *cx, JSObj
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;

View File

@ -41,6 +41,7 @@
#include "jsapi.h"
#include "jsprvtd.h" // we are using private JS typedefs...
#include "jscntxt.h"
#include "jsobj.h"
#include "jsdbgapi.h"
#include "nscore.h"
@ -1469,7 +1470,7 @@ jsval nsDOMClassInfo::sJava_id = JSVAL_VOID;
jsval nsDOMClassInfo::sPackages_id = JSVAL_VOID;
static const JSClass *sObjectClass = nsnull;
const JSClass *nsDOMClassInfo::sXPCNativeWrapperClass = nsnull;
JSPropertyOp nsDOMClassInfo::sXPCNativeWrapperGetPropertyOp = nsnull;
/**
* Set our JSClass pointer for the Object class

View File

@ -174,17 +174,17 @@ public:
/**
* Get our JSClass pointer for the XPCNativeWrapper class
*/
static const JSClass* GetXPCNativeWrapperClass() {
return sXPCNativeWrapperClass;
static JSPropertyOp GetXPCNativeWrapperGetPropertyOp() {
return sXPCNativeWrapperGetPropertyOp;
}
/**
* Set our JSClass pointer for the XPCNativeWrapper class
*/
static void SetXPCNativeWrapperClass(JSClass* aClass) {
NS_ASSERTION(!sXPCNativeWrapperClass,
"Double set of sXPCNativeWrapperClass");
sXPCNativeWrapperClass = aClass;
static void SetXPCNativeWrapperGetPropertyOp(JSPropertyOp getPropertyOp) {
NS_ASSERTION(!sXPCNativeWrapperGetPropertyOp,
"Double set of sXPCNativeWrapperGetPropertyOp");
sXPCNativeWrapperGetPropertyOp = getPropertyOp;
}
static PRBool ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
@ -194,13 +194,13 @@ public:
nsIScriptContext *scx = GetScriptContextFromJSContext(cx);
NS_PRECONDITION(!scx || !scx->IsContextInitialized() ||
sXPCNativeWrapperClass,
"Must know what the XPCNativeWrapper class is!");
sXPCNativeWrapperGetPropertyOp,
"Must know what the XPCNativeWrapper class GetProperty op is!");
}
#endif
return sXPCNativeWrapperClass &&
::JS_GET_CLASS(cx, obj) == sXPCNativeWrapperClass;
return sXPCNativeWrapperGetPropertyOp &&
::JS_GET_CLASS(cx, obj)->getProperty == sXPCNativeWrapperGetPropertyOp;
}
static void PreserveNodeWrapper(nsIXPConnectWrappedNative *aWrapper);
@ -365,7 +365,7 @@ protected:
static jsval sJava_id;
static jsval sPackages_id;
static const JSClass *sXPCNativeWrapperClass;
static JSPropertyOp sXPCNativeWrapperGetPropertyOp;
};

View File

@ -2108,15 +2108,11 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
return NS_OK;
}
jsval targetVal = JSVAL_VOID;
JSAutoTempValueRooter tvr(mContext, 1, &targetVal);
JSObject* target = nsnull;
nsresult rv = JSObjectFromInterface(aTarget, aScope, &target);
NS_ENSURE_SUCCESS(rv, rv);
targetVal = OBJECT_TO_JSVAL(target);
js::AutoObjectRooter targetVal(mContext, target);
jsval rval = JSVAL_VOID;
// This one's a lot easier than EvaluateString because we don't have to
@ -2140,7 +2136,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
jsval *argv = nsnull;
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<JSAutoTempValueRooter> tvr;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
// Use |target| as the scope for wrapping the arguments, since aScope is
// the safe scope in many cases, which isn't very useful. Wrapping aTarget
@ -2587,8 +2583,10 @@ nsJSContext::InitContext(nsIScriptGlobalObject *aGlobalObject)
// Now check whether we need to grab a pointer to the
// XPCNativeWrapper class
if (!nsDOMClassInfo::GetXPCNativeWrapperClass()) {
nsDOMClassInfo::SetXPCNativeWrapperClass(xpc->GetNativeWrapperClass());
if (!nsDOMClassInfo::GetXPCNativeWrapperGetPropertyOp()) {
JSPropertyOp getProperty;
xpc->GetNativeWrapperGetPropertyOp(&getProperty);
nsDOMClassInfo::SetXPCNativeWrapperGetPropertyOp(getProperty);
}
} else {
// There's already a global object. We are preparing this outer window
@ -2652,7 +2650,7 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg
JSAutoRequest ar(mContext);
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<JSAutoTempValueRooter> tvr;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
nsresult rv;
rv = ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc,
@ -2687,7 +2685,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<JSAutoTempValueRooter> &aRooter)
js::LazilyConstructed<js::AutoArrayRooter> &aRooter)
{
nsresult rv = NS_OK;

View File

@ -49,8 +49,10 @@
class nsIXPConnectJSObjectHolder;
class nsAutoPoolRelease;
class JSAutoTempValueRooter;
namespace js { template <class> class LazilyConstructed; }
namespace js {
class AutoArrayRooter;
template <class> class LazilyConstructed;
}
class nsJSContext : public nsIScriptContext,
public nsIXPCScriptNotify
@ -215,7 +217,7 @@ protected:
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<JSAutoTempValueRooter> &aRooter);
js::LazilyConstructed<js::AutoArrayRooter> &aRooter);
nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv);

View File

@ -1,4 +1,4 @@
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- */
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -504,72 +504,50 @@ DOMWorkerOperationCallback(JSContext* aCx)
nsDOMWorker* worker = (nsDOMWorker*)JS_GetContextPrivate(aCx);
NS_ASSERTION(worker, "This must never be null!");
PRBool wasSuspended = PR_FALSE;
PRBool extraThreadAllowed = PR_FALSE;
jsrefcount suspendDepth = 0;
for (;;) {
// Kill execution if we're canceled.
if (worker->IsCanceled()) {
LOG(("Forcefully killing JS for worker [0x%p]",
static_cast<void*>(worker)));
if (wasSuspended) {
if (extraThreadAllowed) {
gDOMThreadService->ChangeThreadPoolMaxThreads(-1);
}
JS_ResumeRequest(aCx, suspendDepth);
}
// Kill execution of the currently running JS.
JS_ClearPendingException(aCx);
return JS_FALSE;
}
// Break out if we're not suspended.
if (!worker->IsSuspended()) {
if (wasSuspended) {
if (extraThreadAllowed) {
gDOMThreadService->ChangeThreadPoolMaxThreads(-1);
}
JS_ResumeRequest(aCx, suspendDepth);
}
return JS_TRUE;
}
if (!wasSuspended) {
// Make sure to suspend our request while we block like this, otherwise we
// prevent GC for everyone.
suspendDepth = JS_SuspendRequest(aCx);
PRBool canceled = worker->IsCanceled();
if (!canceled && worker->IsSuspended()) {
JSAutoSuspendRequest suspended(aCx);
// Since we're going to block this thread we should open up a new thread
// in the thread pool for other workers. Must check the return value to
// make sure we don't decrement when we failed.
extraThreadAllowed =
PRBool extraThreadAllowed =
NS_SUCCEEDED(gDOMThreadService->ChangeThreadPoolMaxThreads(1));
// Flush JIT caches now before suspending to avoid holding memory that we
// are not going to use.
JS_FlushCaches(aCx);
// Only do all this setup once.
wasSuspended = PR_TRUE;
}
for (;;) {
nsAutoMonitor mon(worker->Pool()->Monitor());
// There's a small chance that the worker was canceled after our check
// above in which case we shouldn't wait here. We're guaranteed not to race
// here because the pool reenters its monitor after canceling each worker
// in order to notify its condition variable.
if (worker->IsSuspended() && !worker->IsCanceled()) {
// above in which case we shouldn't wait here. We're guaranteed not to
// race here because the pool reenters its monitor after canceling each
// worker in order to notify its condition variable.
canceled = worker->IsCanceled();
if (!canceled && worker->IsSuspended()) {
mon.Wait();
}
else {
break;
}
}
NS_NOTREACHED("Should never get here!");
if (extraThreadAllowed) {
gDOMThreadService->ChangeThreadPoolMaxThreads(-1);
}
}
if (canceled) {
LOG(("Forcefully killing JS for worker [0x%p]",
static_cast<void*>(worker)));
// Kill execution of the currently running JS.
JS_ClearPendingException(aCx);
return JS_FALSE;
}
return JS_TRUE;
}
void
DOMWorkerErrorReporter(JSContext* aCx,

View File

@ -152,6 +152,8 @@ CPPSRCS = \
jsopcode.cpp \
jsparse.cpp \
jsprf.cpp \
jspropertycache.cpp \
jspropertytree.cpp \
jsregexp.cpp \
jsscan.cpp \
jsscope.cpp \
@ -206,6 +208,9 @@ INSTALLED_HEADERS = \
jsotypes.h \
jsparse.h \
jsprf.h \
jspropertycache.h \
jspropertycacheinlines.h \
jspropertytree.h \
jsproto.tbl \
jsprvtd.h \
jspubtd.h \
@ -274,6 +279,27 @@ endif
endif # ENABLE_TRACEJIT
ifdef JS_HAS_CTYPES
CPPSRCS += \
ctypes/CTypes.cpp \
ctypes/Library.cpp \
$(NULL)
LOCAL_INCLUDES = \
-Ictypes/libffi/include \
$(NULL)
ifeq ($(OS_ARCH),OS2)
# libffi builds an aout lib on OS/2; convert it to an OMF lib.
ctypes/libffi/.libs/libffi.$(LIB_SUFFIX): ctypes/libffi/.libs/libffi.a
emxomf $<
endif
SHARED_LIBRARY_LIBS = \
ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \
$(NULL)
endif # JS_HAS_CTYPES
ifdef HAVE_DTRACE
INSTALLED_HEADERS += \
jsdtracef.h \
@ -343,6 +369,16 @@ endif
include $(topsrcdir)/config/rules.mk
ifdef JS_HAS_CTYPES
# Build libffi proper as part of the 'exports' target, so things get built
# in the right order.
export::
$(call SUBMAKE,,ctypes/libffi)
clean::
$(call SUBMAKE,clean,ctypes/libffi)
endif
ifdef MOZ_SYNC_BUILD_FILES
# Because the SpiderMonkey can be distributed and built independently
# of the Mozilla source tree, it contains its own copies of many of
@ -405,6 +441,10 @@ ifdef JS_THREADSAFE
DEFINES += -DJS_THREADSAFE
endif
ifdef JS_HAS_CTYPES
DEFINES += -DJS_HAS_CTYPES
endif
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif

View File

@ -91,6 +91,16 @@ OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX)
endif
endif
ifdef JS_HAS_CTYPES
DEFINES += -DJS_HAS_CTYPES
INCLUDES += -I$(DIST)/include/nspr
ifdef USE_MSVC
OTHER_LIBS += $(DIST)/lib/libnspr$(NSPR_LIBSUFFIX).lib
else
OTHER_LIBS += -L$(DIST)/lib -lnspr$(NSPR_LIBSUFFIX)
endif
endif
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif
@ -392,6 +402,7 @@ js-config-switch=$(if $(value $($1)),-e 's/\#undef $1/\#define $1/')
$(OBJDIR)/js-config.h.stamp: js-config.h.in Makefile.ref
sed < $< > $(@:.stamp=.tmp) \
$(call js-config-switch,JS_THREADSAFE) \
$(call js-config-switch,JS_HAS_CTYPES) \
$(call js-config-switch,JS_GC_ZEAL) \
-e :dummy
if ! [ -f $(@:.stamp=) ] || ! cmp $(@:.stamp=.tmp) $(@:.stamp=); then \

View File

@ -127,9 +127,9 @@ INTERP_OPTIMIZER = -O2 -GL
BUILTINS_OPTIMIZER = -O2 -GL
LDFLAGS += -LTCG
else
OPTIMIZER = -Os -fstrict-aliasing -fno-exceptions -fno-rtti -Wstrict-aliasing=2
BUILTINS_OPTIMIZER = -O9 -fstrict-aliasing -fno-exceptions -fno-rtti
INTERP_OPTIMIZER = -O3 -fstrict-aliasing -fno-exceptions -fno-rtti
OPTIMIZER = -Os -fno-exceptions -fno-rtti -fstrict-aliasing -Wstrict-aliasing=3
BUILTINS_OPTIMIZER = -O9 -fno-exceptions -fno-rtti -fstrict-aliasing
INTERP_OPTIMIZER = -O3 -fno-exceptions -fno-rtti -fstrict-aliasing
endif
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(USER)
OBJDIR_TAG = _OPT
@ -139,7 +139,7 @@ OPTIMIZER = -Zi
INTERP_OPTIMIZER = -Zi
BUILTINS_OPTIMIZER = $(INTERP_OPTIMIZER)
else
OPTIMIZER = -g3 -fstrict-aliasing -fno-exceptions -fno-rtti -Wstrict-aliasing=2
OPTIMIZER = -g3 -fstrict-aliasing -fno-exceptions -fno-rtti -Wstrict-aliasing=3
INTERP_OPTIMIZER = -g3 -fstrict-aliasing -fno-exceptions -fno-rtti
BUILTINS_OPTIMIZER = $(INTERP_OPTIMIZER)
endif

View File

@ -92,6 +92,7 @@ MOZ_JPROF = @MOZ_JPROF@
MOZ_SHARK = @MOZ_SHARK@
MOZ_CALLGRIND = @MOZ_CALLGRIND@
MOZ_VTUNE = @MOZ_VTUNE@
JS_HAS_CTYPES = @JS_HAS_CTYPES@
DEHYDRA_PATH = @DEHYDRA_PATH@
NS_TRACE_MALLOC = @NS_TRACE_MALLOC@

View File

@ -513,6 +513,8 @@ case "$target" in
# Make sure compilers are valid
CFLAGS="$CFLAGS -TC -nologo"
CXXFLAGS="$CXXFLAGS -TP -nologo"
# MSVC warning C4345 warns of newly conformant behavior as of VS2003.
CXXFLAGS="$CXXFLAGS -wd4345"
AC_LANG_SAVE
AC_LANG_C
AC_TRY_COMPILE([#include <stdio.h>],
@ -4303,6 +4305,22 @@ MOZ_ARG_WITH_STRING(wrap-malloc,
[ --with-wrap-malloc=DIR Location of malloc wrapper library],
WRAP_MALLOC_LIB=$withval)
dnl ========================================================
dnl = Build jsctypes if it's enabled
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(ctypes,
[ --enable-ctypes Enable js-ctypes (default=no)],
JS_HAS_CTYPES=1,
JS_HAS_CTYPES= )
AC_SUBST(JS_HAS_CTYPES)
if test "$JS_HAS_CTYPES"; then
if test "$_MSC_VER" && test -z $AS; then
# Error out if we're on MSVC and MASM is unavailable.
AC_MSG_ERROR([No suitable assembler found. An assembler is required to build js-ctypes. If you are building with MS Visual Studio 8 Express, you may download the MASM 8.0 package, upgrade to Visual Studio 9 Express, or install the Vista SDK.])
fi
AC_DEFINE(JS_HAS_CTYPES)
fi
dnl ========================================================
dnl = Use TraceVis
dnl ========================================================
@ -4317,6 +4335,16 @@ if test -n "$MOZ_TRACEVIS"; then
fi
fi
dnl ========================================================
dnl = Use GCTimer
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(gctimer,
[ --enable-gctimer Enable GC timer (default=no)],
MOZ_GCTIMER=1,
MOZ_GCTIMER= )
if test -n "$MOZ_GCTIMER"; then
AC_DEFINE(MOZ_GCTIMER)
fi
dnl ========================================================
dnl = Use Valgrind
@ -5245,6 +5273,8 @@ MAKEFILES="
Makefile
shell/Makefile
lirasm/Makefile
ctypes/Makefile
ctypes/tests/Makefile
jsapi-tests/Makefile
tests/Makefile
config/Makefile
@ -5295,3 +5325,55 @@ fi
# 'js-config' in Makefile.in.
AC_MSG_RESULT(invoking make to create js-config script)
$MAKE js-config
# Build jsctypes if it's enabled.
if test "$JS_HAS_CTYPES"; then
# Run the libffi 'configure' script.
ac_configure_args="--disable-shared --enable-static --disable-raw-api"
if test "$MOZ_DEBUG"; then
ac_configure_args="$ac_configure_args --enable-debug"
fi
if test "$DSO_PIC_CFLAGS"; then
ac_configure_args="$ac_configure_args --with-pic"
fi
if test "$CROSS_COMPILE"; then
case "$target" in
*-mingw*)
ac_configure_args="$ac_configure_args --build=$build --host=${target_cpu}-${target_os} HOST_CC=\"$HOST_CC\" CC=\"$CC\""
;;
*)
ac_configure_args="$ac_configure_args --build=$build --host=$target HOST_CC=\"$HOST_CC\" CC=\"$CC\""
;;
esac
fi
if test "$_MSC_VER"; then
# Use a wrapper script for cl and ml that looks more like gcc.
# autotools can't quite handle an MSVC build environment yet.
ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe"
case "${target_cpu}" in
x86_64)
# Need target since MSYS tools into mozilla-build may be 32bit
ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/ctypes/libffi/msvcc.sh -m64\" --build=$build --host=$target"
;;
*)
ac_configure_args="$ac_configure_args CC=$_topsrcdir/ctypes/libffi/msvcc.sh"
;;
esac
fi
if test "$SOLARIS_SUNPRO_CC"; then
# Always use gcc for libffi on Solaris
ac_configure_args="$ac_configure_args CC=gcc"
fi
# Use a separate cache file for libffi, since it does things differently
# from our configure.
old_cache_file=$cache_file
cache_file=ctypes/libffi/config.cache
old_config_files=$CONFIG_FILES
unset CONFIG_FILES
AC_OUTPUT_SUBDIRS(ctypes/libffi)
cache_file=$old_cache_file
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
CONFIG_FILES=$old_config_files
fi

File diff suppressed because it is too large Load Diff

View File

@ -39,15 +39,168 @@
#ifndef CTYPES_H
#define CTYPES_H
#include "jscntxt.h"
#include "jsapi.h"
#include "nsString.h"
#include "nsTArray.h"
#include "prlink.h"
#include "ffi.h"
namespace mozilla {
namespace js {
namespace ctypes {
/*******************************************************************************
** Utility classes
*******************************************************************************/
template<class T>
class OperatorDelete
{
public:
static void destroy(T* ptr) { delete ptr; }
};
template<class T>
class OperatorArrayDelete
{
public:
static void destroy(T* ptr) { delete[] ptr; }
};
// Class that takes ownership of a pointer T*, and calls operator delete or
// operator delete[] upon destruction.
template<class T, class DeleteTraits = OperatorDelete<T> >
class AutoPtr {
private:
typedef AutoPtr<T, DeleteTraits> self_type;
public:
// An AutoPtr variant that calls operator delete[] instead.
typedef AutoPtr<T, OperatorArrayDelete<T> > Array;
AutoPtr() : mPtr(NULL) { }
explicit AutoPtr(T* ptr) : mPtr(ptr) { }
~AutoPtr() { DeleteTraits::destroy(mPtr); }
T* operator->() { return mPtr; }
bool operator!() { return mPtr == NULL; }
T& operator[](size_t i) { return *(mPtr + i); }
// Note: we cannot safely provide an 'operator T*()', since this would allow
// the compiler to perform implicit conversion from one AutoPtr to another
// via the constructor AutoPtr(T*).
T* get() { return mPtr; }
void set(T* other) { JS_ASSERT(mPtr == NULL); mPtr = other; }
T* forget() { T* result = mPtr; mPtr = NULL; return result; }
self_type& operator=(T* rhs) { mPtr = rhs; return *this; }
private:
// Do not allow copy construction or assignment from another AutoPtr.
template<class U> AutoPtr(AutoPtr<T, U>&);
template<class U> self_type& operator=(AutoPtr<T, U>& rhs);
T* mPtr;
};
// Container class for Vector, using SystemAllocPolicy.
template<class T, size_t N = 0>
class Array : public Vector<T, N, SystemAllocPolicy>
{
};
// String and AutoString classes, based on Vector.
typedef Vector<jschar, 0, SystemAllocPolicy> String;
typedef Vector<jschar, 64, SystemAllocPolicy> AutoString;
// Convenience functions to append, insert, and compare Strings.
template <class T, size_t N, class AP, size_t ArrayLength>
void
AppendString(Vector<T, N, AP> &v, const char (&array)[ArrayLength])
{
// Don't include the trailing '\0'.
size_t alen = ArrayLength - 1;
size_t vlen = v.length();
if (!v.resize(vlen + alen))
return;
for (size_t i = 0; i < alen; ++i)
v[i + vlen] = array[i];
}
template <class T, size_t N, size_t M, class AP>
void
AppendString(Vector<T, N, AP> &v, Vector<T, M, AP> &w)
{
v.append(w.begin(), w.length());
}
template <size_t N, class AP>
void
AppendString(Vector<jschar, N, AP> &v, JSString* str)
{
JS_ASSERT(str);
const jschar* chars = JS_GetStringChars(str);
size_t length = JS_GetStringLength(str);
v.append(chars, length);
}
template <class T, size_t N, class AP, size_t ArrayLength>
void
PrependString(Vector<T, N, AP> &v, const char (&array)[ArrayLength])
{
// Don't include the trailing '\0'.
size_t alen = ArrayLength - 1;
size_t vlen = v.length();
if (!v.resize(vlen + alen))
return;
// Move vector data forward. This is safe since we've already resized.
memmove(v.begin() + alen, v.begin(), vlen * sizeof(T));
// Copy data to insert.
for (size_t i = 0; i < alen; ++i)
v[i] = array[i];
}
template <size_t N, class AP>
void
PrependString(Vector<jschar, N, AP> &v, JSString* str)
{
JS_ASSERT(str);
size_t vlen = v.length();
size_t alen = JS_GetStringLength(str);
if (!v.resize(vlen + alen))
return;
// Move vector data forward. This is safe since we've already resized.
memmove(v.begin() + alen, v.begin(), vlen * sizeof(jschar));
// Copy data to insert.
memcpy(v.begin(), JS_GetStringChars(str), alen * sizeof(jschar));
}
template <class T, size_t N, size_t M, class AP>
bool
StringsEqual(Vector<T, N, AP> &v, Vector<T, M, AP> &w)
{
if (v.length() != w.length())
return false;
return memcmp(v.begin(), w.begin(), v.length() * sizeof(T)) == 0;
}
template <size_t N, class AP>
bool
StringsEqual(Vector<jschar, N, AP> &v, JSString* str)
{
JS_ASSERT(str);
size_t length = JS_GetStringLength(str);
if (v.length() != length)
return false;
const jschar* chars = JS_GetStringChars(str);
return memcmp(v.begin(), chars, length * sizeof(jschar)) == 0;
}
/*******************************************************************************
** Function and struct API definitions
*******************************************************************************/
@ -89,7 +242,14 @@ enum TypeCode {
struct FieldInfo
{
nsString mName;
// We need to provide a copy constructor because of Vector.
FieldInfo() {}
FieldInfo(const FieldInfo& other)
{
JS_NOT_REACHED("shouldn't be copy constructing FieldInfo");
}
String mName;
JSObject* mType;
size_t mOffset;
};
@ -122,12 +282,12 @@ struct FunctionInfo
// A fixed array of known parameter types, excluding any variadic
// parameters (if mIsVariadic).
nsTArray<JSObject*> mArgTypes;
Array<JSObject*> mArgTypes;
// A variable array of ffi_type*s corresponding to both known parameter
// types and dynamic (variadic) parameter types. Longer than mArgTypes
// only if mIsVariadic.
nsTArray<ffi_type*> mFFITypes;
Array<ffi_type*> mFFITypes;
// Flag indicating whether the function behaves like a C function with
// ... as the final formal parameter.
@ -143,9 +303,6 @@ struct ClosureInfo
JSObject* thisObj; // 'this' object to use for the JS function call
JSObject* jsfnObj; // JS function
ffi_closure* closure; // The C closure itself
#ifdef DEBUG
PRThread* thread; // The thread the closure was created on
#endif
};
JSBool InitTypeClasses(JSContext* cx, JSObject* parent);
@ -275,7 +432,7 @@ namespace ArrayType {
}
namespace StructType {
nsTArray<FieldInfo>* GetFieldInfo(JSContext* cx, JSObject* obj);
Array<FieldInfo>* GetFieldInfo(JSContext* cx, JSObject* obj);
FieldInfo* LookupField(JSContext* cx, JSObject* obj, jsval idval);
}

View File

@ -41,12 +41,9 @@
#include "jscntxt.h"
#include "Library.h"
#include "CTypes.h"
#include "nsServiceManagerUtils.h"
#include "nsIXPConnect.h"
#include "nsILocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "prlink.h"
namespace mozilla {
namespace js {
namespace ctypes {
/*******************************************************************************
@ -88,7 +85,7 @@ Library::Create(JSContext* cx, jsval aPath)
JSObject* libraryObj = JS_NewObject(cx, &sLibraryClass, NULL, NULL);
if (!libraryObj)
return NULL;
JSAutoTempValueRooter root(cx, libraryObj);
js::AutoValueRooter root(cx, libraryObj);
// initialize the library
if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL)))
@ -98,59 +95,40 @@ Library::Create(JSContext* cx, jsval aPath)
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
return NULL;
nsresult rv;
PRLibrary* library;
if (!JSVAL_IS_STRING(aPath)) {
JS_ReportError(cx, "open takes a string argument");
return NULL;
}
// get the path argument. we accept either an nsILocalFile or a string path.
// determine which we have...
if (JSVAL_IS_STRING(aPath)) {
PRLibSpec libSpec;
#ifdef XP_WIN
// On Windows, converting to native charset may corrupt path string.
// So, we have to use Unicode path directly.
const PRUnichar* path = reinterpret_cast<const PRUnichar*>(
JS_GetStringCharsZ(cx, JSVAL_TO_STRING(aPath)));
if (!path)
return NULL;
// We don't use nsILocalFile, because it doesn't use the system search
// rules when resolving library path.
PRLibSpec libSpec;
#ifdef XP_WIN
// On Windows, converting to native charset may corrupt path string.
// So, we have to use Unicode path directly.
libSpec.value.pathname_u = path;
libSpec.type = PR_LibSpec_PathnameU;
#else
nsCAutoString nativePath;
NS_CopyUnicodeToNative(nsDependentString(path), nativePath);
libSpec.value.pathname = nativePath.get();
// Assume the JS string is not UTF-16, but is in the platform's native
// charset. (This basically means ASCII.) It would be nice to have a
// UTF-16 -> native charset implementation available. :(
const char* path = JS_GetStringBytesZ(cx, JSVAL_TO_STRING(aPath));
if (!path)
return NULL;
libSpec.value.pathname = path;
libSpec.type = PR_LibSpec_Pathname;
#endif
library = PR_LoadLibraryWithFlags(libSpec, 0);
PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, 0);
if (!library) {
JS_ReportError(cx, "couldn't open library");
return NULL;
}
} else if (!JSVAL_IS_PRIMITIVE(aPath)) {
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
nsISupports* file = xpc->GetNativeOfWrapper(cx, JSVAL_TO_OBJECT(aPath));
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(file);
if (!localFile) {
JS_ReportError(cx, "open takes a string or nsILocalFile argument");
return NULL;
}
rv = localFile->Load(&library);
if (NS_FAILED(rv)) {
JS_ReportError(cx, "couldn't open library");
return NULL;
}
} else {
// don't convert the argument
JS_ReportError(cx, "open takes a string or nsIFile argument");
return NULL;
}
// stash the library
if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY,
PRIVATE_TO_JSVAL(library)))
@ -264,7 +242,7 @@ Library::Declare(JSContext* cx, uintN argc, jsval* vp)
argv[1], argv[2], &argv[3], argc - 3);
if (!typeObj)
return JS_FALSE;
JSAutoTempValueRooter root(cx, typeObj);
js::AutoValueRooter root(cx, typeObj);
JSObject* fn = CData::Create(cx, typeObj, obj, &func, true);
if (!fn)

View File

@ -40,9 +40,11 @@
#ifndef LIBRARY_H
#define LIBRARY_H
#include "jsapi.h"
struct PRLibrary;
namespace mozilla {
namespace js {
namespace ctypes {
enum LibrarySlot {

Some files were not shown because too many files have changed in this diff Show More