Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
jsatom.h File Reference
#include <stddef.h>
#include "jstypes.h"
#include "jshash.h"
#include "jsapi.h"
#include "jsprvtd.h"
#include "jspubtd.h"
#include "jsproto.tbl"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JSAtom
struct  JSAtomListElement
struct  JSAtomList
struct  JSAtomMap
struct  JSAtomState
struct  JSAtomState.lazy

Defines

#define ATOM_PINNED   0x01 /* atom is pinned against GC */
#define ATOM_INTERNED   0x02 /* pinned variant for JS_Intern* API */
#define ATOM_MARK   0x04 /* atom is reachable via GC */
#define ATOM_HIDDEN   0x08 /* atom is in special hidden subspace */
#define ATOM_NOCOPY   0x40 /* don't copy atom string bytes */
#define ATOM_TMPSTR   0x80 /* internal, to avoid extra string */
#define ATOM_KEY(atom)   ((jsval)(atom)->entry.key)
#define ATOM_IS_OBJECT(atom)   JSVAL_IS_OBJECT(ATOM_KEY(atom))
#define ATOM_TO_OBJECT(atom)   JSVAL_TO_OBJECT(ATOM_KEY(atom))
#define ATOM_IS_INT(atom)   JSVAL_IS_INT(ATOM_KEY(atom))
#define ATOM_TO_INT(atom)   JSVAL_TO_INT(ATOM_KEY(atom))
#define ATOM_IS_DOUBLE(atom)   JSVAL_IS_DOUBLE(ATOM_KEY(atom))
#define ATOM_TO_DOUBLE(atom)   JSVAL_TO_DOUBLE(ATOM_KEY(atom))
#define ATOM_IS_STRING(atom)   JSVAL_IS_STRING(ATOM_KEY(atom))
#define ATOM_TO_STRING(atom)   JSVAL_TO_STRING(ATOM_KEY(atom))
#define ATOM_IS_BOOLEAN(atom)   JSVAL_IS_BOOLEAN(ATOM_KEY(atom))
#define ATOM_TO_BOOLEAN(atom)   JSVAL_TO_BOOLEAN(ATOM_KEY(atom))
#define ALE_ATOM(ale)   ((JSAtom *) (ale)->entry.key)
#define ALE_INDEX(ale)   ((jsatomid) JS_PTR_TO_UINT32((ale)->entry.value))
#define ALE_JSOP(ale)   ((JSOp) (ale)->entry.value)
#define ALE_VALUE(ale)   ((jsval) (ale)->entry.value)
#define ALE_NEXT(ale)   ((JSAtomListElement *) (ale)->entry.next)
#define ALE_SET_ATOM(ale, atom)   ((ale)->entry.key = (const void *)(atom))
#define ALE_SET_INDEX(ale, index)   ((ale)->entry.value = JS_UINT32_TO_PTR(index))
#define ALE_SET_JSOP(ale, op)   ((ale)->entry.value = JS_UINT32_TO_PTR(op))
#define ALE_SET_VALUE(ale, val)   ((ale)->entry.value = (JSHashEntry *)(val))
#define ALE_SET_NEXT(ale, link)   ((ale)->entry.next = (JSHashEntry *)(link))
#define ATOM_LIST_INIT(al)
#define ATOM_LIST_SEARCH(_ale, _al, _atom)
#define ATOM_LIST_LOOKUP(_ale, _hep, _al, _atom)
#define CLASS_ATOM(cx, name)   ((cx)->runtime->atomState.classAtoms[JSProto_##name])
#define JS_PROTO(name, code, init)   extern const char js_##name##_str[];

Typedefs

typedef void(* JSGCThingMarker )(void *thing, void *data)

