Classes | Defines | Typedefs | Enumerations | Functions | Variables

jsopcode.h File Reference

#include <stddef.h>
#include "jsprvtd.h"
#include "jspubtd.h"
#include "jsutil.h"
#include "jsopcode.tbl"
Include dependency graph for jsopcode.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  JSCodeSpec

Defines

#define OPDEF(op, val, name, token, length, nuses, ndefs, prec, format)   op = val,
#define JOF_BYTE   0
#define JOF_JUMP   1
#define JOF_ATOM   2
#define JOF_UINT16   3
#define JOF_TABLESWITCH   4
#define JOF_LOOKUPSWITCH   5
#define JOF_QARG   6
#define JOF_LOCAL   7
#define JOF_SLOTATOM   8
#define JOF_JUMPX   9
#define JOF_TABLESWITCHX   10
#define JOF_LOOKUPSWITCHX   11
#define JOF_UINT24   12
#define JOF_UINT8   13
#define JOF_INT32   14
#define JOF_OBJECT   15
#define JOF_SLOTOBJECT   16
#define JOF_REGEXP   17
#define JOF_INT8   18
#define JOF_ATOMOBJECT   19
#define JOF_UINT16PAIR   20
#define JOF_TYPEMASK   0x001f
#define JOF_NAME   (1U<<5)
#define JOF_PROP   (2U<<5)
#define JOF_ELEM   (3U<<5)
#define JOF_XMLNAME   (4U<<5)
#define JOF_VARPROP   (5U<<5)
#define JOF_MODEMASK   (7U<<5)
#define JOF_SET   (1U<<8)
#define JOF_DEL   (1U<<9)
#define JOF_DEC   (1U<<10)
#define JOF_INC   (2U<<10)
#define JOF_INCDEC   (3U<<10)
#define JOF_POST   (1U<<12)
#define JOF_FOR   (1U<<13)
#define JOF_ASSIGNING   JOF_SET
#define JOF_DETECTING   (1U<<14)
#define JOF_BACKPATCH   (1U<<15)
#define JOF_LEFTASSOC   (1U<<16)
#define JOF_DECLARING   (1U<<17)
#define JOF_INDEXBASE   (1U<<18)
#define JOF_CALLOP   (1U<<19)
#define JOF_PARENHEAD   (1U<<20)
#define JOF_INVOKE   (1U<<21)
#define JOF_TMPSLOT   (1U<<22)
#define JOF_TMPSLOT2   (2U<<22)
#define JOF_TMPSLOT_SHIFT   22
#define JOF_TMPSLOT_MASK   (JS_BITMASK(2) << JOF_TMPSLOT_SHIFT)
#define JOF_SHARPSLOT   (1U<<24)
#define JOF_TYPE(fmt)   ((fmt) & JOF_TYPEMASK)
#define JOF_OPTYPE(op)   JOF_TYPE(js_CodeSpec[op].format)
#define JOF_MODE(fmt)   ((fmt) & JOF_MODEMASK)
#define JOF_OPMODE(op)   JOF_MODE(js_CodeSpec[op].format)
#define JOF_TYPE_IS_EXTENDED_JUMP(t)   ((unsigned)((t) - JOF_JUMPX) <= (unsigned)(JOF_LOOKUPSWITCHX - JOF_JUMPX))
#define UINT16_LEN   2
#define UINT16_HI(i)   ((jsbytecode)((i) >> 8))
#define UINT16_LO(i)   ((jsbytecode)(i))
#define GET_UINT16(pc)   ((uintN)(((pc)[1] << 8) | (pc)[2]))
#define SET_UINT16(pc, i)   ((pc)[1] = UINT16_HI(i), (pc)[2] = UINT16_LO(i))
#define UINT16_LIMIT   ((uintN)1 << 16)
#define JUMP_OFFSET_LEN   2
#define JUMP_OFFSET_HI(off)   ((jsbytecode)((off) >> 8))
#define JUMP_OFFSET_LO(off)   ((jsbytecode)(off))
#define GET_JUMP_OFFSET(pc)   ((int16)GET_UINT16(pc))
#define SET_JUMP_OFFSET(pc, off)
#define JUMP_OFFSET_MIN   ((int16)0x8000)
#define JUMP_OFFSET_MAX   ((int16)0x7fff)
#define GET_SPANDEP_INDEX(pc)   ((uint16)GET_UINT16(pc))
#define SET_SPANDEP_INDEX(pc, i)
#define SPANDEP_INDEX_MAX   ((uint16)0xfffe)
#define SPANDEP_INDEX_HUGE   ((uint16)0xffff)
#define JUMPX_OFFSET_LEN   4
#define JUMPX_OFFSET_B3(off)   ((jsbytecode)((off) >> 24))
#define JUMPX_OFFSET_B2(off)   ((jsbytecode)((off) >> 16))
#define JUMPX_OFFSET_B1(off)   ((jsbytecode)((off) >> 8))
#define JUMPX_OFFSET_B0(off)   ((jsbytecode)(off))
#define GET_JUMPX_OFFSET(pc)
#define SET_JUMPX_OFFSET(pc, off)
#define JUMPX_OFFSET_MIN   ((int32)0x80000000)
#define JUMPX_OFFSET_MAX   ((int32)0x7fffffff)
#define INDEX_LEN   2
#define INDEX_HI(i)   ((jsbytecode)((i) >> 8))
#define INDEX_LO(i)   ((jsbytecode)(i))
#define GET_INDEX(pc)   GET_UINT16(pc)
#define SET_INDEX(pc, i)   ((pc)[1] = INDEX_HI(i), (pc)[2] = INDEX_LO(i))
#define GET_INDEXBASE(pc)
#define INDEXBASE_LEN   1
#define UINT24_HI(i)   ((jsbytecode)((i) >> 16))
#define UINT24_MID(i)   ((jsbytecode)((i) >> 8))
#define UINT24_LO(i)   ((jsbytecode)(i))
#define GET_UINT24(pc)
#define SET_UINT24(pc, i)
#define GET_INT8(pc)   ((jsint)(int8)(pc)[1])
#define GET_INT32(pc)
#define SET_INT32(pc, i)
#define INDEX_LIMIT_LOG2   23
#define INDEX_LIMIT   ((uint32)1 << INDEX_LIMIT_LOG2)
#define ARGC_HI(argc)   UINT16_HI(argc)
#define ARGC_LO(argc)   UINT16_LO(argc)
#define GET_ARGC(pc)   GET_UINT16(pc)
#define ARGC_LIMIT   UINT16_LIMIT
#define GET_ARGNO(pc)   GET_UINT16(pc)
#define SET_ARGNO(pc, argno)   SET_UINT16(pc,argno)
#define ARGNO_LEN   2
#define ARGNO_LIMIT   UINT16_LIMIT
#define GET_SLOTNO(pc)   GET_UINT16(pc)
#define SET_SLOTNO(pc, varno)   SET_UINT16(pc,varno)
#define SLOTNO_LEN   2
#define SLOTNO_LIMIT   UINT16_LIMIT
#define GET_ATOM_FROM_BYTECODE(script, pc, pcoff, atom)
#define GET_DOUBLE_FROM_BYTECODE(script, pc, pcoff, atom)
#define GET_OBJECT_FROM_BYTECODE(script, pc, pcoff, obj)
#define GET_FUNCTION_FROM_BYTECODE(script, pc, pcoff, fun)
#define GET_REGEXP_FROM_BYTECODE(script, pc, pcoff, obj)
#define JSDVG_IGNORE_STACK   0
#define JSDVG_SEARCH_STACK   1

