diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h index 48ca97da542..0f4033af1fd 100644 --- a/js/src/assembler/jit/ExecutableAllocator.h +++ b/js/src/assembler/jit/ExecutableAllocator.h @@ -28,11 +28,12 @@ #include // for ptrdiff_t #include -#include +#include "assembler/wtf/Assertions.h" #include "jsapi.h" #include "jsprvtd.h" #include "jsvector.h" +#include "jslock.h" #if WTF_PLATFORM_IPHONE #include @@ -80,7 +81,7 @@ inline size_t roundUpAllocationSize(size_t request, size_t granularity) // Round up to next page boundary size_t size = request + (granularity - 1); size = size & ~(granularity - 1); - ASSERT(size >= request); + JS_ASSERT(size >= request); return size; } @@ -104,16 +105,16 @@ private: typedef js::Vector AllocationList; // Reference count for automatic reclamation. - unsigned m_refCount; + jsrefcount m_refCount; public: // It should be impossible for us to roll over, because only small // pools have multiple holders, and they have one holder per chunk // of generated code, and they only hold 16KB or so of code. - void addRef() { ++m_refCount; } + void addRef() { JS_ATOMIC_INCREMENT(&m_refCount); } void release() { - ASSERT(m_refCount != 0); - if (--m_refCount == 0) + JS_ASSERT(m_refCount != 0); + if (JS_ATOMIC_DECREMENT(&m_refCount) == 0) delete this; } @@ -125,7 +126,7 @@ public: void* alloc(size_t n) { - ASSERT(m_freePtr <= m_end); + JS_ASSERT(m_freePtr <= m_end); // Round 'n' up to a multiple of word size; if all allocations are of // word sized quantities, then all subsequent allocations will be aligned. @@ -339,7 +340,7 @@ inline void* ExecutablePool::poolAllocate(size_t n) if (!result.pages) CRASH(); // Failed to allocate - ASSERT(m_end >= m_freePtr); + JS_ASSERT(m_end >= m_freePtr); if ((allocSize - n) > static_cast(m_end - m_freePtr)) { // Replace allocation pool m_freePtr = result.pages + n; diff --git a/js/src/jsbuiltins.cpp b/js/src/jsbuiltins.cpp index d4534be6703..09d66e362ff 100644 --- a/js/src/jsbuiltins.cpp +++ b/js/src/jsbuiltins.cpp @@ -343,9 +343,9 @@ js_PopInterpFrame(JSContext* cx, TracerState* state) * some things we just don't want to handle. In those cases, the trace will * MISMATCH_EXIT. */ - if (fp->hookData) + if (fp->hasHookData()) return JS_FALSE; - if (cx->version != fp->callerVersion) + if (cx->version != fp->getCallerVersion()) return JS_FALSE; if (fp->flags & JSFRAME_CONSTRUCTING) return JS_FALSE; diff --git a/js/src/jsdbgapi.cpp b/js/src/jsdbgapi.cpp index 7220b6ab972..853da1aa7c8 100644 --- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -1256,7 +1256,7 @@ JS_EvalFramePrincipals(JSContext *cx, JSStackFrame *fp, JSStackFrame *caller) JS_PUBLIC_API(void *) JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp) { - if (fp->annotation && fp->script) { + if (fp->hasAnnotation() && fp->script) { JSPrincipals *principals = JS_StackFramePrincipals(cx, fp); if (principals && principals->globalPrivilegesEnabled(cx, principals)) { @@ -1264,7 +1264,7 @@ JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp) * Give out an annotation only if privileges have not been revoked * or disabled globally. */ - return fp->annotation; + return fp->getAnnotation(); } } @@ -1274,7 +1274,7 @@ JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp) JS_PUBLIC_API(void) JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation) { - fp->annotation = annotation; + fp->setAnnotation(annotation); } JS_PUBLIC_API(void *) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 357c56a9569..6559924c877 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -543,7 +543,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native, fp->argc = args.argc(); fp->argv = args.argv(); fp->rval = (flags & JSINVOKE_CONSTRUCT) ? fp->thisv : UndefinedValue(); - fp->annotation = NULL; + fp->setAnnotation(NULL); fp->setScopeChain(NULL); fp->setBlockChain(NULL); fp->imacpc = NULL; @@ -884,7 +884,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, fp->flags = flags; fp->argc = down->argc; fp->argv = down->argv; - fp->annotation = down->annotation; + fp->setAnnotation(down->maybeAnnotation()); fp->setScopeChain(chain); /* @@ -905,7 +905,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, fp->flags = flags; fp->argc = 0; fp->argv = NULL; - fp->annotation = NULL; + fp->setAnnotation(NULL); JSObject *innerizedChain = chain; OBJ_TO_INNER_OBJECT(cx, innerizedChain); @@ -2744,10 +2744,9 @@ BEGIN_CASE(JSOP_STOP) { JS_ASSERT(!fp->hasBlockChain()); JS_ASSERT(!js_IsActiveWithOrBlock(cx, fp->getScopeChain(), 0)); - void *hookData = fp->hookData; - if (JS_UNLIKELY(hookData != NULL)) { + if (JS_UNLIKELY(fp->hasHookData())) { if (JSInterpreterHook hook = cx->debugHooks->callHook) { - hook(cx, fp, JS_FALSE, &interpReturnOK, hookData); + hook(cx, fp, JS_FALSE, &interpReturnOK, fp->getHookData()); CHECK_INTERRUPT_HANDLER(); } } @@ -2764,7 +2763,7 @@ BEGIN_CASE(JSOP_STOP) /* Restore context version only if callee hasn't set version. */ if (JS_LIKELY(cx->version == currentVersion)) { - currentVersion = fp->callerVersion; + currentVersion = fp->getCallerVersion(); if (currentVersion != cx->version) js_SetVersion(cx, currentVersion); } @@ -4727,7 +4726,7 @@ BEGIN_CASE(JSOP_APPLY) newfp->argc = argc; newfp->argv = vp + 2; newfp->rval.setUndefined(); - newfp->annotation = NULL; + newfp->setAnnotation(NULL); newfp->setScopeChain(obj->getParent()); newfp->flags = flags; newfp->setBlockChain(NULL); @@ -4741,7 +4740,7 @@ BEGIN_CASE(JSOP_APPLY) SetValueRangeToUndefined(newfp->slots(), newsp); /* Switch version if currentVersion wasn't overridden. */ - newfp->callerVersion = (JSVersion) cx->version; + newfp->setCallerVersion((JSVersion) cx->version); if (JS_LIKELY(cx->version == currentVersion)) { currentVersion = (JSVersion) newscript->version; if (JS_UNLIKELY(currentVersion != cx->version)) @@ -4767,11 +4766,11 @@ BEGIN_CASE(JSOP_APPLY) /* Call the debugger hook if present. */ if (JSInterpreterHook hook = cx->debugHooks->callHook) { - fp->hookData = hook(cx, fp, JS_TRUE, 0, - cx->debugHooks->callHookData); + fp->setHookData(hook(cx, fp, JS_TRUE, 0, + cx->debugHooks->callHookData)); CHECK_INTERRUPT_HANDLER(); } else { - fp->hookData = NULL; + fp->setHookData(NULL); } inlineCallCount++; diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index 3490055b6a5..62dab5c365f 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -281,6 +281,54 @@ struct JSStackFrame blockChain = obj; } + /* Annotation accessors */ + + bool hasAnnotation() const { + return annotation != NULL; + } + + void* getAnnotation() const { + JS_ASSERT(hasAnnotation()); + return annotation; + } + + void* maybeAnnotation() const { + return annotation; + } + + void setAnnotation(void *annot) { + annotation = annot; + } + + /* Debugger hook data accessors */ + + bool hasHookData() const { + return hookData != NULL; + } + + void* getHookData() const { + JS_ASSERT(hasHookData()); + return hookData; + } + + void* maybeHookData() const { + return hookData; + } + + void setHookData(void *data) { + hookData = data; + } + + /* Version accessors */ + + JSVersion getCallerVersion() const { + return callerVersion; + } + + void setCallerVersion(JSVersion version) { + callerVersion = version; + } + /* Other accessors */ void putActivationObjects(JSContext *cx) { diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 5ce7fcdaa05..ca4b013299f 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -1189,7 +1189,7 @@ js_NewGenerator(JSContext *cx) newfp->argc = fp->argc; newfp->argv = vp + 2; newfp->rval = fp->rval; - newfp->annotation = NULL; + newfp->setAnnotation(NULL); newfp->setScopeChain(fp->maybeScopeChain()); JS_ASSERT(!fp->hasBlockChain()); newfp->setBlockChain(NULL); diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 6241cda07c4..cd34dab42f6 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -5710,7 +5710,7 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee) newfp->argv[-1].setMagic(JS_THIS_POISON); #endif newfp->rval = UndefinedValue(); - newfp->annotation = NULL; + newfp->setAnnotation(NULL); newfp->setScopeChain(NULL); // will be updated in FlushNativeStackFrame newfp->flags = fi.is_constructing() ? JSFRAME_CONSTRUCTING : 0; newfp->setBlockChain(NULL); @@ -5721,7 +5721,7 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee) * Note that fp->script is still the caller's script; set the callee * inline frame's idea of caller version from its version. */ - newfp->callerVersion = (JSVersion) fp->script->version; + newfp->setCallerVersion((JSVersion) fp->script->version); /* Push inline frame. (Copied from js_Interpret.) */ stack.pushInlineFrame(cx, fp, fi.pc, newfp); @@ -5736,9 +5736,9 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee) */ JSInterpreterHook hook = cx->debugHooks->callHook; if (hook) { - newfp->hookData = hook(cx, newfp, JS_TRUE, 0, cx->debugHooks->callHookData); + newfp->setHookData(hook(cx, newfp, JS_TRUE, 0, cx->debugHooks->callHookData)); } else { - newfp->hookData = NULL; + newfp->setHookData(NULL); } /* @@ -5782,8 +5782,8 @@ SynthesizeSlowNativeFrame(TracerState& state, JSContext *cx, VMSideExit *exit) fp->argv = state.nativeVp + 2; fp->fun = GET_FUNCTION_PRIVATE(cx, fp->callee()); fp->rval = UndefinedValue(); - fp->annotation = NULL; - fp->setScopeChain(cx->fp->maybeScopeChain()); + fp->setAnnotation(NULL); + fp->setScopeChain(cx->fp->getScopeChain()); fp->setBlockChain(NULL); fp->flags = exit->constructing() ? JSFRAME_CONSTRUCTING : 0;