/[jscoverage]/trunk/js/jsinterp.h
ViewVC logotype

Contents of /trunk/js/jsinterp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 332 - (show annotations)
Thu Oct 23 19:03:33 2008 UTC (11 years ago) by siliconforks
File MIME type: text/plain
File size: 23926 byte(s)
Add SpiderMonkey from Firefox 3.1b1.

The following directories and files were removed:
correct/, correct.js
liveconnect/
nanojit/
t/
v8/
vprof/
xpconnect/
all JavaScript files (Y.js, call.js, if.js, math-partial-sums.js, md5.js, perfect.js, trace-test.js, trace.js)


1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sw=4 et tw=78:
3 *
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is Mozilla Communicator client code, released
18 * March 31, 1998.
19 *
20 * The Initial Developer of the Original Code is
21 * Netscape Communications Corporation.
22 * Portions created by the Initial Developer are Copyright (C) 1998
23 * the Initial Developer. All Rights Reserved.
24 *
25 * Contributor(s):
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41 #ifndef jsinterp_h___
42 #define jsinterp_h___
43 /*
44 * JS interpreter interface.
45 */
46 #include "jsprvtd.h"
47 #include "jspubtd.h"
48 #include "jsfun.h"
49 #include "jsopcode.h"
50 #include "jsscript.h"
51
52 JS_BEGIN_EXTERN_C
53
54 typedef struct JSFrameRegs {
55 jsbytecode *pc; /* program counter */
56 jsval *sp; /* stack pointer */
57 } JSFrameRegs;
58
59 /*
60 * JS stack frame, may be allocated on the C stack by native callers. Always
61 * allocated on cx->stackPool for calls from the interpreter to an interpreted
62 * function.
63 *
64 * NB: This struct is manually initialized in jsinterp.c and jsiter.c. If you
65 * add new members, update both files. But first, try to remove members. The
66 * sharp* and xml* members should be moved onto the stack as local variables
67 * with well-known slots, if possible.
68 */
69 struct JSStackFrame {
70 JSFrameRegs *regs;
71 jsval *slots; /* variables, locals and operand stack */
72 JSObject *callobj; /* lazily created Call object */
73 JSObject *argsobj; /* lazily created arguments object */
74 JSObject *varobj; /* variables object, where vars go */
75 JSObject *callee; /* function or script object */
76 JSScript *script; /* script being interpreted */
77 JSFunction *fun; /* function being called or null */
78 JSObject *thisp; /* "this" pointer if in method */
79 uintN argc; /* actual argument count */
80 jsval *argv; /* base of argument stack slots */
81 jsval rval; /* function return value */
82 JSStackFrame *down; /* previous frame */
83 void *annotation; /* used by Java security */
84 JSObject *scopeChain; /* scope chain */
85 uintN sharpDepth; /* array/object initializer depth */
86 JSObject *sharpArray; /* scope for #n= initializer vars */
87 uint32 flags; /* frame flags -- see below */
88 JSStackFrame *dormantNext; /* next dormant frame chain */
89 JSObject *xmlNamespace; /* null or default xml namespace in E4X */
90 JSObject *blockChain; /* active compile-time block scopes */
91 JSStackFrame *displaySave; /* previous value of display entry for
92 script->staticDepth */
93 #ifdef DEBUG
94 jsrefcount pcDisabledSave; /* for balanced property cache control */
95 #endif
96 };
97
98 static JS_INLINE jsval *
99 StackBase(JSStackFrame *fp)
100 {
101 return fp->slots + fp->script->nfixed;
102 }
103
104 static JS_INLINE uintN
105 GlobalVarCount(JSStackFrame *fp)
106 {
107 uintN n;
108
109 JS_ASSERT(!fp->fun);
110 n = fp->script->nfixed;
111 if (fp->script->regexpsOffset != 0)
112 n -= JS_SCRIPT_REGEXPS(fp->script)->length;
113 return n;
114 }
115
116 typedef struct JSInlineFrame {
117 JSStackFrame frame; /* base struct */
118 JSFrameRegs callerRegs; /* parent's frame registers */
119 void *mark; /* mark before inline frame */
120 void *hookData; /* debugger call hook data */
121 JSVersion callerVersion; /* dynamic version of calling script */
122 } JSInlineFrame;
123
124 /* JS stack frame flags. */
125 #define JSFRAME_CONSTRUCTING 0x01 /* frame is for a constructor invocation */
126 #define JSFRAME_COMPUTED_THIS 0x02 /* frame.thisp was computed already */
127 #define JSFRAME_ASSIGNING 0x04 /* a complex (not simplex JOF_ASSIGNING) op
128 is currently assigning to a property */
129 #define JSFRAME_DEBUGGER 0x08 /* frame for JS_EvaluateInStackFrame */
130 #define JSFRAME_EVAL 0x10 /* frame for obj_eval */
131 #define JSFRAME_ROOTED_ARGV 0x20 /* frame.argv is rooted by the caller */
132 #define JSFRAME_YIELDING 0x40 /* js_Interpret dispatched JSOP_YIELD */
133 #define JSFRAME_ITERATOR 0x80 /* trying to get an iterator for for-in */
134 #define JSFRAME_POP_BLOCKS 0x100 /* scope chain contains blocks to pop */
135 #define JSFRAME_GENERATOR 0x200 /* frame belongs to generator-iterator */
136
137 #define JSFRAME_OVERRIDE_SHIFT 24 /* override bit-set params; see jsfun.c */
138 #define JSFRAME_OVERRIDE_BITS 8
139
140 #define JSFRAME_SPECIAL (JSFRAME_DEBUGGER | JSFRAME_EVAL)
141
142 /*
143 * Property cache with structurally typed capabilities for invalidation, for
144 * polymorphic callsite method/get/set speedups.
145 *
146 * See bug https://bugzilla.mozilla.org/show_bug.cgi?id=365851.
147 */
148 #define PROPERTY_CACHE_LOG2 12
149 #define PROPERTY_CACHE_SIZE JS_BIT(PROPERTY_CACHE_LOG2)
150 #define PROPERTY_CACHE_MASK JS_BITMASK(PROPERTY_CACHE_LOG2)
151
152 /*
153 * Add kshape rather than xor it to avoid collisions between nearby bytecode
154 * that are evolving an object by setting successive properties, incrementing
155 * the object's scope->shape on each set.
156 */
157 #define PROPERTY_CACHE_HASH(pc,kshape) \
158 (((((jsuword)(pc) >> PROPERTY_CACHE_LOG2) ^ (jsuword)(pc)) + (kshape)) & \
159 PROPERTY_CACHE_MASK)
160
161 #define PROPERTY_CACHE_HASH_PC(pc,kshape) \
162 PROPERTY_CACHE_HASH(pc, kshape)
163
164 #define PROPERTY_CACHE_HASH_ATOM(atom,obj,pobj) \
165 PROPERTY_CACHE_HASH((jsuword)(atom) >> 2, OBJ_SHAPE(obj))
166
167 /*
168 * Property cache value capability macros.
169 */
170 #define PCVCAP_PROTOBITS 4
171 #define PCVCAP_PROTOSIZE JS_BIT(PCVCAP_PROTOBITS)
172 #define PCVCAP_PROTOMASK JS_BITMASK(PCVCAP_PROTOBITS)
173
174 #define PCVCAP_SCOPEBITS 4
175 #define PCVCAP_SCOPESIZE JS_BIT(PCVCAP_SCOPEBITS)
176 #define PCVCAP_SCOPEMASK JS_BITMASK(PCVCAP_SCOPEBITS)
177
178 #define PCVCAP_TAGBITS (PCVCAP_PROTOBITS + PCVCAP_SCOPEBITS)
179 #define PCVCAP_TAGMASK JS_BITMASK(PCVCAP_TAGBITS)
180 #define PCVCAP_TAG(t) ((t) & PCVCAP_TAGMASK)
181
182 #define PCVCAP_MAKE(t,s,p) (((t) << PCVCAP_TAGBITS) | \
183 ((s) << PCVCAP_PROTOBITS) | \
184 (p))
185 #define PCVCAP_SHAPE(t) ((t) >> PCVCAP_TAGBITS)
186
187 #define SHAPE_OVERFLOW_BIT JS_BIT(32 - PCVCAP_TAGBITS)
188
189 extern uint32
190 js_GenerateShape(JSContext *cx, JSBool gcLocked);
191
192 struct JSPropCacheEntry {
193 jsbytecode *kpc; /* pc if vcap tag is <= 1, else atom */
194 jsuword kshape; /* key shape if pc, else obj for atom */
195 jsuword vcap; /* value capability, see above */
196 jsuword vword; /* value word, see PCVAL_* below */
197 };
198
199 #if defined DEBUG_brendan || defined DEBUG_brendaneich
200 #define JS_PROPERTY_CACHE_METERING 1
201 #endif
202
203 typedef struct JSPropertyCache {
204 JSPropCacheEntry table[PROPERTY_CACHE_SIZE];
205 JSBool empty;
206 jsrefcount disabled; /* signed for anti-underflow asserts */
207 #ifdef JS_PROPERTY_CACHE_METERING
208 uint32 fills; /* number of cache entry fills */
209 uint32 nofills; /* couldn't fill (e.g. default get) */
210 uint32 rofills; /* set on read-only prop can't fill */
211 uint32 disfills; /* fill attempts on disabled cache */
212 uint32 oddfills; /* fill attempt after setter deleted */
213 uint32 modfills; /* fill that rehashed to a new entry */
214 uint32 brandfills; /* scope brandings to type structural
215 method fills */
216 uint32 noprotos; /* resolve-returned non-proto pobj */
217 uint32 longchains; /* overlong scope and/or proto chain */
218 uint32 recycles; /* cache entries recycled by fills */
219 uint32 pcrecycles; /* pc-keyed entries recycled by atom-
220 keyed fills */
221 uint32 tests; /* cache probes */
222 uint32 pchits; /* fast-path polymorphic op hits */
223 uint32 protopchits; /* pchits hitting immediate prototype */
224 uint32 initests; /* cache probes from JSOP_INITPROP */
225 uint32 inipchits; /* init'ing next property pchit case */
226 uint32 inipcmisses; /* init'ing next property pc misses */
227 uint32 settests; /* cache probes from JOF_SET opcodes */
228 uint32 addpchits; /* adding next property pchit case */
229 uint32 setpchits; /* setting existing property pchit */
230 uint32 setpcmisses; /* setting/adding property pc misses */
231 uint32 slotchanges; /* clasp->reserveSlots result variance-
232 induced slot changes */
233 uint32 setmisses; /* JSOP_SET{NAME,PROP} total misses */
234 uint32 idmisses; /* slow-path key id == atom misses */
235 uint32 komisses; /* slow-path key object misses */
236 uint32 vcmisses; /* value capability misses */
237 uint32 misses; /* cache misses */
238 uint32 flushes; /* cache flushes */
239 uint32 pcpurges; /* shadowing purges on proto chain */
240 # define PCMETER(x) x
241 #else
242 # define PCMETER(x) ((void)0)
243 #endif
244 } JSPropertyCache;
245
246 /*
247 * Property cache value tagging/untagging macros.
248 */
249 #define PCVAL_OBJECT 0
250 #define PCVAL_SLOT 1
251 #define PCVAL_SPROP 2
252
253 #define PCVAL_TAGBITS 2
254 #define PCVAL_TAGMASK JS_BITMASK(PCVAL_TAGBITS)
255 #define PCVAL_TAG(v) ((v) & PCVAL_TAGMASK)
256 #define PCVAL_CLRTAG(v) ((v) & ~(jsuword)PCVAL_TAGMASK)
257 #define PCVAL_SETTAG(v,t) ((jsuword)(v) | (t))
258
259 #define PCVAL_NULL 0
260 #define PCVAL_IS_NULL(v) ((v) == PCVAL_NULL)
261
262 #define PCVAL_IS_OBJECT(v) (PCVAL_TAG(v) == PCVAL_OBJECT)
263 #define PCVAL_TO_OBJECT(v) ((JSObject *) (v))
264 #define OBJECT_TO_PCVAL(obj) ((jsuword) (obj))
265
266 #define PCVAL_OBJECT_TO_JSVAL(v) OBJECT_TO_JSVAL(PCVAL_TO_OBJECT(v))
267 #define JSVAL_OBJECT_TO_PCVAL(v) OBJECT_TO_PCVAL(JSVAL_TO_OBJECT(v))
268
269 #define PCVAL_IS_SLOT(v) ((v) & PCVAL_SLOT)
270 #define PCVAL_TO_SLOT(v) ((jsuint)(v) >> 1)
271 #define SLOT_TO_PCVAL(i) (((jsuword)(i) << 1) | PCVAL_SLOT)
272
273 #define PCVAL_IS_SPROP(v) (PCVAL_TAG(v) == PCVAL_SPROP)
274 #define PCVAL_TO_SPROP(v) ((JSScopeProperty *) PCVAL_CLRTAG(v))
275 #define SPROP_TO_PCVAL(sprop) PCVAL_SETTAG(sprop, PCVAL_SPROP)
276
277 /*
278 * Fill property cache entry for key cx->fp->pc, optimized value word computed
279 * from obj and sprop, and entry capability forged from 24-bit OBJ_SHAPE(obj),
280 * 4-bit scopeIndex, and 4-bit protoIndex.
281 */
282 extern void
283 js_FillPropertyCache(JSContext *cx, JSObject *obj, jsuword kshape,
284 uintN scopeIndex, uintN protoIndex,
285 JSObject *pobj, JSScopeProperty *sprop,
286 JSPropCacheEntry **entryp);
287
288 /*
289 * Property cache lookup macros. PROPERTY_CACHE_TEST is designed to inline the
290 * fast path in js_Interpret, so it makes "just-so" restrictions on parameters,
291 * e.g. pobj and obj should not be the same variable, since for JOF_PROP-mode
292 * opcodes, obj must not be changed because of a cache miss.
293 *
294 * On return from PROPERTY_CACHE_TEST, if atom is null then obj points to the
295 * scope chain element in which the property was found, pobj is locked, and
296 * entry is valid. If atom is non-null then no object is locked but entry is
297 * still set correctly for use, e.g., by js_FillPropertyCache and atom should
298 * be used as the id to find.
299 *
300 * We must lock pobj on a hit in order to close races with threads that might
301 * be deleting a property from its scope, or otherwise invalidating property
302 * caches (on all threads) by re-generating scope->shape.
303 */
304 #define PROPERTY_CACHE_TEST(cx, pc, obj, pobj, entry, atom) \
305 do { \
306 JSPropertyCache *cache_ = &JS_PROPERTY_CACHE(cx); \
307 uint32 kshape_ = (JS_ASSERT(OBJ_IS_NATIVE(obj)), OBJ_SHAPE(obj)); \
308 entry = &cache_->table[PROPERTY_CACHE_HASH_PC(pc, kshape_)]; \
309 PCMETER(cache_->tests++); \
310 JS_ASSERT(&obj != &pobj); \
311 if (entry->kpc == pc && entry->kshape == kshape_) { \
312 JSObject *tmp_; \
313 pobj = obj; \
314 JS_LOCK_OBJ(cx, pobj); \
315 JS_ASSERT(PCVCAP_TAG(entry->vcap) <= 1); \
316 if (PCVCAP_TAG(entry->vcap) == 1 && \
317 (tmp_ = LOCKED_OBJ_GET_PROTO(pobj)) != NULL && \
318 OBJ_IS_NATIVE(tmp_)) { \
319 JS_UNLOCK_OBJ(cx, pobj); \
320 pobj = tmp_; \
321 JS_LOCK_OBJ(cx, pobj); \
322 } \
323 if (PCVCAP_SHAPE(entry->vcap) == OBJ_SHAPE(pobj)) { \
324 PCMETER(cache_->pchits++); \
325 PCMETER(!PCVCAP_TAG(entry->vcap) || cache_->protopchits++); \
326 pobj = OBJ_SCOPE(pobj)->object; \
327 atom = NULL; \
328 break; \
329 } \
330 JS_UNLOCK_OBJ(cx, pobj); \
331 } \
332 atom = js_FullTestPropertyCache(cx, pc, &obj, &pobj, &entry); \
333 if (atom) \
334 PCMETER(cache_->misses++); \
335 } while (0)
336
337 extern JSAtom *
338 js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc,
339 JSObject **objp, JSObject **pobjp,
340 JSPropCacheEntry **entryp);
341
342 extern void
343 js_FlushPropertyCache(JSContext *cx);
344
345 extern void
346 js_FlushPropertyCacheForScript(JSContext *cx, JSScript *script);
347
348 extern void
349 js_DisablePropertyCache(JSContext *cx);
350
351 extern void
352 js_EnablePropertyCache(JSContext *cx);
353
354 /*
355 * Interpreter stack arena-pool alloc and free functions.
356 */
357 extern JS_FRIEND_API(jsval *)
358 js_AllocStack(JSContext *cx, uintN nslots, void **markp);
359
360 extern JS_FRIEND_API(void)
361 js_FreeStack(JSContext *cx, void *mark);
362
363 /*
364 * Refresh and return fp->scopeChain. It may be stale if block scopes are
365 * active but not yet reflected by objects in the scope chain. If a block
366 * scope contains a with, eval, XML filtering predicate, or similar such
367 * dynamically scoped construct, then compile-time block scope at fp->blocks
368 * must reflect at runtime.
369 */
370 extern JSObject *
371 js_GetScopeChain(JSContext *cx, JSStackFrame *fp);
372
373 /*
374 * Given a context and a vector of [callee, this, args...] for a function that
375 * was specified with a JSFUN_THISP_PRIMITIVE flag, get the primitive value of
376 * |this| into *thisvp. In doing so, if |this| is an object, insist it is an
377 * instance of clasp and extract its private slot value to return via *thisvp.
378 *
379 * NB: this function loads and uses *vp before storing *thisvp, so the two may
380 * alias the same jsval.
381 */
382 extern JSBool
383 js_GetPrimitiveThis(JSContext *cx, jsval *vp, JSClass *clasp, jsval *thisvp);
384
385 /*
386 * For a call with arguments argv including argv[-1] (nominal |this|) and
387 * argv[-2] (callee) replace null |this| with callee's parent, replace
388 * primitive values with the equivalent wrapper objects and censor activation
389 * objects as, per ECMA-262, they may not be referred to by |this|. argv[-1]
390 * must not be a JSVAL_VOID.
391 */
392 extern JSObject *
393 js_ComputeThis(JSContext *cx, JSBool lazy, jsval *argv);
394
395 extern const uint16 js_PrimitiveTestFlags[];
396
397 #define PRIMITIVE_THIS_TEST(fun,thisv) \
398 (JS_ASSERT(!JSVAL_IS_VOID(thisv)), \
399 JSFUN_THISP_TEST(JSFUN_THISP_FLAGS((fun)->flags), \
400 js_PrimitiveTestFlags[JSVAL_TAG(thisv) - 1]))
401
402 /*
403 * NB: js_Invoke requires that cx is currently running JS (i.e., that cx->fp
404 * is non-null), and that vp points to the callee, |this| parameter, and
405 * actual arguments of the call. [vp .. vp + 2 + argc) must belong to the last
406 * JS stack segment that js_AllocStack allocated. The function may use the
407 * space available after vp + 2 + argc in the stack segment for temporaries,
408 * so the caller should not use that space for values that must be preserved
409 * across the call.
410 */
411 extern JS_FRIEND_API(JSBool)
412 js_Invoke(JSContext *cx, uintN argc, jsval *vp, uintN flags);
413
414 /*
415 * Consolidated js_Invoke flags simply rename certain JSFRAME_* flags, so that
416 * we can share bits stored in JSStackFrame.flags and passed to:
417 *
418 * js_Invoke
419 * js_InternalInvoke
420 * js_ValueToFunction
421 * js_ValueToFunctionObject
422 * js_ValueToCallableObject
423 * js_ReportIsNotFunction
424 *
425 * See jsfun.h for the latter four and flag renaming macros.
426 */
427 #define JSINVOKE_CONSTRUCT JSFRAME_CONSTRUCTING
428 #define JSINVOKE_ITERATOR JSFRAME_ITERATOR
429
430 /*
431 * Mask to isolate construct and iterator flags for use with jsfun.h functions.
432 */
433 #define JSINVOKE_FUNFLAGS (JSINVOKE_CONSTRUCT | JSINVOKE_ITERATOR)
434
435 /*
436 * "Internal" calls may come from C or C++ code using a JSContext on which no
437 * JS is running (!cx->fp), so they may need to push a dummy JSStackFrame.
438 */
439 #define js_InternalCall(cx,obj,fval,argc,argv,rval) \
440 js_InternalInvoke(cx, obj, fval, 0, argc, argv, rval)
441
442 #define js_InternalConstruct(cx,obj,fval,argc,argv,rval) \
443 js_InternalInvoke(cx, obj, fval, JSINVOKE_CONSTRUCT, argc, argv, rval)
444
445 extern JSBool
446 js_InternalInvoke(JSContext *cx, JSObject *obj, jsval fval, uintN flags,
447 uintN argc, jsval *argv, jsval *rval);
448
449 extern JSBool
450 js_InternalGetOrSet(JSContext *cx, JSObject *obj, jsid id, jsval fval,
451 JSAccessMode mode, uintN argc, jsval *argv, jsval *rval);
452
453 extern JSBool
454 js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
455 JSStackFrame *down, uintN flags, jsval *result);
456
457 extern JSBool
458 js_InvokeConstructor(JSContext *cx, uintN argc, JSBool clampReturn, jsval *vp);
459
460 extern JSBool
461 js_Interpret(JSContext *cx);
462
463 #define JSPROP_INITIALIZER 0x100 /* NB: Not a valid property attribute. */
464
465 extern JSBool
466 js_CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs,
467 JSObject **objp, JSProperty **propp);
468
469 extern JSBool
470 js_StrictlyEqual(JSContext *cx, jsval lval, jsval rval);
471
472 /*
473 * JS_LONE_INTERPRET indicates that the compiler should see just the code for
474 * the js_Interpret function when compiling jsinterp.cpp. The rest of the code
475 * from the file should be visible only when compiling jsinvoke.cpp. It allows
476 * platform builds to optimize selectively js_Interpret when the granularity
477 * of the optimizations with the given compiler is a compilation unit.
478 *
479 * JS_STATIC_INTERPRET is the modifier for functions defined in jsinterp.cpp
480 * that only js_Interpret calls. When JS_LONE_INTERPRET is true all such
481 * functions are declared below.
482 */
483 #ifndef JS_LONE_INTERPRET
484 # ifdef _MSC_VER
485 # define JS_LONE_INTERPRET 0
486 # else
487 # define JS_LONE_INTERPRET 1
488 # endif
489 #endif
490
491 #if !JS_LONE_INTERPRET
492 # define JS_STATIC_INTERPRET static
493 #else
494 # define JS_STATIC_INTERPRET
495
496 extern jsval *
497 js_AllocRawStack(JSContext *cx, uintN nslots, void **markp);
498
499 extern void
500 js_FreeRawStack(JSContext *cx, void *mark);
501
502 /*
503 * ECMA requires "the global object", but in embeddings such as the browser,
504 * which have multiple top-level objects (windows, frames, etc. in the DOM),
505 * we prefer fun's parent. An example that causes this code to run:
506 *
507 * // in window w1
508 * function f() { return this }
509 * function g() { return f }
510 *
511 * // in window w2
512 * var h = w1.g()
513 * alert(h() == w1)
514 *
515 * The alert should display "true".
516 */
517 extern JSObject *
518 js_ComputeGlobalThis(JSContext *cx, JSBool lazy, jsval *argv);
519
520 extern JSBool
521 js_EnterWith(JSContext *cx, jsint stackIndex);
522
523 extern void
524 js_LeaveWith(JSContext *cx);
525
526 extern JSClass *
527 js_IsActiveWithOrBlock(JSContext *cx, JSObject *obj, int stackDepth);
528
529 extern jsint
530 js_CountWithBlocks(JSContext *cx, JSStackFrame *fp);
531
532 /*
533 * Unwind block and scope chains to match the given depth. The function sets
534 * fp->sp on return to stackDepth.
535 */
536 extern JSBool
537 js_UnwindScope(JSContext *cx, JSStackFrame *fp, jsint stackDepth,
538 JSBool normalUnwind);
539
540 extern JSBool
541 js_InternNonIntElementId(JSContext *cx, JSObject *obj, jsval idval, jsid *idp);
542
543 extern JSBool
544 js_OnUnknownMethod(JSContext *cx, jsval *vp);
545
546 /*
547 * Find the results of incrementing or decrementing *vp. For pre-increments,
548 * both *vp and *vp2 will contain the result on return. For post-increments,
549 * vp will contain the original value converted to a number and vp2 will get
550 * the result. Both vp and vp2 must be roots.
551 */
552 extern JSBool
553 js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, jsval *vp, jsval *vp2);
554
555 /*
556 * Opcode tracing helper. When len is not 0, cx->fp->regs->pc[-len] gives the
557 * previous opcode.
558 */
559 extern void
560 js_TraceOpcode(JSContext *cx, jsint len);
561
562 /*
563 * JS_OPMETER helper functions.
564 */
565 extern void
566 js_MeterOpcodePair(JSOp op1, JSOp op2);
567
568 extern void
569 js_MeterSlotOpcode(JSOp op, uint32 slot);
570
571 #endif /* JS_LONE_INTERPRET */
572
573 JS_END_EXTERN_C
574
575 #endif /* jsinterp_h___ */

  ViewVC Help
Powered by ViewVC 1.1.24