Typedefs

typedef enum JSOp JSOp
typedef JSBool(* JSDecompilerPtr )(JSPrinter *)

Enumerations

enum  JSOp

Functions

JSStringjs_QuoteString (JSContext *cx, JSString *str, jschar quote)
JSPrinterjs_NewPrinter (JSContext *cx, const char *name, JSFunction *fun, uintN indent, JSBool pretty, JSBool grouped, JSBool strict)
void js_DestroyPrinter (JSPrinter *jp)
JSStringjs_GetPrinterOutput (JSPrinter *jp)
int js_printf (JSPrinter *jp, const char *format,...)
JSBool js_puts (JSPrinter *jp, const char *s)
uintN js_GetIndexFromBytecode (JSContext *cx, JSScript *script, jsbytecode *pc, ptrdiff_t pcoff)
uintN js_GetVariableBytecodeLength (jsbytecode *pc)
uintN js_GetVariableStackUses (JSOp op, jsbytecode *pc)
uintN js_GetEnterBlockStackDefs (JSContext *cx, JSScript *script, jsbytecode *pc)
JSBool js_DecompileScript (JSPrinter *jp, JSScript *script)
JSBool js_DecompileFunctionBody (JSPrinter *jp)
JSBool js_DecompileFunction (JSPrinter *jp)
JSStringjs_DecompileToString (JSContext *cx, const char *name, JSFunction *fun, uintN indent, JSBool pretty, JSBool grouped, JSBool strict, JSDecompilerPtr decompiler)
char * js_DecompileValueGenerator (JSContext *cx, intN spindex, jsval v, JSString *fallback)
uintN js_ReconstructStackDepth (JSContext *cx, JSScript *script, jsbytecode *pc)