Functions

 JS_FRIEND_API (const char *) js_AtomToPrintableString(JSContext *cx
JSBool js_InitAtomState (JSContext *cx, JSAtomState *state)
void js_FreeAtomState (JSContext *cx, JSAtomState *state)
void js_FinishAtomState (JSAtomState *state)
void js_MarkAtomState (JSAtomState *state, JSBool keepAtoms, JSGCThingMarker mark, void *data)
void js_SweepAtomState (JSAtomState *state)
JSBool js_InitPinnedAtoms (JSContext *cx, JSAtomState *state)
void js_UnpinPinnedAtoms (JSAtomState *state)
JSAtomjs_AtomizeObject (JSContext *cx, JSObject *obj, uintN flags)
JSAtomjs_AtomizeBoolean (JSContext *cx, JSBool b, uintN flags)
JSAtomjs_AtomizeInt (JSContext *cx, jsint i, uintN flags)
JSAtomjs_AtomizeDouble (JSContext *cx, jsdouble d, uintN flags)
JSAtomjs_AtomizeString (JSContext *cx, JSString *str, uintN flags)
 JS_FRIEND_API (JSAtom *) js_Atomize(JSContext *cx
JSAtomjs_GetExistingStringAtom (JSContext *cx, const jschar *chars, size_t length)
JSAtomjs_AtomizeValue (JSContext *cx, jsval value, uintN flags)
JSAtomjs_ValueToStringAtom (JSContext *cx, jsval v)
JSAtomListElementjs_IndexAtom (JSContext *cx, JSAtom *atom, JSAtomList *al)
 JS_FRIEND_API (JSBool) js_InitAtomMap(JSContext *cx
 JS_FRIEND_API (void) js_FreeAtomMap(JSContext *cx

Variables

JSAtomatom
const char * js_type_strs []
const char * js_boolean_strs []
const char * js_proto_strs []
const char js_anonymous_str []
const char js_arguments_str []
const char js_arity_str []
const char js_callee_str []
const char js_caller_str []
const char js_class_prototype_str []
const char js_close_str []
const char js_constructor_str []
const char js_count_str []
const char js_etago_str []
const char js_each_str []
const char js_eval_str []
const char js_fileName_str []
const char js_get_str []
const char js_getter_str []
const char js_index_str []
const char js_input_str []
const char js_iterator_str []
const char js_length_str []
const char js_lineNumber_str []
const char js_message_str []
const char js_name_str []
const char js_namespace_str []
const char js_next_str []
const char js_noSuchMethod_str []
const char js_object_str []
const char js_parent_str []
const char js_private_str []
const char js_proto_str []
const char js_ptagc_str []
const char js_qualifier_str []
const char js_send_str []
const char js_setter_str []
const char js_set_str []
const char js_space_str []
const char js_stack_str []
const char js_stago_str []
const char js_star_str []
const char js_starQualifier_str []
const char js_tagc_str []
const char js_toSource_str []
const char js_toString_str []
const char js_toLocaleString_str []
const char js_valueOf_str []
const char js_xml_str []
const char * bytes
const char size_t length
const char size_t uintN flags
const jscharchars
JSAtomMapmap
JSAtomMap jsatomid i
JSAtomMap JSAtomListal

Class Documentation

struct JSAtom

Definition at line 65 of file jsatom.h.

Class Members
JSHashEntry entry
uint32 flags
jsatomid number
struct JSAtomListElement

Definition at line 92 of file jsatom.h.

Class Members
JSHashEntry entry
struct JSAtomList

Definition at line 108 of file jsatom.h.

Collaboration diagram for JSAtomList:
Class Members
jsuint count
JSAtomListElement * list
JSHashTable * table
struct JSAtomMap

Definition at line 144 of file jsatom.h.

Collaboration diagram for JSAtomMap:
Class Members
jsatomid length
JSAtom ** vector
struct JSAtomState

Definition at line 149 of file jsatom.h.

Collaboration diagram for JSAtomState:
Class Members
JSAtom * anonymousAtom
JSAtom * argumentsAtom
JSAtom * arityAtom
JSAtom * booleanAtoms
JSAtom * calleeAtom
JSAtom * callerAtom
JSAtom * classAtoms
JSAtom * classPrototypeAtom
JSAtom * closeAtom
JSAtom * constructorAtom
JSAtom * countAtom
JSAtom * eachAtom
JSAtom * emptyAtom
JSAtom * etagoAtom
JSAtom * evalAtom
JSAtom * fileNameAtom
JSAtom * getAtom
JSAtom * getterAtom
JSAtom * indexAtom
JSAtom * inputAtom
JSAtom * iteratorAtom
struct JSAtomState lazy
JSAtom * lengthAtom
JSAtom * lineNumberAtom
jsatomid liveAtoms
JSAtom * messageAtom
JSAtom * nameAtom
JSAtom * namespaceAtom
JSAtom * nextAtom
JSAtom * noSuchMethodAtom
JSAtom * nullAtom
jsatomid number
JSAtom * parentAtom
JSAtom * protoAtom
JSAtom * ptagcAtom
JSAtom * qualifierAtom
JSRuntime * runtime
JSAtom * setAtom
JSAtom * setterAtom
JSAtom * spaceAtom
JSAtom * stackAtom
JSAtom * stagoAtom
JSAtom * starAtom
JSAtom * starQualifierAtom
JSHashTable * table
JSAtom * tagcAtom
JSAtom * toLocaleStringAtom
JSAtom * toSourceAtom
JSAtom * toStringAtom
JSAtom * typeAtoms
JSAtom * valueOfAtom
JSAtom * xmlAtom
struct JSAtomState.lazy

Definition at line 211 of file jsatom.h.

Class Members
JSAtom * decodeURIAtom
JSAtom * decodeURIComponentAtom
JSAtom * defineGetterAtom
JSAtom * defineSetterAtom
JSAtom * encodeURIAtom
JSAtom * encodeURIComponentAtom
JSAtom * escapeAtom
JSAtom * functionNamespaceURIAtom
JSAtom * hasOwnPropertyAtom
JSAtom * InfinityAtom
JSAtom * isFiniteAtom
JSAtom * isNaNAtom
JSAtom * isPrototypeOfAtom
JSAtom * isXMLNameAtom
JSAtom * lookupGetterAtom
JSAtom * lookupSetterAtom
JSAtom * NaNAtom
JSAtom * parseFloatAtom
JSAtom * parseIntAtom
JSAtom * propertyIsEnumerableAtom
JSAtom * unescapeAtom
JSAtom * unevalAtom
JSAtom * unwatchAtom
JSAtom * watchAtom
JSAtom * XMLListAtom

Define Documentation

#define ALE_ATOM (   ale)    ((JSAtom *) (ale)->entry.key)

Definition at line 96 of file jsatom.h.

#define ALE_INDEX (   ale)    ((jsatomid) JS_PTR_TO_UINT32((ale)->entry.value))

Definition at line 97 of file jsatom.h.

#define ALE_JSOP (   ale)    ((JSOp) (ale)->entry.value)

Definition at line 98 of file jsatom.h.

#define ALE_NEXT (   ale)    ((JSAtomListElement *) (ale)->entry.next)

Definition at line 100 of file jsatom.h.

#define ALE_SET_ATOM (   ale,
  atom 
)    ((ale)->entry.key = (const void *)(atom))

Definition at line 102 of file jsatom.h.

#define ALE_SET_INDEX (   ale,
  index 
)    ((ale)->entry.value = JS_UINT32_TO_PTR(index))

Definition at line 103 of file jsatom.h.

#define ALE_SET_JSOP (   ale,
  op 
)    ((ale)->entry.value = JS_UINT32_TO_PTR(op))

Definition at line 104 of file jsatom.h.

#define ALE_SET_NEXT (   ale,
  link 
)    ((ale)->entry.next = (JSHashEntry *)(link))

