[JAEGER] Merge from Tracemonkey part 1: don't change visibility of JSStackFrame members yet

This commit is contained in:
David Mandelin 2010-08-16 15:10:41 -07:00
commit 0a8cb3e43f
7 changed files with 80 additions and 32 deletions

View File

@ -28,11 +28,12 @@
#include <stddef.h> // for ptrdiff_t
#include <limits>
#include <wtf/Assertions.h>
#include "assembler/wtf/Assertions.h"
#include "jsapi.h"
#include "jsprvtd.h"
#include "jsvector.h"
#include "jslock.h"
#if WTF_PLATFORM_IPHONE
#include <libkern/OSCacheControl.h>
@ -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<Allocation, 2 ,js::SystemAllocPolicy > 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<size_t>(m_end - m_freePtr)) {
// Replace allocation pool
m_freePtr = result.pages + n;

View File

@ -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;

View File

@ -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 *)

View File

@ -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++;

View File

@ -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) {

View File

@ -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);

View File

@ -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;