Variables

const JSCodeSpec js_CodeSpec []
uintN js_NumCodeSpecs
const char * js_CodeName []
const char js_EscapeMap []

Define Documentation

#define ARGC_HI (   argc  )     UINT16_HI(argc)
#define ARGC_LIMIT   UINT16_LIMIT
#define ARGC_LO (   argc  )     UINT16_LO(argc)
#define ARGNO_LEN   2
#define ARGNO_LIMIT   UINT16_LIMIT
#define GET_ARGC (   pc  )     GET_UINT16(pc)
#define GET_ARGNO (   pc  )     GET_UINT16(pc)
#define GET_ATOM_FROM_BYTECODE (   script,
  pc,
  pcoff,
  atom 
)
Value:
JS_BEGIN_MACRO                                                            \
        JS_ASSERT(*(pc) != JSOP_DOUBLE);                                      \
        uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff));  \
        JS_GET_SCRIPT_ATOM(script, pc, index_, atom);                         \
    JS_END_MACRO
#define GET_DOUBLE_FROM_BYTECODE (   script,
  pc,
  pcoff,
  atom 
)
Value:
JS_BEGIN_MACRO                                                            \
        uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff));  \
        JS_ASSERT(index_ < (script)->atomMap.length);                         \
        (atom) = (script)->atomMap.vector[index_];                            \
        JS_ASSERT(ATOM_IS_DOUBLE(atom));                                      \
    JS_END_MACRO
#define GET_FUNCTION_FROM_BYTECODE (   script,
  pc,
  pcoff,
  fun 
)
Value:
JS_BEGIN_MACRO                                                            \
        uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff));  \
        fun = (script)->getFunction(index_);                                  \
    JS_END_MACRO
#define GET_INDEX (   pc  )     GET_UINT16(pc)
#define GET_INDEXBASE (   pc  ) 
Value:
(JS_ASSERT(*(pc) == JSOP_INDEXBASE),          \
                                 ((uintN)((pc)[1])) << 16)
#define GET_INT32 (   pc  ) 
Value:
((jsint)(((uint32)((pc)[1]) << 24) |          \
                                         ((uint32)((pc)[2]) << 16) |          \
                                         ((uint32)((pc)[3]) << 8)  |          \
                                         (uint32)(pc)[4]))
#define GET_INT8 (   pc  )     ((jsint)(int8)(pc)[1])
#define GET_JUMP_OFFSET (   pc  )     ((int16)GET_UINT16(pc))
#define GET_JUMPX_OFFSET (   pc  ) 
Value:
((int32)(((pc)[1] << 24) | ((pc)[2] << 16)    \
                                         | ((pc)[3] << 8) | (pc)[4]))
#define GET_OBJECT_FROM_BYTECODE (   script,
  pc,
  pcoff,
  obj 
)
Value:
JS_BEGIN_MACRO                                                            \
        uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff));  \
        obj = (script)->getObject(index_);                                    \
    JS_END_MACRO
#define GET_REGEXP_FROM_BYTECODE (   script,
  pc,
  pcoff,
  obj 
)
Value:
JS_BEGIN_MACRO                                                            \
        uintN index_ = js_GetIndexFromBytecode(cx, (script), (pc), (pcoff));  \
        obj = (script)->getRegExp(index_);                                    \
    JS_END_MACRO
#define GET_SLOTNO (   pc  )     GET_UINT16(pc)
#define GET_SPANDEP_INDEX (   pc  )     ((uint16)GET_UINT16(pc))
#define GET_UINT16 (   pc  )     ((uintN)(((pc)[1] << 8) | (pc)[2]))
#define GET_UINT24 (   pc  ) 
Value:
((jsatomid)(((pc)[1] << 16) |                 \
                                            ((pc)[2] << 8) |                  \
                                            (pc)[3]))