Definition at line 106 of file jsatom.h.

#define ALE_SET_VALUE (   ale,
  val 
)    ((ale)->entry.value = (JSHashEntry *)(val))

Definition at line 105 of file jsatom.h.

#define ALE_VALUE (   ale)    ((jsval) (ale)->entry.value)

Definition at line 99 of file jsatom.h.

#define ATOM_HIDDEN   0x08 /* atom is in special hidden subspace */

Definition at line 61 of file jsatom.h.

#define ATOM_INTERNED   0x02 /* pinned variant for JS_Intern* API */

Definition at line 59 of file jsatom.h.

Definition at line 81 of file jsatom.h.

Definition at line 77 of file jsatom.h.

Definition at line 75 of file jsatom.h.

Definition at line 73 of file jsatom.h.

Definition at line 79 of file jsatom.h.

#define ATOM_KEY (   atom)    ((jsval)(atom)->entry.key)

Definition at line 72 of file jsatom.h.

Value:
((al)->list = NULL, (al)->table = NULL,           \
                             (al)->count = 0)

Definition at line 114 of file jsatom.h.

#define ATOM_LIST_LOOKUP (   _ale,
  _hep,
  _al,
  _atom 
)
Value:
JS_BEGIN_MACRO                                                            \
        if ((_al)->table) {                                                   \
            _hep = JS_HashTableRawLookup((_al)->table, _atom->number, _atom); \
            _ale = *_hep ? (JSAtomListElement *) *_hep : NULL;                \
        } else {                                                              \
            JSAtomListElement **_alep = &(_al)->list;                         \
            _hep = NULL;                                                      \
            while ((_ale = *_alep) != NULL) {                                 \
                if (ALE_ATOM(_ale) == (_atom)) {                              \
                    /* Hit, move atom's element to the front of the list. */  \
                    *_alep = ALE_NEXT(_ale);                                  \
                    ALE_SET_NEXT(_ale, (_al)->list);                          \
                    (_al)->list = _ale;                                       \
                    break;                                                    \
                }                                                             \
                _alep = (JSAtomListElement **)&_ale->entry.next;              \
            }                                                                 \
        }                                                                     \
    JS_END_MACRO

