зеркало из https://github.com/mozilla/gecko-dev.git
Merge tracemonkey to mozilla-central.
This commit is contained in:
Коммит
f412b45d68
|
@ -297,6 +297,7 @@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
|
|||
MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@
|
||||
|
||||
MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@
|
||||
MOZ_EXCEPTIONS_FLAGS_ON = @_MOZ_EXCEPTIONS_FLAGS_ON@
|
||||
|
||||
MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@
|
||||
PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
|
||||
|
|
|
@ -7330,6 +7330,8 @@ else
|
|||
_MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_OFF
|
||||
fi
|
||||
|
||||
AC_SUBST(_MOZ_EXCEPTIONS_FLAGS_ON)
|
||||
|
||||
# Irix & OSF native compilers do not like exception declarations
|
||||
# when exceptions are disabled
|
||||
if test -n "$MIPSPRO_CXX" -o -n "$COMPAQ_CXX" -o -n "$VACPP"; then
|
||||
|
|
|
@ -144,6 +144,7 @@ CPPSRCS = \
|
|||
jsscope.cpp \
|
||||
jsscript.cpp \
|
||||
jsstr.cpp \
|
||||
jstask.cpp \
|
||||
jsutil.cpp \
|
||||
jsxdrapi.cpp \
|
||||
jsxml.cpp \
|
||||
|
@ -200,6 +201,7 @@ INSTALLED_HEADERS = \
|
|||
jsscript.h \
|
||||
jsstaticcheck.h \
|
||||
jsstr.h \
|
||||
jstask.h \
|
||||
jstracer.h \
|
||||
jstypes.h \
|
||||
jsutil.h \
|
||||
|
|
|
@ -162,6 +162,7 @@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
|
|||
MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@
|
||||
|
||||
MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@
|
||||
MOZ_EXCEPTIONS_FLAGS_ON = @_MOZ_EXCEPTIONS_FLAGS_ON@
|
||||
|
||||
MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@
|
||||
PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
|
||||
|
|
|
@ -4742,6 +4742,8 @@ else
|
|||
_MOZ_EXCEPTIONS_FLAGS=$_MOZ_EXCEPTIONS_FLAGS_OFF
|
||||
fi
|
||||
|
||||
AC_SUBST(_MOZ_EXCEPTIONS_FLAGS_ON)
|
||||
|
||||
# Irix & OSF native compilers do not like exception declarations
|
||||
# when exceptions are disabled
|
||||
if test -n "$MIPSPRO_CXX" -o -n "$COMPAQ_CXX" -o -n "$VACPP"; then
|
||||
|
|
100
js/src/jsapi.cpp
100
js/src/jsapi.cpp
|
@ -79,6 +79,7 @@
|
|||
#include "jsscope.h"
|
||||
#include "jsscript.h"
|
||||
#include "jsstr.h"
|
||||
#include "jstask.h"
|
||||
#include "jstracer.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "prmjtime.h"
|
||||
|
@ -448,7 +449,7 @@ JS_AddArgumentFormatter(JSContext *cx, const char *format,
|
|||
goto out;
|
||||
mpp = &map->next;
|
||||
}
|
||||
map = (JSArgumentFormatMap *) JS_malloc(cx, sizeof *map);
|
||||
map = (JSArgumentFormatMap *) cx->malloc(sizeof *map);
|
||||
if (!map)
|
||||
return JS_FALSE;
|
||||
map->format = format;
|
||||
|
@ -471,7 +472,7 @@ JS_RemoveArgumentFormatter(JSContext *cx, const char *format)
|
|||
while ((map = *mpp) != NULL) {
|
||||
if (map->length == length && !strcmp(map->format, format)) {
|
||||
*mpp = map->next;
|
||||
JS_free(cx, map);
|
||||
cx->free(map);
|
||||
return;
|
||||
}
|
||||
mpp = &map->next;
|
||||
|
@ -773,7 +774,7 @@ JS_NewRuntime(uint32 maxbytes)
|
|||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
rt = (JSRuntime *) malloc(sizeof(JSRuntime));
|
||||
rt = (JSRuntime *) js_malloc(sizeof(JSRuntime));
|
||||
if (!rt)
|
||||
return NULL;
|
||||
|
||||
|
@ -817,6 +818,9 @@ JS_NewRuntime(uint32 maxbytes)
|
|||
rt->debuggerLock = JS_NEW_LOCK();
|
||||
if (!rt->debuggerLock)
|
||||
goto bad;
|
||||
rt->deallocatorThread = new JSBackgroundThread();
|
||||
if (!rt->deallocatorThread || !rt->deallocatorThread->init())
|
||||
goto bad;
|
||||
#endif
|
||||
if (!js_InitPropertyTree(rt))
|
||||
goto bad;
|
||||
|
@ -886,9 +890,13 @@ JS_DestroyRuntime(JSRuntime *rt)
|
|||
JS_DESTROY_CONDVAR(rt->titleSharingDone);
|
||||
if (rt->debuggerLock)
|
||||
JS_DESTROY_LOCK(rt->debuggerLock);
|
||||
if (rt->deallocatorThread) {
|
||||
rt->deallocatorThread->cancel();
|
||||
delete rt->deallocatorThread;
|
||||
}
|
||||
#endif
|
||||
js_FinishPropertyTree(rt);
|
||||
free(rt);
|
||||
js_free(rt);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
@ -1328,7 +1336,7 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
|||
/* Define a top-level property 'undefined' with the undefined value. */
|
||||
atom = cx->runtime->atomState.typeAtoms[JSTYPE_VOID];
|
||||
if (!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
||||
JS_PropertyStub, JS_PropertyStub, JSPROP_PERMANENT,
|
||||
JS_PropertyStub, JS_PropertyStub, JSPROP_PERMANENT,
|
||||
NULL)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1535,7 +1543,7 @@ JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsval id,
|
|||
if (idstr == ATOM_TO_STRING(atom)) {
|
||||
*resolved = JS_TRUE;
|
||||
return OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
JS_PropertyStub, JS_PropertyStub,
|
||||
JSPROP_PERMANENT, NULL);
|
||||
}
|
||||
|
||||
|
@ -1630,7 +1638,7 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj)
|
|||
atom = rt->atomState.typeAtoms[JSTYPE_VOID];
|
||||
if (!AlreadyHasOwnProperty(cx, obj, atom) &&
|
||||
!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom), JSVAL_VOID,
|
||||
JS_PropertyStub, JS_PropertyStub, JSPROP_PERMANENT,
|
||||
JS_PropertyStub, JS_PropertyStub, JSPROP_PERMANENT,
|
||||
NULL)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1653,7 +1661,7 @@ NewIdArray(JSContext *cx, jsint length)
|
|||
JSIdArray *ida;
|
||||
|
||||
ida = (JSIdArray *)
|
||||
JS_malloc(cx, offsetof(JSIdArray, vector) + length * sizeof(jsval));
|
||||
cx->malloc(offsetof(JSIdArray, vector) + length * sizeof(jsval));
|
||||
if (ida)
|
||||
ida->length = length;
|
||||
return ida;
|
||||
|
@ -1831,41 +1839,19 @@ JS_ComputeThis(JSContext *cx, jsval *vp)
|
|||
JS_PUBLIC_API(void *)
|
||||
JS_malloc(JSContext *cx, size_t nbytes)
|
||||
{
|
||||
void *p;
|
||||
|
||||
JS_ASSERT(nbytes != 0);
|
||||
if (nbytes == 0)
|
||||
nbytes = 1;
|
||||
|
||||
p = malloc(nbytes);
|
||||
if (!p) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return NULL;
|
||||
}
|
||||
cx->updateMallocCounter(nbytes);
|
||||
|
||||
return p;
|
||||
return cx->malloc(nbytes);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void *)
|
||||
JS_realloc(JSContext *cx, void *p, size_t nbytes)
|
||||
{
|
||||
void *orig = p;
|
||||
p = realloc(p, nbytes);
|
||||
if (!p) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return NULL;
|
||||
}
|
||||
if (!orig)
|
||||
cx->updateMallocCounter(nbytes);
|
||||
return p;
|
||||
return cx->realloc(p, nbytes);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_free(JSContext *cx, void *p)
|
||||
{
|
||||
if (p)
|
||||
free(p);
|
||||
return cx->free(p);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(char *)
|
||||
|
@ -1875,7 +1861,7 @@ JS_strdup(JSContext *cx, const char *s)
|
|||
void *p;
|
||||
|
||||
n = strlen(s) + 1;
|
||||
p = JS_malloc(cx, n);
|
||||
p = cx->malloc(n);
|
||||
if (!p)
|
||||
return NULL;
|
||||
return (char *)memcpy(p, s, n);
|
||||
|
@ -2260,7 +2246,7 @@ DumpNotify(JSTracer *trc, void *thing, uint32 kind)
|
|||
|
||||
edgeNameSize = strlen(edgeName) + 1;
|
||||
node = (JSHeapDumpNode *)
|
||||
JS_malloc(cx, offsetof(JSHeapDumpNode, edgeName) + edgeNameSize);
|
||||
cx->malloc(offsetof(JSHeapDumpNode, edgeName) + edgeNameSize);
|
||||
if (!node) {
|
||||
dtrc->ok = JS_FALSE;
|
||||
return;
|
||||
|
@ -2412,7 +2398,7 @@ JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, uint32 startKind,
|
|||
for (;;) {
|
||||
next = node->next;
|
||||
parent = node->parent;
|
||||
JS_free(cx, node);
|
||||
cx->free(node);
|
||||
node = next;
|
||||
if (node)
|
||||
break;
|
||||
|
@ -2679,7 +2665,7 @@ JS_SetScriptStackQuota(JSContext *cx, size_t quota)
|
|||
JS_PUBLIC_API(void)
|
||||
JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
|
||||
{
|
||||
JS_free(cx, ida);
|
||||
cx->free(ida);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
@ -3001,7 +2987,7 @@ DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
|
|||
attrs, flags, tinyid, NULL);
|
||||
}
|
||||
return OBJ_DEFINE_PROPERTY(cx, obj, id, value, getter, setter, attrs,
|
||||
NULL);
|
||||
NULL);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -3720,7 +3706,7 @@ JS_HasUCProperty(JSContext *cx, JSObject *obj,
|
|||
JSProperty *prop;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
ok = LookupUCProperty(cx, obj, name, namelen,
|
||||
ok = LookupUCProperty(cx, obj, name, namelen,
|
||||
JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
|
||||
&obj2, &prop);
|
||||
if (ok) {
|
||||
|
@ -4072,13 +4058,13 @@ prop_iter_trace(JSTracer *trc, JSObject *obj)
|
|||
/* Native case: just mark the next property to visit. */
|
||||
sprop = (JSScopeProperty *) JSVAL_TO_PRIVATE(v);
|
||||
if (sprop)
|
||||
TRACE_SCOPE_PROPERTY(trc, sprop);
|
||||
sprop->trace(trc);
|
||||
} else {
|
||||
/* Non-native case: mark each id in the JSIdArray private. */
|
||||
ida = (JSIdArray *) JSVAL_TO_PRIVATE(v);
|
||||
for (i = 0, n = ida->length; i < n; i++) {
|
||||
id = ida->vector[i];
|
||||
TRACE_ID(trc, id);
|
||||
js_TraceId(trc, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4644,7 +4630,7 @@ JS_CompileScript(JSContext *cx, JSObject *obj,
|
|||
if (!chars)
|
||||
return NULL;
|
||||
script = JS_CompileUCScript(cx, obj, chars, length, filename, lineno);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return script;
|
||||
}
|
||||
|
||||
|
@ -4663,7 +4649,7 @@ JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj,
|
|||
return NULL;
|
||||
script = JS_CompileUCScriptForPrincipals(cx, obj, principals,
|
||||
chars, length, filename, lineno);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return script;
|
||||
}
|
||||
|
||||
|
@ -4748,7 +4734,7 @@ JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj,
|
|||
JS_SetErrorReporter(cx, older);
|
||||
}
|
||||
}
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
JS_RestoreExceptionState(cx, exnState);
|
||||
return result;
|
||||
}
|
||||
|
@ -4857,7 +4843,7 @@ JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name,
|
|||
return NULL;
|
||||
fun = JS_CompileUCFunction(cx, obj, name, nargs, argnames, chars, length,
|
||||
filename, lineno);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
@ -4878,7 +4864,7 @@ JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj,
|
|||
fun = JS_CompileUCFunctionForPrincipals(cx, obj, principals, name,
|
||||
nargs, argnames, chars, length,
|
||||
filename, lineno);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
@ -5088,7 +5074,7 @@ JS_EvaluateScript(JSContext *cx, JSObject *obj,
|
|||
if (!chars)
|
||||
return JS_FALSE;
|
||||
ok = JS_EvaluateUCScript(cx, obj, chars, length, filename, lineno, rval);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -5110,7 +5096,7 @@ JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj,
|
|||
return JS_FALSE;
|
||||
ok = JS_EvaluateUCScriptForPrincipals(cx, obj, principals, chars, length,
|
||||
filename, lineno, rval);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -5197,7 +5183,7 @@ JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback)
|
|||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_ASSERT(CURRENT_THREAD_IS_ME(cx->thread));
|
||||
#endif
|
||||
#endif
|
||||
JSOperationCallback old = cx->operationCallback;
|
||||
cx->operationCallback = callback;
|
||||
return old;
|
||||
|
@ -5319,13 +5305,13 @@ JS_NewString(JSContext *cx, char *bytes, size_t nbytes)
|
|||
/* Free chars (but not bytes, which caller frees on error) if we fail. */
|
||||
str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Hand off bytes to the deflated string cache, if possible. */
|
||||
if (!js_SetStringBytes(cx, str, bytes, nbytes))
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -5341,7 +5327,7 @@ JS_NewStringCopyN(JSContext *cx, const char *s, size_t n)
|
|||
return NULL;
|
||||
str = js_NewString(cx, js, n);
|
||||
if (!str)
|
||||
JS_free(cx, js);
|
||||
cx->free(js);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -5361,7 +5347,7 @@ JS_NewStringCopyZ(JSContext *cx, const char *s)
|
|||
return NULL;
|
||||
str = js_NewString(cx, js, n);
|
||||
if (!str)
|
||||
JS_free(cx, js);
|
||||
cx->free(js);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -5449,7 +5435,7 @@ JS_GetStringChars(JSString *str)
|
|||
if (str->isDependent()) {
|
||||
n = str->dependentLength();
|
||||
size = (n + 1) * sizeof(jschar);
|
||||
s = (jschar *) malloc(size);
|
||||
s = (jschar *) js_malloc(size);
|
||||
if (s) {
|
||||
memcpy(s, str->dependentChars(), n * sizeof *s);
|
||||
s[n] = 0;
|
||||
|
@ -5727,7 +5713,7 @@ JS_NewRegExpObject(JSContext *cx, char *bytes, size_t length, uintN flags)
|
|||
if (!chars)
|
||||
return NULL;
|
||||
obj = js_NewRegExpObject(cx, NULL, chars, length, flags);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -5857,7 +5843,7 @@ JS_SaveExceptionState(JSContext *cx)
|
|||
JSExceptionState *state;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
state = (JSExceptionState *) JS_malloc(cx, sizeof(JSExceptionState));
|
||||
state = (JSExceptionState *) cx->malloc(sizeof(JSExceptionState));
|
||||
if (state) {
|
||||
state->throwing = JS_GetPendingException(cx, &state->exception);
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
|
@ -5886,7 +5872,7 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
|||
if (state) {
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
JS_RemoveRoot(cx, &state->exception);
|
||||
JS_free(cx, state);
|
||||
cx->free(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
165
js/src/jsapi.h
165
js/src/jsapi.h
|
@ -54,35 +54,122 @@ JS_BEGIN_EXTERN_C
|
|||
/*
|
||||
* Type tags stored in the low bits of a jsval.
|
||||
*/
|
||||
#define JSVAL_OBJECT 0x0 /* untagged reference to object */
|
||||
#define JSVAL_INT 0x1 /* tagged 31-bit integer value */
|
||||
#define JSVAL_DOUBLE 0x2 /* tagged reference to double */
|
||||
#define JSVAL_STRING 0x4 /* tagged reference to string */
|
||||
#define JSVAL_BOOLEAN 0x6 /* tagged boolean value */
|
||||
typedef enum jsvaltag {
|
||||
JSVAL_OBJECT = 0x0, /* untagged reference to object */
|
||||
JSVAL_INT = 0x1, /* tagged 31-bit integer value */
|
||||
JSVAL_DOUBLE = 0x2, /* tagged reference to double */
|
||||
JSVAL_STRING = 0x4, /* tagged reference to string */
|
||||
JSVAL_BOOLEAN = 0x6 /* tagged boolean value */
|
||||
} jsvaltag;
|
||||
|
||||
#define JSVAL_OBJECT ((jsvaltag)0x0)
|
||||
#define JSVAL_INT ((jsvaltag)0x1)
|
||||
#define JSVAL_DOUBLE ((jsvaltag)0x2)
|
||||
#define JSVAL_STRING ((jsvaltag)0x4)
|
||||
#define JSVAL_BOOLEAN ((jsvaltag)0x6)
|
||||
|
||||
/* Type tag bitfield length and derived macros. */
|
||||
#define JSVAL_TAGBITS 3
|
||||
#define JSVAL_TAGMASK JS_BITMASK(JSVAL_TAGBITS)
|
||||
#define JSVAL_TAG(v) ((v) & JSVAL_TAGMASK)
|
||||
#define JSVAL_SETTAG(v,t) ((v) | (t))
|
||||
#define JSVAL_CLRTAG(v) ((v) & ~(jsval)JSVAL_TAGMASK)
|
||||
#define JSVAL_ALIGN JS_BIT(JSVAL_TAGBITS)
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
#define JSVAL_TAG(v) ((jsvaltag)((v) & JSVAL_TAGMASK))
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
#define JSVAL_SETTAG(v, t) ((v) | (t))
|
||||
|
||||
static JS_ALWAYS_INLINE jsval
|
||||
JSVAL_CLRTAG(jsval v)
|
||||
{
|
||||
return v & ~(jsval)JSVAL_TAGMASK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Well-known JS values. The extern'd variables are initialized when the
|
||||
* first JSContext is created by JS_NewContext (see below).
|
||||
*/
|
||||
#define JSVAL_NULL ((jsval) 0)
|
||||
#define JSVAL_ZERO INT_TO_JSVAL(0)
|
||||
#define JSVAL_ONE INT_TO_JSVAL(1)
|
||||
#define JSVAL_FALSE PSEUDO_BOOLEAN_TO_JSVAL(JS_FALSE)
|
||||
#define JSVAL_TRUE PSEUDO_BOOLEAN_TO_JSVAL(JS_TRUE)
|
||||
#define JSVAL_VOID PSEUDO_BOOLEAN_TO_JSVAL(2)
|
||||
|
||||
/*
|
||||
* A pseudo-boolean is a 29-bit (for 32-bit jsval) or 61-bit (for 64-bit jsval)
|
||||
* value other than 0 or 1 encoded as a jsval whose tag is JSVAL_BOOLEAN.
|
||||
*
|
||||
* JSVAL_VOID happens to be defined as a jsval encoding a pseudo-boolean, but
|
||||
* embedders MUST NOT rely on this. All other possible pseudo-boolean values
|
||||
* are implementation-reserved and MUST NOT be constructed by any embedding of
|
||||
* SpiderMonkey.
|
||||
*/
|
||||
#define JSVAL_TO_PSEUDO_BOOLEAN(v) ((JSBool) ((v) >> JSVAL_TAGBITS))
|
||||
#define PSEUDO_BOOLEAN_TO_JSVAL(b) \
|
||||
JSVAL_SETTAG((jsval) (b) << JSVAL_TAGBITS, JSVAL_BOOLEAN)
|
||||
|
||||
/* Predicates for type testing. */
|
||||
#define JSVAL_IS_OBJECT(v) (JSVAL_TAG(v) == JSVAL_OBJECT)
|
||||
#define JSVAL_IS_NUMBER(v) (JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v))
|
||||
#define JSVAL_IS_INT(v) ((v) & JSVAL_INT)
|
||||
#define JSVAL_IS_DOUBLE(v) (JSVAL_TAG(v) == JSVAL_DOUBLE)
|
||||
#define JSVAL_IS_STRING(v) (JSVAL_TAG(v) == JSVAL_STRING)
|
||||
#define JSVAL_IS_BOOLEAN(v) (((v) & ~((jsval)1 << JSVAL_TAGBITS)) == \
|
||||
JSVAL_BOOLEAN)
|
||||
#define JSVAL_IS_NULL(v) ((v) == JSVAL_NULL)
|
||||
#define JSVAL_IS_VOID(v) ((v) == JSVAL_VOID)
|
||||
#define JSVAL_IS_PRIMITIVE(v) (!JSVAL_IS_OBJECT(v) || JSVAL_IS_NULL(v))
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_OBJECT(jsval v)
|
||||
{
|
||||
return JSVAL_TAG(v) == JSVAL_OBJECT;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_INT(jsval v)
|
||||
{
|
||||
return v & JSVAL_INT;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_DOUBLE(jsval v)
|
||||
{
|
||||
return JSVAL_TAG(v) == JSVAL_DOUBLE;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_NUMBER(jsval v)
|
||||
{
|
||||
return JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_STRING(jsval v)
|
||||
{
|
||||
return JSVAL_TAG(v) == JSVAL_STRING;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_BOOLEAN(jsval v)
|
||||
{
|
||||
return (v & ~((jsval)1 << JSVAL_TAGBITS)) == JSVAL_BOOLEAN;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_NULL(jsval v)
|
||||
{
|
||||
return v == JSVAL_NULL;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_VOID(jsval v)
|
||||
{
|
||||
return v == JSVAL_VOID;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_PRIMITIVE(jsval v)
|
||||
{
|
||||
return !JSVAL_IS_OBJECT(v) || JSVAL_IS_NULL(v);
|
||||
}
|
||||
|
||||
/* Objects, strings, and doubles are GC'ed. */
|
||||
#define JSVAL_IS_GCTHING(v) (!((v) & JSVAL_INT) && \
|
||||
JSVAL_TAG(v) != JSVAL_BOOLEAN)
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_IS_GCTHING(jsval v)
|
||||
{
|
||||
return !(v & JSVAL_INT) && JSVAL_TAG(v) != JSVAL_BOOLEAN;
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE void *
|
||||
JSVAL_TO_GCTHING(jsval v)
|
||||
|
@ -145,36 +232,18 @@ STRING_TO_JSVAL(JSString *str)
|
|||
#define JSVAL_INT_POW2(n) ((jsval)1 << (n))
|
||||
#define JSVAL_INT_MIN (-JSVAL_INT_POW2(30))
|
||||
#define JSVAL_INT_MAX (JSVAL_INT_POW2(30) - 1)
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
#define INT_FITS_IN_JSVAL(i) ((jsuint)(i) - (jsuint)JSVAL_INT_MIN <= \
|
||||
(jsuint)(JSVAL_INT_MAX - JSVAL_INT_MIN))
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
/* FIXME: Bug 506721, since that means we can't assert JSVAL_IS_INT(v) */
|
||||
#define JSVAL_TO_INT(v) ((jsint)(v) >> 1)
|
||||
|
||||
/* Not a function, because we have static asserts that use it */
|
||||
/* FIXME: Bug 506721, since that means we can't assert INT_FITS_IN_JSVAL(i) */
|
||||
#define INT_TO_JSVAL(i) (((jsval)(i) << 1) | JSVAL_INT)
|
||||
|
||||
/*
|
||||
* A pseudo-boolean is a 29-bit (for 32-bit jsval) or 61-bit (for 64-bit jsval)
|
||||
* value other than 0 or 1 encoded as a jsval whose tag is JSVAL_BOOLEAN.
|
||||
*
|
||||
* JSVAL_VOID happens to be defined as a jsval encoding a pseudo-boolean, but
|
||||
* embedders MUST NOT rely on this. All other possible pseudo-boolean values
|
||||
* are implementation-reserved and MUST NOT be constructed by any embedding of
|
||||
* SpiderMonkey.
|
||||
*/
|
||||
#define JSVAL_TO_PSEUDO_BOOLEAN(v) ((JSBool) ((v) >> JSVAL_TAGBITS))
|
||||
#define PSEUDO_BOOLEAN_TO_JSVAL(b) \
|
||||
JSVAL_SETTAG((jsval) (b) << JSVAL_TAGBITS, JSVAL_BOOLEAN)
|
||||
|
||||
/*
|
||||
* Well-known JS values. The extern'd variables are initialized when the
|
||||
* first JSContext is created by JS_NewContext (see below).
|
||||
*/
|
||||
#define JSVAL_NULL ((jsval) 0)
|
||||
#define JSVAL_ZERO INT_TO_JSVAL(0)
|
||||
#define JSVAL_ONE INT_TO_JSVAL(1)
|
||||
#define JSVAL_FALSE PSEUDO_BOOLEAN_TO_JSVAL(JS_FALSE)
|
||||
#define JSVAL_TRUE PSEUDO_BOOLEAN_TO_JSVAL(JS_TRUE)
|
||||
#define JSVAL_VOID PSEUDO_BOOLEAN_TO_JSVAL(2)
|
||||
|
||||
|
||||
/* Convert between boolean and jsval, asserting that inputs are valid. */
|
||||
static JS_ALWAYS_INLINE JSBool
|
||||
JSVAL_TO_BOOLEAN(jsval v)
|
||||
|
@ -2229,14 +2298,14 @@ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc,
|
|||
* These functions allow setting an operation callback that will be called
|
||||
* from the thread the context is associated with some time after any thread
|
||||
* triggered the callback using JS_TriggerOperationCallback(cx).
|
||||
*
|
||||
*
|
||||
* In a threadsafe build the engine internally triggers operation callbacks
|
||||
* under certain circumstances (i.e. GC and title transfer) to force the
|
||||
* context to yield its current request, which the engine always
|
||||
* context to yield its current request, which the engine always
|
||||
* automatically does immediately prior to calling the callback function.
|
||||
* The embedding should thus not rely on callbacks being triggered through
|
||||
* the external API only.
|
||||
*
|
||||
*
|
||||
* Important note: Additional callbacks can occur inside the callback handler
|
||||
* if it re-enters the JS engine. The embedding must ensure that the callback
|
||||
* is disconnected before attempting such re-entry.
|
||||
|
|
|
@ -160,12 +160,12 @@ JS_ArenaAllocate(JSArenaPool *pool, size_t nb)
|
|||
if (pool->quotap) {
|
||||
if (gross > *pool->quotap)
|
||||
return NULL;
|
||||
b = (JSArena *) malloc(gross);
|
||||
b = (JSArena *) js_malloc(gross);
|
||||
if (!b)
|
||||
return NULL;
|
||||
*pool->quotap -= gross;
|
||||
} else {
|
||||
b = (JSArena *) malloc(gross);
|
||||
b = (JSArena *) js_malloc(gross);
|
||||
if (!b)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -227,12 +227,12 @@ JS_ArenaRealloc(JSArenaPool *pool, void *p, size_t size, size_t incr)
|
|||
growth = gross - (a->limit - (jsuword) a);
|
||||
if (growth > *pool->quotap)
|
||||
return NULL;
|
||||
a = (JSArena *) realloc(a, gross);
|
||||
a = (JSArena *) js_realloc(a, gross);
|
||||
if (!a)
|
||||
return NULL;
|
||||
*pool->quotap -= growth;
|
||||
} else {
|
||||
a = (JSArena *) realloc(a, gross);
|
||||
a = (JSArena *) js_realloc(a, gross);
|
||||
if (!a)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ FreeArenaList(JSArenaPool *pool, JSArena *head)
|
|||
*pool->quotap += a->limit - (jsuword) a;
|
||||
JS_CLEAR_ARENA(a);
|
||||
JS_COUNT_ARENA(pool,--);
|
||||
free(a);
|
||||
js_free(a);
|
||||
} while ((a = *ap) != NULL);
|
||||
|
||||
pool->current = head;
|
||||
|
@ -354,7 +354,7 @@ JS_FinishArenaPool(JSArenaPool *pool)
|
|||
JSArenaStats *stats, **statsp;
|
||||
|
||||
if (pool->stats.name) {
|
||||
free(pool->stats.name);
|
||||
js_free(pool->stats.name);
|
||||
pool->stats.name = NULL;
|
||||
}
|
||||
for (statsp = &arena_stats_list; (stats = *statsp) != 0;
|
||||
|
|
|
@ -314,7 +314,7 @@ ResizeSlots(JSContext *cx, JSObject *obj, uint32 oldsize, uint32 size)
|
|||
|
||||
if (size == 0) {
|
||||
if (obj->dslots) {
|
||||
JS_free(cx, obj->dslots - 1);
|
||||
cx->free(obj->dslots - 1);
|
||||
obj->dslots = NULL;
|
||||
}
|
||||
return JS_TRUE;
|
||||
|
@ -330,7 +330,7 @@ ResizeSlots(JSContext *cx, JSObject *obj, uint32 oldsize, uint32 size)
|
|||
}
|
||||
|
||||
slots = obj->dslots ? obj->dslots - 1 : NULL;
|
||||
newslots = (jsval *) JS_realloc(cx, slots, (size + 1) * sizeof(jsval));
|
||||
newslots = (jsval *) cx->realloc(slots, (size + 1) * sizeof(jsval));
|
||||
if (!newslots)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ array_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (obj->dslots[i] == JSVAL_HOLE) {
|
||||
if (!ii) {
|
||||
ii = (JSIndexIterState *)
|
||||
JS_malloc(cx, offsetof(JSIndexIterState, holes) +
|
||||
cx->malloc(offsetof(JSIndexIterState, holes) +
|
||||
JS_BITMAP_SIZE(capacity));
|
||||
if (!ii)
|
||||
return JS_FALSE;
|
||||
|
@ -1116,7 +1116,7 @@ array_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
break;
|
||||
}
|
||||
ii = (JSIndexIterState *)
|
||||
JS_malloc(cx, offsetof(JSIndexIterState, holes));
|
||||
cx->malloc(offsetof(JSIndexIterState, holes));
|
||||
if (!ii)
|
||||
return JS_FALSE;
|
||||
ii->hasHoles = JS_FALSE;
|
||||
|
@ -1157,7 +1157,7 @@ array_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (JSVAL_TAG(*statep) != JSVAL_BOOLEAN) {
|
||||
JS_ASSERT((*statep & INDEX_ITER_TAG) == INDEX_ITER_TAG);
|
||||
ii = (JSIndexIterState *) (*statep & ~INDEX_ITER_TAG);
|
||||
JS_free(cx, ii);
|
||||
cx->free(ii);
|
||||
}
|
||||
*statep = JSVAL_NULL;
|
||||
break;
|
||||
|
@ -1188,7 +1188,7 @@ static void
|
|||
array_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
if (obj->dslots)
|
||||
JS_free(cx, obj->dslots - 1);
|
||||
cx->free(obj->dslots - 1);
|
||||
obj->dslots = NULL;
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ BufferToString(JSContext *cx, JSTempVector<jschar> &buf, jsval *rval)
|
|||
jschar *chars = buf.extractRawBuffer();
|
||||
JSString *str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
|
@ -1368,7 +1368,7 @@ array_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
JSBool ok = JS_TRUE;
|
||||
|
||||
/*
|
||||
* This object will take responsibility for the jschar buffer until the
|
||||
* This object will take responsibility for the jschar buffer until the
|
||||
* buffer is transferred to the returned JSString.
|
||||
*/
|
||||
JSTempVector<jschar> buf(cx);
|
||||
|
@ -1392,7 +1392,7 @@ array_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
if (!(ok = buf.pushBack(arr, arr + 3)))
|
||||
goto done;
|
||||
if (sharpchars)
|
||||
JS_free(cx, sharpchars);
|
||||
cx->free(sharpchars);
|
||||
goto make_string;
|
||||
}
|
||||
#endif
|
||||
|
@ -1520,7 +1520,7 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
|
|||
}
|
||||
|
||||
/*
|
||||
* This object will take responsibility for the jschar buffer until the
|
||||
* This object will take responsibility for the jschar buffer until the
|
||||
* buffer is transferred to the returned JSString.
|
||||
*/
|
||||
JSTempVector<jschar> buf(cx);
|
||||
|
@ -2151,7 +2151,7 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
#endif
|
||||
vec = (jsval *) JS_malloc(cx, 2 * (size_t) len * sizeof(jsval));
|
||||
vec = (jsval *) cx->malloc(2 * (size_t) len * sizeof(jsval));
|
||||
if (!vec)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -2280,8 +2280,8 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
|
|||
} while (i != 0);
|
||||
|
||||
JS_ASSERT(tvr.u.array == vec);
|
||||
vec = (jsval *) JS_realloc(cx, vec,
|
||||
4 * (size_t) newlen * sizeof(jsval));
|
||||
vec = (jsval *) cx->realloc(vec,
|
||||
4 * (size_t) newlen * sizeof(jsval));
|
||||
if (!vec) {
|
||||
vec = tvr.u.array;
|
||||
ok = JS_FALSE;
|
||||
|
@ -2342,7 +2342,7 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
out:
|
||||
JS_POP_TEMP_ROOT(cx, &tvr);
|
||||
JS_free(cx, vec);
|
||||
cx->free(vec);
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -3507,7 +3507,7 @@ js_ArrayInfo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
if (JSVAL_IS_PRIMITIVE(argv[i]) ||
|
||||
!OBJ_IS_ARRAY(cx, (array = JSVAL_TO_OBJECT(argv[i])))) {
|
||||
fprintf(stderr, "%s: not array\n", bytes);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "%s: %s (len %lu", bytes,
|
||||
|
@ -3519,7 +3519,7 @@ js_ArrayInfo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
js_DenseArrayCapacity(array));
|
||||
}
|
||||
fputs(")\n", stderr);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
|
|
@ -207,6 +207,10 @@ JSBool
|
|||
js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, JSProperty *prop,
|
||||
jsval *vp);
|
||||
|
||||
/* Array constructor native. Exposed only so the JIT can know its address. */
|
||||
JSBool
|
||||
js_Array(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsarray_h___ */
|
||||
|
|
|
@ -783,7 +783,7 @@ js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
|
|||
str.initFlat(chars, inflatedLength);
|
||||
atom = js_AtomizeString(cx, &str, ATOM_TMPSTR | flags);
|
||||
if (chars != inflated && str.flatChars())
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return atom;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ js_BoxInt32(JSContext* cx, int32 i)
|
|||
if (!js_NewDoubleInRootedValue(cx, d, &v))
|
||||
return JSVAL_ERROR_COOKIE;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
JS_DEFINE_CALLINFO_2(extern, JSVAL, js_BoxInt32, CONTEXT, INT32, 1, 1)
|
||||
|
||||
jsdouble FASTCALL
|
||||
|
@ -242,8 +242,6 @@ JSBool FASTCALL
|
|||
js_AddProperty(JSContext* cx, JSObject* obj, JSScopeProperty* sprop)
|
||||
{
|
||||
JS_ASSERT(OBJ_IS_NATIVE(obj));
|
||||
JS_ASSERT(SPROP_HAS_STUB_SETTER(sprop));
|
||||
|
||||
JS_LOCK_OBJ(cx, obj);
|
||||
|
||||
JSScope* scope = OBJ_SCOPE(obj);
|
||||
|
|
|
@ -86,7 +86,7 @@ struct JSTraceableNative {
|
|||
const nanojit::CallInfo *builtin;
|
||||
const char *prefix;
|
||||
const char *argtypes;
|
||||
uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
|
||||
uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
|
||||
JSTN_CONSTRUCTOR */
|
||||
};
|
||||
|
||||
|
@ -117,7 +117,7 @@ struct JSTraceableNative {
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Supported types for builtin functions.
|
||||
* Supported types for builtin functions.
|
||||
*
|
||||
* Types with -- for the two string fields are not permitted as argument types
|
||||
* in JS_DEFINE_TRCINFO.
|
||||
|
@ -165,7 +165,7 @@ struct JSTraceableNative {
|
|||
* trace. If an exception is pending, it is thrown; otherwise, we assume the
|
||||
* builtin had no side effects and retry the current bytecode in the
|
||||
* interpreter.
|
||||
*
|
||||
*
|
||||
* So a builtin must not return a value indicating failure after causing side
|
||||
* effects (such as reporting an error), without setting an exception pending.
|
||||
* The operation would be retried, despite the first attempt's observable
|
||||
|
@ -187,6 +187,7 @@ struct JSTraceableNative {
|
|||
#define _JS_CTYPE_JSVAL _JS_JSVAL_CTYPE( _JS_PTR, "","v", INFALLIBLE)
|
||||
#define _JS_CTYPE_JSVAL_RETRY _JS_JSVAL_CTYPE( _JS_PTR, --, --, FAIL_COOKIE)
|
||||
#define _JS_CTYPE_JSVAL_FAIL _JS_JSVAL_CTYPE( _JS_PTR, --, --, FAIL_STATUS)
|
||||
#define _JS_CTYPE_JSID _JS_CTYPE(jsid, _JS_PTR, --, --, INFALLIBLE)
|
||||
#define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
|
||||
#define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_VOID)
|
||||
#define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
|
||||
|
@ -414,6 +415,9 @@ js_BooleanOrUndefinedToNumber(JSContext* cx, int32 unboxed);
|
|||
extern JS_FRIEND_API(void)
|
||||
js_SetTraceableNativeFailed(JSContext *cx);
|
||||
|
||||
extern jsdouble FASTCALL
|
||||
js_dmod(jsdouble a, jsdouble b);
|
||||
|
||||
#else
|
||||
|
||||
#define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, cse, fold)
|
||||
|
@ -444,6 +448,10 @@ JS_DECLARE_CALLINFO(js_ArrayCompPush)
|
|||
JS_DECLARE_CALLINFO(js_AllocFlatClosure)
|
||||
JS_DECLARE_CALLINFO(js_PutArguments)
|
||||
|
||||
/* Defined in jsfun.cpp. */
|
||||
JS_DECLARE_CALLINFO(js_SetCallVar)
|
||||
JS_DECLARE_CALLINFO(js_SetCallArg)
|
||||
|
||||
/* Defined in jsnum.cpp. */
|
||||
JS_DECLARE_CALLINFO(js_NumberToString)
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ static JSThread *
|
|||
NewThread(jsword id)
|
||||
{
|
||||
JS_ASSERT(js_CurrentThreadId() == id);
|
||||
JSThread *thread = (JSThread *) calloc(1, sizeof(JSThread));
|
||||
JSThread *thread = (JSThread *) js_calloc(sizeof(JSThread));
|
||||
if (!thread)
|
||||
return NULL;
|
||||
JS_INIT_CLIST(&thread->contextList);
|
||||
|
@ -158,7 +158,7 @@ DestroyThread(JSThread *thread)
|
|||
JS_ASSERT(JS_CLIST_IS_EMPTY(&thread->contextList));
|
||||
JS_ASSERT(!thread->titleToShare);
|
||||
FinishThreadData(&thread->data);
|
||||
free(thread);
|
||||
js_free(thread);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -370,7 +370,7 @@ js_NewContext(JSRuntime *rt, size_t stackChunkSize)
|
|||
* runtime list. After that it can be accessed from another thread via
|
||||
* js_ContextIterator.
|
||||
*/
|
||||
cx = (JSContext *) calloc(1, sizeof *cx);
|
||||
cx = (JSContext *) js_calloc(sizeof *cx);
|
||||
if (!cx)
|
||||
return NULL;
|
||||
|
||||
|
@ -743,14 +743,14 @@ FreeContext(JSContext *cx)
|
|||
JS_FinishArenaPool(&cx->tempPool);
|
||||
|
||||
if (cx->lastMessage)
|
||||
free(cx->lastMessage);
|
||||
js_free(cx->lastMessage);
|
||||
|
||||
/* Remove any argument formatters. */
|
||||
map = cx->argumentFormatMap;
|
||||
while (map) {
|
||||
JSArgumentFormatMap *temp = map;
|
||||
map = map->next;
|
||||
JS_free(cx, temp);
|
||||
cx->free(temp);
|
||||
}
|
||||
|
||||
/* Destroy the busy array table. */
|
||||
|
@ -769,13 +769,13 @@ FreeContext(JSContext *cx)
|
|||
if (lrs) {
|
||||
while ((lrc = lrs->topChunk) != &lrs->firstChunk) {
|
||||
lrs->topChunk = lrc->down;
|
||||
JS_free(cx, lrc);
|
||||
cx->free(lrc);
|
||||
}
|
||||
JS_free(cx, lrs);
|
||||
cx->free(lrs);
|
||||
}
|
||||
|
||||
/* Finally, free cx itself. */
|
||||
free(cx);
|
||||
js_free(cx);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -819,7 +819,7 @@ js_NextActiveContext(JSRuntime *rt, JSContext *cx)
|
|||
return cx;
|
||||
#else
|
||||
return js_ContextIterator(rt, JS_FALSE, &iter);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
@ -1013,7 +1013,7 @@ js_EnterLocalRootScope(JSContext *cx)
|
|||
|
||||
lrs = cx->localRootStack;
|
||||
if (!lrs) {
|
||||
lrs = (JSLocalRootStack *) JS_malloc(cx, sizeof *lrs);
|
||||
lrs = (JSLocalRootStack *) cx->malloc(sizeof *lrs);
|
||||
if (!lrs)
|
||||
return JS_FALSE;
|
||||
lrs->scopeMark = JSLRS_NULL_MARK;
|
||||
|
@ -1056,7 +1056,7 @@ js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval)
|
|||
lrc = lrs->topChunk;
|
||||
JS_ASSERT(lrc != &lrs->firstChunk);
|
||||
lrs->topChunk = lrc->down;
|
||||
JS_free(cx, lrc);
|
||||
cx->free(lrc);
|
||||
--n;
|
||||
}
|
||||
|
||||
|
@ -1096,10 +1096,10 @@ js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval)
|
|||
*/
|
||||
if (mark == 0) {
|
||||
cx->localRootStack = NULL;
|
||||
JS_free(cx, lrs);
|
||||
cx->free(lrs);
|
||||
} else if (m == 0) {
|
||||
lrs->topChunk = lrc->down;
|
||||
JS_free(cx, lrc);
|
||||
cx->free(lrc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ js_ForgetLocalRoot(JSContext *cx, jsval v)
|
|||
JS_ASSERT(n != 0);
|
||||
JS_ASSERT(lrc != &lrs->firstChunk);
|
||||
lrs->topChunk = lrc->down;
|
||||
JS_free(cx, lrc);
|
||||
cx->free(lrc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ js_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v)
|
|||
* After lrs->firstChunk, trying to index at a power-of-two chunk
|
||||
* boundary: need a new chunk.
|
||||
*/
|
||||
lrc = (JSLocalRootChunk *) JS_malloc(cx, sizeof *lrc);
|
||||
lrc = (JSLocalRootChunk *) cx->malloc(sizeof *lrc);
|
||||
if (!lrc)
|
||||
return -1;
|
||||
lrc->down = lrs->topChunk;
|
||||
|
@ -1380,8 +1380,8 @@ js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap)
|
|||
}
|
||||
|
||||
ReportError(cx, message, &report);
|
||||
free(message);
|
||||
JS_free(cx, ucmessage);
|
||||
js_free(message);
|
||||
cx->free(ucmessage);
|
||||
return warning;
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1432,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
|||
* pointers later.
|
||||
*/
|
||||
reportp->messageArgs = (const jschar **)
|
||||
JS_malloc(cx, sizeof(jschar *) * (argCount + 1));
|
||||
cx->malloc(sizeof(jschar *) * (argCount + 1));
|
||||
if (!reportp->messageArgs)
|
||||
return JS_FALSE;
|
||||
reportp->messageArgs[argCount] = NULL;
|
||||
|
@ -1476,9 +1476,9 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
|||
* is used once and only once in the expansion !!!
|
||||
*/
|
||||
reportp->ucmessage = out = (jschar *)
|
||||
JS_malloc(cx, (expandedLength + 1) * sizeof(jschar));
|
||||
cx->malloc((expandedLength + 1) * sizeof(jschar));
|
||||
if (!out) {
|
||||
JS_free (cx, buffer);
|
||||
cx->free(buffer);
|
||||
goto error;
|
||||
}
|
||||
while (*fmt) {
|
||||
|
@ -1498,7 +1498,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
|||
}
|
||||
JS_ASSERT(expandedArgs == argCount);
|
||||
*out = 0;
|
||||
JS_free (cx, buffer);
|
||||
cx->free(buffer);
|
||||
*messagep =
|
||||
js_DeflateString(cx, reportp->ucmessage,
|
||||
(size_t)(out - reportp->ucmessage));
|
||||
|
@ -1527,7 +1527,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
|||
const char *defaultErrorMessage
|
||||
= "No error message available for error number %d";
|
||||
size_t nbytes = strlen(defaultErrorMessage) + 16;
|
||||
*messagep = (char *)JS_malloc(cx, nbytes);
|
||||
*messagep = (char *)cx->malloc(nbytes);
|
||||
if (!*messagep)
|
||||
goto error;
|
||||
JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);
|
||||
|
@ -1540,17 +1540,17 @@ error:
|
|||
if (charArgs) {
|
||||
i = 0;
|
||||
while (reportp->messageArgs[i])
|
||||
JS_free(cx, (void *)reportp->messageArgs[i++]);
|
||||
cx->free((void *)reportp->messageArgs[i++]);
|
||||
}
|
||||
JS_free(cx, (void *)reportp->messageArgs);
|
||||
cx->free((void *)reportp->messageArgs);
|
||||
reportp->messageArgs = NULL;
|
||||
}
|
||||
if (reportp->ucmessage) {
|
||||
JS_free(cx, (void *)reportp->ucmessage);
|
||||
cx->free((void *)reportp->ucmessage);
|
||||
reportp->ucmessage = NULL;
|
||||
}
|
||||
if (*messagep) {
|
||||
JS_free(cx, (void *)*messagep);
|
||||
cx->free((void *)*messagep);
|
||||
*messagep = NULL;
|
||||
}
|
||||
return JS_FALSE;
|
||||
|
@ -1581,7 +1581,7 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
|||
ReportError(cx, message, &report);
|
||||
|
||||
if (message)
|
||||
JS_free(cx, message);
|
||||
cx->free(message);
|
||||
if (report.messageArgs) {
|
||||
/*
|
||||
* js_ExpandErrorArguments owns its messageArgs only if it had to
|
||||
|
@ -1590,12 +1590,12 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
|||
if (charArgs) {
|
||||
int i = 0;
|
||||
while (report.messageArgs[i])
|
||||
JS_free(cx, (void *)report.messageArgs[i++]);
|
||||
cx->free((void *)report.messageArgs[i++]);
|
||||
}
|
||||
JS_free(cx, (void *)report.messageArgs);
|
||||
cx->free((void *)report.messageArgs);
|
||||
}
|
||||
if (report.ucmessage)
|
||||
JS_free(cx, (void *)report.ucmessage);
|
||||
cx->free((void *)report.ucmessage);
|
||||
|
||||
return warning;
|
||||
}
|
||||
|
@ -1609,7 +1609,7 @@ js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
|
|||
return;
|
||||
|
||||
if (cx->lastMessage)
|
||||
free(cx->lastMessage);
|
||||
js_free(cx->lastMessage);
|
||||
cx->lastMessage = JS_strdup(cx, message);
|
||||
if (!cx->lastMessage)
|
||||
return;
|
||||
|
@ -1667,7 +1667,7 @@ js_ReportIsNullOrUndefined(JSContext *cx, intN spindex, jsval v,
|
|||
js_null_str, NULL);
|
||||
}
|
||||
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ js_ReportMissingArg(JSContext *cx, jsval *vp, uintN arg)
|
|||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_MISSING_FUN_ARG, argbuf,
|
||||
bytes ? bytes : "");
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -1709,7 +1709,7 @@ js_ReportValueErrorFlags(JSContext *cx, uintN flags, const uintN errorNumber,
|
|||
|
||||
ok = JS_ReportErrorFlagsAndNumber(cx, flags, js_GetErrorMessage,
|
||||
NULL, errorNumber, bytes, arg1, arg2);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -1738,10 +1738,10 @@ JSBool
|
|||
js_InvokeOperationCallback(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(cx->operationCallbackFlag);
|
||||
|
||||
|
||||
/*
|
||||
* Reset the callback flag first, then yield. If another thread is racing
|
||||
* us here we will accumulate another callback request which will be
|
||||
* us here we will accumulate another callback request which will be
|
||||
* serviced at the next opportunity.
|
||||
*/
|
||||
cx->operationCallbackFlag = 0;
|
||||
|
@ -1755,7 +1755,7 @@ js_InvokeOperationCallback(JSContext *cx)
|
|||
*/
|
||||
if (cx->runtime->gcIsNeeded)
|
||||
js_GC(cx, GC_NORMAL);
|
||||
#ifdef JS_THREADSAFE
|
||||
#ifdef JS_THREADSAFE
|
||||
else
|
||||
JS_YieldRequest(cx);
|
||||
#endif
|
||||
|
|
117
js/src/jscntxt.h
117
js/src/jscntxt.h
|
@ -57,6 +57,7 @@
|
|||
#include "jsregexp.h"
|
||||
#include "jsutil.h"
|
||||
#include "jsarray.h"
|
||||
#include "jstask.h"
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
|
@ -255,6 +256,13 @@ struct JSThreadData {
|
|||
* locks on each JS_malloc.
|
||||
*/
|
||||
size_t gcMallocBytes;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
/*
|
||||
* Deallocator task for this thread.
|
||||
*/
|
||||
JSFreePointerListTask *deallocatorTask;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
@ -391,7 +399,18 @@ struct JSRuntime {
|
|||
JSPackedBool gcPoke;
|
||||
JSPackedBool gcRunning;
|
||||
JSPackedBool gcRegenShapes;
|
||||
uint8 gcPadding;
|
||||
|
||||
/*
|
||||
* During gc, if rt->gcRegenShapes &&
|
||||
* (scope->flags & JSScope::SHAPE_REGEN) == rt->gcRegenShapesScopeFlag,
|
||||
* then the scope's shape has already been regenerated during this GC.
|
||||
* To avoid having to sweep JSScopes, the bit's meaning toggles with each
|
||||
* shape-regenerating GC.
|
||||
*
|
||||
* FIXME Once scopes are GC'd (bug 505004), this will be obsolete.
|
||||
*/
|
||||
uint8 gcRegenShapesScopeFlag;
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
jsrefcount gcZeal;
|
||||
#endif
|
||||
|
@ -688,6 +707,26 @@ struct JSRuntime {
|
|||
|
||||
void setGCTriggerFactor(uint32 factor);
|
||||
void setGCLastBytes(size_t lastBytes);
|
||||
|
||||
inline void* malloc(size_t bytes) {
|
||||
return ::js_malloc(bytes);
|
||||
}
|
||||
|
||||
inline void* calloc(size_t bytes) {
|
||||
return ::js_calloc(bytes);
|
||||
}
|
||||
|
||||
inline void* realloc(void* p, size_t bytes) {
|
||||
return ::js_realloc(p, bytes);
|
||||
}
|
||||
|
||||
inline void free(void* p) {
|
||||
::js_free(p);
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JSBackgroundThread *deallocatorThread;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Common macros to access thread-local caches in JSThread or JSRuntime. */
|
||||
|
@ -1039,16 +1078,86 @@ struct JSContext {
|
|||
jsval *nativeVp;
|
||||
#endif
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
inline void createDeallocatorTask() {
|
||||
JSThreadData* tls = JS_THREAD_DATA(this);
|
||||
JS_ASSERT(!tls->deallocatorTask);
|
||||
if (runtime->deallocatorThread && !runtime->deallocatorThread->busy())
|
||||
tls->deallocatorTask = new JSFreePointerListTask();
|
||||
}
|
||||
|
||||
inline void submitDeallocatorTask() {
|
||||
JSThreadData* tls = JS_THREAD_DATA(this);
|
||||
if (tls->deallocatorTask) {
|
||||
runtime->deallocatorThread->schedule(tls->deallocatorTask);
|
||||
tls->deallocatorTask = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Call this after succesful malloc of memory for GC-related things. */
|
||||
inline void
|
||||
updateMallocCounter(size_t nbytes)
|
||||
{
|
||||
inline void updateMallocCounter(size_t nbytes) {
|
||||
size_t *pbytes, bytes;
|
||||
|
||||
pbytes = &JS_THREAD_DATA(this)->gcMallocBytes;
|
||||
bytes = *pbytes;
|
||||
*pbytes = (size_t(-1) - bytes <= nbytes) ? size_t(-1) : bytes + nbytes;
|
||||
}
|
||||
|
||||
inline void* malloc(size_t bytes) {
|
||||
JS_ASSERT(bytes != 0);
|
||||
void *p = runtime->malloc(bytes);
|
||||
if (!p) {
|
||||
JS_ReportOutOfMemory(this);
|
||||
return NULL;
|
||||
}
|
||||
updateMallocCounter(bytes);
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void* calloc(size_t bytes) {
|
||||
JS_ASSERT(bytes != 0);
|
||||
void *p = runtime->calloc(bytes);
|
||||
if (!p) {
|
||||
JS_ReportOutOfMemory(this);
|
||||
return NULL;
|
||||
}
|
||||
updateMallocCounter(bytes);
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void* realloc(void* p, size_t bytes) {
|
||||
void *orig = p;
|
||||
p = runtime->realloc(p, bytes);
|
||||
if (!p) {
|
||||
JS_ReportOutOfMemory(this);
|
||||
return NULL;
|
||||
}
|
||||
if (!orig)
|
||||
updateMallocCounter(bytes);
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
inline void free(void* p) {
|
||||
if (!p)
|
||||
return;
|
||||
if (thread) {
|
||||
JSFreePointerListTask* task = JS_THREAD_DATA(this)->deallocatorTask;
|
||||
if (task) {
|
||||
task->add(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
runtime->free(p);
|
||||
}
|
||||
#else
|
||||
inline void free(void* p) {
|
||||
if (!p)
|
||||
return;
|
||||
runtime->free(p);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
|
|
@ -1961,7 +1961,7 @@ date_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
str = JS_NewString(cx, bytes, strlen(bytes));
|
||||
if (!str) {
|
||||
free(bytes);
|
||||
js_free(bytes);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
|
|
@ -124,6 +124,10 @@ typedef uint32 JSIntervalTime;
|
|||
extern JS_FRIEND_API(JSIntervalTime)
|
||||
js_IntervalNow();
|
||||
|
||||
/* Date constructor native. Exposed only so the JIT can know its address. */
|
||||
JSBool
|
||||
js_Date(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdate_h___ */
|
||||
|
|
|
@ -123,7 +123,7 @@ js_UntrapScriptCode(JSContext *cx, JSScript *script)
|
|||
continue;
|
||||
nbytes += (sn - notes + 1) * sizeof *sn;
|
||||
|
||||
code = (jsbytecode *) JS_malloc(cx, nbytes);
|
||||
code = (jsbytecode *) cx->malloc(nbytes);
|
||||
if (!code)
|
||||
break;
|
||||
memcpy(code, script->code, nbytes);
|
||||
|
@ -155,12 +155,12 @@ JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
} else {
|
||||
sample = rt->debuggerMutations;
|
||||
DBG_UNLOCK(rt);
|
||||
trap = (JSTrap *) JS_malloc(cx, sizeof *trap);
|
||||
trap = (JSTrap *) cx->malloc(sizeof *trap);
|
||||
if (!trap)
|
||||
return JS_FALSE;
|
||||
trap->closure = NULL;
|
||||
if(!js_AddRoot(cx, &trap->closure, "trap->closure")) {
|
||||
JS_free(cx, trap);
|
||||
cx->free(trap);
|
||||
return JS_FALSE;
|
||||
}
|
||||
DBG_LOCK(rt);
|
||||
|
@ -184,7 +184,7 @@ JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
|||
DBG_UNLOCK(rt);
|
||||
if (junk) {
|
||||
js_RemoveRoot(rt, &junk->closure);
|
||||
JS_free(cx, junk);
|
||||
cx->free(junk);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ DestroyTrapAndUnlock(JSContext *cx, JSTrap *trap)
|
|||
DBG_UNLOCK(cx->runtime);
|
||||
|
||||
js_RemoveRoot(cx->runtime, &trap->closure);
|
||||
JS_free(cx, trap);
|
||||
cx->free(trap);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
@ -413,7 +413,7 @@ DropWatchPointAndUnlock(JSContext *cx, JSWatchPoint *wp, uintN flag)
|
|||
}
|
||||
}
|
||||
|
||||
JS_free(cx, wp);
|
||||
cx->free(wp);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ js_TraceWatchPoints(JSTracer *trc, JSObject *obj)
|
|||
&wp->links != &rt->watchPointList;
|
||||
wp = (JSWatchPoint *)wp->links.next) {
|
||||
if (wp->object == obj) {
|
||||
TRACE_SCOPE_PROPERTY(trc, wp->sprop);
|
||||
wp->sprop->trace(trc);
|
||||
if ((wp->sprop->attrs & JSPROP_SETTER) && wp->setter) {
|
||||
JS_CALL_OBJECT_TRACER(trc, js_CastAsObject(wp->setter),
|
||||
"wp->setter");
|
||||
|
@ -619,7 +619,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
if (nslots <= JS_ARRAY_LENGTH(smallv)) {
|
||||
argv = smallv;
|
||||
} else {
|
||||
argv = (jsval *) JS_malloc(cx, nslots * sizeof(jsval));
|
||||
argv = (jsval *) cx->malloc(nslots * sizeof(jsval));
|
||||
if (!argv) {
|
||||
DBG_LOCK(rt);
|
||||
DropWatchPointAndUnlock(cx, wp, JSWP_HELD);
|
||||
|
@ -651,7 +651,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
JSFUN_HEAVYWEIGHT_TEST(fun->flags) &&
|
||||
!js_GetCallObject(cx, &frame)) {
|
||||
if (argv != smallv)
|
||||
JS_free(cx, argv);
|
||||
cx->free(argv);
|
||||
DBG_LOCK(rt);
|
||||
DropWatchPointAndUnlock(cx, wp, JSWP_HELD);
|
||||
return JS_FALSE;
|
||||
|
@ -679,7 +679,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
cx->fp = frame.down;
|
||||
if (argv != smallv)
|
||||
JS_free(cx, argv);
|
||||
cx->free(argv);
|
||||
}
|
||||
}
|
||||
DBG_LOCK(rt);
|
||||
|
@ -825,7 +825,7 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval idval,
|
|||
goto out;
|
||||
}
|
||||
|
||||
wp = (JSWatchPoint *) JS_malloc(cx, sizeof *wp);
|
||||
wp = (JSWatchPoint *) cx->malloc(sizeof *wp);
|
||||
if (!wp) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -1343,7 +1343,7 @@ JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
|
|||
length = (uintN) len;
|
||||
ok = JS_EvaluateUCInStackFrame(cx, fp, chars, length, filename, lineno,
|
||||
rval);
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda)
|
|||
}
|
||||
|
||||
n = scope->entryCount;
|
||||
pd = (JSPropertyDesc *) JS_malloc(cx, (size_t)n * sizeof(JSPropertyDesc));
|
||||
pd = (JSPropertyDesc *) cx->malloc((size_t)n * sizeof(JSPropertyDesc));
|
||||
if (!pd)
|
||||
return JS_FALSE;
|
||||
i = 0;
|
||||
|
@ -1511,7 +1511,7 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda)
|
|||
if (pd[i].flags & JSPD_ALIAS)
|
||||
js_RemoveRoot(cx->runtime, &pd[i].alias);
|
||||
}
|
||||
JS_free(cx, pd);
|
||||
cx->free(pd);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -1884,7 +1884,7 @@ js_DumpCallgrind(JSContext *cx, JSObject *obj,
|
|||
cstr = js_DeflateString(cx, str->chars(), str->length());
|
||||
if (cstr) {
|
||||
CALLGRIND_DUMP_STATS_AT(cstr);
|
||||
JS_free(cx, cstr);
|
||||
cx->free(cstr);
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1962,7 +1962,7 @@ js_StartVtune(JSContext *cx, JSObject *obj,
|
|||
status = VTStartSampling(¶ms);
|
||||
|
||||
if (params.tb5Filename != default_filename)
|
||||
JS_free(cx, params.tb5Filename);
|
||||
cx->free(params.tb5Filename);
|
||||
|
||||
if (status != 0) {
|
||||
if (status == VTAPI_MULTIPLE_RUNS)
|
||||
|
|
|
@ -111,13 +111,13 @@
|
|||
JS_PUBLIC_API(void *)
|
||||
JS_DHashAllocTable(JSDHashTable *table, uint32 nbytes)
|
||||
{
|
||||
return malloc(nbytes);
|
||||
return js_malloc(nbytes);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DHashFreeTable(JSDHashTable *table, void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
js_free(ptr);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSDHashNumber)
|
||||
|
@ -180,7 +180,7 @@ JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry)
|
|||
{
|
||||
const JSDHashEntryStub *stub = (const JSDHashEntryStub *)entry;
|
||||
|
||||
free((void *) stub->key);
|
||||
js_free((void *) stub->key);
|
||||
memset(entry, 0, table->entrySize);
|
||||
}
|
||||
|
||||
|
@ -212,11 +212,11 @@ JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32 entrySize,
|
|||
{
|
||||
JSDHashTable *table;
|
||||
|
||||
table = (JSDHashTable *) malloc(sizeof *table);
|
||||
table = (JSDHashTable *) js_malloc(sizeof *table);
|
||||
if (!table)
|
||||
return NULL;
|
||||
if (!JS_DHashTableInit(table, ops, data, entrySize, capacity)) {
|
||||
free(table);
|
||||
js_free(table);
|
||||
return NULL;
|
||||
}
|
||||
return table;
|
||||
|
@ -226,7 +226,7 @@ JS_PUBLIC_API(void)
|
|||
JS_DHashTableDestroy(JSDHashTable *table)
|
||||
{
|
||||
JS_DHashTableFinish(table);
|
||||
free(table);
|
||||
js_free(table);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
|
|
@ -368,7 +368,7 @@ JS_dtobasestr(int base, double dinput)
|
|||
JS_ASSERT(base >= 2 && base <= 36);
|
||||
|
||||
dval(d) = dinput;
|
||||
buffer = (char*) malloc(DTOBASESTR_BUFFER_SIZE);
|
||||
buffer = (char*) js_malloc(DTOBASESTR_BUFFER_SIZE);
|
||||
if (buffer) {
|
||||
p = buffer;
|
||||
if (dval(d) < 0.0
|
||||
|
@ -412,7 +412,7 @@ JS_dtobasestr(int base, double dinput)
|
|||
nomem1:
|
||||
Bfree(b);
|
||||
UNLOCK_DTOA();
|
||||
free(buffer);
|
||||
js_free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
do {
|
||||
|
@ -449,7 +449,7 @@ JS_dtobasestr(int base, double dinput)
|
|||
Bfree(mlo);
|
||||
Bfree(mhi);
|
||||
UNLOCK_DTOA();
|
||||
free(buffer);
|
||||
js_free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
JS_ASSERT(e < 0);
|
||||
|
|
|
@ -112,10 +112,10 @@ JSCodeGenerator::~JSCodeGenerator()
|
|||
|
||||
/* NB: non-null only after OOM. */
|
||||
if (spanDeps)
|
||||
JS_free(compiler->context, spanDeps);
|
||||
compiler->context->free(spanDeps);
|
||||
|
||||
if (upvarMap.vector)
|
||||
JS_free(compiler->context, upvarMap.vector);
|
||||
compiler->context->free(upvarMap.vector);
|
||||
}
|
||||
|
||||
static ptrdiff_t
|
||||
|
@ -549,7 +549,7 @@ AddSpanDep(JSContext *cx, JSCodeGenerator *cg, jsbytecode *pc, jsbytecode *pc2,
|
|||
if ((index & (index - 1)) == 0 &&
|
||||
(!(sdbase = cg->spanDeps) || index >= SPANDEPS_MIN)) {
|
||||
size = sdbase ? SPANDEPS_SIZE(index) : SPANDEPS_SIZE_MIN / 2;
|
||||
sdbase = (JSSpanDep *) JS_realloc(cx, sdbase, size + size);
|
||||
sdbase = (JSSpanDep *) cx->realloc(sdbase, size + size);
|
||||
if (!sdbase)
|
||||
return JS_FALSE;
|
||||
cg->spanDeps = sdbase;
|
||||
|
@ -1165,7 +1165,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
|
|||
* can span top-level statements, because JS lacks goto.
|
||||
*/
|
||||
size = SPANDEPS_SIZE(JS_BIT(JS_CeilingLog2(cg->numSpanDeps)));
|
||||
JS_free(cx, cg->spanDeps);
|
||||
cx->free(cg->spanDeps);
|
||||
cg->spanDeps = NULL;
|
||||
FreeJumpTargets(cg, cg->jumpTargets);
|
||||
cg->jumpTargets = NULL;
|
||||
|
@ -1899,7 +1899,7 @@ MakeUpvarForEval(JSParseNode *pn, JSCodeGenerator *cg)
|
|||
JS_ASSERT(ALE_INDEX(ale) <= length);
|
||||
if (ALE_INDEX(ale) == length) {
|
||||
length = 2 * JS_MAX(2, length);
|
||||
vector = (uint32 *) JS_realloc(cx, vector, length * sizeof *vector);
|
||||
vector = (uint32 *) cx->realloc(vector, length * sizeof *vector);
|
||||
if (!vector)
|
||||
return false;
|
||||
cg->upvarMap.vector = vector;
|
||||
|
@ -2197,7 +2197,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
if (!vector) {
|
||||
uint32 length = cg->lexdeps.count;
|
||||
|
||||
vector = (uint32 *) calloc(length, sizeof *vector);
|
||||
vector = (uint32 *) js_calloc(length * sizeof *vector);
|
||||
if (!vector) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -3144,9 +3144,8 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||
/* Just grab 8K for the worst-case bitmap. */
|
||||
intmap_bitlen = JS_BIT(16);
|
||||
intmap = (jsbitmap *)
|
||||
JS_malloc(cx,
|
||||
(JS_BIT(16) >> JS_BITS_PER_WORD_LOG2)
|
||||
* sizeof(jsbitmap));
|
||||
cx->malloc((JS_BIT(16) >> JS_BITS_PER_WORD_LOG2)
|
||||
* sizeof(jsbitmap));
|
||||
if (!intmap) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -3163,7 +3162,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||
|
||||
release:
|
||||
if (intmap && intmap != intmap_space)
|
||||
JS_free(cx, intmap);
|
||||
cx->free(intmap);
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -3307,7 +3306,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||
*/
|
||||
if (tableLength != 0) {
|
||||
tableSize = (size_t)tableLength * sizeof *table;
|
||||
table = (JSParseNode **) JS_malloc(cx, tableSize);
|
||||
table = (JSParseNode **) cx->malloc(tableSize);
|
||||
if (!table)
|
||||
return JS_FALSE;
|
||||
memset(table, 0, tableSize);
|
||||
|
@ -3475,7 +3474,7 @@ EmitSwitch(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
|
|||
|
||||
out:
|
||||
if (table)
|
||||
JS_free(cx, table);
|
||||
cx->free(table);
|
||||
if (ok) {
|
||||
ok = js_PopStatementCG(cx, cg);
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ CopyErrorReport(JSContext *cx, JSErrorReport *report)
|
|||
*/
|
||||
mallocSize = sizeof(JSErrorReport) + argsArraySize + argsCopySize +
|
||||
ucmessageSize + uclinebufSize + linebufSize + filenameSize;
|
||||
cursor = (uint8 *)JS_malloc(cx, mallocSize);
|
||||
cursor = (uint8 *)cx->malloc(mallocSize);
|
||||
if (!cursor)
|
||||
return NULL;
|
||||
|
||||
|
@ -301,7 +301,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
|
|||
js_ReportAllocationOverflow(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
priv = (JSExnPrivate *)JS_malloc(cx, size);
|
||||
priv = (JSExnPrivate *)cx->malloc(size);
|
||||
if (!priv)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -417,8 +417,8 @@ exn_finalize(JSContext *cx, JSObject *obj)
|
|||
priv = GetExnPrivate(cx, obj);
|
||||
if (priv) {
|
||||
if (priv->errorReport)
|
||||
JS_free(cx, priv->errorReport);
|
||||
JS_free(cx, priv);
|
||||
cx->free(priv->errorReport);
|
||||
cx->free(priv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
|||
if (stackmax >= STACK_LENGTH_LIMIT) \
|
||||
goto done; \
|
||||
stackmax = stackmax ? 2 * stackmax : 64; \
|
||||
ptr_ = JS_realloc(cx, stackbuf, (stackmax+1) * sizeof(jschar)); \
|
||||
ptr_ = cx->realloc(stackbuf, (stackmax+1) * sizeof(jschar)); \
|
||||
if (!ptr_) \
|
||||
goto bad; \
|
||||
stackbuf = (jschar *) ptr_; \
|
||||
|
@ -608,7 +608,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
|||
goto done; \
|
||||
} \
|
||||
stackmax = JS_BIT(JS_CeilingLog2(stacklen + length_)); \
|
||||
ptr_ = JS_realloc(cx, stackbuf, (stackmax+1) * sizeof(jschar)); \
|
||||
ptr_ = cx->realloc(stackbuf, (stackmax+1) * sizeof(jschar)); \
|
||||
if (!ptr_) \
|
||||
goto bad; \
|
||||
stackbuf = (jschar *) ptr_; \
|
||||
|
@ -659,7 +659,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
|||
* don't use JS_realloc here; simply let the oversized allocation
|
||||
* be owned by the string in that rare case.
|
||||
*/
|
||||
void *shrunk = JS_realloc(cx, stackbuf, (stacklen+1) * sizeof(jschar));
|
||||
void *shrunk = cx->realloc(stackbuf, (stacklen+1) * sizeof(jschar));
|
||||
if (shrunk)
|
||||
stackbuf = (jschar *) shrunk;
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
|||
|
||||
bad:
|
||||
if (stackbuf)
|
||||
JS_free(cx, stackbuf);
|
||||
cx->free(stackbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ exn_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
name_length = name->length();
|
||||
message_length = message->length();
|
||||
length = (name_length ? name_length + 2 : 0) + message_length;
|
||||
cp = chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
cp = chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -815,7 +815,7 @@ exn_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
result = js_NewString(cx, chars, length);
|
||||
if (!result) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
|
@ -915,7 +915,7 @@ exn_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
}
|
||||
|
||||
cp = chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
cp = chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -955,7 +955,7 @@ exn_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
result = js_NewString(cx, chars, length);
|
||||
if (!result) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ static char*
|
|||
js_combinePath(JSContext *cx, const char *base, const char *name)
|
||||
{
|
||||
int len = strlen(base);
|
||||
char* result = JS_malloc(cx, len + strlen(name) + 2);
|
||||
char* result = cx->malloc(len + strlen(name) + 2);
|
||||
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
@ -335,7 +335,7 @@ js_fileBaseName(JSContext *cx, const char *pathname)
|
|||
}
|
||||
|
||||
/* Allocate and copy. */
|
||||
result = JS_malloc(cx, aux - index + 1);
|
||||
result = cx->malloc(aux - index + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
strncpy(result, pathname + index + 1, aux - index);
|
||||
|
@ -366,7 +366,7 @@ js_fileDirectoryName(JSContext *cx, const char *pathname)
|
|||
|
||||
if (cp < pathname && end != pathname) {
|
||||
/* There were just /s, return the root. */
|
||||
result = JS_malloc(cx, 1 + 1); /* The separator + trailing NUL. */
|
||||
result = cx->malloc(1 + 1); /* The separator + trailing NUL. */
|
||||
result[0] = FILESEPARATOR;
|
||||
result[1] = '\0';
|
||||
return result;
|
||||
|
@ -388,7 +388,7 @@ js_fileDirectoryName(JSContext *cx, const char *pathname)
|
|||
}
|
||||
|
||||
pathsize = end - pathname + 1;
|
||||
result = JS_malloc(cx, pathsize + 1);
|
||||
result = cx->malloc(pathsize + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
@ -401,7 +401,7 @@ js_fileDirectoryName(JSContext *cx, const char *pathname)
|
|||
|
||||
/* Return everything up to and including the seperator. */
|
||||
pathsize = cp - pathname + 1;
|
||||
result = JS_malloc(cx, pathsize + 1);
|
||||
result = cx->malloc(pathsize + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
@ -462,7 +462,7 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
while (j >= 0 && path[j] == ' ')
|
||||
j--;
|
||||
|
||||
tmp = JS_malloc(cx, j-i+2);
|
||||
tmp = cx->malloc(j-i+2);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
|
||||
|
@ -478,7 +478,7 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
/* file:// support. */
|
||||
if (!strncmp(path, URL_PREFIX, strlen(URL_PREFIX))) {
|
||||
tmp = js_canonicalPath(cx, path + strlen(URL_PREFIX));
|
||||
JS_free(cx, path);
|
||||
cx->free(path);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
tmp = js_absolutePath(cx, path);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
JS_free(cx, path);
|
||||
cx->free(path);
|
||||
path = tmp;
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
back--;
|
||||
} else {
|
||||
tmp = result;
|
||||
result = JS_malloc(cx, strlen(base) + 1 + strlen(tmp) + 1);
|
||||
result = cx->malloc(strlen(base) + 1 + strlen(tmp) + 1);
|
||||
if (!result)
|
||||
goto out;
|
||||
|
||||
|
@ -516,18 +516,18 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
result[c + 1] = '\0';
|
||||
strcat(result, tmp);
|
||||
}
|
||||
JS_free(cx, tmp);
|
||||
cx->free(tmp);
|
||||
}
|
||||
}
|
||||
JS_free(cx, current);
|
||||
JS_free(cx, base);
|
||||
cx->free(current);
|
||||
cx->free(base);
|
||||
current = dir;
|
||||
base = js_fileBaseName(cx, current);
|
||||
dir = js_fileDirectoryName(cx, current);
|
||||
}
|
||||
|
||||
tmp = result;
|
||||
result = JS_malloc(cx, strlen(dir)+1+strlen(tmp)+1);
|
||||
result = cx->malloc(strlen(dir) + 1 + strlen(tmp) + 1);
|
||||
if (!result)
|
||||
goto out;
|
||||
|
||||
|
@ -543,13 +543,13 @@ js_canonicalPath(JSContext *cx, char *oldpath)
|
|||
|
||||
out:
|
||||
if (tmp)
|
||||
JS_free(cx, tmp);
|
||||
cx->free(tmp);
|
||||
if (dir)
|
||||
JS_free(cx, dir);
|
||||
cx->free(dir);
|
||||
if (base)
|
||||
JS_free(cx, base);
|
||||
cx->free(base);
|
||||
if (current)
|
||||
JS_free(cx, current);
|
||||
cx->free(current);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ js_FileHasOption(JSContext *cx, const char *oldoptions, const char *name)
|
|||
break;
|
||||
current = comma + 1;
|
||||
}
|
||||
JS_free(cx, options);
|
||||
cx->free(options);
|
||||
return found;
|
||||
}
|
||||
|
||||
|
@ -838,20 +838,20 @@ js_FileRead(JSContext *cx, JSFile *file, jschar *buf, int32 len, int32 mode)
|
|||
|
||||
switch (mode) {
|
||||
case ASCII:
|
||||
aux = (unsigned char*)JS_malloc(cx, len);
|
||||
aux = (unsigned char*)cx->malloc(len);
|
||||
if (!aux)
|
||||
return 0;
|
||||
|
||||
count = js_BufferedRead(file, aux, len);
|
||||
if (count == -1) {
|
||||
JS_free(cx, aux);
|
||||
cx->free(aux);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = (jschar)aux[i];
|
||||
|
||||
JS_free(cx, aux);
|
||||
cx->free(aux);
|
||||
break;
|
||||
|
||||
case UTF8:
|
||||
|
@ -977,7 +977,7 @@ js_FileWrite(JSContext *cx, JSFile *file, jschar *buf, int32 len, int32 mode)
|
|||
|
||||
switch (mode) {
|
||||
case ASCII:
|
||||
aux = (unsigned char*)JS_malloc(cx, len);
|
||||
aux = (unsigned char*)cx->malloc(len);
|
||||
if (!aux)
|
||||
return 0;
|
||||
|
||||
|
@ -989,21 +989,21 @@ js_FileWrite(JSContext *cx, JSFile *file, jschar *buf, int32 len, int32 mode)
|
|||
: fwrite(aux, 1, len, file->nativehandle);
|
||||
|
||||
if (count==-1) {
|
||||
JS_free(cx, aux);
|
||||
cx->free(aux);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JS_free(cx, aux);
|
||||
cx->free(aux);
|
||||
break;
|
||||
|
||||
case UTF8:
|
||||
utfbuf = (unsigned char*)JS_malloc(cx, len*3);
|
||||
utfbuf = (unsigned char*)cx->malloc(len*3);
|
||||
if (!utfbuf) return 0;
|
||||
i = 0;
|
||||
for (count = 0;count<len;count++) {
|
||||
j = one_ucs2_to_utf8_char(utfbuf+i, utfbuf+len*3, buf[count]);
|
||||
if (j==-1) {
|
||||
JS_free(cx, utfbuf);
|
||||
cx->free(utfbuf);
|
||||
return 0;
|
||||
}
|
||||
i+=j;
|
||||
|
@ -1013,10 +1013,10 @@ js_FileWrite(JSContext *cx, JSFile *file, jschar *buf, int32 len, int32 mode)
|
|||
: fwrite(utfbuf, 1, i, file->nativehandle);
|
||||
|
||||
if (j<i) {
|
||||
JS_free(cx, utfbuf);
|
||||
cx->free(utfbuf);
|
||||
return 0;
|
||||
}
|
||||
JS_free(cx, utfbuf);
|
||||
cx->free(utfbuf);
|
||||
break;
|
||||
|
||||
case UCS2:
|
||||
|
@ -1179,13 +1179,13 @@ js_parent(JSContext *cx, JSFile *file, jsval *resultp)
|
|||
} else {
|
||||
JSObject *obj = js_NewFileObject(cx, str);
|
||||
if (!obj) {
|
||||
JS_free(cx, str);
|
||||
cx->free(str);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*resultp = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
|
||||
JS_free(cx, str);
|
||||
cx->free(str);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1206,7 @@ js_name(JSContext *cx, JSFile *file, jsval *vp)
|
|||
|
||||
str = JS_NewString(cx, name, strlen(name));
|
||||
if (!str) {
|
||||
JS_free(cx, name);
|
||||
cx->free(name);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1353,7 +1353,7 @@ file_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
pipemode[i++] = '\0';
|
||||
file->nativehandle = POPEN(&file->path[1], pipemode);
|
||||
} else if(file->path[len-1] == PIPE_SYMBOL) {
|
||||
char *command = JS_malloc(cx, len);
|
||||
char *command = cx->malloc(len);
|
||||
|
||||
strncpy(command, file->path, len-1);
|
||||
command[len-1] = '\0';
|
||||
|
@ -1364,7 +1364,7 @@ file_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
#endif
|
||||
pipemode[i++] = '\0';
|
||||
file->nativehandle = POPEN(command, pipemode);
|
||||
JS_free(cx, command);
|
||||
cx->free(command);
|
||||
}
|
||||
/* set the flags */
|
||||
file->isNative = JS_TRUE;
|
||||
|
@ -1377,7 +1377,7 @@ file_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
}
|
||||
|
||||
js_ResetBuffers(file);
|
||||
JS_free(cx, mode);
|
||||
cx->free(mode);
|
||||
mode = NULL;
|
||||
|
||||
/* Set the open flag and return result */
|
||||
|
@ -1396,7 +1396,7 @@ good:
|
|||
|
||||
out:
|
||||
if(mode)
|
||||
JS_free(cx, mode);
|
||||
cx->free(mode);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1511,13 +1511,13 @@ file_copyTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
goto out;
|
||||
}
|
||||
|
||||
buffer = JS_malloc(cx, size);
|
||||
buffer = cx->malloc(size);
|
||||
|
||||
count = INT_TO_JSVAL(PR_Read(file->handle, buffer, size));
|
||||
|
||||
/* reading panic */
|
||||
if (count!=size) {
|
||||
JS_free(cx, buffer);
|
||||
cx->free(buffer);
|
||||
JS_ReportErrorNumber(cx, JSFile_GetErrorMessage, NULL,
|
||||
JSFILEMSG_COPY_READ_ERROR, file->path);
|
||||
goto out;
|
||||
|
@ -1527,13 +1527,13 @@ file_copyTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
|
||||
/* writing panic */
|
||||
if (count!=size) {
|
||||
JS_free(cx, buffer);
|
||||
cx->free(buffer);
|
||||
JS_ReportErrorNumber(cx, JSFile_GetErrorMessage, NULL,
|
||||
JSFILEMSG_COPY_WRITE_ERROR, file->path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
JS_free(cx, buffer);
|
||||
cx->free(buffer);
|
||||
|
||||
if(!fileInitiallyOpen){
|
||||
if(!file_close(cx, obj, 0, NULL, rval)) goto out;
|
||||
|
@ -1577,7 +1577,7 @@ file_renameTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
|
||||
if (PR_Rename(file->path, dest)==PR_SUCCESS){
|
||||
/* copy the new filename */
|
||||
JS_free(cx, file->path);
|
||||
cx->free(file->path);
|
||||
file->path = dest;
|
||||
*rval = JSVAL_TRUE;
|
||||
return JS_TRUE;
|
||||
|
@ -1729,17 +1729,17 @@ file_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
|
||||
/* want = (want>262144)?262144:want; * arbitrary size limitation */
|
||||
|
||||
buf = JS_malloc(cx, want*sizeof buf[0]);
|
||||
buf = cx->malloc(want*sizeof buf[0]);
|
||||
if (!buf) goto out;
|
||||
|
||||
count = js_FileRead(cx, file, buf, want, file->type);
|
||||
if (count>0) {
|
||||
str = JS_NewUCStringCopyN(cx, buf, count);
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
JS_free(cx, buf);
|
||||
cx->free(buf);
|
||||
return JS_TRUE;
|
||||
} else {
|
||||
JS_free(cx, buf);
|
||||
cx->free(buf);
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
|
@ -1760,7 +1760,7 @@ file_readln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
SECURITY_CHECK(cx, NULL, "readln", file);
|
||||
JSFILE_CHECK_READ;
|
||||
|
||||
buf = JS_malloc(cx, MAX_LINE_LENGTH * sizeof data);
|
||||
buf = cx->malloc(MAX_LINE_LENGTH * sizeof data);
|
||||
if (!buf)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -1792,8 +1792,7 @@ file_readln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
|
||||
default:
|
||||
if (--room < 0) {
|
||||
tmp = JS_realloc(cx, buf,
|
||||
(offset + MAX_LINE_LENGTH) * sizeof data);
|
||||
tmp = cx->realloc(buf, (offset + MAX_LINE_LENGTH) * sizeof data);
|
||||
if (!tmp)
|
||||
goto out;
|
||||
|
||||
|
@ -1814,7 +1813,7 @@ eof:
|
|||
|
||||
done:
|
||||
buf[offset] = 0;
|
||||
tmp = JS_realloc(cx, buf, (offset + 1) * sizeof data);
|
||||
tmp = cx->realloc(buf, (offset + 1) * sizeof data);
|
||||
if (!tmp)
|
||||
goto out;
|
||||
|
||||
|
@ -1827,7 +1826,7 @@ done:
|
|||
|
||||
out:
|
||||
if (buf)
|
||||
JS_free(cx, buf);
|
||||
cx->free(buf);
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1980,7 +1979,7 @@ file_list(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
filePath = js_combinePath(cx, file->path, (char*)entry->name);
|
||||
|
||||
eachFile = js_NewFileObject(cx, filePath);
|
||||
JS_free(cx, filePath);
|
||||
cx->free(filePath);
|
||||
if (!eachFile){
|
||||
JS_ReportWarning(cx, "File %s cannot be retrieved", filePath);
|
||||
continue;
|
||||
|
@ -2017,7 +2016,7 @@ file_mkdir(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
char *dir = js_fileDirectoryName(cx, file->path);
|
||||
JSObject *dirObj = js_NewFileObject(cx, dir);
|
||||
|
||||
JS_free(cx, dir);
|
||||
cx->free(dir);
|
||||
|
||||
/* call file_mkdir with the right set of parameters if needed */
|
||||
if (file_mkdir(cx, dirObj, argc, argv, rval))
|
||||
|
@ -2031,12 +2030,12 @@ file_mkdir(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
fullName = js_combinePath(cx, file->path, dirName);
|
||||
if (PR_MkDir(fullName, 0755)==PR_SUCCESS){
|
||||
*rval = JSVAL_TRUE;
|
||||
JS_free(cx, fullName);
|
||||
cx->free(fullName);
|
||||
return JS_TRUE;
|
||||
}else{
|
||||
JS_ReportErrorNumber(cx, JSFile_GetErrorMessage, NULL,
|
||||
JSFILEMSG_OP_FAILED, "mkdir", fullName);
|
||||
JS_free(cx, fullName);
|
||||
cx->free(fullName);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -2077,7 +2076,7 @@ file_toURL(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
return JS_FALSE;
|
||||
str = js_NewString(cx, urlChars, len);
|
||||
if (!str) {
|
||||
JS_free(cx, urlChars);
|
||||
cx->free(urlChars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
|
@ -2104,9 +2103,9 @@ file_finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
if (file->path)
|
||||
JS_free(cx, file->path);
|
||||
cx->free(file->path);
|
||||
|
||||
JS_free(cx, file);
|
||||
cx->free(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2118,7 +2117,7 @@ file_init(JSContext *cx, JSObject *obj, char *bytes)
|
|||
{
|
||||
JSFile *file;
|
||||
|
||||
file = JS_malloc(cx, sizeof *file);
|
||||
file = cx->malloc(sizeof *file);
|
||||
if (!file)
|
||||
return NULL;
|
||||
memset(file, 0 , sizeof *file);
|
||||
|
@ -2130,7 +2129,7 @@ file_init(JSContext *cx, JSObject *obj, char *bytes)
|
|||
if (!JS_SetPrivate(cx, obj, file)) {
|
||||
JS_ReportErrorNumber(cx, JSFile_GetErrorMessage, NULL,
|
||||
JSFILEMSG_CANNOT_SET_PRIVATE_FILE, file->path);
|
||||
JS_free(cx, file);
|
||||
cx->free(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2176,7 +2175,7 @@ js_NewFileObjectFromFILE(JSContext *cx, FILE *nativehandle, char *filename,
|
|||
|
||||
/* free result of RESOLVE_PATH from file_init. */
|
||||
JS_ASSERT(file->path != NULL);
|
||||
JS_free(cx, file->path);
|
||||
cx->free(file->path);
|
||||
|
||||
file->path = strdup(filename);
|
||||
file->isOpen = open;
|
||||
|
@ -2399,7 +2398,7 @@ file_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
case FILE_MODE:
|
||||
SECURITY_CHECK(cx, NULL, "mode", file);
|
||||
JSFILE_CHECK_OPEN("mode");
|
||||
bytes = JS_malloc(cx, MODE_SIZE);
|
||||
bytes = cx->malloc(MODE_SIZE);
|
||||
bytes[0] = '\0';
|
||||
flag = JS_FALSE;
|
||||
|
||||
|
@ -2439,7 +2438,7 @@ file_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
flag = JS_TRUE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, bytes));
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
break;
|
||||
case FILE_CREATED:
|
||||
SECURITY_CHECK(cx, NULL, "creationTime", file);
|
||||
|
@ -2575,7 +2574,7 @@ file_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
bytes = js_combinePath(cx, file->path, prop_name);
|
||||
*vp = OBJECT_TO_JSVAL(js_NewFileObject(cx, bytes));
|
||||
PR_CloseDir(dir);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
return !JSVAL_IS_NULL(*vp);
|
||||
}
|
||||
}
|
||||
|
@ -2717,10 +2716,10 @@ js_InitFileClass(JSContext *cx, JSObject* obj)
|
|||
/* Define CURRENTDIR property. We are doing this to get a
|
||||
slash at the end of the current dir */
|
||||
afile = js_NewFileObject(cx, CURRENT_DIR);
|
||||
currentdir = JS_malloc(cx, MAX_PATH_LENGTH);
|
||||
currentdir = getcwd(currentdir, MAX_PATH_LENGTH);
|
||||
currentdir = cx->malloc(MAX_PATH_LENGTH);
|
||||
currentdir = getcwd(currentdir, MAX_PATH_LENGTH);
|
||||
afile = js_NewFileObject(cx, currentdir);
|
||||
JS_free(cx, currentdir);
|
||||
cx->free(currentdir);
|
||||
vp = OBJECT_TO_JSVAL(afile);
|
||||
JS_DefinePropertyWithTinyId(cx, ctor, CURRENTDIR_PROPERTY, 0, vp,
|
||||
JS_PropertyStub, file_currentDirSetter,
|
||||
|
|
|
@ -136,7 +136,7 @@ MarkArgDeleted(JSContext *cx, JSStackFrame *fp, uintN slot)
|
|||
bitmap = (jsbitmap *) &bmapint;
|
||||
} else {
|
||||
nbytes = JS_HOWMANY(nbits, JS_BITS_PER_WORD) * sizeof(jsbitmap);
|
||||
bitmap = (jsbitmap *) JS_malloc(cx, nbytes);
|
||||
bitmap = (jsbitmap *) cx->malloc(nbytes);
|
||||
if (!bitmap)
|
||||
return JS_FALSE;
|
||||
memset(bitmap, 0, nbytes);
|
||||
|
@ -311,7 +311,7 @@ js_PutArgsObject(JSContext *cx, JSStackFrame *fp)
|
|||
if (!JSVAL_IS_VOID(bmapval)) {
|
||||
JS_SetReservedSlot(cx, argsobj, 0, JSVAL_VOID);
|
||||
if (fp->argc > JSVAL_INT_BITS)
|
||||
JS_free(cx, JSVAL_TO_PRIVATE(bmapval));
|
||||
cx->free(JSVAL_TO_PRIVATE(bmapval));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1133,7 +1133,7 @@ js_GetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
return CallPropertyOp(cx, obj, id, vp, JSCPK_ARG, JS_FALSE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
JSBool
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_ARG, JS_TRUE);
|
||||
|
@ -1154,12 +1154,27 @@ js_GetCallVarChecked(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
|||
return CheckForEscapingClosure(cx, obj, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
JSBool
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, vp, JSCPK_VAR, JS_TRUE);
|
||||
}
|
||||
|
||||
JSBool JS_FASTCALL
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval v)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, &v, JSCPK_ARG, JS_TRUE);
|
||||
}
|
||||
|
||||
JSBool JS_FASTCALL
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, jsid id, jsval v)
|
||||
{
|
||||
return CallPropertyOp(cx, obj, id, &v, JSCPK_VAR, JS_TRUE);
|
||||
}
|
||||
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallArg, CONTEXT, OBJECT, JSID, JSVAL, 0, 0)
|
||||
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallVar, CONTEXT, OBJECT, JSID, JSVAL, 0, 0)
|
||||
|
||||
static JSBool
|
||||
call_resolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
||||
JSObject **objp)
|
||||
|
@ -2743,10 +2758,10 @@ FreeLocalNameHash(JSContext *cx, JSLocalNameMap *map)
|
|||
|
||||
for (dup = map->lastdup; dup; dup = next) {
|
||||
next = dup->link;
|
||||
JS_free(cx, dup);
|
||||
cx->free(dup);
|
||||
}
|
||||
JS_DHashTableFinish(&map->names);
|
||||
JS_free(cx, map);
|
||||
cx->free(map);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -2774,7 +2789,7 @@ HashLocalName(JSContext *cx, JSLocalNameMap *map, JSAtom *name,
|
|||
if (entry->name) {
|
||||
JS_ASSERT(entry->name == name);
|
||||
JS_ASSERT(entry->localKind == JSLOCAL_ARG);
|
||||
dup = (JSNameIndexPair *) JS_malloc(cx, sizeof *dup);
|
||||
dup = (JSNameIndexPair *) cx->malloc(sizeof *dup);
|
||||
if (!dup)
|
||||
return JS_FALSE;
|
||||
dup->name = entry->name;
|
||||
|
@ -2820,7 +2835,7 @@ js_AddLocal(JSContext *cx, JSFunction *fun, JSAtom *atom, JSLocalKind kind)
|
|||
if (n > 1) {
|
||||
array = fun->u.i.names.array;
|
||||
} else {
|
||||
array = (jsuword *) JS_malloc(cx, MAX_ARRAY_LOCALS * sizeof *array);
|
||||
array = (jsuword *) cx->malloc(MAX_ARRAY_LOCALS * sizeof *array);
|
||||
if (!array)
|
||||
return JS_FALSE;
|
||||
array[0] = fun->u.i.names.taggedAtom;
|
||||
|
@ -2845,7 +2860,7 @@ js_AddLocal(JSContext *cx, JSFunction *fun, JSAtom *atom, JSLocalKind kind)
|
|||
}
|
||||
} else if (n == MAX_ARRAY_LOCALS) {
|
||||
array = fun->u.i.names.array;
|
||||
map = (JSLocalNameMap *) JS_malloc(cx, sizeof *map);
|
||||
map = (JSLocalNameMap *) cx->malloc(sizeof *map);
|
||||
if (!map)
|
||||
return JS_FALSE;
|
||||
if (!JS_DHashTableInit(&map->names, JS_DHashGetStubOps(),
|
||||
|
@ -2853,7 +2868,7 @@ js_AddLocal(JSContext *cx, JSFunction *fun, JSAtom *atom, JSLocalKind kind)
|
|||
JS_DHASH_DEFAULT_CAPACITY(MAX_ARRAY_LOCALS
|
||||
* 2))) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
JS_free(cx, map);
|
||||
cx->free(map);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -2886,7 +2901,7 @@ js_AddLocal(JSContext *cx, JSFunction *fun, JSAtom *atom, JSLocalKind kind)
|
|||
* to replace fun->u.i.names with the built map.
|
||||
*/
|
||||
fun->u.i.names.map = map;
|
||||
JS_free(cx, array);
|
||||
cx->free(array);
|
||||
} else {
|
||||
if (*indexp == JS_BITMASK(16)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
|
@ -3108,7 +3123,7 @@ DestroyLocalNames(JSContext *cx, JSFunction *fun)
|
|||
if (n <= 1)
|
||||
return;
|
||||
if (n <= MAX_ARRAY_LOCALS)
|
||||
JS_free(cx, fun->u.i.names.array);
|
||||
cx->free(fun->u.i.names.array);
|
||||
else
|
||||
FreeLocalNameHash(cx, fun->u.i.names.map);
|
||||
}
|
||||
|
@ -3124,8 +3139,8 @@ js_FreezeLocalNames(JSContext *cx, JSFunction *fun)
|
|||
n = fun->nargs + fun->u.i.nvars + fun->u.i.nupvars;
|
||||
if (2 <= n && n < MAX_ARRAY_LOCALS) {
|
||||
/* Shrink over-allocated array ignoring realloc failures. */
|
||||
array = (jsuword *) JS_realloc(cx, fun->u.i.names.array,
|
||||
n * sizeof *array);
|
||||
array = (jsuword *) cx->realloc(fun->u.i.names.array,
|
||||
n * sizeof *array);
|
||||
if (array)
|
||||
fun->u.i.names.array = array;
|
||||
}
|
||||
|
|
|
@ -280,7 +280,25 @@ extern JSBool
|
|||
js_GetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
js_GetCallVar(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
SetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
extern JSBool
|
||||
SetCallVar(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
|
||||
|
||||
/*
|
||||
* js_SetCallArg and js_SetCallVar are extern fastcall copies of the setter
|
||||
* functions. These versions are required in order to set call vars from traces.
|
||||
* The normal versions must not be fastcall because they are stored in the
|
||||
* property ops map.
|
||||
*/
|
||||
extern JSBool JS_FASTCALL
|
||||
js_SetCallArg(JSContext *cx, JSObject *obj, jsid id, jsval v);
|
||||
|
||||
extern JSBool JS_FASTCALL
|
||||
js_SetCallVar(JSContext *cx, JSObject *obj, jsid id, jsval v);
|
||||
|
||||
/*
|
||||
* Slower version of js_GetCallVar used when call_resolve detects an attempt to
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
#include "jsscript.h"
|
||||
#include "jsstaticcheck.h"
|
||||
#include "jsstr.h"
|
||||
#include "jstask.h"
|
||||
#include "jstracer.h"
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
|
@ -722,7 +723,7 @@ FreePtrTable(JSPtrTable *table, const JSPtrTableInfo *info)
|
|||
{
|
||||
if (table->array) {
|
||||
JS_ASSERT(table->count > 0);
|
||||
free(table->array);
|
||||
js_free(table->array);
|
||||
table->array = NULL;
|
||||
table->count = 0;
|
||||
}
|
||||
|
@ -756,8 +757,8 @@ AddToPtrTable(JSContext *cx, JSPtrTable *table, const JSPtrTableInfo *info,
|
|||
if (capacity > (size_t)-1 / sizeof table->array[0])
|
||||
goto bad;
|
||||
}
|
||||
array = (void **) realloc(table->array,
|
||||
capacity * sizeof table->array[0]);
|
||||
array = (void **) js_realloc(table->array,
|
||||
capacity * sizeof table->array[0]);
|
||||
if (!array)
|
||||
goto bad;
|
||||
#ifdef DEBUG
|
||||
|
@ -796,11 +797,11 @@ ShrinkPtrTable(JSPtrTable *table, const JSPtrTableInfo *info,
|
|||
array = table->array;
|
||||
JS_ASSERT(array);
|
||||
if (capacity == 0) {
|
||||
free(array);
|
||||
js_free(array);
|
||||
table->array = NULL;
|
||||
return;
|
||||
}
|
||||
array = (void **) realloc(array, capacity * sizeof array[0]);
|
||||
array = (void **) js_realloc(array, capacity * sizeof array[0]);
|
||||
if (array)
|
||||
table->array = array;
|
||||
}
|
||||
|
@ -881,7 +882,7 @@ NewGCChunk(void)
|
|||
*
|
||||
* bytes to ensure that we always have room to store the gap.
|
||||
*/
|
||||
p = malloc((js_gcArenasPerChunk + 1) << GC_ARENA_SHIFT);
|
||||
p = js_malloc((js_gcArenasPerChunk + 1) << GC_ARENA_SHIFT);
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
|
@ -913,11 +914,11 @@ DestroyGCChunk(jsuword chunk)
|
|||
#endif
|
||||
|
||||
#if HAS_POSIX_MEMALIGN
|
||||
free((void *) chunk);
|
||||
js_free((void *) chunk);
|
||||
#else
|
||||
/* See comments in NewGCChunk. */
|
||||
JS_ASSERT(*GetMallocedChunkGapPtr(chunk) < GC_ARENA_SIZE);
|
||||
free((void *) (chunk - *GetMallocedChunkGapPtr(chunk)));
|
||||
js_free((void *) (chunk - *GetMallocedChunkGapPtr(chunk)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3042,7 +3043,7 @@ js_TraceContext(JSTracer *trc, JSContext *acx)
|
|||
tvr->u.trace(trc, tvr);
|
||||
break;
|
||||
case JSTVU_SPROP:
|
||||
TRACE_SCOPE_PROPERTY(trc, tvr->u.sprop);
|
||||
tvr->u.sprop->trace(trc);
|
||||
break;
|
||||
case JSTVU_WEAK_ROOTS:
|
||||
TraceWeakRoots(trc, tvr->u.weakRoots);
|
||||
|
@ -3270,7 +3271,10 @@ js_FinalizeStringRT(JSRuntime *rt, JSString *str, intN type, JSContext *cx)
|
|||
JS_ASSERT(type < 0);
|
||||
rt->unitStrings[*chars] = NULL;
|
||||
} else if (type < 0) {
|
||||
free(chars);
|
||||
if (cx)
|
||||
cx->free(chars);
|
||||
else
|
||||
rt->free(chars);
|
||||
} else {
|
||||
JS_ASSERT((uintN) type < JS_ARRAY_LENGTH(str_finalizers));
|
||||
finalizer = str_finalizers[type];
|
||||
|
@ -3519,6 +3523,7 @@ js_GC(JSContext *cx, JSGCInvocationKind gckind)
|
|||
*/
|
||||
if (rt->shapeGen & SHAPE_OVERFLOW_BIT) {
|
||||
rt->gcRegenShapes = true;
|
||||
rt->gcRegenShapesScopeFlag ^= JSScope::SHAPE_REGEN;
|
||||
rt->shapeGen = 0;
|
||||
rt->protoHazardShape = 0;
|
||||
}
|
||||
|
@ -3555,6 +3560,10 @@ js_GC(JSContext *cx, JSGCInvocationKind gckind)
|
|||
|
||||
rt->gcMarkingTracer = NULL;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
cx->createDeallocatorTask();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Sweep phase.
|
||||
*
|
||||
|
@ -3733,6 +3742,10 @@ js_GC(JSContext *cx, JSGCInvocationKind gckind)
|
|||
*/
|
||||
DestroyGCArenas(rt, emptyArenas);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
cx->submitDeallocatorTask();
|
||||
#endif
|
||||
|
||||
if (rt->gcCallback)
|
||||
(void) rt->gcCallback(cx, JSGC_FINALIZE_END);
|
||||
#ifdef DEBUG_srcnotesize
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "jsdhash.h"
|
||||
#include "jsbit.h"
|
||||
#include "jsutil.h"
|
||||
#include "jstask.h"
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
|
@ -341,6 +342,28 @@ js_AddAsGCBytes(JSContext *cx, size_t sz);
|
|||
extern void
|
||||
js_RemoveAsGCBytes(JSRuntime* rt, size_t sz);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
class JSFreePointerListTask : public JSBackgroundTask {
|
||||
void *head;
|
||||
public:
|
||||
JSFreePointerListTask() : head(NULL) {}
|
||||
|
||||
void add(void* ptr) {
|
||||
*(void**)ptr = head;
|
||||
head = ptr;
|
||||
}
|
||||
|
||||
void run() {
|
||||
void *ptr = head;
|
||||
while (ptr) {
|
||||
void *next = *(void **)ptr;
|
||||
js_free(ptr);
|
||||
ptr = next;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Free the chars held by str when it is finalized by the GC. When type is
|
||||
* less then zero, it denotes an internal string. Otherwise it denotes the
|
||||
|
|
|
@ -73,7 +73,7 @@ DefaultAllocTable(void *pool, size_t size)
|
|||
static void
|
||||
DefaultFreeTable(void *pool, void *item, size_t size)
|
||||
{
|
||||
free(item);
|
||||
js_free(item);
|
||||
}
|
||||
|
||||
static JSHashEntry *
|
||||
|
@ -86,7 +86,7 @@ static void
|
|||
DefaultFreeEntry(void *pool, JSHashEntry *he, uintN flag)
|
||||
{
|
||||
if (flag == HT_FREE_ENTRY)
|
||||
free(he);
|
||||
js_free(he);
|
||||
}
|
||||
|
||||
static JSHashAllocOps defaultHashAllocOps = {
|
||||
|
|
|
@ -1534,7 +1534,7 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
|
|||
js_LeaveTrace(cx);
|
||||
|
||||
#ifdef JS_TRACER
|
||||
/*
|
||||
/*
|
||||
* The JIT requires that the scope chain here is equal to its global
|
||||
* object. Disable the JIT for this call if this condition is not true.
|
||||
*/
|
||||
|
@ -2095,7 +2095,7 @@ js_GetUpvar(JSContext *cx, uintN level, uintN cookie)
|
|||
} else if (slot == CALLEE_UPVAR_SLOT) {
|
||||
vp = &fp->argv[-2];
|
||||
slot = 0;
|
||||
} else {
|
||||
} else {
|
||||
slot -= fp->fun->nargs;
|
||||
JS_ASSERT(slot < fp->script->nslots);
|
||||
vp = fp->slots;
|
||||
|
@ -2132,7 +2132,7 @@ js_TraceOpcode(JSContext *cx)
|
|||
fp->script, cx->tracePrevPc);
|
||||
|
||||
/*
|
||||
* If there aren't that many elements on the stack, then
|
||||
* If there aren't that many elements on the stack, then
|
||||
* we have probably entered a new frame, and printing output
|
||||
* would just be misleading.
|
||||
*/
|
||||
|
@ -2145,7 +2145,7 @@ js_TraceOpcode(JSContext *cx)
|
|||
fprintf(tracefp, "%s %s",
|
||||
(n == -ndefs) ? " output:" : ",",
|
||||
bytes);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
}
|
||||
fprintf(tracefp, " @ %u\n", (uintN) (regs->sp - StackBase(fp)));
|
||||
|
@ -2177,7 +2177,7 @@ js_TraceOpcode(JSContext *cx)
|
|||
fprintf(tracefp, "%s %s",
|
||||
(n == -nuses) ? " inputs:" : ",",
|
||||
bytes);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
}
|
||||
fprintf(tracefp, " @ %u\n", (uintN) (regs->sp - StackBase(fp)));
|
||||
|
@ -2264,7 +2264,7 @@ js_DumpOpMeters()
|
|||
|
||||
# define SIGNIFICANT(count,total) (200. * (count) >= (total))
|
||||
|
||||
graph = (Edge *) calloc(nedges, sizeof graph[0]);
|
||||
graph = (Edge *) js_calloc(nedges * sizeof graph[0]);
|
||||
for (i = nedges = 0; i < JSOP_LIMIT; i++) {
|
||||
from = js_CodeName[i];
|
||||
for (j = 0; j < JSOP_LIMIT; j++) {
|
||||
|
@ -2293,7 +2293,7 @@ js_DumpOpMeters()
|
|||
graph[i].from, graph[i].to,
|
||||
(unsigned long)graph[i].count, style);
|
||||
}
|
||||
free(graph);
|
||||
js_free(graph);
|
||||
fputs("}\n", fp);
|
||||
fclose(fp);
|
||||
|
||||
|
@ -2717,7 +2717,7 @@ js_Interpret(JSContext *cx)
|
|||
* 'op=x; DO_OP()' to let another opcode's implementation finish
|
||||
* their work, and many opcodes share entry points with a run of
|
||||
* consecutive BEGIN_CASEs.
|
||||
*
|
||||
*
|
||||
* Take care to trace OP only when it is the opcode fetched from
|
||||
* the instruction stream, so the trace matches what one would
|
||||
* expect from looking at the code. (We do omit POPs after SETs;
|
||||
|
@ -4802,7 +4802,6 @@ js_Interpret(JSContext *cx)
|
|||
}
|
||||
JS_UNLOCK_SCOPE(cx, scope);
|
||||
PCMETER(cache->setpcmisses++);
|
||||
atom = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ struct JSStackFrame {
|
|||
* variables on the stack initially, note when they are closed
|
||||
* over, and copy those that are out to the heap when we leave
|
||||
* their dynamic scope.
|
||||
*
|
||||
*
|
||||
* The bytecode compiler produces a tree of block objects
|
||||
* accompanying each JSScript representing those lexical blocks in
|
||||
* the script that have let-bound variables associated with them.
|
||||
|
@ -102,7 +102,7 @@ struct JSStackFrame {
|
|||
* When we are in the static scope of such a block, blockChain
|
||||
* points to its compiler-allocated block object; otherwise, it is
|
||||
* NULL.
|
||||
*
|
||||
*
|
||||
* scopeChain is the current scope chain, including 'call' and
|
||||
* 'block' objects for those function calls and lexical blocks
|
||||
* whose static scope we are currently executing in, and 'with'
|
||||
|
@ -158,7 +158,7 @@ static JS_INLINE uintN
|
|||
GlobalVarCount(JSStackFrame *fp)
|
||||
{
|
||||
uintN n;
|
||||
|
||||
|
||||
JS_ASSERT(!fp->fun);
|
||||
n = fp->script->nfixed;
|
||||
if (fp->script->regexpsOffset != 0)
|
||||
|
@ -243,6 +243,10 @@ struct JSPropCacheEntry {
|
|||
jsuword kshape; /* key shape if pc, else obj for atom */
|
||||
jsuword vcap; /* value capability, see above */
|
||||
jsuword vword; /* value word, see PCVAL_* below */
|
||||
|
||||
bool adding() const {
|
||||
return PCVCAP_TAG(vcap) == 0 && kshape != PCVCAP_SHAPE(vcap);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
* Types:
|
||||
* JSInt<N>, JSUint<N> (for <N> = 8, 16, 32, and 64)
|
||||
* JSIntPtr, JSUIntPtr
|
||||
*
|
||||
*
|
||||
* JSInt<N> and JSUint<N> are signed and unsigned types known to be
|
||||
* <N> bits long. Note that neither JSInt8 nor JSUInt8 is necessarily
|
||||
* equivalent to a plain "char".
|
||||
|
|
|
@ -649,7 +649,7 @@ generator_finalize(JSContext *cx, JSObject *obj)
|
|||
*/
|
||||
JS_ASSERT(gen->state == JSGEN_NEWBORN || gen->state == JSGEN_CLOSED ||
|
||||
gen->state == JSGEN_OPEN);
|
||||
JS_free(cx, gen);
|
||||
cx->free(gen);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -716,7 +716,7 @@ js_NewGenerator(JSContext *cx, JSStackFrame *fp)
|
|||
|
||||
/* Allocate obj's private data struct. */
|
||||
gen = (JSGenerator *)
|
||||
JS_malloc(cx, sizeof(JSGenerator) + (nslots - 1) * sizeof(jsval));
|
||||
cx->malloc(sizeof(JSGenerator) + (nslots - 1) * sizeof(jsval));
|
||||
if (!gen)
|
||||
goto bad;
|
||||
|
||||
|
@ -783,7 +783,7 @@ js_NewGenerator(JSContext *cx, JSStackFrame *fp)
|
|||
gen->state = JSGEN_NEWBORN;
|
||||
|
||||
if (!JS_SetPrivate(cx, obj, gen)) {
|
||||
JS_free(cx, gen);
|
||||
cx->free(gen);
|
||||
goto bad;
|
||||
}
|
||||
return obj;
|
||||
|
|
|
@ -909,7 +909,7 @@ DestroyFatlock(JSFatLock *fl)
|
|||
{
|
||||
PR_DestroyLock(fl->slock);
|
||||
PR_DestroyCondVar(fl->svar);
|
||||
free(fl);
|
||||
js_free(fl);
|
||||
}
|
||||
|
||||
static JSFatLock *
|
||||
|
@ -1003,7 +1003,7 @@ js_SetupLocks(int listc, int globc)
|
|||
global_locks_log2 = JS_CeilingLog2(globc);
|
||||
global_locks_mask = JS_BITMASK(global_locks_log2);
|
||||
global_lock_count = JS_BIT(global_locks_log2);
|
||||
global_locks = (PRLock **) malloc(global_lock_count * sizeof(PRLock*));
|
||||
global_locks = (PRLock **) js_malloc(global_lock_count * sizeof(PRLock*));
|
||||
if (!global_locks)
|
||||
return JS_FALSE;
|
||||
for (i = 0; i < global_lock_count; i++) {
|
||||
|
@ -1014,7 +1014,7 @@ js_SetupLocks(int listc, int globc)
|
|||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
fl_list_table = (JSFatLockTable *) malloc(i * sizeof(JSFatLockTable));
|
||||
fl_list_table = (JSFatLockTable *) js_malloc(i * sizeof(JSFatLockTable));
|
||||
if (!fl_list_table) {
|
||||
js_CleanupLocks();
|
||||
return JS_FALSE;
|
||||
|
@ -1036,7 +1036,7 @@ js_CleanupLocks()
|
|||
if (global_locks) {
|
||||
for (i = 0; i < global_lock_count; i++)
|
||||
PR_DestroyLock(global_locks[i]);
|
||||
free(global_locks);
|
||||
js_free(global_locks);
|
||||
global_locks = NULL;
|
||||
global_lock_count = 1;
|
||||
global_locks_log2 = 0;
|
||||
|
@ -1049,7 +1049,7 @@ js_CleanupLocks()
|
|||
DeleteListOfFatlocks(fl_list_table[i].taken);
|
||||
fl_list_table[i].taken = NULL;
|
||||
}
|
||||
free(fl_list_table);
|
||||
js_free(fl_list_table);
|
||||
fl_list_table = NULL;
|
||||
fl_list_table_len = 0;
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ static inline jsdouble JS_FASTCALL
|
|||
math_ceil_kernel(jsdouble x)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
if (x < 0 && x > -1.0)
|
||||
if (x < 0 && x > -1.0)
|
||||
return js_copysign(0, -1);
|
||||
#endif
|
||||
return ceil(x);
|
||||
|
|
|
@ -384,7 +384,7 @@ num_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
str = JS_NewStringCopyZ(cx, dStr);
|
||||
free(dStr);
|
||||
js_free(dStr);
|
||||
}
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
@ -460,7 +460,7 @@ num_toLocaleString(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
tmpGroup--;
|
||||
|
||||
buf = (char *)JS_malloc(cx, size + 1);
|
||||
buf = (char *)cx->malloc(size + 1);
|
||||
if (!buf)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -492,7 +492,7 @@ num_toLocaleString(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
str = JS_NewString(cx, buf, size);
|
||||
if (!str) {
|
||||
JS_free(cx, buf);
|
||||
cx->free(buf);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -739,9 +739,9 @@ js_FinishRuntimeNumberState(JSContext *cx)
|
|||
rt->jsNegativeInfinity = NULL;
|
||||
rt->jsPositiveInfinity = NULL;
|
||||
|
||||
JS_free(cx, (void *)rt->thousandsSeparator);
|
||||
JS_free(cx, (void *)rt->decimalSeparator);
|
||||
JS_free(cx, (void *)rt->numGrouping);
|
||||
cx->free((void *)rt->thousandsSeparator);
|
||||
cx->free((void *)rt->decimalSeparator);
|
||||
cx->free((void *)rt->numGrouping);
|
||||
rt->thousandsSeparator = rt->decimalSeparator = rt->numGrouping = NULL;
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,7 @@ NumberToStringWithBase(JSContext *cx, jsdouble d, jsint base)
|
|||
return NULL;
|
||||
s = JS_NewStringCopyZ(cx, numStr);
|
||||
if (!(numStr >= buf && numStr < buf + sizeof buf))
|
||||
free(numStr);
|
||||
js_free(numStr);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1251,7 @@ js_strtod(JSContext *cx, const jschar *s, const jschar *send,
|
|||
|
||||
/* Use cbuf to avoid malloc */
|
||||
if (length >= sizeof cbuf) {
|
||||
cstr = (char *) JS_malloc(cx, length + 1);
|
||||
cstr = (char *) cx->malloc(length + 1);
|
||||
if (!cstr)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
|
@ -1292,7 +1292,7 @@ js_strtod(JSContext *cx, const jschar *s, const jschar *send,
|
|||
|
||||
i = estr - cstr;
|
||||
if (cstr != cbuf)
|
||||
JS_free(cx, cstr);
|
||||
cx->free(cstr);
|
||||
*ep = i ? s1 + i : s;
|
||||
*dp = d;
|
||||
return JS_TRUE;
|
||||
|
@ -1405,7 +1405,7 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar *send,
|
|||
*/
|
||||
size_t i;
|
||||
size_t length = s1 - start;
|
||||
char *cstr = (char *) JS_malloc(cx, length + 1);
|
||||
char *cstr = (char *) cx->malloc(length + 1);
|
||||
char *estr;
|
||||
int err=0;
|
||||
|
||||
|
@ -1418,12 +1418,12 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar *send,
|
|||
value = JS_strtod(cstr, &estr, &err);
|
||||
if (err == JS_DTOA_ENOMEM) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
JS_free(cx, cstr);
|
||||
cx->free(cstr);
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (err == JS_DTOA_ERANGE && value == HUGE_VAL)
|
||||
value = *cx->runtime->jsPositiveInfinity;
|
||||
JS_free(cx, cstr);
|
||||
cx->free(cstr);
|
||||
} else if ((base & (base - 1)) == 0) {
|
||||
/*
|
||||
* The number may also be inaccurate for power-of-two bases. This
|
||||
|
|
|
@ -560,7 +560,7 @@ out:
|
|||
ida = JS_Enumerate(cx, obj);
|
||||
if (!ida) {
|
||||
if (*sp) {
|
||||
JS_free(cx, *sp);
|
||||
cx->free(*sp);
|
||||
*sp = NULL;
|
||||
}
|
||||
goto bad;
|
||||
|
@ -704,7 +704,7 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
if (!chars) {
|
||||
/* If outermost, allocate 4 + 1 for "({})" and the terminator. */
|
||||
chars = (jschar *) malloc(((outermost ? 4 : 2) + 1) * sizeof(jschar));
|
||||
chars = (jschar *) js_malloc(((outermost ? 4 : 2) + 1) * sizeof(jschar));
|
||||
nchars = 0;
|
||||
if (!chars)
|
||||
goto error;
|
||||
|
@ -715,9 +715,9 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
MAKE_SHARP(he);
|
||||
nchars = js_strlen(chars);
|
||||
chars = (jschar *)
|
||||
realloc((ochars = chars), (nchars + 2 + 1) * sizeof(jschar));
|
||||
js_realloc((ochars = chars), (nchars + 2 + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
free(ochars);
|
||||
js_free(ochars);
|
||||
goto error;
|
||||
}
|
||||
if (outermost) {
|
||||
|
@ -958,11 +958,11 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
/* Allocate 1 + 1 at end for closing brace and terminating 0. */
|
||||
chars = (jschar *)
|
||||
realloc((ochars = chars), curlen * sizeof(jschar));
|
||||
js_realloc((ochars = chars), curlen * sizeof(jschar));
|
||||
if (!chars) {
|
||||
/* Save code space on error: let JS_free ignore null vsharp. */
|
||||
JS_free(cx, vsharp);
|
||||
free(ochars);
|
||||
cx->free(vsharp);
|
||||
js_free(ochars);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
nchars += vlength;
|
||||
|
||||
if (vsharp)
|
||||
JS_free(cx, vsharp);
|
||||
cx->free(vsharp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1019,7 +1019,7 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
if (!ok) {
|
||||
if (chars)
|
||||
free(chars);
|
||||
js_free(chars);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
make_string:
|
||||
str = js_NewString(cx, chars, nchars);
|
||||
if (!str) {
|
||||
free(chars);
|
||||
js_free(chars);
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1042,8 +1042,8 @@ obj_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
return ok;
|
||||
|
||||
overflow:
|
||||
JS_free(cx, vsharp);
|
||||
free(chars);
|
||||
cx->free(vsharp);
|
||||
js_free(chars);
|
||||
chars = NULL;
|
||||
goto error;
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
obj = js_GetWrappedObject(cx, obj);
|
||||
clazz = OBJ_GET_CLASS(cx, obj)->name;
|
||||
nchars = 9 + strlen(clazz); /* 9 for "[object ]" */
|
||||
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((nchars + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ obj_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
str = js_NewString(cx, chars, nchars);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -2986,7 +2986,7 @@ AllocSlots(JSContext *cx, JSObject *obj, size_t nslots)
|
|||
JS_ASSERT(nslots > JS_INITIAL_NSLOTS);
|
||||
|
||||
jsval* slots;
|
||||
slots = (jsval*) JS_malloc(cx, SLOTS_TO_DYNAMIC_WORDS(nslots) * sizeof(jsval));
|
||||
slots = (jsval*) cx->malloc(SLOTS_TO_DYNAMIC_WORDS(nslots) * sizeof(jsval));
|
||||
if (!slots)
|
||||
return true;
|
||||
|
||||
|
@ -3044,7 +3044,7 @@ js_GrowSlots(JSContext *cx, JSObject *obj, size_t nslots)
|
|||
|
||||
size_t oslots = size_t(slots[-1]);
|
||||
|
||||
slots = (jsval*) JS_realloc(cx, slots - 1, nwords * sizeof(jsval));
|
||||
slots = (jsval*) cx->realloc(slots - 1, nwords * sizeof(jsval));
|
||||
*slots++ = nslots;
|
||||
obj->dslots = slots;
|
||||
|
||||
|
@ -3069,11 +3069,11 @@ js_ShrinkSlots(JSContext *cx, JSObject *obj, size_t nslots)
|
|||
JS_ASSERT(nslots <= size_t(slots[-1]));
|
||||
|
||||
if (nslots <= JS_INITIAL_NSLOTS) {
|
||||
JS_free(cx, slots - 1);
|
||||
cx->free(slots - 1);
|
||||
obj->dslots = NULL;
|
||||
} else {
|
||||
size_t nwords = SLOTS_TO_DYNAMIC_WORDS(nslots);
|
||||
slots = (jsval*) JS_realloc(cx, slots - 1, nwords * sizeof(jsval));
|
||||
slots = (jsval*) cx->realloc(slots - 1, nwords * sizeof(jsval));
|
||||
*slots++ = nslots;
|
||||
obj->dslots = slots;
|
||||
}
|
||||
|
@ -4965,7 +4965,7 @@ js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
}
|
||||
|
||||
allocated = NativeEnumeratorSize(length);
|
||||
ne = (JSNativeEnumerator *) JS_malloc(cx, allocated);
|
||||
ne = (JSNativeEnumerator *) cx->malloc(allocated);
|
||||
if (!ne) {
|
||||
JS_UNLOCK_SCOPE(cx, scope);
|
||||
return JS_FALSE;
|
||||
|
@ -4997,7 +4997,7 @@ js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
JS_LOCK_GC(cx->runtime);
|
||||
if (!js_AddAsGCBytes(cx, allocated)) {
|
||||
/* js_AddAsGCBytes releases the GC lock on failures. */
|
||||
JS_free(cx, ne);
|
||||
cx->free(ne);
|
||||
return JS_FALSE;
|
||||
}
|
||||
ne->next = cx->runtime->nativeEnumerators;
|
||||
|
@ -5085,12 +5085,12 @@ js_TraceNativeEnumerators(JSTracer *trc)
|
|||
cursor = ne->ids;
|
||||
end = cursor + ne->length;
|
||||
do {
|
||||
TRACE_ID(trc, *cursor);
|
||||
js_TraceId(trc, *cursor);
|
||||
} while (++cursor != end);
|
||||
} else if (doGC) {
|
||||
js_RemoveAsGCBytes(rt, NativeEnumeratorSize(ne->length));
|
||||
*nep = ne->next;
|
||||
JS_free(trc->context, ne);
|
||||
trc->context->free(ne);
|
||||
continue;
|
||||
}
|
||||
nep = &ne->next;
|
||||
|
@ -5748,7 +5748,6 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
|
|||
{
|
||||
JSContext *cx;
|
||||
JSScope *scope;
|
||||
JSScopeProperty *sprop;
|
||||
JSClass *clasp;
|
||||
size_t nslots, i;
|
||||
jsval v;
|
||||
|
@ -5772,32 +5771,7 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
|
|||
MeterEntryCount(scope->entryCount);
|
||||
#endif
|
||||
|
||||
sprop = scope->lastProp;
|
||||
if (sprop) {
|
||||
JS_ASSERT(scope->has(sprop));
|
||||
|
||||
/* Regenerate property cache shape ids if GC'ing. */
|
||||
if (IS_GC_MARKING_TRACER(trc) && cx->runtime->gcRegenShapes) {
|
||||
if (!(sprop->flags & SPROP_FLAG_SHAPE_REGEN)) {
|
||||
sprop->shape = js_RegenerateShapeForGC(cx);
|
||||
sprop->flags |= SPROP_FLAG_SHAPE_REGEN;
|
||||
}
|
||||
|
||||
uint32 shape = sprop->shape;
|
||||
if (scope->hasOwnShape()) {
|
||||
shape = js_RegenerateShapeForGC(cx);
|
||||
JS_ASSERT(shape != sprop->shape);
|
||||
}
|
||||
scope->shape = shape;
|
||||
}
|
||||
|
||||
/* Trace scope's property tree ancestor line. */
|
||||
do {
|
||||
if (scope->hadMiddleDelete() && !scope->has(sprop))
|
||||
continue;
|
||||
TRACE_SCOPE_PROPERTY(trc, sprop);
|
||||
} while ((sprop = sprop->parent) != NULL);
|
||||
}
|
||||
scope->trace(trc);
|
||||
|
||||
if (!JS_CLIST_IS_EMPTY(&cx->runtime->watchPointList))
|
||||
js_TraceWatchPoints(trc, obj);
|
||||
|
|
|
@ -914,6 +914,10 @@ JS_FRIEND_API(void) js_DumpStackFrame(JSStackFrame *fp);
|
|||
extern uintN
|
||||
js_InferFlags(JSContext *cx, uintN defaultFlags);
|
||||
|
||||
/* Object constructor native. Exposed only so the JIT can know its address. */
|
||||
JSBool
|
||||
js_Object(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsobj_h___ */
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <string.h> /* memset */
|
||||
#include <string.h>
|
||||
#include "jsapi.h"
|
||||
#include "jsarena.h"
|
||||
#include "jsarray.h"
|
||||
|
@ -78,7 +78,7 @@ js_json_parse(JSContext *cx, uintN argc, jsval *vp)
|
|||
jsval *argv = vp + 2;
|
||||
jsval reviver = JSVAL_NULL;
|
||||
JSAutoTempValueRooter(cx, 1, &reviver);
|
||||
|
||||
|
||||
if (!JS_ConvertArguments(cx, argc, argv, "S / v", &s, &reviver))
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -523,7 +523,7 @@ Str(JSContext *cx, jsid id, JSObject *holder, StringifyContext *scx, jsval *vp,
|
|||
|
||||
char numBuf[DTOSTR_STANDARD_BUFFER_SIZE], *numStr;
|
||||
jsdouble d = JSVAL_IS_INT(*vp) ? jsdouble(JSVAL_TO_INT(*vp)) : *JSVAL_TO_DOUBLE(*vp);
|
||||
numStr = JS_dtostr(numBuf, sizeof numBuf, DTOSTR_STANDARD, 0, d);
|
||||
numStr = JS_dtostr(numBuf, sizeof numBuf, DTOSTR_STANDARD, 0, d);
|
||||
if (!numStr) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -546,7 +546,7 @@ Str(JSContext *cx, jsid id, JSObject *holder, StringifyContext *scx, jsval *vp,
|
|||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
*vp = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ static JSBool
|
|||
Walk(JSContext *cx, jsid id, JSObject *holder, jsval reviver, jsval *vp)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return JS_FALSE);
|
||||
|
||||
|
||||
if (!OBJ_GET_PROPERTY(cx, holder, id, vp))
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -649,7 +649,7 @@ Walk(JSContext *cx, jsid id, JSObject *holder, jsval reviver, jsval *vp)
|
|||
if (!JSVAL_IS_PRIMITIVE(*vp) && !js_IsCallable(obj = JSVAL_TO_OBJECT(*vp), cx)) {
|
||||
jsval propValue = JSVAL_NULL;
|
||||
JSAutoTempValueRooter tvr(cx, 1, &propValue);
|
||||
|
||||
|
||||
if(OBJ_IS_ARRAY(cx, obj)) {
|
||||
jsuint length = 0;
|
||||
if (!js_GetLengthProperty(cx, obj, &length))
|
||||
|
@ -713,7 +713,7 @@ Walk(JSContext *cx, jsid id, JSObject *holder, jsval reviver, jsval *vp)
|
|||
static JSBool
|
||||
Revive(JSContext *cx, jsval reviver, jsval *vp)
|
||||
{
|
||||
|
||||
|
||||
JSObject *obj = js_NewObject(cx, &js_ObjectClass, NULL, NULL);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
@ -740,10 +740,9 @@ js_BeginJSONParse(JSContext *cx, jsval *rootVal)
|
|||
if (!arr)
|
||||
return NULL;
|
||||
|
||||
JSONParser *jp = (JSONParser*) JS_malloc(cx, sizeof(JSONParser));
|
||||
JSONParser *jp = (JSONParser*) cx->calloc(sizeof(JSONParser));
|
||||
if (!jp)
|
||||
return NULL;
|
||||
memset(jp, 0, sizeof *jp);
|
||||
|
||||
jp->objectStack = arr;
|
||||
if (!js_AddRoot(cx, &jp->objectStack, "JSON parse stack"))
|
||||
|
@ -798,7 +797,7 @@ js_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver)
|
|||
|
||||
JSBool ok = *jp->statep == JSON_PARSE_STATE_FINISHED;
|
||||
jsval *vp = jp->rootVal;
|
||||
JS_free(cx, jp);
|
||||
cx->free(jp);
|
||||
|
||||
if (!early_ok)
|
||||
return JS_FALSE;
|
||||
|
@ -820,7 +819,7 @@ PushState(JSContext *cx, JSONParser *jp, JSONParserState state)
|
|||
if (*jp->statep == JSON_PARSE_STATE_FINISHED) {
|
||||
// extra input
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
|
||||
return JS_FALSE;
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
jp->statep++;
|
||||
|
@ -993,10 +992,10 @@ HandleNumber(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
jsval numVal;
|
||||
jsval numVal;
|
||||
if (!JS_NewNumberValue(cx, val, &numVal))
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
return PushPrimitive(cx, jp, numVal);
|
||||
}
|
||||
|
||||
|
@ -1248,7 +1247,7 @@ js_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len
|
|||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (++(jp->numHex) == 4) {
|
||||
js_FastAppendChar(&jp->buffer, jp->hexChar);
|
||||
jp->hexChar = 0;
|
||||
|
@ -1265,7 +1264,7 @@ js_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len
|
|||
i--;
|
||||
if (!PopState(cx, jp))
|
||||
return JS_FALSE;
|
||||
|
||||
|
||||
if (!HandleData(cx, jp, JSON_DATA_KEYWORD))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ Sprint(Sprinter *sp, const char *format, ...)
|
|||
return -1;
|
||||
}
|
||||
offset = SprintCString(sp, bp);
|
||||
free(bp);
|
||||
js_free(bp);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ JS_NEW_PRINTER(JSContext *cx, const char *name, JSFunction *fun,
|
|||
{
|
||||
JSPrinter *jp;
|
||||
|
||||
jp = (JSPrinter *) JS_malloc(cx, sizeof(JSPrinter));
|
||||
jp = (JSPrinter *) cx->malloc(sizeof(JSPrinter));
|
||||
if (!jp)
|
||||
return NULL;
|
||||
INIT_SPRINTER(cx, &jp->sprinter, &jp->pool, 0);
|
||||
|
@ -764,7 +764,7 @@ void
|
|||
js_DestroyPrinter(JSPrinter *jp)
|
||||
{
|
||||
JS_FinishArenaPool(&jp->pool);
|
||||
JS_free(jp->sprinter.context, jp);
|
||||
jp->sprinter.context->free(jp);
|
||||
}
|
||||
|
||||
JSString *
|
||||
|
@ -832,7 +832,7 @@ js_printf(JSPrinter *jp, const char *format, ...)
|
|||
/* Allocate temp space, convert format, and put. */
|
||||
bp = JS_vsmprintf(format, ap); /* XXX vsaprintf */
|
||||
if (fp) {
|
||||
JS_free(jp->sprinter.context, fp);
|
||||
jp->sprinter.context->free(fp);
|
||||
format = NULL;
|
||||
}
|
||||
if (!bp) {
|
||||
|
@ -843,7 +843,7 @@ js_printf(JSPrinter *jp, const char *format, ...)
|
|||
cc = strlen(bp);
|
||||
if (SprintPut(&jp->sprinter, bp, (size_t)cc) < 0)
|
||||
cc = -1;
|
||||
free(bp);
|
||||
js_free(bp);
|
||||
|
||||
va_end(ap);
|
||||
return cc;
|
||||
|
@ -929,7 +929,7 @@ GetOff(SprintStack *ss, uintN i)
|
|||
if (off < 0)
|
||||
off = 0;
|
||||
ss->offsets[i] = off;
|
||||
JS_free(ss->sprinter.context, bytes);
|
||||
ss->sprinter.context->free(bytes);
|
||||
return off;
|
||||
}
|
||||
if (!ss->sprinter.base && SprintPut(&ss->sprinter, "", 0) >= 0) {
|
||||
|
@ -2508,14 +2508,14 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
len = 0;
|
||||
|
||||
if (!Decompile(ss, done, pc - done, JSOP_POP)) {
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Pop Decompile result and print comma expression. */
|
||||
rval = POP_STR();
|
||||
todo = Sprint(&ss->sprinter, "%s, %s", lval, rval);
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
break;
|
||||
|
||||
case SRC_HIDDEN:
|
||||
|
@ -2547,7 +2547,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
/* Set saveop to reflect what we will push. */
|
||||
saveop = JSOP_LEAVEBLOCKEXPR;
|
||||
if (!Decompile(ss, pc, len, saveop)) {
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
return NULL;
|
||||
}
|
||||
rval = PopStr(ss, JSOP_SETNAME);
|
||||
|
@ -2556,7 +2556,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
? "let (%s) (%s)"
|
||||
: "let (%s) %s",
|
||||
lval, rval);
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2620,7 +2620,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
if ((size_t)argc <= JS_ARRAY_LENGTH(smallv)) {
|
||||
atomv = smallv;
|
||||
} else {
|
||||
atomv = (JSAtom **) JS_malloc(cx, argc * sizeof(JSAtom *));
|
||||
atomv = (JSAtom **) cx->malloc(argc * sizeof(JSAtom *));
|
||||
if (!atomv)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2755,7 +2755,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
#undef LOCAL_ASSERT_OUT
|
||||
enterblock_out:
|
||||
if (atomv != smallv)
|
||||
JS_free(cx, atomv);
|
||||
cx->free(atomv);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3280,7 +3280,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
DECOMPILE_CODE(pc + oplen, len - oplen);
|
||||
lval = JS_strdup(cx, POP_STR());
|
||||
if (!lval) {
|
||||
JS_free(cx, (void *)xval);
|
||||
cx->free((void *)xval);
|
||||
return NULL;
|
||||
}
|
||||
pc += len;
|
||||
|
@ -3291,8 +3291,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
rval = POP_STR();
|
||||
todo = Sprint(&ss->sprinter, "%s ? %s : %s",
|
||||
xval, lval, rval);
|
||||
JS_free(cx, (void *)xval);
|
||||
JS_free(cx, (void *)lval);
|
||||
cx->free((void *)xval);
|
||||
cx->free((void *)lval);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -3319,7 +3319,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
pc += len;
|
||||
len = done - pc;
|
||||
if (!Decompile(ss, pc, len, op)) {
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
return NULL;
|
||||
}
|
||||
rval = POP_STR();
|
||||
|
@ -3332,14 +3332,14 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
todo = Sprint(&ss->sprinter, "%s %s\n", lval, xval);
|
||||
tail = Sprint(&ss->sprinter, "%*s%s",
|
||||
jp->indent + 4, "", rval);
|
||||
JS_free(cx, (char *)rval);
|
||||
cx->free((char *)rval);
|
||||
}
|
||||
if (tail < 0)
|
||||
todo = -1;
|
||||
} else {
|
||||
todo = Sprint(&ss->sprinter, "%s %s %s", lval, xval, rval);
|
||||
}
|
||||
JS_free(cx, (char *)lval);
|
||||
cx->free((char *)lval);
|
||||
break;
|
||||
|
||||
case JSOP_AND:
|
||||
|
@ -3532,7 +3532,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
#endif
|
||||
argc = GET_ARGC(pc);
|
||||
argv = (char **)
|
||||
JS_malloc(cx, (size_t)(argc + 1) * sizeof *argv);
|
||||
cx->malloc((size_t)(argc + 1) * sizeof *argv);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
|
@ -3590,8 +3590,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
ok = JS_FALSE;
|
||||
|
||||
for (i = 0; i <= argc; i++)
|
||||
JS_free(cx, argv[i]);
|
||||
JS_free(cx, argv);
|
||||
cx->free(argv[i]);
|
||||
cx->free(argv);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
#if JS_HAS_LVALUE_RETURN
|
||||
|
@ -4095,7 +4095,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
if (!rval)
|
||||
return NULL;
|
||||
todo = SprintCString(&ss->sprinter, rval);
|
||||
JS_free(cx, (void *)rval);
|
||||
cx->free((void *)rval);
|
||||
break;
|
||||
}
|
||||
#endif /* JS_HAS_GENERATOR_EXPRS */
|
||||
|
@ -4166,7 +4166,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
ok = JS_TRUE;
|
||||
} else {
|
||||
table = (TableEntry *)
|
||||
JS_malloc(cx, (size_t)n * sizeof *table);
|
||||
cx->malloc((size_t)n * sizeof *table);
|
||||
if (!table)
|
||||
return NULL;
|
||||
for (i = j = 0; i < n; i++) {
|
||||
|
@ -4186,12 +4186,12 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
pc2 += jmplen;
|
||||
}
|
||||
tmp = (TableEntry *)
|
||||
JS_malloc(cx, (size_t)j * sizeof *table);
|
||||
cx->malloc((size_t)j * sizeof *table);
|
||||
if (tmp) {
|
||||
VOUCH_DOES_NOT_REQUIRE_STACK();
|
||||
ok = js_MergeSort(table, (size_t)j, sizeof(TableEntry),
|
||||
CompareOffsets, NULL, tmp);
|
||||
JS_free(cx, tmp);
|
||||
cx->free(tmp);
|
||||
} else {
|
||||
ok = JS_FALSE;
|
||||
}
|
||||
|
@ -4201,7 +4201,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
ok = DecompileSwitch(ss, table, (uintN)j, pc, len, off,
|
||||
JS_FALSE);
|
||||
}
|
||||
JS_free(cx, table);
|
||||
cx->free(table);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
todo = -2;
|
||||
|
@ -4227,7 +4227,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
pc2 += UINT16_LEN;
|
||||
|
||||
table = (TableEntry *)
|
||||
JS_malloc(cx, (size_t)npairs * sizeof *table);
|
||||
cx->malloc((size_t)npairs * sizeof *table);
|
||||
if (!table)
|
||||
return NULL;
|
||||
for (k = 0; k < npairs; k++) {
|
||||
|
@ -4248,7 +4248,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
|
||||
ok = DecompileSwitch(ss, table, (uintN)npairs, pc, len, off,
|
||||
JS_FALSE);
|
||||
JS_free(cx, table);
|
||||
cx->free(table);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
todo = -2;
|
||||
|
@ -4292,7 +4292,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
* and the distance to its statements in table[i].offset.
|
||||
*/
|
||||
table = (TableEntry *)
|
||||
JS_malloc(cx, (size_t)ncases * sizeof *table);
|
||||
cx->malloc((size_t)ncases * sizeof *table);
|
||||
if (!table)
|
||||
return NULL;
|
||||
pc2 = pc;
|
||||
|
@ -4322,7 +4322,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
|
||||
ok = DecompileSwitch(ss, table, (uintN)ncases, pc, len, off,
|
||||
JS_TRUE);
|
||||
JS_free(cx, table);
|
||||
cx->free(table);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
todo = -2;
|
||||
|
@ -4370,7 +4370,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
break;
|
||||
}
|
||||
|
||||
argv = (char **) JS_malloc(cx, size_t(argc) * sizeof *argv);
|
||||
argv = (char **) cx->malloc(size_t(argc) * sizeof *argv);
|
||||
if (!argv)
|
||||
return NULL;
|
||||
|
||||
|
@ -4394,8 +4394,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
}
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
JS_free(cx, argv[i]);
|
||||
JS_free(cx, argv);
|
||||
cx->free(argv[i]);
|
||||
cx->free(argv);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
|
||||
|
@ -4728,7 +4728,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
|
|||
(*rval == '\0' ||
|
||||
(SprintPut(&ss->sprinter, " ", 1) >= 0 &&
|
||||
SprintCString(&ss->sprinter, rval)));
|
||||
JS_free(cx, (char *)rval);
|
||||
cx->free((char *)rval);
|
||||
if (!ok)
|
||||
return NULL;
|
||||
SprintPut(&ss->sprinter, "?>", 2);
|
||||
|
@ -4836,7 +4836,7 @@ DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len,
|
|||
|
||||
ok = Decompile(&ss, pc, len, JSOP_NOP) != NULL;
|
||||
if (code != oldcode) {
|
||||
JS_free(cx, jp->script->code);
|
||||
cx->free(jp->script->code);
|
||||
jp->script->code = oldcode;
|
||||
jp->script->main = oldmain;
|
||||
}
|
||||
|
@ -5055,7 +5055,7 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v,
|
|||
* populated interpreter's stack with its current content.
|
||||
*/
|
||||
pcstack = (jsbytecode **)
|
||||
JS_malloc(cx, StackDepth(script) * sizeof *pcstack);
|
||||
cx->malloc(StackDepth(script) * sizeof *pcstack);
|
||||
if (!pcstack)
|
||||
return NULL;
|
||||
pcdepth = ReconstructPCStack(cx, script, pc, pcstack);
|
||||
|
@ -5096,7 +5096,7 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v,
|
|||
}
|
||||
|
||||
release_pcstack:
|
||||
JS_free(cx, pcstack);
|
||||
cx->free(pcstack);
|
||||
if (pcdepth < 0)
|
||||
goto do_fallback;
|
||||
}
|
||||
|
@ -5232,7 +5232,7 @@ DecompileExpression(JSContext *cx, JSScript *script, JSFunction *fun,
|
|||
}
|
||||
|
||||
pcstack = (jsbytecode **)
|
||||
JS_malloc(cx, StackDepth(script) * sizeof *pcstack);
|
||||
cx->malloc(StackDepth(script) * sizeof *pcstack);
|
||||
if (!pcstack) {
|
||||
name = NULL;
|
||||
goto out;
|
||||
|
@ -5259,12 +5259,12 @@ DecompileExpression(JSContext *cx, JSScript *script, JSFunction *fun,
|
|||
|
||||
out:
|
||||
if (code != oldcode) {
|
||||
JS_free(cx, script->code);
|
||||
cx->free(script->code);
|
||||
script->code = oldcode;
|
||||
script->main = oldmain;
|
||||
}
|
||||
|
||||
JS_free(cx, pcstack);
|
||||
cx->free(pcstack);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -5339,7 +5339,7 @@ SimulateImacroCFG(JSContext *cx, JSScript *script,
|
|||
jsbytecode **pcstack)
|
||||
{
|
||||
size_t nbytes = StackDepth(script) * sizeof *pcstack;
|
||||
jsbytecode** tmp_pcstack = (jsbytecode **) JS_malloc(cx, nbytes);
|
||||
jsbytecode** tmp_pcstack = (jsbytecode **) cx->malloc(nbytes);
|
||||
if (!tmp_pcstack)
|
||||
return -1;
|
||||
memcpy(tmp_pcstack, pcstack, nbytes);
|
||||
|
@ -5379,11 +5379,11 @@ SimulateImacroCFG(JSContext *cx, JSScript *script,
|
|||
|
||||
success:
|
||||
memcpy(pcstack, tmp_pcstack, nbytes);
|
||||
JS_free(cx, tmp_pcstack);
|
||||
cx->free(tmp_pcstack);
|
||||
return pcdepth;
|
||||
|
||||
failure:
|
||||
JS_free(cx, tmp_pcstack);
|
||||
cx->free(tmp_pcstack);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -3802,7 +3802,7 @@ CheckDestructuring(JSContext *cx, BindData *data,
|
|||
/*
|
||||
* This is a greatly pared down version of CheckDestructuring that extends the
|
||||
* pn_pos.end source coordinate of each name in a destructuring binding such as
|
||||
*
|
||||
*
|
||||
* var [x, y] = [function () y, 42];
|
||||
*
|
||||
* to cover its corresponding initializer, so that the initialized binding does
|
||||
|
@ -9036,12 +9036,12 @@ js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc, bool inCond)
|
|||
}
|
||||
|
||||
/* Allocate a new buffer and string descriptor for the result. */
|
||||
chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ static int cvt_ws(SprintfState *ss, const jschar *ws, int width, int prec,
|
|||
if (!s)
|
||||
return -1; /* JSStuffFunc error indicator. */
|
||||
result = cvt_s(ss, s, width, prec, flags);
|
||||
free(s);
|
||||
js_free(s);
|
||||
} else {
|
||||
result = cvt_s(ss, NULL, width, prec, flags);
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
|
|||
|
||||
if( *rv < 0 ){
|
||||
if( nas != nasArray )
|
||||
free( nas );
|
||||
js_free( nas );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -667,7 +667,7 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
|
|||
|
||||
default:
|
||||
if( nas != nasArray )
|
||||
free( nas );
|
||||
js_free( nas );
|
||||
*rv = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
|
|||
|
||||
if( nas[i-1].type == TYPE_UNKNOWN ){
|
||||
if( nas && ( nas != nasArray ) )
|
||||
free( nas );
|
||||
js_free( nas );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
|
|||
rv = (*ss->stuff)(ss, "\0", 1);
|
||||
|
||||
if( nas && ( nas != nasArray ) ){
|
||||
free( nas );
|
||||
js_free( nas );
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -1098,9 +1098,9 @@ static int GrowStuff(SprintfState *ss, const char *sp, JSUint32 len)
|
|||
/* Grow the buffer */
|
||||
newlen = ss->maxlen + ((len > 32) ? len : 32);
|
||||
if (ss->base) {
|
||||
newbase = (char*) realloc(ss->base, newlen);
|
||||
newbase = (char*) js_realloc(ss->base, newlen);
|
||||
} else {
|
||||
newbase = (char*) malloc(newlen);
|
||||
newbase = (char*) js_malloc(newlen);
|
||||
}
|
||||
if (!newbase) {
|
||||
/* Ran out of memory */
|
||||
|
@ -1139,7 +1139,7 @@ JS_PUBLIC_API(char *) JS_smprintf(const char *fmt, ...)
|
|||
*/
|
||||
JS_PUBLIC_API(void) JS_smprintf_free(char *mem)
|
||||
{
|
||||
free(mem);
|
||||
js_free(mem);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(char *) JS_vsmprintf(const char *fmt, va_list ap)
|
||||
|
@ -1154,7 +1154,7 @@ JS_PUBLIC_API(char *) JS_vsmprintf(const char *fmt, va_list ap)
|
|||
rv = dosprintf(&ss, fmt, ap);
|
||||
if (rv < 0) {
|
||||
if (ss.base) {
|
||||
free(ss.base);
|
||||
js_free(ss.base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1253,7 +1253,7 @@ JS_PUBLIC_API(char *) JS_vsprintf_append(char *last, const char *fmt, va_list ap
|
|||
rv = dosprintf(&ss, fmt, ap);
|
||||
if (rv < 0) {
|
||||
if (ss.base) {
|
||||
free(ss.base);
|
||||
js_free(ss.base);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -106,8 +106,8 @@ typedef enum JSAccessMode {
|
|||
JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */
|
||||
JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */
|
||||
|
||||
/*
|
||||
* enum value #2 formerly called JSACC_IMPORT,
|
||||
/*
|
||||
* enum value #2 formerly called JSACC_IMPORT,
|
||||
* gap preserved for ABI compatibility.
|
||||
*/
|
||||
|
||||
|
@ -145,7 +145,6 @@ typedef struct JSObject JSObject;
|
|||
typedef struct JSObjectMap JSObjectMap;
|
||||
typedef struct JSObjectOps JSObjectOps;
|
||||
typedef struct JSRuntime JSRuntime;
|
||||
typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
|
||||
typedef struct JSScript JSScript;
|
||||
typedef struct JSStackFrame JSStackFrame;
|
||||
typedef struct JSString JSString;
|
||||
|
|
|
@ -585,12 +585,12 @@ ParseRegExp(CompilerState *state)
|
|||
}
|
||||
|
||||
operatorStack = (REOpData *)
|
||||
JS_malloc(state->context, sizeof(REOpData) * operatorStackSize);
|
||||
state->context->malloc(sizeof(REOpData) * operatorStackSize);
|
||||
if (!operatorStack)
|
||||
return JS_FALSE;
|
||||
|
||||
operandStack = (RENode **)
|
||||
JS_malloc(state->context, sizeof(RENode *) * operandStackSize);
|
||||
state->context->malloc(sizeof(RENode *) * operandStackSize);
|
||||
if (!operandStack)
|
||||
goto out;
|
||||
|
||||
|
@ -682,8 +682,8 @@ pushOperand:
|
|||
RENode **tmp;
|
||||
operandStackSize += operandStackSize;
|
||||
tmp = (RENode **)
|
||||
JS_realloc(state->context, operandStack,
|
||||
sizeof(RENode *) * operandStackSize);
|
||||
state->context->realloc(operandStack,
|
||||
sizeof(RENode *) * operandStackSize);
|
||||
if (!tmp)
|
||||
goto out;
|
||||
operandStack = tmp;
|
||||
|
@ -817,8 +817,8 @@ pushOperator:
|
|||
REOpData *tmp;
|
||||
operatorStackSize += operatorStackSize;
|
||||
tmp = (REOpData *)
|
||||
JS_realloc(state->context, operatorStack,
|
||||
sizeof(REOpData) * operatorStackSize);
|
||||
state->context->realloc(operatorStack,
|
||||
sizeof(REOpData) * operatorStackSize);
|
||||
if (!tmp)
|
||||
goto out;
|
||||
operatorStack = tmp;
|
||||
|
@ -831,9 +831,9 @@ pushOperator:
|
|||
}
|
||||
out:
|
||||
if (operatorStack)
|
||||
JS_free(state->context, operatorStack);
|
||||
state->context->free(operatorStack);
|
||||
if (operandStack)
|
||||
JS_free(state->context, operandStack);
|
||||
state->context->free(operandStack);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1647,9 +1647,8 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth,
|
|||
emitStateStack = NULL;
|
||||
} else {
|
||||
emitStateStack =
|
||||
(EmitStateStackEntry *)JS_malloc(state->context,
|
||||
sizeof(EmitStateStackEntry) *
|
||||
treeDepth);
|
||||
(EmitStateStackEntry *)
|
||||
state->context->malloc(sizeof(EmitStateStackEntry) * treeDepth);
|
||||
if (!emitStateStack)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1951,7 +1950,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth,
|
|||
|
||||
cleanup:
|
||||
if (emitStateStack)
|
||||
JS_free(state->context, emitStateStack);
|
||||
state->context->free(emitStateStack);
|
||||
return pc;
|
||||
|
||||
jump_too_big:
|
||||
|
@ -1997,7 +1996,7 @@ CompileRegExpToAST(JSContext* cx, JSTokenStream* ts,
|
|||
+ GetCompactIndexWidth(len);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return ParseRegExp(&state);
|
||||
}
|
||||
|
||||
|
@ -2410,7 +2409,7 @@ class RegExpNativeCompiler {
|
|||
LIns *branch = lir->insBranch(LIR_jt, test, 0);
|
||||
extras[i].match = branch;
|
||||
}
|
||||
|
||||
|
||||
fails.pushBack(lir->insBranch(LIR_jf, lir->ins2(LIR_eq, text_ch, lir->insImm(ch)), 0));
|
||||
|
||||
for (int i = 0; i < nextras; ++i)
|
||||
|
@ -2418,7 +2417,7 @@ class RegExpNativeCompiler {
|
|||
return lir->ins2(LIR_piadd, pos, lir->insImm(2));
|
||||
}
|
||||
|
||||
JS_INLINE bool hasCases(jschar ch)
|
||||
JS_INLINE bool hasCases(jschar ch)
|
||||
{
|
||||
return JS_TOLOWER(ch) != JS_TOUPPER(ch);
|
||||
}
|
||||
|
@ -3166,10 +3165,6 @@ CompileRegExpToNative(JSContext* cx, JSRegExp* re, Fragment* fragment)
|
|||
goto out;
|
||||
}
|
||||
rv = rc.compile(cx);
|
||||
static int fail = 0; // TODO: remove
|
||||
if (!rv)
|
||||
++fail;
|
||||
debug_only_printf(LC_TMRegexp, "## Fail? %d, Total %d\n", (int)!rv, fail);
|
||||
out:
|
||||
JS_ARENA_RELEASE(&cx->tempPool, mark);
|
||||
return rv;
|
||||
|
@ -3232,7 +3227,7 @@ js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
|||
goto out;
|
||||
|
||||
resize = offsetof(JSRegExp, program) + state.progLength + 1;
|
||||
re = (JSRegExp *) JS_malloc(cx, resize);
|
||||
re = (JSRegExp *) cx->malloc(resize);
|
||||
if (!re)
|
||||
goto out;
|
||||
|
||||
|
@ -3241,7 +3236,7 @@ js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
|||
re->classCount = state.classCount;
|
||||
if (re->classCount) {
|
||||
re->classList = (RECharSet *)
|
||||
JS_malloc(cx, re->classCount * sizeof(RECharSet));
|
||||
cx->malloc(re->classCount * sizeof(RECharSet));
|
||||
if (!re->classList) {
|
||||
js_DestroyRegExp(cx, re);
|
||||
re = NULL;
|
||||
|
@ -3270,7 +3265,7 @@ js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
|||
JSRegExp *tmp;
|
||||
JS_ASSERT((size_t)(endPC - re->program) < state.progLength + 1);
|
||||
resize = offsetof(JSRegExp, program) + (endPC - re->program);
|
||||
tmp = (JSRegExp *) JS_realloc(cx, re, resize);
|
||||
tmp = (JSRegExp *) cx->realloc(re, resize);
|
||||
if (tmp)
|
||||
re = tmp;
|
||||
}
|
||||
|
@ -3610,7 +3605,7 @@ ProcessCharSet(JSContext *cx, JSRegExp *re, RECharSet *charSet)
|
|||
JS_ASSERT(end[0] == ']');
|
||||
|
||||
byteLength = (charSet->length >> 3) + 1;
|
||||
charSet->u.bits = (uint8 *)JS_malloc(cx, byteLength);
|
||||
charSet->u.bits = (uint8 *)cx->malloc(byteLength);
|
||||
if (!charSet->u.bits) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -3804,12 +3799,12 @@ js_DestroyRegExp(JSContext *cx, JSRegExp *re)
|
|||
uintN i;
|
||||
for (i = 0; i < re->classCount; i++) {
|
||||
if (re->classList[i].converted)
|
||||
JS_free(cx, re->classList[i].u.bits);
|
||||
cx->free(re->classList[i].u.bits);
|
||||
re->classList[i].u.bits = NULL;
|
||||
}
|
||||
JS_free(cx, re->classList);
|
||||
cx->free(re->classList);
|
||||
}
|
||||
JS_free(cx, re);
|
||||
cx->free(re);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4874,12 +4869,12 @@ js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp,
|
|||
if (!morepar) {
|
||||
res->moreLength = 10;
|
||||
morepar = (JSSubString*)
|
||||
JS_malloc(cx, 10 * sizeof(JSSubString));
|
||||
cx->malloc(10 * sizeof(JSSubString));
|
||||
} else if (morenum >= res->moreLength) {
|
||||
res->moreLength += 10;
|
||||
morepar = (JSSubString*)
|
||||
JS_realloc(cx, morepar,
|
||||
res->moreLength * sizeof(JSSubString));
|
||||
cx->realloc(morepar,
|
||||
res->moreLength * sizeof(JSSubString));
|
||||
}
|
||||
if (!morepar) {
|
||||
cx->weakRoots.newborn[GCX_OBJECT] = NULL;
|
||||
|
@ -5118,7 +5113,7 @@ js_FreeRegExpStatics(JSContext *cx)
|
|||
JSRegExpStatics *res = &cx->regExpStatics;
|
||||
|
||||
if (res->moreParens) {
|
||||
JS_free(cx, res->moreParens);
|
||||
cx->free(res->moreParens);
|
||||
res->moreParens = NULL;
|
||||
}
|
||||
JS_FinishArenaPool(&cx->regexpPool);
|
||||
|
@ -5369,7 +5364,7 @@ js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp)
|
|||
nflags = 0;
|
||||
for (flags = re->flags; flags != 0; flags &= flags - 1)
|
||||
nflags++;
|
||||
chars = (jschar*) JS_malloc(cx, (length + nflags + 1) * sizeof(jschar));
|
||||
chars = (jschar*) cx->malloc((length + nflags + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
JS_UNLOCK_OBJ(cx, obj);
|
||||
return JS_FALSE;
|
||||
|
@ -5393,7 +5388,7 @@ js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp)
|
|||
|
||||
str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -5476,15 +5471,15 @@ regexp_compile_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
if (*cp == '/' && (cp == start || cp[-1] != '\\')) {
|
||||
nbytes = (++length + 1) * sizeof(jschar);
|
||||
if (!nstart) {
|
||||
nstart = (jschar *) JS_malloc(cx, nbytes);
|
||||
nstart = (jschar *) cx->malloc(nbytes);
|
||||
if (!nstart)
|
||||
return JS_FALSE;
|
||||
ncp = nstart + (cp - start);
|
||||
js_strncpy(nstart, start, cp - start);
|
||||
} else {
|
||||
tmp = (jschar *) JS_realloc(cx, nstart, nbytes);
|
||||
tmp = (jschar *) cx->realloc(nstart, nbytes);
|
||||
if (!tmp) {
|
||||
JS_free(cx, nstart);
|
||||
cx->free(nstart);
|
||||
return JS_FALSE;
|
||||
}
|
||||
ncp = tmp + (ncp - nstart);
|
||||
|
@ -5502,7 +5497,7 @@ regexp_compile_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
*ncp = 0;
|
||||
str = js_NewString(cx, nstart, length);
|
||||
if (!str) {
|
||||
JS_free(cx, nstart);
|
||||
cx->free(nstart);
|
||||
return JS_FALSE;
|
||||
}
|
||||
argv[0] = STRING_TO_JSVAL(str);
|
||||
|
|
|
@ -258,7 +258,7 @@ void
|
|||
js_CloseTokenStream(JSContext *cx, JSTokenStream *ts)
|
||||
{
|
||||
if (ts->flags & TSF_OWNFILENAME)
|
||||
JS_free(cx, (void *) ts->filename);
|
||||
cx->free((void *) ts->filename);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(int)
|
||||
|
@ -308,7 +308,7 @@ GetChar(JSTokenStream *ts)
|
|||
ts->flags |= TSF_EOF;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
||||
/* Fill ts->userbuf so that \r and \r\n convert to \n. */
|
||||
crflag = (ts->flags & TSF_CRFLAG) != 0;
|
||||
len = js_fgets(cbuf, JS_LINE_LIMIT - crflag, ts->file);
|
||||
|
@ -336,7 +336,7 @@ GetChar(JSTokenStream *ts)
|
|||
ts->listener(ts->filename, ts->lineno, ts->userbuf.ptr, len,
|
||||
&ts->listenerTSData, ts->listenerData);
|
||||
}
|
||||
|
||||
|
||||
nl = ts->saveEOL;
|
||||
if (!nl) {
|
||||
/*
|
||||
|
@ -362,7 +362,7 @@ GetChar(JSTokenStream *ts)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If there was a line terminator, copy thru it into linebuf.
|
||||
* Else copy JS_LINE_LIMIT-1 bytes into linebuf.
|
||||
|
@ -378,7 +378,7 @@ GetChar(JSTokenStream *ts)
|
|||
js_strncpy(ts->linebuf.base, ts->userbuf.ptr, len);
|
||||
ts->userbuf.ptr += len;
|
||||
olen = len;
|
||||
|
||||
|
||||
/*
|
||||
* Make sure linebuf contains \n for EOL (don't do this in
|
||||
* userbuf because the user's string might be readonly).
|
||||
|
@ -420,11 +420,11 @@ GetChar(JSTokenStream *ts)
|
|||
ts->linebuf.base[len-1] = '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Reset linebuf based on adjusted segment length. */
|
||||
ts->linebuf.limit = ts->linebuf.base + len;
|
||||
ts->linebuf.ptr = ts->linebuf.base;
|
||||
|
||||
|
||||
/* Update position of linebuf within physical userbuf line. */
|
||||
if (!(ts->flags & TSF_NLFLAG))
|
||||
ts->linepos += ts->linelen;
|
||||
|
@ -434,7 +434,7 @@ GetChar(JSTokenStream *ts)
|
|||
ts->flags |= TSF_NLFLAG;
|
||||
else
|
||||
ts->flags &= ~TSF_NLFLAG;
|
||||
|
||||
|
||||
/* Update linelen from original segment length. */
|
||||
ts->linelen = olen;
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
|
|||
}
|
||||
report.lineno = ts->lineno;
|
||||
linelength = ts->linebuf.limit - ts->linebuf.base;
|
||||
linechars = (jschar *)JS_malloc(cx, (linelength + 1) * sizeof(jschar));
|
||||
linechars = (jschar *)cx->malloc((linelength + 1) * sizeof(jschar));
|
||||
if (!linechars) {
|
||||
warning = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -651,21 +651,21 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
|
|||
|
||||
out:
|
||||
if (linebytes)
|
||||
JS_free(cx, linebytes);
|
||||
cx->free(linebytes);
|
||||
if (linechars)
|
||||
JS_free(cx, linechars);
|
||||
cx->free(linechars);
|
||||
if (message)
|
||||
JS_free(cx, message);
|
||||
cx->free(message);
|
||||
if (report.ucmessage)
|
||||
JS_free(cx, (void *)report.ucmessage);
|
||||
cx->free((void *)report.ucmessage);
|
||||
|
||||
if (report.messageArgs) {
|
||||
if (!(flags & JSREPORT_UC)) {
|
||||
i = 0;
|
||||
while (report.messageArgs[i])
|
||||
JS_free(cx, (void *)report.messageArgs[i++]);
|
||||
cx->free((void *)report.messageArgs[i++]);
|
||||
}
|
||||
JS_free(cx, (void *)report.messageArgs);
|
||||
cx->free((void *)report.messageArgs);
|
||||
}
|
||||
|
||||
if (!JSREPORT_IS_WARNING(flags)) {
|
||||
|
@ -698,7 +698,7 @@ GrowStringBuffer(JSStringBuffer *sb, size_t amount)
|
|||
|
||||
/* Now do the full overflow check. */
|
||||
if (size_t(offset) < newlength && newlength < ~size_t(0) / sizeof(jschar)) {
|
||||
jschar *bp = (jschar *) realloc(sb->base, newlength * sizeof(jschar));
|
||||
jschar *bp = (jschar *) js_realloc(sb->base, newlength * sizeof(jschar));
|
||||
if (bp) {
|
||||
sb->base = bp;
|
||||
sb->ptr = bp + offset;
|
||||
|
@ -709,7 +709,7 @@ GrowStringBuffer(JSStringBuffer *sb, size_t amount)
|
|||
}
|
||||
|
||||
/* Either newlength overflow or realloc failure: poison the well. */
|
||||
free(sb->base);
|
||||
js_free(sb->base);
|
||||
sb->base = STRING_BUFFER_ERROR_BASE;
|
||||
return false;
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ FreeStringBuffer(JSStringBuffer *sb)
|
|||
{
|
||||
JS_ASSERT(STRING_BUFFER_OK(sb));
|
||||
if (sb->base)
|
||||
free(sb->base);
|
||||
js_free(sb->base);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -924,7 +924,7 @@ bad:
|
|||
if (bytes) {
|
||||
js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
|
||||
msg, bytes);
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1788,7 +1788,7 @@ retry:
|
|||
if (c == '\n') {
|
||||
if (i > 0) {
|
||||
if (ts->flags & TSF_OWNFILENAME)
|
||||
JS_free(cx, (void *) ts->filename);
|
||||
cx->free((void *) ts->filename);
|
||||
ts->filename = JS_strdup(cx, filename);
|
||||
if (!ts->filename)
|
||||
goto error;
|
||||
|
|
|
@ -166,7 +166,7 @@ JSScope::createTable(JSContext *cx, bool report)
|
|||
sizeLog2 = MIN_SCOPE_SIZE_LOG2;
|
||||
}
|
||||
|
||||
table = (JSScopeProperty **) calloc(JS_BIT(sizeLog2), sizeof(JSScopeProperty *));
|
||||
table = (JSScopeProperty **) js_calloc(JS_BIT(sizeLog2) * sizeof(JSScopeProperty *));
|
||||
if (!table) {
|
||||
if (report)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
@ -188,7 +188,7 @@ JSScope::create(JSContext *cx, JSObjectOps *ops, JSClass *clasp, JSObject *obj)
|
|||
JS_ASSERT(OPS_IS_NATIVE(ops));
|
||||
JS_ASSERT(obj);
|
||||
|
||||
JSScope *scope = (JSScope *) JS_malloc(cx, sizeof(JSScope));
|
||||
JSScope *scope = (JSScope *) cx->malloc(sizeof(JSScope));
|
||||
if (!scope)
|
||||
return NULL;
|
||||
|
||||
|
@ -196,7 +196,7 @@ JSScope::create(JSContext *cx, JSObjectOps *ops, JSClass *clasp, JSObject *obj)
|
|||
scope->object = obj;
|
||||
scope->nrefs = 1;
|
||||
scope->freeslot = JSSLOT_FREE(clasp);
|
||||
scope->flags = 0;
|
||||
scope->flags = cx->runtime->gcRegenShapesScopeFlag;
|
||||
js_LeaveTraceIfGlobalObject(cx, obj);
|
||||
scope->initMinimal(cx);
|
||||
|
||||
|
@ -213,7 +213,7 @@ JSScope::createEmptyScope(JSContext *cx, JSClass *clasp)
|
|||
{
|
||||
JS_ASSERT(!emptyScope);
|
||||
|
||||
JSScope *scope = (JSScope *) JS_malloc(cx, sizeof(JSScope));
|
||||
JSScope *scope = (JSScope *) cx->malloc(sizeof(JSScope));
|
||||
if (!scope)
|
||||
return NULL;
|
||||
|
||||
|
@ -226,7 +226,7 @@ JSScope::createEmptyScope(JSContext *cx, JSClass *clasp)
|
|||
*/
|
||||
scope->nrefs = 2;
|
||||
scope->freeslot = JSSLOT_FREE(clasp);
|
||||
scope->flags = 0;
|
||||
scope->flags = OWN_SHAPE | cx->runtime->gcRegenShapesScopeFlag;
|
||||
scope->initMinimal(cx);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
@ -252,13 +252,13 @@ JSScope::destroy(JSContext *cx, JSScope *scope)
|
|||
js_FinishTitle(cx, &scope->title);
|
||||
#endif
|
||||
if (scope->table)
|
||||
JS_free(cx, scope->table);
|
||||
cx->free(scope->table);
|
||||
if (scope->emptyScope)
|
||||
scope->emptyScope->drop(cx, NULL);
|
||||
|
||||
LIVE_SCOPE_METER(cx, cx->runtime->liveScopeProps -= scope->entryCount);
|
||||
JS_RUNTIME_UNMETER(cx->runtime, liveScopes);
|
||||
JS_free(cx, scope);
|
||||
cx->free(scope);
|
||||
}
|
||||
|
||||
#ifdef JS_DUMP_PROPTREE_STATS
|
||||
|
@ -401,11 +401,9 @@ JSScope::changeTable(JSContext *cx, int change)
|
|||
oldsize = JS_BIT(oldlog2);
|
||||
newsize = JS_BIT(newlog2);
|
||||
nbytes = SCOPE_TABLE_NBYTES(newsize);
|
||||
newtable = (JSScopeProperty **) calloc(nbytes, 1);
|
||||
if (!newtable) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
newtable = (JSScopeProperty **) cx->calloc(nbytes);
|
||||
if (!newtable)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Now that we have newtable allocated, update members. */
|
||||
hashShift = JS_DHASH_BITS - newlog2;
|
||||
|
@ -428,7 +426,7 @@ JSScope::changeTable(JSContext *cx, int change)
|
|||
}
|
||||
|
||||
/* Finally, free the old table storage. */
|
||||
JS_free(cx, oldtable);
|
||||
cx->free(oldtable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -578,7 +576,7 @@ NewPropTreeKidsChunk(JSRuntime *rt)
|
|||
{
|
||||
PropTreeKidsChunk *chunk;
|
||||
|
||||
chunk = (PropTreeKidsChunk *) calloc(1, sizeof *chunk);
|
||||
chunk = (PropTreeKidsChunk *) js_calloc(sizeof *chunk);
|
||||
if (!chunk)
|
||||
return NULL;
|
||||
JS_ASSERT(((jsuword)chunk & CHUNKY_KIDS_TAG) == 0);
|
||||
|
@ -592,7 +590,7 @@ DestroyPropTreeKidsChunk(JSRuntime *rt, PropTreeKidsChunk *chunk)
|
|||
JS_RUNTIME_UNMETER(rt, propTreeKidsChunks);
|
||||
if (chunk->table)
|
||||
JS_DHashTableDestroy(chunk->table);
|
||||
free(chunk);
|
||||
js_free(chunk);
|
||||
}
|
||||
|
||||
/* NB: Called with rt->gcLock held. */
|
||||
|
@ -1215,7 +1213,7 @@ JSScope::add(JSContext *cx, jsid id,
|
|||
splen = entryCount;
|
||||
JS_ASSERT(splen != 0);
|
||||
spvec = (JSScopeProperty **)
|
||||
JS_malloc(cx, SCOPE_TABLE_NBYTES(splen));
|
||||
cx->malloc(SCOPE_TABLE_NBYTES(splen));
|
||||
if (!spvec)
|
||||
goto fail_overwrite;
|
||||
i = splen;
|
||||
|
@ -1248,7 +1246,7 @@ JSScope::add(JSContext *cx, jsid id,
|
|||
} else {
|
||||
sprop = GetPropertyTreeChild(cx, sprop, spvec[i]);
|
||||
if (!sprop) {
|
||||
JS_free(cx, spvec);
|
||||
cx->free(spvec);
|
||||
goto fail_overwrite;
|
||||
}
|
||||
|
||||
|
@ -1257,7 +1255,7 @@ JSScope::add(JSContext *cx, jsid id,
|
|||
SPROP_STORE_PRESERVING_COLLISION(spp2, sprop);
|
||||
}
|
||||
} while (++i < splen);
|
||||
JS_free(cx, spvec);
|
||||
cx->free(spvec);
|
||||
|
||||
/*
|
||||
* Now sprop points to the last property in this scope, where
|
||||
|
@ -1558,7 +1556,7 @@ JSScope::clear(JSContext *cx)
|
|||
LIVE_SCOPE_METER(cx, cx->runtime->liveScopeProps -= entryCount);
|
||||
|
||||
if (table)
|
||||
free(table);
|
||||
js_free(table);
|
||||
clearMiddleDelete();
|
||||
js_LeaveTraceIfGlobalObject(cx, object);
|
||||
initMinimal(cx);
|
||||
|
@ -1594,7 +1592,7 @@ JSScope::replacingShapeChange(JSContext *cx, JSScopeProperty *sprop, JSScopeProp
|
|||
{
|
||||
if (shape == sprop->shape)
|
||||
shape = newsprop->shape;
|
||||
else
|
||||
else
|
||||
generateOwnShape(cx);
|
||||
}
|
||||
|
||||
|
@ -1604,7 +1602,7 @@ JSScope::sealingShapeChange(JSContext *cx)
|
|||
generateOwnShape(cx);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
JSScope::shadowingShapeChange(JSContext *cx, JSScopeProperty *sprop)
|
||||
{
|
||||
generateOwnShape(cx);
|
||||
|
@ -1651,7 +1649,7 @@ JSScopeProperty::trace(JSTracer *trc)
|
|||
{
|
||||
if (IS_GC_MARKING_TRACER(trc))
|
||||
flags |= SPROP_MARK;
|
||||
TRACE_ID(trc, id);
|
||||
js_TraceId(trc, id);
|
||||
|
||||
#if JS_HAS_GETTER_SETTER
|
||||
if (attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
|
||||
|
|
|
@ -265,6 +265,8 @@ struct JSScope {
|
|||
|
||||
void extend(JSContext *cx, JSScopeProperty *sprop);
|
||||
|
||||
void trace(JSTracer *trc);
|
||||
|
||||
void brandingShapeChange(JSContext *cx, uint32 slot, jsval v);
|
||||
void deletingShapeChange(JSContext *cx, JSScopeProperty *sprop);
|
||||
void methodShapeChange(JSContext *cx, uint32 slot, jsval toval);
|
||||
|
@ -283,7 +285,13 @@ struct JSScope {
|
|||
SEALED = 0x0002,
|
||||
BRANDED = 0x0004,
|
||||
INDEXED_PROPERTIES = 0x0008,
|
||||
OWN_SHAPE = 0x0010
|
||||
OWN_SHAPE = 0x0010,
|
||||
|
||||
/*
|
||||
* This flag toggles with each shape-regenerating GC cycle.
|
||||
* See JSRuntime::gcRegenShapesScopeFlag.
|
||||
*/
|
||||
SHAPE_REGEN = 0x0020
|
||||
};
|
||||
|
||||
bool hadMiddleDelete() { return flags & MIDDLE_DELETE; }
|
||||
|
@ -312,6 +320,8 @@ struct JSScope {
|
|||
bool hasOwnShape() { return flags & OWN_SHAPE; }
|
||||
void setOwnShape() { flags |= OWN_SHAPE; }
|
||||
|
||||
bool hasRegenFlag(uint8 regenFlag) { return (flags & SHAPE_REGEN) == regenFlag; }
|
||||
|
||||
bool owned() { return object != NULL; }
|
||||
};
|
||||
|
||||
|
@ -493,6 +503,54 @@ JSScope::extend(JSContext *cx, JSScopeProperty *sprop)
|
|||
lastProp = sprop;
|
||||
}
|
||||
|
||||
inline void
|
||||
JSScope::trace(JSTracer *trc)
|
||||
{
|
||||
JSContext *cx = trc->context;
|
||||
JSScopeProperty *sprop = lastProp;
|
||||
uint8 regenFlag = cx->runtime->gcRegenShapesScopeFlag;
|
||||
if (IS_GC_MARKING_TRACER(trc) && cx->runtime->gcRegenShapes && hasRegenFlag(regenFlag)) {
|
||||
/*
|
||||
* Either this scope has its own shape, which must be regenerated, or
|
||||
* it must have the same shape as lastProp.
|
||||
*/
|
||||
uint32 newShape;
|
||||
|
||||
if (sprop) {
|
||||
if (!(sprop->flags & SPROP_FLAG_SHAPE_REGEN)) {
|
||||
sprop->shape = js_RegenerateShapeForGC(cx);
|
||||
sprop->flags |= SPROP_FLAG_SHAPE_REGEN;
|
||||
}
|
||||
newShape = sprop->shape;
|
||||
}
|
||||
if (!sprop || hasOwnShape()) {
|
||||
newShape = js_RegenerateShapeForGC(cx);
|
||||
JS_ASSERT_IF(sprop, newShape != sprop->shape);
|
||||
}
|
||||
shape = newShape;
|
||||
flags ^= JSScope::SHAPE_REGEN;
|
||||
|
||||
/* Also regenerate the shapes of empty scopes, in case they are not shared. */
|
||||
for (JSScope *empty = emptyScope;
|
||||
empty && empty->hasRegenFlag(regenFlag);
|
||||
empty = empty->emptyScope) {
|
||||
empty->shape = js_RegenerateShapeForGC(cx);
|
||||
empty->flags ^= JSScope::SHAPE_REGEN;
|
||||
}
|
||||
}
|
||||
if (sprop) {
|
||||
JS_ASSERT(has(sprop));
|
||||
|
||||
/* Trace scope's property tree ancestor line. */
|
||||
do {
|
||||
if (hadMiddleDelete() && !has(sprop))
|
||||
continue;
|
||||
sprop->trace(trc);
|
||||
} while ((sprop = sprop->parent) != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static JS_INLINE bool
|
||||
js_GetSprop(JSContext* cx, JSScopeProperty* sprop, JSObject* obj, jsval* vp)
|
||||
{
|
||||
|
@ -545,14 +603,6 @@ js_SetSprop(JSContext* cx, JSScopeProperty* sprop, JSObject* obj, jsval* vp)
|
|||
extern JSScope *
|
||||
js_GetMutableScope(JSContext *cx, JSObject *obj);
|
||||
|
||||
/*
|
||||
* These macros used to inline short code sequences, but they grew over time.
|
||||
* We retain them for internal backward compatibility, and in case one or both
|
||||
* ever shrink to inline-able size.
|
||||
*/
|
||||
#define TRACE_ID(trc, id) js_TraceId(trc, id)
|
||||
#define TRACE_SCOPE_PROPERTY(trc, sprop) sprop->trace(trc)
|
||||
|
||||
extern void
|
||||
js_TraceId(JSTracer *trc, jsid id);
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ script_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
/* Allocate the source string and copy into it. */
|
||||
t = (jschar *) JS_malloc(cx, (n + 1) * sizeof(jschar));
|
||||
t = (jschar *) cx->malloc((n + 1) * sizeof(jschar));
|
||||
if (!t)
|
||||
return JS_FALSE;
|
||||
for (i = 0; i < j; i++)
|
||||
|
@ -154,7 +154,7 @@ script_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
/* Create and return a JS string for t. */
|
||||
str = JS_NewUCString(cx, t, n);
|
||||
if (!str) {
|
||||
JS_free(cx, t);
|
||||
cx->free(t);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -533,7 +533,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
|||
ok = JS_XDRBytes(xdr, (char *) code, length * sizeof(jsbytecode));
|
||||
|
||||
if (code != script->code)
|
||||
JS_free(cx, code);
|
||||
cx->free(code);
|
||||
|
||||
if (!ok)
|
||||
goto error;
|
||||
|
@ -576,7 +576,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
|||
filename = js_SaveScriptFilename(cx, filename);
|
||||
if (!filename)
|
||||
goto error;
|
||||
JS_free(cx, (void *) script->filename);
|
||||
cx->free((void *) script->filename);
|
||||
script->filename = filename;
|
||||
filenameWasSaved = JS_TRUE;
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
|||
if (xdr->mode == JSXDR_DECODE) {
|
||||
JS_POP_TEMP_ROOT(cx, &tvr);
|
||||
if (script->filename && !filenameWasSaved) {
|
||||
JS_free(cx, (void *) script->filename);
|
||||
cx->free((void *) script->filename);
|
||||
script->filename = NULL;
|
||||
}
|
||||
js_DestroyScript(cx, script);
|
||||
|
@ -783,7 +783,7 @@ script_thaw(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
/* Swap bytes in Unichars to keep frozen strings machine-independent. */
|
||||
from = (jschar *)buf;
|
||||
to = (jschar *) JS_malloc(cx, len * sizeof(jschar));
|
||||
to = (jschar *) cx->malloc(len * sizeof(jschar));
|
||||
if (!to) {
|
||||
JS_XDRDestroy(xdr);
|
||||
return JS_FALSE;
|
||||
|
@ -839,7 +839,7 @@ out:
|
|||
JS_XDRMemSetData(xdr, NULL, 0);
|
||||
JS_XDRDestroy(xdr);
|
||||
#if IS_BIG_ENDIAN
|
||||
JS_free(cx, buf);
|
||||
cx->free(buf);
|
||||
#endif
|
||||
*vp = JSVAL_TRUE;
|
||||
return ok;
|
||||
|
@ -995,13 +995,13 @@ typedef struct ScriptFilenameEntry {
|
|||
static void *
|
||||
js_alloc_table_space(void *priv, size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
return js_malloc(size);
|
||||
}
|
||||
|
||||
static void
|
||||
js_free_table_space(void *priv, void *item, size_t size)
|
||||
{
|
||||
free(item);
|
||||
js_free(item);
|
||||
}
|
||||
|
||||
static JSHashEntry *
|
||||
|
@ -1010,7 +1010,7 @@ js_alloc_sftbl_entry(void *priv, const void *key)
|
|||
size_t nbytes = offsetof(ScriptFilenameEntry, filename) +
|
||||
strlen((const char *) key) + 1;
|
||||
|
||||
return (JSHashEntry *) malloc(JS_MAX(nbytes, sizeof(JSHashEntry)));
|
||||
return (JSHashEntry *) js_malloc(JS_MAX(nbytes, sizeof(JSHashEntry)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1018,7 +1018,7 @@ js_free_sftbl_entry(void *priv, JSHashEntry *he, uintN flag)
|
|||
{
|
||||
if (flag != HT_FREE_ENTRY)
|
||||
return;
|
||||
free(he);
|
||||
js_free(he);
|
||||
}
|
||||
|
||||
static JSHashAllocOps sftbl_alloc_ops = {
|
||||
|
@ -1080,7 +1080,7 @@ js_FreeRuntimeScriptState(JSRuntime *rt)
|
|||
while (!JS_CLIST_IS_EMPTY(&rt->scriptFilenamePrefixes)) {
|
||||
sfp = (ScriptFilenamePrefix *) rt->scriptFilenamePrefixes.next;
|
||||
JS_REMOVE_LINK(&sfp->links);
|
||||
free(sfp);
|
||||
js_free(sfp);
|
||||
}
|
||||
js_FinishRuntimeScriptState(rt);
|
||||
}
|
||||
|
@ -1143,7 +1143,7 @@ SaveScriptFilename(JSRuntime *rt, const char *filename, uint32 flags)
|
|||
|
||||
if (!sfp) {
|
||||
/* No such prefix: add one now. */
|
||||
sfp = (ScriptFilenamePrefix *) malloc(sizeof(ScriptFilenamePrefix));
|
||||
sfp = (ScriptFilenamePrefix *) js_malloc(sizeof(ScriptFilenamePrefix));
|
||||
if (!sfp)
|
||||
return NULL;
|
||||
JS_INSERT_AFTER(&sfp->links, link);
|
||||
|
@ -1384,7 +1384,7 @@ js_NewScript(JSContext *cx, uint32 length, uint32 nsrcnotes, uint32 natoms,
|
|||
if (ntrynotes != 0)
|
||||
size += sizeof(JSTryNoteArray) + ntrynotes * sizeof(JSTryNote);
|
||||
|
||||
script = (JSScript *) JS_malloc(cx, size);
|
||||
script = (JSScript *) cx->malloc(size);
|
||||
if (!script)
|
||||
return NULL;
|
||||
memset(script, 0, sizeof(JSScript));
|
||||
|
@ -1536,7 +1536,7 @@ js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
|||
memcpy(JS_SCRIPT_UPVARS(script)->vector, cg->upvarMap.vector,
|
||||
cg->upvarList.count * sizeof(uint32));
|
||||
cg->upvarList.clear();
|
||||
JS_free(cx, cg->upvarMap.vector);
|
||||
cx->free(cg->upvarMap.vector);
|
||||
cg->upvarMap.vector = NULL;
|
||||
}
|
||||
|
||||
|
@ -1648,7 +1648,7 @@ js_DestroyScript(JSContext *cx, JSScript *script)
|
|||
}
|
||||
}
|
||||
|
||||
JS_free(cx, script);
|
||||
cx->free(script);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/*
|
||||
* This header provides definitions for the <stdint.h> types we use,
|
||||
* even on systems that lack <stdint.h>.
|
||||
*
|
||||
*
|
||||
* NOTE: This header should only be included in private SpiderMonkey
|
||||
* code; public headers should use only the JS{Int,Uint}N types; see
|
||||
* the comment for them in "jsinttypes.h".
|
||||
|
|
|
@ -145,7 +145,7 @@ js_ConcatStrings(JSContext *cx, JSString *left, JSString *right)
|
|||
|
||||
if (!left->isMutable()) {
|
||||
/* We must copy if left does not own a buffer to realloc. */
|
||||
s = (jschar *) JS_malloc(cx, (ln + rn + 1) * sizeof(jschar));
|
||||
s = (jschar *) cx->malloc((ln + rn + 1) * sizeof(jschar));
|
||||
if (!s)
|
||||
return NULL;
|
||||
js_strncpy(s, ls, ln);
|
||||
|
@ -153,7 +153,7 @@ js_ConcatStrings(JSContext *cx, JSString *left, JSString *right)
|
|||
} else {
|
||||
/* We can realloc left's space and make it depend on our result. */
|
||||
JS_ASSERT(left->isFlat());
|
||||
s = (jschar *) JS_realloc(cx, ls, (ln + rn + 1) * sizeof(jschar));
|
||||
s = (jschar *) cx->realloc(ls, (ln + rn + 1) * sizeof(jschar));
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
|
@ -173,9 +173,9 @@ js_ConcatStrings(JSContext *cx, JSString *left, JSString *right)
|
|||
if (!str) {
|
||||
/* Out of memory: clean up any space we (re-)allocated. */
|
||||
if (!ldep) {
|
||||
JS_free(cx, s);
|
||||
cx->free(s);
|
||||
} else {
|
||||
s = (jschar *) JS_realloc(cx, ls, (ln + 1) * sizeof(jschar));
|
||||
s = (jschar *) cx->realloc(ls, (ln + 1) * sizeof(jschar));
|
||||
if (s)
|
||||
left->mChars = s;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ js_UndependString(JSContext *cx, JSString *str)
|
|||
if (str->isDependent()) {
|
||||
n = str->dependentLength();
|
||||
size = (n + 1) * sizeof(jschar);
|
||||
s = (jschar *) JS_malloc(cx, size);
|
||||
s = (jschar *) cx->malloc(size);
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
|
@ -402,7 +402,7 @@ js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
newchars = (jschar *) JS_malloc(cx, (newlength + 1) * sizeof(jschar));
|
||||
newchars = (jschar *) cx->malloc((newlength + 1) * sizeof(jschar));
|
||||
if (!newchars)
|
||||
return JS_FALSE;
|
||||
for (i = 0, ni = 0; i < length; i++) {
|
||||
|
@ -430,7 +430,7 @@ js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||
|
||||
str = js_NewString(cx, newchars, newlength);
|
||||
if (!str) {
|
||||
JS_free(cx, newchars);
|
||||
cx->free(newchars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
|
@ -464,7 +464,7 @@ str_unescape(JSContext *cx, uintN argc, jsval *vp)
|
|||
str->getCharsAndLength(chars, length);
|
||||
|
||||
/* Don't bother allocating less space for the new string. */
|
||||
newchars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
newchars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!newchars)
|
||||
return JS_FALSE;
|
||||
ni = i = 0;
|
||||
|
@ -493,7 +493,7 @@ str_unescape(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
str = js_NewString(cx, newchars, ni);
|
||||
if (!str) {
|
||||
JS_free(cx, newchars);
|
||||
cx->free(newchars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -695,7 +695,7 @@ str_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
j = JS_snprintf(buf, sizeof buf, "(new %s(", js_StringClass.name);
|
||||
str->getCharsAndLength(s, k);
|
||||
n = j + k + 2;
|
||||
t = (jschar *) JS_malloc(cx, (n + 1) * sizeof(jschar));
|
||||
t = (jschar *) cx->malloc((n + 1) * sizeof(jschar));
|
||||
if (!t)
|
||||
return JS_FALSE;
|
||||
for (i = 0; i < j; i++)
|
||||
|
@ -707,7 +707,7 @@ str_toSource(JSContext *cx, uintN argc, jsval *vp)
|
|||
t[i] = 0;
|
||||
str = js_NewString(cx, t, n);
|
||||
if (!str) {
|
||||
JS_free(cx, t);
|
||||
cx->free(t);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -799,7 +799,7 @@ js_toLowerCase(JSContext *cx, JSString *str)
|
|||
jschar *news;
|
||||
|
||||
str->getCharsAndLength(s, n);
|
||||
news = (jschar *) JS_malloc(cx, (n + 1) * sizeof(jschar));
|
||||
news = (jschar *) cx->malloc((n + 1) * sizeof(jschar));
|
||||
if (!news)
|
||||
return NULL;
|
||||
for (i = 0; i < n; i++)
|
||||
|
@ -807,7 +807,7 @@ js_toLowerCase(JSContext *cx, JSString *str)
|
|||
news[n] = 0;
|
||||
str = js_NewString(cx, news, n);
|
||||
if (!str) {
|
||||
JS_free(cx, news);
|
||||
cx->free(news);
|
||||
return NULL;
|
||||
}
|
||||
return str;
|
||||
|
@ -850,7 +850,7 @@ js_toUpperCase(JSContext *cx, JSString *str)
|
|||
jschar *news;
|
||||
|
||||
str->getCharsAndLength(s, n);
|
||||
news = (jschar *) JS_malloc(cx, (n + 1) * sizeof(jschar));
|
||||
news = (jschar *) cx->malloc((n + 1) * sizeof(jschar));
|
||||
if (!news)
|
||||
return NULL;
|
||||
for (i = 0; i < n; i++)
|
||||
|
@ -858,7 +858,7 @@ js_toUpperCase(JSContext *cx, JSString *str)
|
|||
news[n] = 0;
|
||||
str = js_NewString(cx, news, n);
|
||||
if (!str) {
|
||||
JS_free(cx, news);
|
||||
cx->free(news);
|
||||
return NULL;
|
||||
}
|
||||
return str;
|
||||
|
@ -1659,7 +1659,7 @@ find_replen(JSContext *cx, ReplaceData *rdata, size_t *sizep)
|
|||
lambda_out:
|
||||
js_FreeStack(cx, mark);
|
||||
if (freeMoreParens)
|
||||
JS_free(cx, cx->regExpStatics.moreParens);
|
||||
cx->free(cx->regExpStatics.moreParens);
|
||||
cx->regExpStatics = save;
|
||||
return ok;
|
||||
}
|
||||
|
@ -1716,7 +1716,7 @@ replace_destroy(JSContext *cx, GlobData *data)
|
|||
ReplaceData *rdata;
|
||||
|
||||
rdata = (ReplaceData *)data;
|
||||
JS_free(cx, rdata->chars);
|
||||
cx->free(rdata->chars);
|
||||
rdata->chars = NULL;
|
||||
}
|
||||
|
||||
|
@ -1741,9 +1741,9 @@ replace_glob(JSContext *cx, jsint count, GlobData *data)
|
|||
growth = leftlen + replen;
|
||||
chars = (jschar *)
|
||||
(rdata->chars
|
||||
? JS_realloc(cx, rdata->chars, (rdata->length + growth + 1)
|
||||
? cx->realloc(rdata->chars, (rdata->length + growth + 1)
|
||||
* sizeof(jschar))
|
||||
: JS_malloc(cx, (growth + 1) * sizeof(jschar)));
|
||||
: cx->malloc((growth + 1) * sizeof(jschar)));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
rdata->chars = chars;
|
||||
|
@ -1826,7 +1826,7 @@ js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,
|
|||
if (!ok)
|
||||
goto out;
|
||||
length += leftlen;
|
||||
chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -1840,9 +1840,9 @@ js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,
|
|||
rightlen = cx->regExpStatics.rightContext.length;
|
||||
length = rdata.length + rightlen;
|
||||
chars = (jschar *)
|
||||
JS_realloc(cx, rdata.chars, (length + 1) * sizeof(jschar));
|
||||
cx->realloc(rdata.chars, (length + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
JS_free(cx, rdata.chars);
|
||||
cx->free(rdata.chars);
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1852,7 +1852,7 @@ js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,
|
|||
|
||||
str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
@ -2266,7 +2266,7 @@ tagify(JSContext *cx, const char *begin, JSString *param, const char *end,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
tagbuf = (jschar *) JS_malloc(cx, (taglen + 1) * sizeof(jschar));
|
||||
tagbuf = (jschar *) cx->malloc((taglen + 1) * sizeof(jschar));
|
||||
if (!tagbuf)
|
||||
return JS_FALSE;
|
||||
|
||||
|
@ -2294,7 +2294,7 @@ tagify(JSContext *cx, const char *begin, JSString *param, const char *end,
|
|||
|
||||
str = js_NewString(cx, tagbuf, taglen);
|
||||
if (!str) {
|
||||
free((char *)tagbuf);
|
||||
js_free((char *)tagbuf);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -2531,13 +2531,13 @@ str_fromCharCode(JSContext *cx, uintN argc, jsval *vp)
|
|||
*vp = STRING_TO_JSVAL(str);
|
||||
return JS_TRUE;
|
||||
}
|
||||
chars = (jschar *) JS_malloc(cx, (argc + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((argc + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
for (i = 0; i < argc; i++) {
|
||||
code = js_ValueToUint16(cx, &argv[i]);
|
||||
if (JSVAL_IS_NULL(argv[i])) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
chars[i] = (jschar)code;
|
||||
|
@ -2545,7 +2545,7 @@ str_fromCharCode(JSContext *cx, uintN argc, jsval *vp)
|
|||
chars[i] = 0;
|
||||
str = js_NewString(cx, chars, argc);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
*vp = STRING_TO_JSVAL(str);
|
||||
|
@ -2621,9 +2621,8 @@ js_GetUnitStringForChar(JSContext *cx, jschar c)
|
|||
JS_ASSERT(c < UNIT_STRING_LIMIT);
|
||||
rt = cx->runtime;
|
||||
if (!rt->unitStrings) {
|
||||
sp = (JSString **) calloc(UNIT_STRING_LIMIT * sizeof(JSString *) +
|
||||
UNIT_STRING_LIMIT * 2 * sizeof(jschar),
|
||||
1);
|
||||
sp = (JSString **) js_calloc(UNIT_STRING_LIMIT * sizeof(JSString *) +
|
||||
UNIT_STRING_LIMIT * 2 * sizeof(jschar));
|
||||
if (!sp) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return NULL;
|
||||
|
@ -2639,7 +2638,7 @@ js_GetUnitStringForChar(JSContext *cx, jschar c)
|
|||
JS_UNLOCK_GC(rt);
|
||||
} else {
|
||||
JS_UNLOCK_GC(rt);
|
||||
free(sp);
|
||||
js_free(sp);
|
||||
}
|
||||
}
|
||||
if (!rt->unitStrings[c]) {
|
||||
|
@ -2676,7 +2675,7 @@ js_GetUnitString(JSContext *cx, JSString *str, size_t index)
|
|||
void
|
||||
js_FinishUnitStrings(JSRuntime *rt)
|
||||
{
|
||||
free(rt->unitStrings);
|
||||
js_free(rt->unitStrings);
|
||||
rt->unitStrings = NULL;
|
||||
}
|
||||
|
||||
|
@ -2832,14 +2831,14 @@ js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n)
|
|||
jschar *news;
|
||||
JSString *str;
|
||||
|
||||
news = (jschar *) JS_malloc(cx, (n + 1) * sizeof(jschar));
|
||||
news = (jschar *) cx->malloc((n + 1) * sizeof(jschar));
|
||||
if (!news)
|
||||
return NULL;
|
||||
js_strncpy(news, s, n);
|
||||
news[n] = 0;
|
||||
str = js_NewString(cx, news, n);
|
||||
if (!str)
|
||||
JS_free(cx, news);
|
||||
cx->free(news);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -2852,13 +2851,13 @@ js_NewStringCopyZ(JSContext *cx, const jschar *s)
|
|||
|
||||
n = js_strlen(s);
|
||||
m = (n + 1) * sizeof(jschar);
|
||||
news = (jschar *) JS_malloc(cx, m);
|
||||
news = (jschar *) cx->malloc(m);
|
||||
if (!news)
|
||||
return NULL;
|
||||
memcpy(news, s, m);
|
||||
str = js_NewString(cx, news, n);
|
||||
if (!str)
|
||||
JS_free(cx, news);
|
||||
cx->free(news);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -2876,7 +2875,7 @@ js_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str)
|
|||
#ifdef DEBUG
|
||||
rt->deflatedStringCacheBytes -= str->length();
|
||||
#endif
|
||||
free(he->value);
|
||||
js_free(he->value);
|
||||
JS_HashTableRawRemove(rt->deflatedStringCache, hep, he);
|
||||
}
|
||||
JS_RELEASE_LOCK(rt->deflatedStringCacheLock);
|
||||
|
@ -3121,7 +3120,7 @@ js_InflateString(JSContext *cx, const char *bytes, size_t *lengthp)
|
|||
if (js_CStringsAreUTF8) {
|
||||
if (!js_InflateStringToBuffer(cx, bytes, nbytes, NULL, &nchars))
|
||||
goto bad;
|
||||
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof (jschar));
|
||||
chars = (jschar *) cx->malloc((nchars + 1) * sizeof (jschar));
|
||||
if (!chars)
|
||||
goto bad;
|
||||
#ifdef DEBUG
|
||||
|
@ -3131,7 +3130,7 @@ js_InflateString(JSContext *cx, const char *bytes, size_t *lengthp)
|
|||
JS_ASSERT(ok);
|
||||
} else {
|
||||
nchars = nbytes;
|
||||
chars = (jschar *) JS_malloc(cx, (nchars + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((nchars + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
goto bad;
|
||||
for (i = 0; i < nchars; i++)
|
||||
|
@ -3166,7 +3165,7 @@ js_DeflateString(JSContext *cx, const jschar *chars, size_t nchars)
|
|||
nbytes = js_GetDeflatedStringLength(cx, chars, nchars);
|
||||
if (nbytes == (size_t) -1)
|
||||
return NULL;
|
||||
bytes = (char *) (cx ? JS_malloc(cx, nbytes + 1) : malloc(nbytes + 1));
|
||||
bytes = (char *) (cx ? cx->malloc(nbytes + 1) : js_malloc(nbytes + 1));
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
#ifdef DEBUG
|
||||
|
@ -3176,7 +3175,7 @@ js_DeflateString(JSContext *cx, const jschar *chars, size_t nchars)
|
|||
JS_ASSERT(ok);
|
||||
} else {
|
||||
nbytes = nchars;
|
||||
bytes = (char *) (cx ? JS_malloc(cx, nbytes + 1) : malloc(nbytes + 1));
|
||||
bytes = (char *) (cx ? cx->malloc(nbytes + 1) : js_malloc(nbytes + 1));
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
for (i = 0; i < nbytes; i++)
|
||||
|
@ -3491,9 +3490,9 @@ js_GetStringBytes(JSContext *cx, JSString *str)
|
|||
str->setDeflated();
|
||||
} else {
|
||||
if (cx)
|
||||
JS_free(cx, bytes);
|
||||
cx->free(bytes);
|
||||
else
|
||||
free(bytes);
|
||||
js_free(bytes);
|
||||
bytes = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -4836,8 +4835,8 @@ AddCharsToURI(JSContext *cx, JSCharBuffer *buf,
|
|||
if (!buf->chars ||
|
||||
JS_HOWMANY(total, URI_CHUNK) > JS_HOWMANY(buf->length + 1, URI_CHUNK)) {
|
||||
total = JS_ROUNDUP(total, URI_CHUNK);
|
||||
newchars = (jschar *) JS_realloc(cx, buf->chars,
|
||||
total * sizeof(jschar));
|
||||
newchars = (jschar *) cx->realloc(buf->chars,
|
||||
total * sizeof(jschar));
|
||||
if (!newchars)
|
||||
return JS_FALSE;
|
||||
buf->chars = newchars;
|
||||
|
@ -4860,7 +4859,7 @@ TransferBufferToString(JSContext *cx, JSCharBuffer *cb, jsval *rval)
|
|||
* don't worry about that case here.
|
||||
*/
|
||||
n = cb->length;
|
||||
chars = (jschar *) JS_realloc(cx, cb->chars, (n + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->realloc(cb->chars, (n + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
chars = cb->chars;
|
||||
str = js_NewString(cx, chars, n);
|
||||
|
@ -4953,7 +4952,7 @@ Encode(JSContext *cx, JSString *str, const jschar *unescapedSet,
|
|||
return JS_TRUE;
|
||||
|
||||
bad:
|
||||
JS_free(cx, cb.chars);
|
||||
cx->free(cb.chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -5048,7 +5047,7 @@ Decode(JSContext *cx, JSString *str, const jschar *reservedSet, jsval *rval)
|
|||
/* FALL THROUGH */
|
||||
|
||||
bad:
|
||||
JS_free(cx, cb.chars);
|
||||
cx->free(cb.chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=99 ft=cpp:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9.1 code, released
|
||||
* June 30, 2009.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Andreas Gal <gal@mozilla.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "jstask.h"
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
static void start(void* arg) {
|
||||
((JSBackgroundThread*)arg)->work();
|
||||
}
|
||||
|
||||
JSBackgroundThread::JSBackgroundThread()
|
||||
: thread(NULL), stack(NULL), lock(NULL), wakeup(NULL), shutdown(false)
|
||||
{
|
||||
}
|
||||
|
||||
JSBackgroundThread::~JSBackgroundThread()
|
||||
{
|
||||
if (wakeup)
|
||||
PR_DestroyCondVar(wakeup);
|
||||
if (lock)
|
||||
PR_DestroyLock(lock);
|
||||
/* PR_DestroyThread is not necessary. */
|
||||
}
|
||||
|
||||
bool
|
||||
JSBackgroundThread::init()
|
||||
{
|
||||
if (!(lock = PR_NewLock()))
|
||||
return false;
|
||||
if (!(wakeup = PR_NewCondVar(lock)))
|
||||
return false;
|
||||
thread = PR_CreateThread(PR_USER_THREAD, start, this, PR_PRIORITY_LOW,
|
||||
PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
|
||||
return !!thread;
|
||||
}
|
||||
|
||||
void
|
||||
JSBackgroundThread::cancel()
|
||||
{
|
||||
PR_Lock(lock);
|
||||
if (shutdown) {
|
||||
PR_Unlock(lock);
|
||||
return;
|
||||
}
|
||||
shutdown = true;
|
||||
PR_NotifyCondVar(wakeup);
|
||||
PR_Unlock(lock);
|
||||
PR_JoinThread(thread);
|
||||
}
|
||||
|
||||
void
|
||||
JSBackgroundThread::work()
|
||||
{
|
||||
PR_Lock(lock);
|
||||
while (!shutdown) {
|
||||
PR_WaitCondVar(wakeup, PR_INTERVAL_NO_TIMEOUT);
|
||||
JSBackgroundTask* t;
|
||||
while ((t = stack) != NULL) {
|
||||
stack = t->next;
|
||||
PR_Unlock(lock);
|
||||
t->run();
|
||||
delete t;
|
||||
PR_Lock(lock);
|
||||
}
|
||||
}
|
||||
PR_Unlock(lock);
|
||||
}
|
||||
|
||||
bool
|
||||
JSBackgroundThread::busy()
|
||||
{
|
||||
return !!stack; // we tolerate some racing here
|
||||
}
|
||||
|
||||
void
|
||||
JSBackgroundThread::schedule(JSBackgroundTask* task)
|
||||
{
|
||||
PR_Lock(lock);
|
||||
if (shutdown) {
|
||||
PR_Unlock(lock);
|
||||
task->run();
|
||||
delete task;
|
||||
return;
|
||||
}
|
||||
task->next = stack;
|
||||
stack = task;
|
||||
PR_NotifyCondVar(wakeup);
|
||||
PR_Unlock(lock);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=99 ft=cpp:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
|
||||
* June 30, 2009.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Andreas Gal <gal@mozilla.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef jstask_h___
|
||||
#define jstask_h___
|
||||
|
||||
class JSBackgroundTask {
|
||||
friend class JSBackgroundThread;
|
||||
JSBackgroundTask* next;
|
||||
public:
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
||||
#include "prthread.h"
|
||||
#include "prlock.h"
|
||||
#include "prcvar.h"
|
||||
|
||||
class JSBackgroundThread {
|
||||
PRThread* thread;
|
||||
JSBackgroundTask* stack;
|
||||
PRLock* lock;
|
||||
PRCondVar* wakeup;
|
||||
bool shutdown;
|
||||
|
||||
public:
|
||||
JSBackgroundThread();
|
||||
~JSBackgroundThread();
|
||||
|
||||
bool init();
|
||||
void cancel();
|
||||
void work();
|
||||
bool busy();
|
||||
void schedule(JSBackgroundTask* task);
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class JSBackgroundThread {
|
||||
public:
|
||||
void schedule(JSBackgroundTask* task) {
|
||||
task->run();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* jstask_h___ */
|
2260
js/src/jstracer.cpp
2260
js/src/jstracer.cpp
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -166,8 +166,10 @@ public:
|
|||
#if defined(JS_JIT_SPEW) || defined(MOZ_NO_VARADIC_MACROS)
|
||||
|
||||
enum LC_TMBits {
|
||||
/* Output control bits for all non-Nanojit code. Only use bits 16
|
||||
and above, since Nanojit uses 0 .. 15 itself. */
|
||||
/*
|
||||
* Output control bits for all non-Nanojit code. Only use bits 16 and
|
||||
* above, since Nanojit uses 0 .. 15 itself.
|
||||
*/
|
||||
LC_TMMinimal = 1<<16,
|
||||
LC_TMTracer = 1<<17,
|
||||
LC_TMRecorder = 1<<18,
|
||||
|
@ -192,14 +194,22 @@ extern nanojit::LogControl js_LogController;
|
|||
|
||||
#define debug_only_stmt(stmt) \
|
||||
stmt
|
||||
#define debug_only_printf(mask, fmt, ...) \
|
||||
do { if ((js_LogController.lcbits & (mask)) > 0) { \
|
||||
js_LogController.printf(fmt, __VA_ARGS__); fflush(stdout); \
|
||||
}} while (0)
|
||||
#define debug_only_print0(mask, str) \
|
||||
do { if ((js_LogController.lcbits & (mask)) > 0) { \
|
||||
js_LogController.printf(str); fflush(stdout); \
|
||||
}} while (0)
|
||||
|
||||
#define debug_only_printf(mask, fmt, ...) \
|
||||
JS_BEGIN_MACRO \
|
||||
if ((js_LogController.lcbits & (mask)) > 0) { \
|
||||
js_LogController.printf(fmt, __VA_ARGS__); \
|
||||
fflush(stdout); \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define debug_only_print0(mask, str) \
|
||||
JS_BEGIN_MACRO \
|
||||
if ((js_LogController.lcbits & (mask)) > 0) { \
|
||||
js_LogController.printf("%s", str); \
|
||||
fflush(stdout); \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#else
|
||||
|
||||
|
@ -281,7 +291,7 @@ typedef int8_t JSTraceType;
|
|||
|
||||
/*
|
||||
* This indicates an invalid type or error. Note that it should not be used in typemaps,
|
||||
* because it is the wrong size. It can only be used as a uint32, for example as the
|
||||
* because it is the wrong size. It can only be used as a uint32, for example as the
|
||||
* return value from a function that returns a type as a uint32.
|
||||
*/
|
||||
const uint32 TT_INVALID = uint32(-1);
|
||||
|
@ -332,7 +342,6 @@ public:
|
|||
_(TIMEOUT) \
|
||||
_(DEEP_BAIL) \
|
||||
_(STATUS)
|
||||
|
||||
|
||||
enum ExitType {
|
||||
#define MAKE_EXIT_CODE(x) x##_EXIT,
|
||||
|
@ -374,21 +383,6 @@ struct VMSideExit : public nanojit::SideExit
|
|||
}
|
||||
};
|
||||
|
||||
static inline JSTraceType* getStackTypeMap(nanojit::SideExit* exit)
|
||||
{
|
||||
return (JSTraceType*)(((VMSideExit*)exit) + 1);
|
||||
}
|
||||
|
||||
static inline JSTraceType* getGlobalTypeMap(nanojit::SideExit* exit)
|
||||
{
|
||||
return getStackTypeMap(exit) + ((VMSideExit*)exit)->numStackSlots;
|
||||
}
|
||||
|
||||
static inline JSTraceType* getFullTypeMap(nanojit::SideExit* exit)
|
||||
{
|
||||
return getStackTypeMap(exit);
|
||||
}
|
||||
|
||||
struct FrameInfo {
|
||||
JSObject* callee; // callee function object
|
||||
JSObject* block; // caller block chain head
|
||||
|
@ -408,7 +402,7 @@ struct FrameInfo {
|
|||
* stack frame for the caller *before* the slots covered by spdist.
|
||||
* This may be negative if the caller is the top level script.
|
||||
* The key fact is that if we let 'cpos' be the start of the caller's
|
||||
* native stack frame, then (cpos + spoffset) points to the first
|
||||
* native stack frame, then (cpos + spoffset) points to the first
|
||||
* non-argument slot in the callee's native stack frame.
|
||||
*/
|
||||
int32 spoffset;
|
||||
|
@ -548,7 +542,7 @@ struct JSRecordingStatus JSRS_ERROR = { JSRS_ERROR_code };
|
|||
#define STATUS_ABORTS_RECORDING(s) ((s) == JSRS_STOP || (s) == JSRS_ERROR)
|
||||
#else
|
||||
enum JSRecordingStatus {
|
||||
JSRS_ERROR, // Error; propagate to interpreter.
|
||||
JSRS_ERROR, // Error; propagate to interpreter.
|
||||
JSRS_STOP, // Abort recording.
|
||||
JSRS_CONTINUE, // Continue recording.
|
||||
JSRS_IMACRO // Entered imacro; continue recording.
|
||||
|
@ -687,6 +681,15 @@ class TraceRecorder : public avmplus::GCObject {
|
|||
nanojit::LIns*& ops_ins, size_t op_offset = 0);
|
||||
JS_REQUIRES_STACK JSRecordingStatus test_property_cache(JSObject* obj, nanojit::LIns* obj_ins,
|
||||
JSObject*& obj2, jsuword& pcval);
|
||||
JS_REQUIRES_STACK JSRecordingStatus guardNativePropertyOp(JSObject* aobj,
|
||||
nanojit::LIns* map_ins);
|
||||
JS_REQUIRES_STACK JSRecordingStatus guardPropertyCacheHit(nanojit::LIns* obj_ins,
|
||||
nanojit::LIns* map_ins,
|
||||
JSObject* aobj,
|
||||
JSObject* obj2,
|
||||
JSPropCacheEntry* entry,
|
||||
jsuword& pcval);
|
||||
|
||||
void stobj_set_fslot(nanojit::LIns *obj_ins, unsigned slot,
|
||||
nanojit::LIns* v_ins, const char *name);
|
||||
void stobj_set_dslot(nanojit::LIns *obj_ins, unsigned slot, nanojit::LIns*& dslots_ins,
|
||||
|
@ -704,8 +707,6 @@ class TraceRecorder : public avmplus::GCObject {
|
|||
stobj_get_fslot(obj_ins, JSSLOT_PRIVATE),
|
||||
lir->insImmPtr((void*) ~mask));
|
||||
}
|
||||
JSRecordingStatus native_set(nanojit::LIns* obj_ins, JSScopeProperty* sprop,
|
||||
nanojit::LIns*& dslots_ins, nanojit::LIns* v_ins);
|
||||
JSRecordingStatus native_get(nanojit::LIns* obj_ins, nanojit::LIns* pobj_ins,
|
||||
JSScopeProperty* sprop, nanojit::LIns*& dslots_ins,
|
||||
nanojit::LIns*& v_ins);
|
||||
|
@ -722,6 +723,13 @@ class TraceRecorder : public avmplus::GCObject {
|
|||
JS_REQUIRES_STACK JSRecordingStatus getProp(jsval& v);
|
||||
JS_REQUIRES_STACK JSRecordingStatus getThis(nanojit::LIns*& this_ins);
|
||||
|
||||
JS_REQUIRES_STACK JSRecordingStatus nativeSet(JSObject* obj, nanojit::LIns* obj_ins,
|
||||
JSScopeProperty* sprop,
|
||||
jsval v, nanojit::LIns* v_ins);
|
||||
JS_REQUIRES_STACK JSRecordingStatus setProp(jsval &l, JSPropCacheEntry* entry,
|
||||
JSScopeProperty* sprop,
|
||||
jsval &v, nanojit::LIns*& v_ins);
|
||||
|
||||
JS_REQUIRES_STACK void box_jsval(jsval v, nanojit::LIns*& v_ins);
|
||||
JS_REQUIRES_STACK void unbox_jsval(jsval v, nanojit::LIns*& v_ins, VMSideExit* exit);
|
||||
JS_REQUIRES_STACK bool guardClass(JSObject* obj, nanojit::LIns* obj_ins, JSClass* clasp,
|
||||
|
@ -748,8 +756,15 @@ class TraceRecorder : public avmplus::GCObject {
|
|||
jsval* rval);
|
||||
JS_REQUIRES_STACK JSRecordingStatus interpretedFunctionCall(jsval& fval, JSFunction* fun,
|
||||
uintN argc, bool constructing);
|
||||
JS_REQUIRES_STACK void propagateFailureToBuiltinStatus(nanojit::LIns *ok_ins,
|
||||
nanojit::LIns *&status_ins);
|
||||
JS_REQUIRES_STACK JSRecordingStatus emitNativeCall(JSTraceableNative* known, uintN argc,
|
||||
nanojit::LIns* args[]);
|
||||
JS_REQUIRES_STACK void emitNativePropertyOp(JSScope* scope,
|
||||
JSScopeProperty* sprop,
|
||||
nanojit::LIns* obj_ins,
|
||||
bool setflag,
|
||||
nanojit::LIns* boxed_ins);
|
||||
JS_REQUIRES_STACK JSRecordingStatus callTraceableNative(JSFunction* fun, uintN argc,
|
||||
bool constructing);
|
||||
JS_REQUIRES_STACK JSRecordingStatus callNative(uintN argc, JSOp mode);
|
||||
|
@ -974,13 +989,13 @@ js_LogTraceVisState(TraceVisState s, TraceVisExitReason r)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
static inline void
|
||||
js_EnterTraceVisState(TraceVisState s, TraceVisExitReason r)
|
||||
{
|
||||
js_LogTraceVisState(s, r);
|
||||
}
|
||||
|
||||
static inline void
|
||||
static inline void
|
||||
js_ExitTraceVisState(TraceVisExitReason r)
|
||||
{
|
||||
js_LogTraceVisState(S_EXITLAST, r);
|
||||
|
|
|
@ -297,7 +297,7 @@ CallTree(void **bp)
|
|||
return NULL;
|
||||
|
||||
/* Create a new callsite record. */
|
||||
site = (JSCallsite *) malloc(sizeof(JSCallsite));
|
||||
site = (JSCallsite *) js_malloc(sizeof(JSCallsite));
|
||||
if (!site)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#ifndef jsutil_h___
|
||||
#define jsutil_h___
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
|
@ -176,9 +178,30 @@ JS_Backtrace(int skip);
|
|||
|
||||
extern JS_FRIEND_API(void)
|
||||
JS_DumpBacktrace(JSCallsite *trace);
|
||||
|
||||
#endif
|
||||
|
||||
static JS_INLINE void* js_malloc(size_t bytes) {
|
||||
if (bytes < sizeof(void*)) /* for asyncFree */
|
||||
bytes = sizeof(void*);
|
||||
return malloc(bytes);
|
||||
}
|
||||
|
||||
static JS_INLINE void* js_calloc(size_t bytes) {
|
||||
if (bytes < sizeof(void*)) /* for asyncFree */
|
||||
bytes = sizeof(void*);
|
||||
return calloc(bytes, 1);
|
||||
}
|
||||
|
||||
static JS_INLINE void* js_realloc(void* p, size_t bytes) {
|
||||
if (bytes < sizeof(void*)) /* for asyncFree */
|
||||
bytes = sizeof(void*);
|
||||
return realloc(p, bytes);
|
||||
}
|
||||
|
||||
static JS_INLINE void js_free(void* p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsutil_h___ */
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef struct JSXDRMemState {
|
|||
if (MEM_LIMIT(xdr) && \
|
||||
MEM_COUNT(xdr) + bytes > MEM_LIMIT(xdr)) { \
|
||||
uint32 limit_ = JS_ROUNDUP(MEM_COUNT(xdr) + bytes, MEM_BLOCK);\
|
||||
void *data_ = JS_realloc((xdr)->cx, MEM_BASE(xdr), limit_); \
|
||||
void *data_ = (xdr)->cx->realloc(MEM_BASE(xdr), limit_); \
|
||||
if (!data_) \
|
||||
return 0; \
|
||||
MEM_BASE(xdr) = (char *) data_; \
|
||||
|
@ -216,7 +216,7 @@ mem_tell(JSXDRState *xdr)
|
|||
static void
|
||||
mem_finalize(JSXDRState *xdr)
|
||||
{
|
||||
JS_free(xdr->cx, MEM_BASE(xdr));
|
||||
xdr->cx->free(MEM_BASE(xdr));
|
||||
}
|
||||
|
||||
static JSXDROps xdrmem_ops = {
|
||||
|
@ -239,13 +239,13 @@ JS_XDRInitBase(JSXDRState *xdr, JSXDRMode mode, JSContext *cx)
|
|||
JS_PUBLIC_API(JSXDRState *)
|
||||
JS_XDRNewMem(JSContext *cx, JSXDRMode mode)
|
||||
{
|
||||
JSXDRState *xdr = (JSXDRState *) JS_malloc(cx, sizeof(JSXDRMemState));
|
||||
JSXDRState *xdr = (JSXDRState *) cx->malloc(sizeof(JSXDRMemState));
|
||||
if (!xdr)
|
||||
return NULL;
|
||||
JS_XDRInitBase(xdr, mode, cx);
|
||||
if (mode == JSXDR_ENCODE) {
|
||||
if (!(MEM_BASE(xdr) = (char *) JS_malloc(cx, MEM_BLOCK))) {
|
||||
JS_free(cx, xdr);
|
||||
if (!(MEM_BASE(xdr) = (char *) cx->malloc(MEM_BLOCK))) {
|
||||
cx->free(xdr);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -299,11 +299,11 @@ JS_XDRDestroy(JSXDRState *xdr)
|
|||
JSContext *cx = xdr->cx;
|
||||
xdr->ops->finalize(xdr);
|
||||
if (xdr->registry) {
|
||||
JS_free(cx, xdr->registry);
|
||||
cx->free(xdr->registry);
|
||||
if (xdr->reghash)
|
||||
JS_DHashTableDestroy((JSDHashTable *) xdr->reghash);
|
||||
}
|
||||
JS_free(cx, xdr);
|
||||
cx->free(xdr);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
@ -381,18 +381,18 @@ JS_XDRCString(JSXDRState *xdr, char **sp)
|
|||
len = strlen(*sp);
|
||||
JS_XDRUint32(xdr, &len);
|
||||
if (xdr->mode == JSXDR_DECODE) {
|
||||
if (!(*sp = (char *) JS_malloc(xdr->cx, len + 1)))
|
||||
if (!(*sp = (char *) xdr->cx->malloc(len + 1)))
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!JS_XDRBytes(xdr, *sp, len)) {
|
||||
if (xdr->mode == JSXDR_DECODE)
|
||||
JS_free(xdr->cx, *sp);
|
||||
xdr->cx->free(*sp);
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (xdr->mode == JSXDR_DECODE) {
|
||||
(*sp)[len] = '\0';
|
||||
} else if (xdr->mode == JSXDR_FREE) {
|
||||
JS_free(xdr->cx, *sp);
|
||||
xdr->cx->free(*sp);
|
||||
*sp = NULL;
|
||||
}
|
||||
return JS_TRUE;
|
||||
|
@ -452,7 +452,7 @@ JS_XDRString(JSXDRState *xdr, JSString **strp)
|
|||
return JS_FALSE;
|
||||
|
||||
if (xdr->mode == JSXDR_DECODE) {
|
||||
chars = (jschar *) JS_malloc(xdr->cx, (nchars + 1) * sizeof(jschar));
|
||||
chars = (jschar *) xdr->cx->malloc((nchars + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
|
@ -471,7 +471,7 @@ JS_XDRString(JSXDRState *xdr, JSString **strp)
|
|||
|
||||
bad:
|
||||
if (xdr->mode == JSXDR_DECODE)
|
||||
JS_free(xdr->cx, chars);
|
||||
xdr->cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ js_XDRStringAtom(JSXDRState *xdr, JSAtom **atomp)
|
|||
* This is very uncommon. Don't use the tempPool arena for this as
|
||||
* most allocations here will be bigger than tempPool's arenasize.
|
||||
*/
|
||||
chars = (jschar *) JS_malloc(cx, nchars * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc(nchars * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ js_XDRStringAtom(JSXDRState *xdr, JSAtom **atomp)
|
|||
if (XDRChars(xdr, chars, nchars))
|
||||
atom = js_AtomizeChars(cx, chars, nchars, 0);
|
||||
if (chars != stackChars)
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
|
@ -709,7 +709,7 @@ JS_XDRRegisterClass(JSXDRState *xdr, JSClass *clasp, uint32 *idp)
|
|||
if (numclasses == maxclasses) {
|
||||
maxclasses = (maxclasses == 0) ? CLASS_REGISTRY_MIN : maxclasses << 1;
|
||||
registry = (JSClass **)
|
||||
JS_realloc(xdr->cx, xdr->registry, maxclasses * sizeof(JSClass *));
|
||||
xdr->cx->realloc(xdr->registry, maxclasses * sizeof(JSClass *));
|
||||
if (!registry)
|
||||
return JS_FALSE;
|
||||
xdr->registry = registry;
|
||||
|
|
|
@ -460,7 +460,7 @@ qname_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
if (str && clasp == &js_AttributeNameClass) {
|
||||
length = str->length();
|
||||
chars = (jschar *) JS_malloc(cx, (length + 2) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((length + 2) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
*chars = '@';
|
||||
|
@ -468,7 +468,7 @@ qname_toString(JSContext *cx, uintN argc, jsval *vp)
|
|||
chars[++length] = 0;
|
||||
str = js_NewString(cx, chars, length);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -932,8 +932,12 @@ XMLArraySetCapacity(JSContext *cx, JSXMLArray *array, uint32 capacity)
|
|||
|
||||
if (capacity == 0) {
|
||||
/* We could let realloc(p, 0) free this, but purify gets confused. */
|
||||
if (array->vector)
|
||||
free(array->vector);
|
||||
if (array->vector) {
|
||||
if (cx)
|
||||
cx->free(array->vector);
|
||||
else
|
||||
js_free(array->vector);
|
||||
}
|
||||
vector = NULL;
|
||||
} else {
|
||||
if (
|
||||
|
@ -941,7 +945,7 @@ XMLArraySetCapacity(JSContext *cx, JSXMLArray *array, uint32 capacity)
|
|||
(size_t)capacity > ~(size_t)0 / sizeof(void *) ||
|
||||
#endif
|
||||
!(vector = (void **)
|
||||
realloc(array->vector, capacity * sizeof(void *)))) {
|
||||
js_realloc(array->vector, capacity * sizeof(void *)))) {
|
||||
if (cx)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
|
@ -975,7 +979,7 @@ XMLArrayFinish(JSContext *cx, JSXMLArray *array)
|
|||
{
|
||||
JSXMLArrayCursor *cursor;
|
||||
|
||||
JS_free(cx, array->vector);
|
||||
cx->free(array->vector);
|
||||
|
||||
while ((cursor = array->cursors) != NULL)
|
||||
XMLArrayCursorFinish(cursor);
|
||||
|
@ -1039,7 +1043,7 @@ XMLArrayAddMember(JSContext *cx, JSXMLArray *array, uint32 index, void *elt)
|
|||
(size_t)capacity > ~(size_t)0 / sizeof(void *) ||
|
||||
#endif
|
||||
!(vector = (void **)
|
||||
realloc(array->vector, capacity * sizeof(void *)))) {
|
||||
js_realloc(array->vector, capacity * sizeof(void *)))) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -1120,10 +1124,10 @@ XMLArrayTruncate(JSContext *cx, JSXMLArray *array, uint32 length)
|
|||
|
||||
if (length == 0) {
|
||||
if (array->vector)
|
||||
free(array->vector);
|
||||
cx->free(array->vector);
|
||||
vector = NULL;
|
||||
} else {
|
||||
vector = (void **) realloc(array->vector, length * sizeof(void *));
|
||||
vector = (void **) js_realloc(array->vector, length * sizeof(void *));
|
||||
if (!vector)
|
||||
return;
|
||||
}
|
||||
|
@ -1854,7 +1858,7 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
|||
length = constrlen(prefix) + urilen + constrlen(middle) + srclen +
|
||||
constrlen(suffix);
|
||||
|
||||
chars = (jschar *) JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return NULL;
|
||||
|
||||
|
@ -1905,7 +1909,7 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
|||
}
|
||||
}
|
||||
|
||||
JS_free(cx, chars);
|
||||
cx->free(chars);
|
||||
return xml;
|
||||
|
||||
#undef constrlen
|
||||
|
@ -2138,7 +2142,7 @@ MakeXMLSpecialString(JSContext *cx, JSStringBuffer *sb,
|
|||
prefixlength + length + ((length2 != 0) ? 1 + length2 : 0) +
|
||||
suffixlength;
|
||||
bp = base = (jschar *)
|
||||
JS_realloc(cx, sb->base, (newlength + 1) * sizeof(jschar));
|
||||
cx->realloc(sb->base, (newlength + 1) * sizeof(jschar));
|
||||
if (!bp) {
|
||||
js_FinishStringBuffer(sb);
|
||||
return NULL;
|
||||
|
@ -2159,7 +2163,7 @@ MakeXMLSpecialString(JSContext *cx, JSStringBuffer *sb,
|
|||
|
||||
str = js_NewString(cx, base, newlength);
|
||||
if (!str)
|
||||
free(base);
|
||||
cx->free(base);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -2210,7 +2214,7 @@ AppendAttributeValue(JSContext *cx, JSStringBuffer *sb, JSString *valstr)
|
|||
valstr = js_EscapeAttributeValue(cx, valstr, JS_TRUE);
|
||||
if (!valstr) {
|
||||
if (STRING_BUFFER_OK(sb)) {
|
||||
free(sb->base);
|
||||
cx->free(sb->base);
|
||||
sb->base = STRING_BUFFER_ERROR_BASE;
|
||||
}
|
||||
return;
|
||||
|
@ -2482,7 +2486,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls)
|
|||
if (STARTS_WITH_XML(cp, length) || !IsXMLName(cp, length)) {
|
||||
newlength = length + 2 + (size_t) log10((double) decls->length);
|
||||
bp = (jschar *)
|
||||
JS_malloc(cx, (newlength + 1) * sizeof(jschar));
|
||||
cx->malloc((newlength + 1) * sizeof(jschar));
|
||||
if (!bp)
|
||||
return NULL;
|
||||
|
||||
|
@ -2507,7 +2511,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls)
|
|||
if (bp == cp) {
|
||||
newlength = length + 2 + (size_t) log10((double) n);
|
||||
bp = (jschar *)
|
||||
JS_malloc(cx, (newlength + 1) * sizeof(jschar));
|
||||
cx->malloc((newlength + 1) * sizeof(jschar));
|
||||
if (!bp)
|
||||
return NULL;
|
||||
js_strncpy(bp, cp, length);
|
||||
|
@ -2534,7 +2538,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls)
|
|||
} else {
|
||||
prefix = js_NewString(cx, bp, newlength);
|
||||
if (!prefix)
|
||||
JS_free(cx, bp);
|
||||
cx->free(bp);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
@ -5132,7 +5136,7 @@ xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (length == 0) {
|
||||
cursor = NULL;
|
||||
} else {
|
||||
cursor = (JSXMLArrayCursor *) JS_malloc(cx, sizeof *cursor);
|
||||
cursor = (JSXMLArrayCursor *) cx->malloc(sizeof *cursor);
|
||||
if (!cursor)
|
||||
return JS_FALSE;
|
||||
XMLArrayCursorInit(cursor, &xml->xml_kids);
|
||||
|
@ -5155,7 +5159,7 @@ xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
cursor = (JSXMLArrayCursor *) JSVAL_TO_PRIVATE(*statep);
|
||||
if (cursor) {
|
||||
XMLArrayCursorFinish(cursor);
|
||||
JS_free(cx, cursor);
|
||||
cx->free(cursor);
|
||||
}
|
||||
*statep = JSVAL_NULL;
|
||||
break;
|
||||
|
@ -5266,7 +5270,7 @@ js_EnumerateXMLValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (length == 0) {
|
||||
cursor = NULL;
|
||||
} else {
|
||||
cursor = (JSXMLArrayCursor *) JS_malloc(cx, sizeof *cursor);
|
||||
cursor = (JSXMLArrayCursor *) cx->malloc(sizeof *cursor);
|
||||
if (!cursor)
|
||||
return JS_FALSE;
|
||||
XMLArrayCursorInit(cursor, &xml->xml_kids);
|
||||
|
@ -5301,7 +5305,7 @@ js_EnumerateXMLValues(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
|||
if (cursor) {
|
||||
destroy:
|
||||
XMLArrayCursorFinish(cursor);
|
||||
JS_free(cx, cursor);
|
||||
cx->free(cursor);
|
||||
}
|
||||
*statep = JSVAL_NULL;
|
||||
break;
|
||||
|
@ -7801,7 +7805,7 @@ js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str, JSString *str2)
|
|||
|
||||
str2->getCharsAndLength(chars2, len2);
|
||||
newlen = (isName) ? len + 1 + len2 : len + 2 + len2 + 1;
|
||||
chars = (jschar *) JS_realloc(cx, chars, (newlen+1) * sizeof(jschar));
|
||||
chars = (jschar *) cx->realloc(chars, (newlen+1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return NULL;
|
||||
|
||||
|
@ -8114,7 +8118,7 @@ xmlfilter_finalize(JSContext *cx, JSObject *obj)
|
|||
return;
|
||||
|
||||
XMLArrayCursorFinish(&filter->cursor);
|
||||
JS_free(cx, filter);
|
||||
cx->free(filter);
|
||||
}
|
||||
|
||||
JSClass js_XMLFilterClass = {
|
||||
|
@ -8169,7 +8173,7 @@ js_StepXMLListFilter(JSContext *cx, JSBool initialized)
|
|||
if (!filterobj)
|
||||
return JS_FALSE;
|
||||
|
||||
filter = (JSXMLFilter *) JS_malloc(cx, sizeof *filter);
|
||||
filter = (JSXMLFilter *) cx->malloc(sizeof *filter);
|
||||
if (!filter)
|
||||
return JS_FALSE;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -214,7 +214,7 @@ namespace nanojit
|
|||
int offset = (c->_address) - ((int)_nIns) + 4; \
|
||||
int i = 0x40000000 | ((offset >> 2) & 0x3FFFFFFF); \
|
||||
IMM32(i); \
|
||||
verbose_only(asm_output("call %s",(c->_name));) \
|
||||
asm_output("call %s",(c->_name)); \
|
||||
} while (0)
|
||||
|
||||
#define Format_2_1(rd, op2, imm22) do { \
|
||||
|
@ -292,548 +292,548 @@ namespace nanojit
|
|||
|
||||
#define ADDCC(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("addcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x10, rs1, 0, rs2); \
|
||||
asm_output("addcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define ADD(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("add %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0, rs1, 0, rs2); \
|
||||
asm_output("add %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define AND(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("and %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x1, rs1, 0, rs2); \
|
||||
asm_output("and %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define BA(a, dsp22) \
|
||||
do { \
|
||||
asm_output("ba %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x8, 0x2, dsp22); \
|
||||
asm_output("ba %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("be %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x1, 0x2, dsp22); \
|
||||
asm_output("be %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BG(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bg %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xA, 0x2, dsp22); \
|
||||
asm_output("bg %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BGU(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bgu %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xC, 0x2, dsp22); \
|
||||
asm_output("bgu %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BGE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bge %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xB, 0x2, dsp22); \
|
||||
asm_output("bge %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BL(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bl %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x3, 0x2, dsp22); \
|
||||
asm_output("bl %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BLE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("ble %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x2, 0x2, dsp22); \
|
||||
asm_output("ble %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BLEU(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bleu %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x4, 0x2, dsp22); \
|
||||
asm_output("bleu %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BCC(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bcc %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xd, 0x2, dsp22); \
|
||||
asm_output("bcc %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BCS(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bcs %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x5, 0x2, dsp22); \
|
||||
asm_output("bcs %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BVC(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bvc %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xf, 0x2, dsp22); \
|
||||
asm_output("bvc %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BVS(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bvc %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x7, 0x2, dsp22); \
|
||||
asm_output("bvc %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define BNE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("bne %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x9, 0x2, dsp22); \
|
||||
asm_output("bne %p", _nIns + dsp22 - 1); \
|
||||
} while (0)
|
||||
|
||||
#define FABSS(rs2, rd) \
|
||||
do { \
|
||||
asm_output("fabs %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, 0, 0x9, rs2); \
|
||||
asm_output("fabs %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FADDD(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("faddd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, rs1, 0x42, rs2); \
|
||||
asm_output("faddd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FBE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbe %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x9, 0x6, dsp22); \
|
||||
asm_output("fbe %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBNE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbne %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x1, 0x6, dsp22); \
|
||||
asm_output("fbne %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBUE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbue %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xA, 0x6, dsp22); \
|
||||
asm_output("fbue %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBG(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fng %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x6, 0x6, dsp22); \
|
||||
asm_output("fng %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBUG(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbug %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x5, 0x6, dsp22); \
|
||||
asm_output("fbug %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBGE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbge %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xB, 0x6, dsp22); \
|
||||
asm_output("fbge %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBUGE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbuge %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xC, 0x6, dsp22); \
|
||||
asm_output("fbuge %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBL(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fbl %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0x4, 0x6, dsp22); \
|
||||
asm_output("fbl %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FBLE(a, dsp22) \
|
||||
do { \
|
||||
asm_output("fble %p", _nIns + dsp22 - 1); \
|
||||
Format_2_2(a, 0xD, 0x6, dsp22); \
|
||||
asm_output("fble %p", _nIns + dsp22 - 1); \
|
||||
} while(0)
|
||||
|
||||
#define FCMPD(rs1, rs2) \
|
||||
do { \
|
||||
asm_output("fcmpd %s, %s", gpn(rs1+32), gpn(rs2+32)); \
|
||||
Format_3_9(2, 0, 0, 0x35, rs1, 0x52, rs2); \
|
||||
asm_output("fcmpd %s, %s", gpn(rs1+32), gpn(rs2+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FSUBD(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("fsubd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, rs1, 0x46, rs2); \
|
||||
asm_output("fsubd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FMULD(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("fmuld %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, rs1, 0x4a, rs2); \
|
||||
asm_output("fmuld %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FDIVD(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("fdivd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, rs1, 0x4e, rs2); \
|
||||
asm_output("fdivd %s, %s, %s", gpn(rs1+32), gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FMOVD(rs2, rd) \
|
||||
do { \
|
||||
asm_output("fmovd %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, 0, 0x2, rs2); \
|
||||
asm_output("fmovd %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FNEGD(rs2, rd) \
|
||||
do { \
|
||||
asm_output("fnegd %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, 0, 0x6, rs2); \
|
||||
asm_output("fnegd %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define FITOD(rs2, rd) \
|
||||
do { \
|
||||
asm_output("fitod %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
Format_3_8(2, rd, 0x34, 0, 0xc8, rs2); \
|
||||
asm_output("fitod %s, %s", gpn(rs2+32), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define JMPL(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("jmpl [%s + %s]", gpn(rs1), gpn(rs2)); \
|
||||
Format_3_1(2, rd, 0x38, rs1, 0, rs2); \
|
||||
asm_output("jmpl [%s + %s]", gpn(rs1), gpn(rs2)); \
|
||||
} while (0)
|
||||
|
||||
#define JMPLI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("jmpl [%s + %d]", gpn(rs1), simm13); \
|
||||
Format_3_1I(2, rd, 0x38, rs1, simm13); \
|
||||
asm_output("jmpl [%s + %d]", gpn(rs1), simm13); \
|
||||
} while (0)
|
||||
|
||||
#define LDF(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd+32)); \
|
||||
Format_3_1(3, rd, 0x20, rs1, 0, rs2); \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define LDFI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd+32)); \
|
||||
Format_3_1I(3, rd, 0x20, rs1, simm13); \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd+32)); \
|
||||
} while (0)
|
||||
|
||||
#define LDUB(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(3, rd, 0x1, rs1, 0, rs2); \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define LDUBI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(3, rd, 0x1, rs1, simm13); \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define LDUH(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(3, rd, 0x2, rs1, 0, rs2); \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define LDUHI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(3, rd, 0x2, rs1, simm13); \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define LDSW(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(3, rd, 0x8, rs1, 0, rs2); \
|
||||
asm_output("ld [%s + %s], %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define LDSWI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(3, rd, 0x8, rs1, simm13); \
|
||||
asm_output("ld [%s + %d], %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVE(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 1, cc1, cc0, rs); \
|
||||
asm_output("move %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVNE(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movne %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 9, cc1, cc0, rs); \
|
||||
asm_output("movne %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVL(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movl %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 3, cc1, cc0, rs); \
|
||||
asm_output("movl %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVLE(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movle %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 2, cc1, cc0, rs); \
|
||||
asm_output("movle %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVG(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movg %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 0xa, cc1, cc0, rs); \
|
||||
asm_output("movg %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVGE(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movge %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 0xb, cc1, cc0, rs); \
|
||||
asm_output("movge %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVCS(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movcs %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 5, cc1, cc0, rs); \
|
||||
asm_output("movcs %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVLEU(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movleu %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 4, cc1, cc0, rs); \
|
||||
asm_output("movleu %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVGU(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movgu %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 0xc, cc1, cc0, rs); \
|
||||
asm_output("movgu %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVCC(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movcc %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 0xd, cc1, cc0, rs); \
|
||||
asm_output("movcc %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVVC(rs, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movvc %s, %s", gpn(rs), gpn(rd)); \
|
||||
Format_4_2(rd, 0x2c, cc2, 0xf, cc1, cc0, rs); \
|
||||
asm_output("movvc %s, %s", gpn(rs), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 1, cc1, cc0, simm11); \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVFEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 9, cc1, cc0, simm11); \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVNEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 9, cc1, cc0, simm11); \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVLI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 3, cc1, cc0, simm11); \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVFLI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 4, cc1, cc0, simm11); \
|
||||
asm_output("move %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVLEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movle %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 2, cc1, cc0, simm11); \
|
||||
asm_output("movle %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVFLEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movle %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xd, cc1, cc0, simm11); \
|
||||
asm_output("movle %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVGI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movg %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xa, cc1, cc0, simm11); \
|
||||
asm_output("movg %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVFGI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movg %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 6, cc1, cc0, simm11); \
|
||||
asm_output("movg %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVGEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movge %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xb, cc1, cc0, simm11); \
|
||||
asm_output("movge %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVFGEI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movge %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xb, cc1, cc0, simm11); \
|
||||
asm_output("movge %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVLEUI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movleu %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 4, cc1, cc0, simm11); \
|
||||
asm_output("movleu %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVGUI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movgu %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xc, cc1, cc0, simm11); \
|
||||
asm_output("movgu %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVCCI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movcc %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 0xd, cc1, cc0, simm11); \
|
||||
asm_output("movcc %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MOVVSI(simm11, cc2, cc1, cc0, rd) \
|
||||
do { \
|
||||
asm_output("movvs %d, %s", simm11, gpn(rd)); \
|
||||
Format_4_2I(rd, 0x2c, cc2, 7, cc1, cc0, simm11); \
|
||||
asm_output("movvs %d, %s", simm11, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define MULX(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("mul %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x9, rs1, 0, rs2); \
|
||||
asm_output("mul %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define NOP() \
|
||||
do { \
|
||||
asm_output("nop"); \
|
||||
Format_2_1(0, 0x4, 0); \
|
||||
asm_output("nop"); \
|
||||
} while (0)
|
||||
|
||||
#define ORI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("or %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(2, rd, 0x2, rs1, simm13); \
|
||||
asm_output("or %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define OR(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("or %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x2, rs1, 0, rs2); \
|
||||
asm_output("or %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define ORN(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("orn %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x6, rs1, 0, rs2); \
|
||||
asm_output("orn %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define ANDCC(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("andcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x11, rs1, 0, rs2); \
|
||||
asm_output("andcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define RESTORE(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("restore"); \
|
||||
Format_3_1(2, rd, 0x3D, rs1, 0, rs2); \
|
||||
asm_output("restore"); \
|
||||
} while (0)
|
||||
|
||||
#define SAVEI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("save %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(2, rd, 0x3C, rs1, simm13); \
|
||||
asm_output("save %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SAVE(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("save %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x3C, rs1, 0, rs2); \
|
||||
asm_output("save %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SETHI(imm22, rd) \
|
||||
do { \
|
||||
asm_output("sethi %p, %s", imm22, gpn(rd)); \
|
||||
Format_2_1(rd, 0x4, (imm22 >> 10)); \
|
||||
asm_output("sethi %p, %s", imm22, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SLL(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("sll %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_5(2, rd, 0x25, rs1, 0, rs2); \
|
||||
asm_output("sll %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SRA(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("sra %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_5(2, rd, 0x27, rs1, 0, rs2); \
|
||||
asm_output("sra %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SRL(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("srl %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_5(2, rd, 0x26, rs1, 0, rs2); \
|
||||
asm_output("srl %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define STF(rd, rs1, rs2) \
|
||||
do { \
|
||||
asm_output("st %s, [%s + %s]", gpn(rd+32), gpn(rs1), gpn(rs2)); \
|
||||
Format_3_1(3, rd, 0x24, rs1, 0, rs2); \
|
||||
asm_output("st %s, [%s + %s]", gpn(rd+32), gpn(rs1), gpn(rs2)); \
|
||||
} while (0)
|
||||
|
||||
#define STFI(rd, simm13, rs1) \
|
||||
do { \
|
||||
asm_output("st %s, [%s + %d]", gpn(rd+32), gpn(rs1), simm13); \
|
||||
Format_3_1I(3, rd, 0x24, rs1, simm13); \
|
||||
asm_output("st %s, [%s + %d]", gpn(rd+32), gpn(rs1), simm13); \
|
||||
} while (0)
|
||||
|
||||
#define STW(rd, rs2, rs1) \
|
||||
do { \
|
||||
asm_output("st %s, [%s + %s]", gpn(rd), gpn(rs1), gpn(rs2)); \
|
||||
Format_3_1(3, rd, 0x4, rs1, 0, rs2); \
|
||||
asm_output("st %s, [%s + %s]", gpn(rd), gpn(rs1), gpn(rs2)); \
|
||||
} while (0)
|
||||
|
||||
#define STWI(rd, simm13, rs1) \
|
||||
do { \
|
||||
asm_output("st %s, [%s + %d]", gpn(rd), gpn(rs1), simm13); \
|
||||
Format_3_1I(3, rd, 0x4, rs1, simm13); \
|
||||
asm_output("st %s, [%s + %d]", gpn(rd), gpn(rs1), simm13); \
|
||||
} while (0)
|
||||
|
||||
#define SUBCC(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("subcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x14, rs1, 0, rs2); \
|
||||
asm_output("subcc %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SUB(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("sub %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x4, rs1, 0, rs2); \
|
||||
asm_output("sub %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define SUBI(rs1, simm13, rd) \
|
||||
do { \
|
||||
asm_output("sub %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
Format_3_1I(2, rd, 0x4, rs1, simm13); \
|
||||
asm_output("sub %s, %d, %s", gpn(rs1), simm13, gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
#define XOR(rs1, rs2, rd) \
|
||||
do { \
|
||||
asm_output("xor %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
Format_3_1(2, rd, 0x3, rs1, 0, rs2); \
|
||||
asm_output("xor %s, %s, %s", gpn(rs1), gpn(rs2), gpn(rd)); \
|
||||
} while (0)
|
||||
|
||||
// Returns true if imm below 13-bit unsigned immediate)
|
||||
|
|
|
@ -109,7 +109,7 @@ PRMJ_LocalGMTDifference()
|
|||
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
/* Windows does not follow POSIX. Updates to the
|
||||
* TZ environment variable are not reflected
|
||||
* TZ environment variable are not reflected
|
||||
* immediately on that platform as they are
|
||||
* on UNIX systems without this call.
|
||||
*/
|
||||
|
@ -170,8 +170,8 @@ static const JSInt64 win2un = JSLL_INIT(0x19DB1DE, 0xD53E8000);
|
|||
#if defined(HAVE_GETSYSTEMTIMEASFILETIME)
|
||||
inline void
|
||||
LowResTime(LPFILETIME lpft)
|
||||
{
|
||||
GetSystemTimeAsFileTime(lpft);
|
||||
{
|
||||
GetSystemTimeAsFileTime(lpft);
|
||||
}
|
||||
#elif defined(HAVE_SYSTEMTIMETOFILETIME)
|
||||
inline void
|
||||
|
@ -229,9 +229,9 @@ NowCalibrate()
|
|||
LowResTime(&ft);
|
||||
} while (memcmp(&ftStart,&ft, sizeof(ft)) == 0);
|
||||
timeEndPeriod(1);
|
||||
|
||||
|
||||
#ifdef WINCE
|
||||
calibration.granularity = (FILETIME2INT64(ft) -
|
||||
calibration.granularity = (FILETIME2INT64(ft) -
|
||||
FILETIME2INT64(ftStart))/10;
|
||||
#endif
|
||||
/*
|
||||
|
@ -581,7 +581,7 @@ PRMJ_DSTOffset(JSInt64 local_time)
|
|||
|
||||
#if defined(XP_WIN) && !defined(WINCE)
|
||||
/* Windows does not follow POSIX. Updates to the
|
||||
* TZ environment variable are not reflected
|
||||
* TZ environment variable are not reflected
|
||||
* immediately on that platform as they are
|
||||
* on UNIX systems without this call.
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
|
|
|
@ -3660,6 +3660,51 @@ function testComparisons()
|
|||
testComparisons.expected = "no failures reported!";
|
||||
test(testComparisons);
|
||||
|
||||
function testBug504520() {
|
||||
// A bug involving comparisons.
|
||||
var arr = [1/0, 1/0, 1/0, 1/0, 1/0, 0];
|
||||
assertEq(arr.length > RUNLOOP, true);
|
||||
|
||||
var s = '';
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
arr[i] >= 1/0 ? null : (s += i);
|
||||
assertEq(s, '5');
|
||||
}
|
||||
test(testBug504520);
|
||||
|
||||
function testBug504520Harder() {
|
||||
// test 1024 similar cases
|
||||
var vals = [1/0, -1/0, 0, 0/0];
|
||||
var ops = ["===", "!==", "==", "!=", "<", ">", "<=", ">="];
|
||||
for each (var x in vals) {
|
||||
for each (var y in vals) {
|
||||
for each (var op in ops) {
|
||||
for each (var z in vals) {
|
||||
// Assume eval is correct. This depends on the global
|
||||
// Infinity property not having been reassigned.
|
||||
var xz = eval(x + op + z);
|
||||
var yz = eval(y + op + z);
|
||||
|
||||
var arr = [x, x, x, x, x, y];
|
||||
assertEq(arr.length > RUNLOOP, true);
|
||||
var expected = [xz, xz, xz, xz, xz, yz];
|
||||
|
||||
// ?: looks superfluous but that's what we're testing here
|
||||
var fun = eval(
|
||||
'(function (arr, results) {\n' +
|
||||
' for (let i = 0; i < arr.length; i++)\n' +
|
||||
' results.push(arr[i]' + op + z + ' ? "true" : "false");\n' +
|
||||
'});\n');
|
||||
var actual = [];
|
||||
fun(arr, actual);
|
||||
assertEq("" + actual, "" + expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
test(testBug504520Harder);
|
||||
|
||||
function testCaseAbort()
|
||||
{
|
||||
var four = "4";
|
||||
|
@ -5497,6 +5542,21 @@ testOwnPropertyWithInOperator.jitstats = {
|
|||
};
|
||||
test(testEliminatedGuardWithinAnchor);
|
||||
|
||||
function testNativeSetter() {
|
||||
var re = /foo/;
|
||||
var N = RUNLOOP + 10;
|
||||
for (var i = 0; i < N; i++)
|
||||
re.lastIndex = i;
|
||||
assertEq(re.lastIndex, N - 1);
|
||||
}
|
||||
testNativeSetter.jitstats = {
|
||||
recorderStarted: 1,
|
||||
recorderAborted: 0,
|
||||
traceTriggered: 1,
|
||||
sideExitIntoInterpreter: 1
|
||||
};
|
||||
test(testNativeSetter);
|
||||
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* _____ _ _ _____ ______ _____ _______ *
|
||||
|
|
Загрузка…
Ссылка в новой задаче