#define INDEX_HI (   i  )     ((jsbytecode)((i) >> 8))
#define INDEX_LEN   2
#define INDEX_LIMIT   ((uint32)1 << INDEX_LIMIT_LOG2)
#define INDEX_LIMIT_LOG2   23
#define INDEX_LO (   i  )     ((jsbytecode)(i))
#define INDEXBASE_LEN   1
#define JOF_ASSIGNING   JOF_SET
#define JOF_ATOM   2
#define JOF_ATOMOBJECT   19
#define JOF_BACKPATCH   (1U<<15)
#define JOF_BYTE   0
#define JOF_CALLOP   (1U<<19)
#define JOF_DEC   (1U<<10)
#define JOF_DECLARING   (1U<<17)
#define JOF_DEL   (1U<<9)
#define JOF_DETECTING   (1U<<14)
#define JOF_ELEM   (3U<<5)
#define JOF_FOR   (1U<<13)
#define JOF_INC   (2U<<10)
#define JOF_INCDEC   (3U<<10)
#define JOF_INDEXBASE   (1U<<18)
#define JOF_INT32   14
#define JOF_INT8   18
#define JOF_INVOKE   (1U<<21)
#define JOF_JUMP   1
#define JOF_JUMPX   9
#define JOF_LEFTASSOC   (1U<<16)
#define JOF_LOCAL   7
#define JOF_LOOKUPSWITCH   5
#define JOF_LOOKUPSWITCHX   11
#define JOF_MODE (   fmt  )     ((fmt) & JOF_MODEMASK)
#define JOF_MODEMASK   (7U<<5)
#define JOF_NAME   (1U<<5)
#define JOF_OBJECT   15
#define JOF_OPMODE (   op  )     JOF_MODE(js_CodeSpec[op].format)
#define JOF_OPTYPE (   op  )     JOF_TYPE(js_CodeSpec[op].format)
#define JOF_PARENHEAD   (1U<<20)
#define JOF_POST   (1U<<12)
#define JOF_PROP   (2U<<5)
#define JOF_QARG   6
#define JOF_REGEXP   17
#define JOF_SET   (1U<<8)
#define JOF_SHARPSLOT   (1U<<24)
#define JOF_SLOTATOM   8
#define JOF_SLOTOBJECT   16
#define JOF_TABLESWITCH   4
#define JOF_TABLESWITCHX   10
#define JOF_TMPSLOT   (1U<<22)
#define JOF_TMPSLOT2   (2U<<22)
#define JOF_TMPSLOT_MASK   (JS_BITMASK(2) << JOF_TMPSLOT_SHIFT)
#define JOF_TMPSLOT_SHIFT   22
#define JOF_TYPE (   fmt  )     ((fmt) & JOF_TYPEMASK)
#define JOF_TYPE_IS_EXTENDED_JUMP (   t  )     ((unsigned)((t) - JOF_JUMPX) <= (unsigned)(JOF_LOOKUPSWITCHX - JOF_JUMPX))
#define JOF_TYPEMASK   0x001f
#define JOF_UINT16   3
#define JOF_UINT16PAIR   20
#define JOF_UINT24   12
#define JOF_UINT8   13
#define JOF_VARPROP   (5U<<5)
#define JOF_XMLNAME   (4U<<5)
#define JSDVG_IGNORE_STACK   0
#define JSDVG_SEARCH_STACK   1
#define JUMP_OFFSET_HI (   off  )     ((jsbytecode)((off) >> 8))
#define JUMP_OFFSET_LEN   2
#define JUMP_OFFSET_LO (   off  )     ((jsbytecode)(off))
#define JUMP_OFFSET_MAX   ((int16)0x7fff)
#define JUMP_OFFSET_MIN   ((int16)0x8000)
#define JUMPX_OFFSET_B0 (   off  )     ((jsbytecode)(off))
#define JUMPX_OFFSET_B1 (   off  )     ((jsbytecode)((off) >> 8))
#define JUMPX_OFFSET_B2 (   off  )     ((jsbytecode)((off) >> 16))
#define JUMPX_OFFSET_B3 (   off  )     ((jsbytecode)((off) >> 24))
#define JUMPX_OFFSET_LEN   4
#define JUMPX_OFFSET_MAX   ((int32)0x7fffffff)
#define JUMPX_OFFSET_MIN   ((int32)0x80000000)
#define OPDEF (   op,
  val,
  name,
  token,
  length,
  nuses,
  ndefs,
  prec,
  format 
)    op = val,
#define SET_ARGNO (   pc,
  argno 
)    SET_UINT16(pc,argno)
#define SET_INDEX (   pc,
  i 
)    ((pc)[1] = INDEX_HI(i), (pc)[2] = INDEX_LO(i))
#define SET_INT32 (   pc,
  i 
)
Value:
((pc)[1] = (jsbytecode)((uint32)(i) >> 24),   \
                                 (pc)[2] = (jsbytecode)((uint32)(i) >> 16),   \
                                 (pc)[3] = (jsbytecode)((uint32)(i) >> 8),    \
                                 (pc)[4] = (jsbytecode)(uint32)(i))
