Description: Fix an assert when reentering ctypes function callbacks Origin: https://bugzilla.mozilla.org/attachment.cgi?id=545444 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=671027 --- a/mozilla/js/src/ctypes/CTypes.cpp +++ b/mozilla/js/src/ctypes/CTypes.cpp @@ -62,19 +62,6 @@ namespace js { namespace ctypes { /******************************************************************************* -** Helper classes -*******************************************************************************/ - -class ScopedContextThread -{ -public: - ScopedContextThread(JSContext* cx) : mCx(cx) { JS_SetContextThread(cx); } - ~ScopedContextThread() { JS_ClearContextThread(mCx); } -private: - JSContext* mCx; -}; - -/******************************************************************************* ** JSAPI function prototypes *******************************************************************************/ @@ -2749,7 +2736,6 @@ CType::FinalizeProtoClass(JSContext* cx, return; JSContext* closureCx = static_cast(JSVAL_TO_PRIVATE(slot)); - JS_SetContextThread(closureCx); JS_DestroyContextNoGC(closureCx); } @@ -5245,8 +5231,6 @@ CClosure::Create(JSContext* cx, JS_DestroyContextNoGC(cinfo->cx); return NULL; } - - JS_ClearContextThread(cinfo->cx); } #ifdef DEBUG @@ -5342,8 +5326,6 @@ CClosure::ClosureStub(ffi_cif* cif, void JSObject* thisObj = cinfo->thisObj; JSObject* jsfnObj = cinfo->jsfnObj; - ScopedContextThread scopedThread(cx); - // Assert that we're on the thread we were created from. JS_ASSERT(cinfo->cxThread == JS_GetContextThread(cx)); --- /dev/null +++ b/mozilla/js/src/jit-test/tests/basic/bug671027.js @@ -0,0 +1,4 @@ +var fp_t = new ctypes.FunctionType(ctypes.default_abi, ctypes.int32_t).ptr; +var f = fp_t(function () { return 2; }); +var g = fp_t(function () { return f() + 2; }); +assertEq(g(), 4);