Definition at line 123 of file jsatom.h.

#define ATOM_LIST_SEARCH (   _ale,
  _al,
  _atom 
)
Value:
JS_BEGIN_MACRO                                                            \
        JSHashEntry **_hep;                                                   \
        ATOM_LIST_LOOKUP(_ale, _hep, _al, _atom);                             \
    JS_END_MACRO

Definition at line 117 of file jsatom.h.

#define ATOM_MARK   0x04 /* atom is reachable via GC */

Definition at line 60 of file jsatom.h.

#define ATOM_NOCOPY   0x40 /* don't copy atom string bytes */

Definition at line 62 of file jsatom.h.

#define ATOM_PINNED   0x01 /* atom is pinned against GC */

Definition at line 58 of file jsatom.h.

#define ATOM_TMPSTR   0x80 /* internal, to avoid extra string */

Definition at line 63 of file jsatom.h.

Definition at line 82 of file jsatom.h.

Definition at line 78 of file jsatom.h.

Definition at line 76 of file jsatom.h.

Definition at line 74 of file jsatom.h.

Definition at line 80 of file jsatom.h.

#define CLASS_ATOM (   cx,
  name 
)    ((cx)->runtime->atomState.classAtoms[JSProto_##name])

Definition at line 252 of file jsatom.h.

#define JS_PROTO (   name,
  code,
  init 
)    extern const char js_##name##_str[];

Definition at line 260 of file jsatom.h.


Typedef Documentation

Definition at line 351 of file jsatom.h.


Function Documentation

JSAtom* js_AtomizeBoolean ( JSContext cx,
JSBool  b,
uintN  flags 
)

Definition at line 551 of file jsatom.c.

{
    jsval key;
    JSHashNumber keyHash;

    key = BOOLEAN_TO_JSVAL(b);
    keyHash = HASH_BOOLEAN(b);
    return js_AtomizeHashedKey(cx, key, keyHash, flags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtom* js_AtomizeDouble ( JSContext cx,
jsdouble  d,
uintN  flags 
)

Definition at line 577 of file jsatom.c.

{
    jsdouble *dp;
    JSHashNumber keyHash;
    jsval key;
    JSAtomState *state;
    JSHashTable *table;
    JSHashEntry *he, **hep;
    JSAtom *atom;
    char buf[2 * ALIGNMENT(double)];

    dp = ALIGN(buf, double);
    *dp = d;
    keyHash = HASH_DOUBLE(dp);
    key = DOUBLE_TO_JSVAL(dp);
    state = &cx->runtime->atomState;
    JS_LOCK(&state->lock, cx);
    table = state->table;
    hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
    if ((he = *hep) == NULL) {
#ifdef JS_THREADSAFE
        uint32 gen = state->tablegen;
#endif
        JS_UNLOCK(&state->lock,cx);
        if (!js_NewDoubleValue(cx, d, &key))
            return NULL;
        JS_LOCK(&state->lock, cx);
#ifdef JS_THREADSAFE
        if (state->tablegen != gen) {
            hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
            if ((he = *hep) != NULL) {
                atom = (JSAtom *)he;
                goto out;
            }
        }
#endif
        he = JS_HashTableRawAdd(table, hep, keyHash, (void *)key, NULL);
        if (!he) {
            JS_ReportOutOfMemory(cx);
            atom = NULL;
            goto out;
        }
    }

    atom = (JSAtom *)he;
    atom->flags |= flags;
    cx->weakRoots.lastAtom = atom;
out:
    JS_UNLOCK(&state->lock,cx);
    return atom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtom* js_AtomizeInt ( JSContext cx,
jsint  i,
uintN  flags 
)

Definition at line 562 of file jsatom.c.

{
    jsval key;
    JSHashNumber keyHash;

    key = INT_TO_JSVAL(i);
    keyHash = HASH_INT(i);
    return js_AtomizeHashedKey(cx, key, keyHash, flags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtom* js_AtomizeObject ( JSContext cx,
JSObject obj,
uintN  flags 
)

Definition at line 539 of file jsatom.c.

{
    jsval key;
    JSHashNumber keyHash;

    /* XXX must be set in the following order or MSVC1.52 will crash */
    keyHash = HASH_OBJECT(obj);
    key = OBJECT_TO_JSVAL(obj);
    return js_AtomizeHashedKey(cx, key, keyHash, flags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtom* js_AtomizeString ( JSContext cx,
JSString str,
uintN  flags 
)

Definition at line 636 of file jsatom.c.

{
    JSHashNumber keyHash;
    jsval key;
    JSAtomState *state;
    JSHashTable *table;
    JSHashEntry *he, **hep;
    JSAtom *atom;

    keyHash = js_HashString(str);
    if (flags & ATOM_HIDDEN)
        keyHash ^= HIDDEN_ATOM_SUBSPACE_KEYHASH;
    key = STRING_TO_JSVAL(str);
    state = &cx->runtime->atomState;
    JS_LOCK(&state->lock, cx);
    table = state->table;
    hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
    if ((he = *hep) == NULL) {
#ifdef JS_THREADSAFE
        uint32 gen = state->tablegen;
        JS_UNLOCK(&state->lock, cx);
#endif

        if (flags & ATOM_TMPSTR) {
            str = (flags & ATOM_NOCOPY)
                  ? js_NewString(cx, str->chars, str->length, 0)
                  : js_NewStringCopyN(cx, str->chars, str->length, 0);
            if (!str)
                return NULL;
            key = STRING_TO_JSVAL(str);
        } else {
            if (!JS_MakeStringImmutable(cx, str))
                return NULL;
        }

#ifdef JS_THREADSAFE
        JS_LOCK(&state->lock, cx);
        if (state->tablegen != gen) {
            hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
            if ((he = *hep) != NULL) {
                atom = (JSAtom *)he;
                if (flags & ATOM_NOCOPY)
                    str->chars = NULL;
                goto out;
            }
        }
#endif

        he = JS_HashTableRawAdd(table, hep, keyHash, (void *)key, NULL);
        if (!he) {
            JS_ReportOutOfMemory(cx);
            atom = NULL;
            goto out;
        }
    }

    atom = (JSAtom *)he;
    atom->flags |= flags & (ATOM_PINNED | ATOM_INTERNED | ATOM_HIDDEN);
    cx->weakRoots.lastAtom = atom;
out:
    JS_UNLOCK(&state->lock,cx);
    return atom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtom* js_AtomizeValue ( JSContext cx,
jsval  value,
uintN  flags 
)

Definition at line 778 of file jsatom.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 406 of file jsatom.c.

{
    UninternArgs args;

    if (!state->table)
        return;
    args.rt = state->runtime;
    args.leaks = 0;
    JS_HashTableEnumerateEntries(state->table, js_atom_uninterner, &args);
#ifdef DEBUG
    if (args.leaks != 0) {
        fprintf(stderr,
"JS engine warning: %lu atoms remain after destroying the JSRuntime.\n"
"                   These atoms may point to freed memory. Things reachable\n"
"                   through them have not been finalized.\n",
                (unsigned long) args.leaks);
    }
#endif
    js_FreeAtomState(NULL, state);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void js_FreeAtomState ( JSContext cx,
JSAtomState state 
)

Definition at line 375 of file jsatom.c.

{
    if (state->table)
        JS_HashTableDestroy(state->table);
#ifdef JS_THREADSAFE
    js_FinishLock(&state->lock);
#endif
    memset(state, 0, sizeof *state);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JS_FRIEND_API ( const char *  )
JSAtom* js_GetExistingStringAtom ( JSContext cx,
const jschar chars,
size_t  length 
)

Definition at line 754 of file jsatom.c.

{
    JSString *str;
    char buf[2 * ALIGNMENT(JSString)];
    JSHashNumber keyHash;
    jsval key;
    JSAtomState *state;
    JSHashTable *table;
    JSHashEntry **hep;

    str = ALIGN(buf, JSString);
    str->chars = (jschar *)chars;
    str->length = length;
    keyHash = js_HashString(str);
    key = STRING_TO_JSVAL(str);
    state = &cx->runtime->atomState;
    JS_LOCK(&state->lock, cx);
    table = state->table;
    hep = JS_HashTableRawLookup(table, keyHash, (void *)key);
    JS_UNLOCK(&state->lock, cx);
    return (hep) ? (JSAtom *)*hep : NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSAtomListElement* js_IndexAtom ( JSContext cx,
JSAtom atom,
JSAtomList al 
)

Definition at line 853 of file jsatom.c.

{
    JSAtomListElement *ale, *ale2, *next;
    JSHashEntry **hep;

    ATOM_LIST_LOOKUP(ale, hep, al, atom);
    if (!ale) {
        if (al->count < 10) {
            /* Few enough for linear search, no hash table needed. */
            JS_ASSERT(!al->table);
            ale = (JSAtomListElement *)js_alloc_temp_entry(cx, atom);
            if (!ale)
                return NULL;
            ALE_SET_ATOM(ale, atom);
            ALE_SET_NEXT(ale, al->list);
            al->list = ale;
        } else {
            /* We want to hash.  Have we already made a hash table? */
            if (!al->table) {
                /* No hash table yet, so hep had better be null! */
                JS_ASSERT(!hep);
                al->table = JS_NewHashTable(al->count + 1, js_hash_atom_ptr,
                                            JS_CompareValues, JS_CompareValues,
                                            &temp_alloc_ops, cx);
                if (!al->table)
                    return NULL;

                /*
                 * Set ht->nentries explicitly, because we are moving entries
                 * from al to ht, not calling JS_HashTable(Raw|)Add.
                 */
                al->table->nentries = al->count;

                /* Insert each ale on al->list into the new hash table. */
                for (ale2 = al->list; ale2; ale2 = next) {
                    next = ALE_NEXT(ale2);
                    ale2->entry.keyHash = ALE_ATOM(ale2)->number;
                    hep = JS_HashTableRawLookup(al->table, ale2->entry.keyHash,
                                                ale2->entry.key);
                    ALE_SET_NEXT(ale2, *hep);
                    *hep = &ale2->entry;
                }
                al->list = NULL;

                /* Set hep for insertion of atom's ale, immediately below. */
                hep = JS_HashTableRawLookup(al->table, atom->number, atom);
            }

            /* Finally, add an entry for atom into the hash bucket at hep. */
            ale = (JSAtomListElement *)
                  JS_HashTableRawAdd(al->table, hep, atom->number, atom, NULL);
            if (!ale)
                return NULL;
        }

        ALE_SET_INDEX(ale, al->count++);
    }
    return ale;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_InitAtomState ( JSContext cx,
JSAtomState state 
)

Definition at line 266 of file jsatom.c.

{
    state->table = JS_NewHashTable(JS_ATOM_HASH_SIZE, js_hash_atom_key,
                                   js_compare_atom_keys, js_compare_stub,
                                   &atom_alloc_ops, state);
    if (!state->table) {
        JS_ReportOutOfMemory(cx);
        return JS_FALSE;
    }

    state->runtime = cx->runtime;
#ifdef JS_THREADSAFE
    js_InitLock(&state->lock);
    state->tablegen = 0;
#endif

    if (!js_InitPinnedAtoms(cx, state)) {
        js_FreeAtomState(cx, state);
        return JS_FALSE;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 290 of file jsatom.c.

{
    uintN i;

#define FROB(lval,str)                                                        \
    JS_BEGIN_MACRO                                                            \
        if (!(state->lval = js_Atomize(cx, str, strlen(str), ATOM_PINNED)))   \
            return JS_FALSE;                                                  \
    JS_END_MACRO

    for (i = 0; i < JSTYPE_LIMIT; i++)
        FROB(typeAtoms[i],        js_type_strs[i]);

    for (i = 0; i < JSProto_LIMIT; i++)
        FROB(classAtoms[i],       js_proto_strs[i]);

    FROB(booleanAtoms[0],         js_false_str);
    FROB(booleanAtoms[1],         js_true_str);
    FROB(nullAtom,                js_null_str);

    FROB(anonymousAtom,           js_anonymous_str);
    FROB(argumentsAtom,           js_arguments_str);
    FROB(arityAtom,               js_arity_str);
    FROB(calleeAtom,              js_callee_str);
    FROB(callerAtom,              js_caller_str);
    FROB(classPrototypeAtom,      js_class_prototype_str);
    FROB(constructorAtom,         js_constructor_str);
    FROB(countAtom,               js_count_str);
    FROB(eachAtom,                js_each_str);
    FROB(evalAtom,                js_eval_str);
    FROB(fileNameAtom,            js_fileName_str);
    FROB(getAtom,                 js_get_str);
    FROB(getterAtom,              js_getter_str);
    FROB(indexAtom,               js_index_str);
    FROB(inputAtom,               js_input_str);
    FROB(iteratorAtom,            js_iterator_str);
    FROB(lengthAtom,              js_length_str);
    FROB(lineNumberAtom,          js_lineNumber_str);
    FROB(messageAtom,             js_message_str);
    FROB(nameAtom,                js_name_str);
    FROB(nextAtom,                js_next_str);
    FROB(noSuchMethodAtom,        js_noSuchMethod_str);
    FROB(parentAtom,              js_parent_str);
    FROB(protoAtom,               js_proto_str);
    FROB(setAtom,                 js_set_str);
    FROB(setterAtom,              js_setter_str);
    FROB(stackAtom,               js_stack_str);
    FROB(toSourceAtom,            js_toSource_str);
    FROB(toStringAtom,            js_toString_str);
    FROB(toLocaleStringAtom,      js_toLocaleString_str);
    FROB(valueOfAtom,             js_valueOf_str);

#if JS_HAS_XML_SUPPORT
    FROB(etagoAtom,               js_etago_str);
    FROB(namespaceAtom,           js_namespace_str);
    FROB(ptagcAtom,               js_ptagc_str);
    FROB(qualifierAtom,           js_qualifier_str);
    FROB(spaceAtom,               js_space_str);
    FROB(stagoAtom,               js_stago_str);
    FROB(starAtom,                js_star_str);
    FROB(starQualifierAtom,       js_starQualifier_str);
    FROB(tagcAtom,                js_tagc_str);
    FROB(xmlAtom,                 js_xml_str);
#endif

#if JS_HAS_GENERATORS
    FROB(closeAtom,               js_close_str);
#endif

#ifdef NARCISSUS
    FROB(callAtom,                js_call_str);
    FROB(constructAtom,           js_construct_str);
    FROB(hasInstanceAtom,         js_hasInstance_str);
    FROB(ExecutionContextAtom,    js_ExecutionContext_str);
    FROB(currentAtom,             js_current_str);
#endif

#undef FROB

    memset(&state->lazy, 0, sizeof state->lazy);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void js_MarkAtomState ( JSAtomState state,
JSBool  keepAtoms,
JSGCThingMarker  mark,
void data 
)

Definition at line 452 of file jsatom.c.

{
    MarkArgs args;

    if (!state->table)
        return;
    args.keepAtoms = keepAtoms;
    args.mark = mark;
    args.data = data;
    JS_HashTableEnumerateEntries(state->table, js_atom_marker, &args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 485 of file jsatom.c.

{
    state->liveAtoms = 0;
    if (state->table)
        JS_HashTableEnumerateEntries(state->table, js_atom_sweeper, state);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 503 of file jsatom.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 794 of file jsatom.c.

{
    JSString *str;

    str = js_ValueToString(cx, v);
    if (!str)
        return NULL;
    return js_AtomizeString(cx, str, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 446 of file jsatom.h.

Definition at line 90 of file jsatom.h.

const char* bytes

Definition at line 402 of file jsatom.h.

Definition at line 405 of file jsatom.h.

Definition at line 402 of file jsatom.h.

Definition at line 436 of file jsatom.h.

Definition at line 99 of file jsatom.c.

Definition at line 100 of file jsatom.c.

Definition at line 101 of file jsatom.c.

Definition at line 84 of file jsatom.c.

Definition at line 102 of file jsatom.c.

Definition at line 103 of file jsatom.c.

Definition at line 104 of file jsatom.c.

Definition at line 146 of file jsatom.c.

Definition at line 105 of file jsatom.c.

Definition at line 106 of file jsatom.c.

Definition at line 107 of file jsatom.c.

Definition at line 133 of file jsatom.c.

Definition at line 108 of file jsatom.c.

Definition at line 109 of file jsatom.c.

const char js_get_str[]

Definition at line 110 of file jsatom.c.

Definition at line 111 of file jsatom.c.

Definition at line 112 of file jsatom.c.

Definition at line 113 of file jsatom.c.

Definition at line 114 of file jsatom.c.

Definition at line 115 of file jsatom.c.

Definition at line 116 of file jsatom.c.

Definition at line 117 of file jsatom.c.

Definition at line 118 of file jsatom.c.

Definition at line 134 of file jsatom.c.

Definition at line 119 of file jsatom.c.

Definition at line 120 of file jsatom.c.

Definition at line 121 of file jsatom.c.

Definition at line 122 of file jsatom.c.

Definition at line 123 of file jsatom.c.

Definition at line 93 of file jsatom.c.

Definition at line 135 of file jsatom.c.

Definition at line 136 of file jsatom.c.

Definition at line 147 of file jsatom.c.

const char js_set_str[]

Definition at line 125 of file jsatom.c.

Definition at line 124 of file jsatom.c.

Definition at line 137 of file jsatom.c.

Definition at line 126 of file jsatom.c.

Definition at line 138 of file jsatom.c.

Definition at line 139 of file jsatom.c.

Definition at line 140 of file jsatom.c.

Definition at line 141 of file jsatom.c.

Definition at line 129 of file jsatom.c.

Definition at line 127 of file jsatom.c.

Definition at line 128 of file jsatom.c.

Definition at line 70 of file jsatom.c.

Definition at line 130 of file jsatom.c.

const char js_xml_str[]

Definition at line 142 of file jsatom.c.

Definition at line 402 of file jsatom.h.

Definition at line 436 of file jsatom.h.