#define SET_JUMP_OFFSET (   pc,
  off 
)
Value:
((pc)[1] = JUMP_OFFSET_HI(off),               \
                                 (pc)[2] = JUMP_OFFSET_LO(off))
#define SET_JUMPX_OFFSET (   pc,
  off 
)
Value:
((pc)[1] = JUMPX_OFFSET_B3(off),              \
                                 (pc)[2] = JUMPX_OFFSET_B2(off),              \
                                 (pc)[3] = JUMPX_OFFSET_B1(off),              \
                                 (pc)[4] = JUMPX_OFFSET_B0(off))
#define SET_SLOTNO (   pc,
  varno 
)    SET_UINT16(pc,varno)
#define SET_SPANDEP_INDEX (   pc,
  i 
)
Value:
((pc)[1] = JUMP_OFFSET_HI(i),                 \
                                 (pc)[2] = JUMP_OFFSET_LO(i))
#define SET_UINT16 (   pc,
  i 
)    ((pc)[1] = UINT16_HI(i), (pc)[2] = UINT16_LO(i))
#define SET_UINT24 (   pc,
  i 
)
Value:
((pc)[1] = UINT24_HI(i),                      \
                                 (pc)[2] = UINT24_MID(i),                     \
                                 (pc)[3] = UINT24_LO(i))
#define SLOTNO_LEN   2
#define SLOTNO_LIMIT   UINT16_LIMIT
#define SPANDEP_INDEX_HUGE   ((uint16)0xffff)
#define SPANDEP_INDEX_MAX   ((uint16)0xfffe)
#define UINT16_HI (   i  )     ((jsbytecode)((i) >> 8))
#define UINT16_LEN   2
#define UINT16_LIMIT   ((uintN)1 << 16)
#define UINT16_LO (   i  )     ((jsbytecode)(i))
#define UINT24_HI (   i  )     ((jsbytecode)((i) >> 16))
#define UINT24_LO (   i  )     ((jsbytecode)(i))
#define UINT24_MID (   i  )     ((jsbytecode)((i) >> 8))

Typedef Documentation

typedef enum JSOp JSOp

Enumeration Type Documentation

enum JSOp

Function Documentation

JSBool js_DecompileFunction ( JSPrinter jp  ) 
JSBool js_DecompileFunctionBody ( JSPrinter jp  ) 
JSBool js_DecompileScript ( JSPrinter jp,
JSScript script 
)
JSString* js_DecompileToString ( JSContext cx,
const char *  name,
JSFunction fun,
uintN  indent,
JSBool  pretty,
JSBool  grouped,
JSBool  strict,
JSDecompilerPtr  decompiler 
)
char* js_DecompileValueGenerator ( JSContext cx,
intN  spindex,
jsval  v,
JSString fallback 
)
void js_DestroyPrinter ( JSPrinter jp  ) 
uintN js_GetEnterBlockStackDefs ( JSContext cx,
JSScript script,
jsbytecode pc 
)
uintN js_GetIndexFromBytecode ( JSContext cx,
JSScript script,
jsbytecode pc,
ptrdiff_t  pcoff 
)
JSString* js_GetPrinterOutput ( JSPrinter jp  ) 
uintN js_GetVariableBytecodeLength ( jsbytecode pc  ) 
uintN js_GetVariableStackUses ( JSOp  op,
jsbytecode pc 
)
JSPrinter* js_NewPrinter ( JSContext cx,
const char *  name,
JSFunction fun,
uintN  indent,
JSBool  pretty,
JSBool  grouped,
JSBool  strict 
)
int js_printf ( JSPrinter jp,
const char *  format,
  ... 
)
JSBool js_puts ( JSPrinter jp,
const char *  s 
)
JSString* js_QuoteString ( JSContext cx,
JSString str,
jschar  quote 
)
uintN js_ReconstructStackDepth ( JSContext cx,
JSScript script,
jsbytecode pc 
)

Variable Documentation

const char* js_CodeName[]
const char js_EscapeMap[]