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

Annotation of /trunk/js/jsobj.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 507 - (hide annotations)
Sun Jan 10 07:23:34 2010 UTC (9 years, 6 months ago) by siliconforks
File MIME type: text/plain
File size: 40263 byte(s)
Update SpiderMonkey from Firefox 3.6rc1.

1 siliconforks 332 /* -*- 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 jsobj_h___
42     #define jsobj_h___
43     /*
44     * JS object definitions.
45     *
46     * A JS object consists of a possibly-shared object descriptor containing
47     * ordered property names, called the map; and a dense vector of property
48     * values, called slots. The map/slot pointer pair is GC'ed, while the map
49     * is reference counted and the slot vector is malloc'ed.
50     */
51     #include "jshash.h" /* Added by JSIFY */
52     #include "jsprvtd.h"
53     #include "jspubtd.h"
54    
55     JS_BEGIN_EXTERN_C
56    
57 siliconforks 460 /* For detailed comments on these function pointer types, see jsprvtd.h. */
58     struct JSObjectOps {
59     /*
60     * Custom shared object map for non-native objects. For native objects
61     * this should be null indicating, that JSObject.map is an instance of
62     * JSScope.
63     */
64     const JSObjectMap *objectMap;
65    
66     /* Mandatory non-null function pointer members. */
67     JSLookupPropOp lookupProperty;
68     JSDefinePropOp defineProperty;
69     JSPropertyIdOp getProperty;
70     JSPropertyIdOp setProperty;
71     JSAttributesOp getAttributes;
72     JSAttributesOp setAttributes;
73     JSPropertyIdOp deleteProperty;
74     JSConvertOp defaultValue;
75     JSNewEnumerateOp enumerate;
76     JSCheckAccessIdOp checkAccess;
77    
78     /* Optionally non-null members start here. */
79     JSObjectOp thisObject;
80     JSPropertyRefOp dropProperty;
81     JSNative call;
82     JSNative construct;
83     JSHasInstanceOp hasInstance;
84     JSTraceOp trace;
85     JSFinalizeOp clear;
86     };
87    
88 siliconforks 332 struct JSObjectMap {
89 siliconforks 507 const JSObjectOps * const ops; /* high level object operation vtable */
90     uint32 shape; /* shape identifier */
91    
92     #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
93    
94     explicit JSObjectMap(const JSObjectOps *ops, uint32 shape) : ops(ops), shape(shape) {}
95     enum { SHAPELESS = 0xffffffff };
96    
97     #endif
98    
99 siliconforks 332 };
100    
101 siliconforks 507 #ifndef __cplusplus /* Allow inclusion from LiveConnect C files. */
102    
103 siliconforks 332 #define OBJ_LOOKUP_PROPERTY(cx,obj,id,objp,propp) \
104     (obj)->map->ops->lookupProperty(cx,obj,id,objp,propp)
105    
106     #define OBJ_DROP_PROPERTY(cx,obj,prop) \
107     ((obj)->map->ops->dropProperty \
108     ? (obj)->map->ops->dropProperty(cx,obj,prop) \
109     : (void)0)
110    
111 siliconforks 507 #define OBJ_GET_ATTRIBUTES(cx,obj,id,prop,attrsp) \
112     (obj)->map->ops->getAttributes(cx,obj,id,prop,attrsp)
113 siliconforks 332
114 siliconforks 507 #endif /* __cplusplus */
115 siliconforks 332
116 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
117     const uint32 JS_INITIAL_NSLOTS = 5;
118 siliconforks 332
119 siliconforks 507 const uint32 JSSLOT_PROTO = 0;
120     const uint32 JSSLOT_PARENT = 1;
121    
122 siliconforks 332 /*
123 siliconforks 507 * The first available slot to store generic value. For JSCLASS_HAS_PRIVATE
124     * classes the slot stores a pointer to private data reinterpreted as jsval.
125     * Such pointer is stored as is without an overhead of PRIVATE_TO_JSVAL
126     * tagging and should be accessed using the (get|set)Private methods of
127     * JSObject.
128     */
129     const uint32 JSSLOT_PRIVATE = 2;
130    
131     const uint32 JSSLOT_PRIMITIVE_THIS = JSSLOT_PRIVATE;
132    
133     const uintptr_t JSSLOT_CLASS_MASK_BITS = 3;
134     #else /* __cplusplus */
135     #define JS_INITIAL_NSLOTS 5
136    
137     #define JSSLOT_PROTO 0
138     #define JSSLOT_PARENT 1
139     #define JSSLOT_PRIVATE 2
140    
141     #define JSSLOT_CLASS_MASK_BITS 3
142     #endif /* __cplusplus */
143    
144     /*
145 siliconforks 460 * JSObject struct, with members sized to fit in 32 bytes on 32-bit targets,
146     * 64 bytes on 64-bit systems. The JSFunction struct is an extension of this
147     * struct allocated from a larger GC size-class.
148     *
149     * The classword member stores the JSClass pointer for this object, with the
150     * least two bits encoding whether this object is a "delegate" or a "system"
151 siliconforks 507 * object. We do *not* synchronize updates of classword -- API clients must
152     * take care.
153 siliconforks 460 *
154     * An object is a delegate if it is on another object's prototype (linked by
155     * JSSLOT_PROTO) or scope (JSSLOT_PARENT) chain, and therefore the delegate
156     * might be asked implicitly to get or set a property on behalf of another
157     * object. Delegates may be accessed directly too, as may any object, but only
158     * those objects linked after the head of any prototype or scope chain are
159     * flagged as delegates. This definition helps to optimize shape-based property
160     * cache invalidation (see Purge{Scope,Proto}Chain in jsobj.cpp).
161     *
162     * The meaning of the system object bit is defined by the API client. It is
163     * set in JS_NewSystemObject and is queried by JS_IsSystemObject (jsdbgapi.h),
164     * but it has no intrinsic meaning to SpiderMonkey. Further, JSFILENAME_SYSTEM
165     * and JS_FlagScriptFilenamePrefix (also exported via jsdbgapi.h) are intended
166     * to be complementary to this bit, but it is up to the API client to implement
167     * any such association.
168     *
169     * Both these classword tag bits are initially zero; they may be set or queried
170 siliconforks 507 * using the (is|set)(Delegate|System) inline methods.
171 siliconforks 460 *
172     * The dslots member is null or a pointer into a dynamically allocated vector
173     * of jsvals for reserved and dynamic slots. If dslots is not null, dslots[-1]
174     * records the number of available slots.
175 siliconforks 332 */
176     struct JSObject {
177 siliconforks 507 JSObjectMap *map; /* property map, see jsscope.h */
178     jsuword classword; /* JSClass ptr | bits, see above */
179 siliconforks 460 jsval fslots[JS_INITIAL_NSLOTS]; /* small number of fixed slots */
180     jsval *dslots; /* dynamically allocated slots */
181 siliconforks 507
182     #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
183    
184     JSClass *getClass() const {
185     return (JSClass *) (classword & ~JSSLOT_CLASS_MASK_BITS);
186     }
187    
188     bool isDelegate() const {
189     return (classword & jsuword(1)) != jsuword(0);
190     }
191    
192     void setDelegate() {
193     classword |= jsuword(1);
194     }
195    
196     static void setDelegateNullSafe(JSObject *obj) {
197     if (obj)
198     obj->setDelegate();
199     }
200    
201     bool isSystem() const {
202     return (classword & jsuword(2)) != jsuword(0);
203     }
204    
205     void setSystem() {
206     classword |= jsuword(2);
207     }
208    
209     JSObject *getProto() const {
210     return JSVAL_TO_OBJECT(fslots[JSSLOT_PROTO]);
211     }
212    
213     void clearProto() {
214     fslots[JSSLOT_PROTO] = JSVAL_NULL;
215     }
216    
217     void setProto(JSObject *newProto) {
218     setDelegateNullSafe(newProto);
219     fslots[JSSLOT_PROTO] = OBJECT_TO_JSVAL(newProto);
220     }
221    
222     JSObject *getParent() const {
223     return JSVAL_TO_OBJECT(fslots[JSSLOT_PARENT]);
224     }
225    
226     void clearParent() {
227     fslots[JSSLOT_PARENT] = JSVAL_NULL;
228     }
229    
230     void setParent(JSObject *newParent) {
231     setDelegateNullSafe(newParent);
232     fslots[JSSLOT_PARENT] = OBJECT_TO_JSVAL(newParent);
233     }
234    
235     void traceProtoAndParent(JSTracer *trc) const {
236     JSObject *proto = getProto();
237     if (proto)
238     JS_CALL_OBJECT_TRACER(trc, proto, "__proto__");
239    
240     JSObject *parent = getParent();
241     if (parent)
242     JS_CALL_OBJECT_TRACER(trc, parent, "__parent__");
243     }
244    
245     void *getPrivate() const {
246     JS_ASSERT(getClass()->flags & JSCLASS_HAS_PRIVATE);
247     jsval v = fslots[JSSLOT_PRIVATE];
248     JS_ASSERT((v & jsval(1)) == jsval(0));
249     return reinterpret_cast<void *>(v);
250     }
251    
252     void setPrivate(void *data) {
253     JS_ASSERT(getClass()->flags & JSCLASS_HAS_PRIVATE);
254     jsval v = reinterpret_cast<jsval>(data);
255     JS_ASSERT((v & jsval(1)) == jsval(0));
256     fslots[JSSLOT_PRIVATE] = v;
257     }
258    
259     static jsval defaultPrivate(JSClass *clasp) {
260     return (clasp->flags & JSCLASS_HAS_PRIVATE)
261     ? JSVAL_NULL
262     : JSVAL_VOID;
263     }
264    
265     /* The map field is not initialized here and should be set separately. */
266     void init(JSClass *clasp, JSObject *proto, JSObject *parent,
267     jsval privateSlotValue) {
268     JS_ASSERT(((jsuword) clasp & 3) == 0);
269     JS_STATIC_ASSERT(JSSLOT_PRIVATE + 3 == JS_INITIAL_NSLOTS);
270     JS_ASSERT_IF(clasp->flags & JSCLASS_HAS_PRIVATE,
271     (privateSlotValue & jsval(1)) == jsval(0));
272    
273     classword = jsuword(clasp);
274     JS_ASSERT(!isDelegate());
275     JS_ASSERT(!isSystem());
276    
277     setProto(proto);
278     setParent(parent);
279     fslots[JSSLOT_PRIVATE] = privateSlotValue;
280     fslots[JSSLOT_PRIVATE + 1] = JSVAL_VOID;
281     fslots[JSSLOT_PRIVATE + 2] = JSVAL_VOID;
282     dslots = NULL;
283     }
284    
285     /*
286     * Like init, but also initializes map. The catch: proto must be the result
287     * of a call to js_InitClass(...clasp, ...).
288     */
289     inline void initSharingEmptyScope(JSClass *clasp, JSObject *proto, JSObject *parent,
290     jsval privateSlotValue);
291    
292     JSBool lookupProperty(JSContext *cx, jsid id,
293     JSObject **objp, JSProperty **propp) {
294     return map->ops->lookupProperty(cx, this, id, objp, propp);
295     }
296    
297     JSBool defineProperty(JSContext *cx, jsid id, jsval value,
298     JSPropertyOp getter = JS_PropertyStub,
299     JSPropertyOp setter = JS_PropertyStub,
300     uintN attrs = JSPROP_ENUMERATE) {
301     return map->ops->defineProperty(cx, this, id, value, getter, setter, attrs);
302     }
303    
304     JSBool getProperty(JSContext *cx, jsid id, jsval *vp) {
305     return map->ops->getProperty(cx, this, id, vp);
306     }
307    
308     JSBool setProperty(JSContext *cx, jsid id, jsval *vp) {
309     return map->ops->setProperty(cx, this, id, vp);
310     }
311    
312     JSBool getAttributes(JSContext *cx, jsid id, JSProperty *prop,
313     uintN *attrsp) {
314     return map->ops->getAttributes(cx, this, id, prop, attrsp);
315     }
316    
317     JSBool setAttributes(JSContext *cx, jsid id, JSProperty *prop,
318     uintN *attrsp) {
319     return map->ops->setAttributes(cx, this, id, prop, attrsp);
320     }
321    
322     JSBool deleteProperty(JSContext *cx, jsid id, jsval *rval) {
323     return map->ops->deleteProperty(cx, this, id, rval);
324     }
325    
326     JSBool defaultValue(JSContext *cx, JSType hint, jsval *vp) {
327     return map->ops->defaultValue(cx, this, hint, vp);
328     }
329    
330     JSBool enumerate(JSContext *cx, JSIterateOp op, jsval *statep,
331     jsid *idp) {
332     return map->ops->enumerate(cx, this, op, statep, idp);
333     }
334    
335     JSBool checkAccess(JSContext *cx, jsid id, JSAccessMode mode, jsval *vp,
336     uintN *attrsp) {
337     return map->ops->checkAccess(cx, this, id, mode, vp, attrsp);
338     }
339    
340     /* These four are time-optimized to avoid stub calls. */
341     JSObject *thisObject(JSContext *cx) {
342     return map->ops->thisObject ? map->ops->thisObject(cx, this) : this;
343     }
344    
345     void dropProperty(JSContext *cx, JSProperty *prop) {
346     if (map->ops->dropProperty)
347     map->ops->dropProperty(cx, this, prop);
348     }
349    
350     #endif /* __cplusplus */
351 siliconforks 332 };
352    
353 siliconforks 507 /* Compatibility macros. */
354     #define STOBJ_GET_PROTO(obj) ((obj)->getProto())
355     #define STOBJ_SET_PROTO(obj,proto) ((obj)->setProto(proto))
356     #define STOBJ_CLEAR_PROTO(obj) ((obj)->clearProto())
357    
358     #define STOBJ_GET_PARENT(obj) ((obj)->getParent())
359     #define STOBJ_SET_PARENT(obj,parent) ((obj)->setParent(parent))
360     #define STOBJ_CLEAR_PARENT(obj) ((obj)->clearParent())
361    
362     #define OBJ_GET_PROTO(cx,obj) STOBJ_GET_PROTO(obj)
363     #define OBJ_SET_PROTO(cx,obj,proto) STOBJ_SET_PROTO(obj, proto)
364     #define OBJ_CLEAR_PROTO(cx,obj) STOBJ_CLEAR_PROTO(obj)
365    
366     #define OBJ_GET_PARENT(cx,obj) STOBJ_GET_PARENT(obj)
367     #define OBJ_SET_PARENT(cx,obj,parent) STOBJ_SET_PARENT(obj, parent)
368     #define OBJ_CLEAR_PARENT(cx,obj) STOBJ_CLEAR_PARENT(obj)
369    
370 siliconforks 332 #define JSSLOT_START(clasp) (((clasp)->flags & JSCLASS_HAS_PRIVATE) \
371     ? JSSLOT_PRIVATE + 1 \
372 siliconforks 507 : JSSLOT_PRIVATE)
373 siliconforks 332
374     #define JSSLOT_FREE(clasp) (JSSLOT_START(clasp) \
375     + JSCLASS_RESERVED_SLOTS(clasp))
376    
377     /*
378 siliconforks 507 * Maximum capacity of the obj->dslots vector, net of the hidden slot at
379     * obj->dslots[-1] that is used to store the length of the vector biased by
380     * JS_INITIAL_NSLOTS (and again net of the slot at index -1).
381 siliconforks 460 */
382 siliconforks 507 #define MAX_DSLOTS_LENGTH (JS_MAX(~uint32(0), ~size_t(0)) / sizeof(jsval) - 1)
383     #define MAX_DSLOTS_LENGTH32 (~uint32(0) / sizeof(jsval) - 1)
384 siliconforks 460
385     /*
386 siliconforks 332 * STOBJ prefix means Single Threaded Object. Use the following fast macros to
387 siliconforks 460 * directly manipulate slots in obj when only one thread can access obj, or
388     * when accessing read-only slots within JS_INITIAL_NSLOTS.
389 siliconforks 332 */
390    
391     #define STOBJ_NSLOTS(obj) \
392     ((obj)->dslots ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS)
393    
394     #define STOBJ_GET_SLOT(obj,slot) \
395     ((slot) < JS_INITIAL_NSLOTS \
396     ? (obj)->fslots[(slot)] \
397     : (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
398     (obj)->dslots[(slot) - JS_INITIAL_NSLOTS]))
399    
400     #define STOBJ_SET_SLOT(obj,slot,value) \
401     ((slot) < JS_INITIAL_NSLOTS \
402     ? (obj)->fslots[(slot)] = (value) \
403     : (JS_ASSERT((slot) < (uint32)(obj)->dslots[-1]), \
404     (obj)->dslots[(slot) - JS_INITIAL_NSLOTS] = (value)))
405    
406 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
407     inline JSClass*
408     STOBJ_GET_CLASS(const JSObject* obj)
409     {
410     return obj->getClass();
411     }
412     #else
413 siliconforks 460 static JS_ALWAYS_INLINE JSClass*
414     STOBJ_GET_CLASS(const JSObject* obj)
415     {
416     return (JSClass *) (obj->classword & ~JSSLOT_CLASS_MASK_BITS);
417     }
418 siliconforks 507 #endif
419 siliconforks 460
420 siliconforks 332 #define OBJ_CHECK_SLOT(obj,slot) \
421 siliconforks 507 (JS_ASSERT(OBJ_IS_NATIVE(obj)), JS_ASSERT(slot < OBJ_SCOPE(obj)->freeslot))
422 siliconforks 332
423     #define LOCKED_OBJ_GET_SLOT(obj,slot) \
424     (OBJ_CHECK_SLOT(obj, slot), STOBJ_GET_SLOT(obj, slot))
425     #define LOCKED_OBJ_SET_SLOT(obj,slot,value) \
426     (OBJ_CHECK_SLOT(obj, slot), STOBJ_SET_SLOT(obj, slot, value))
427    
428     /*
429     * NB: Don't call LOCKED_OBJ_SET_SLOT or STOBJ_SET_SLOT for a write to a slot
430     * that may contain a function reference already, or where the new value is a
431     * function ref, and the object's scope may be branded with a property cache
432     * structural type capability that distinguishes versions of the object with
433 siliconforks 507 * and without the function property. Instead use LOCKED_OBJ_WRITE_SLOT or a
434     * fast inline equivalent (JSOP_SETNAME/JSOP_SETPROP cases in jsinterp.cpp).
435 siliconforks 332 */
436 siliconforks 507 #define LOCKED_OBJ_WRITE_SLOT(cx,obj,slot,newval) \
437     JS_BEGIN_MACRO \
438     LOCKED_OBJ_WRITE_BARRIER(cx, obj, slot, newval); \
439     LOCKED_OBJ_SET_SLOT(obj, slot, newval); \
440     JS_END_MACRO
441    
442     /*
443     * Write barrier macro monitoring property update for slot in obj from its old
444     * value to newval.
445     *
446     * NB: obj must be locked, and remains locked after the calls to this macro.
447     */
448 siliconforks 332 #define LOCKED_OBJ_WRITE_BARRIER(cx,obj,slot,newval) \
449     JS_BEGIN_MACRO \
450     JSScope *scope_ = OBJ_SCOPE(obj); \
451 siliconforks 507 JS_ASSERT(scope_->object == obj); \
452     if (scope_->branded()) { \
453     jsval oldval_ = LOCKED_OBJ_GET_SLOT(obj, slot); \
454     if (oldval_ != (newval) && \
455     (VALUE_IS_FUNCTION(cx, oldval_) || \
456     VALUE_IS_FUNCTION(cx, newval))) { \
457     scope_->methodShapeChange(cx, slot, newval); \
458     } \
459     } \
460     GC_POKE(cx, oldval); \
461 siliconforks 332 JS_END_MACRO
462    
463     #ifdef JS_THREADSAFE
464    
465     /* Thread-safe functions and wrapper macros for accessing slots in obj. */
466     #define OBJ_GET_SLOT(cx,obj,slot) \
467     (OBJ_CHECK_SLOT(obj, slot), \
468 siliconforks 507 (OBJ_SCOPE(obj)->title.ownercx == cx) \
469 siliconforks 332 ? LOCKED_OBJ_GET_SLOT(obj, slot) \
470     : js_GetSlotThreadSafe(cx, obj, slot))
471    
472     #define OBJ_SET_SLOT(cx,obj,slot,value) \
473     JS_BEGIN_MACRO \
474     OBJ_CHECK_SLOT(obj, slot); \
475 siliconforks 507 if (OBJ_SCOPE(obj)->title.ownercx == cx) \
476     LOCKED_OBJ_WRITE_SLOT(cx, obj, slot, value); \
477 siliconforks 332 else \
478     js_SetSlotThreadSafe(cx, obj, slot, value); \
479     JS_END_MACRO
480    
481     /*
482     * If thread-safe, define an OBJ_GET_SLOT wrapper that bypasses, for a native
483     * object, the lock-free "fast path" test of (OBJ_SCOPE(obj)->ownercx == cx),
484     * to avoid needlessly switching from lock-free to lock-full scope when doing
485     * GC on a different context from the last one to own the scope. The caller
486     * in this case is probably a JSClass.mark function, e.g., fun_mark, or maybe
487     * a finalizer.
488     *
489     * The GC runs only when all threads except the one on which the GC is active
490     * are suspended at GC-safe points, so calling STOBJ_GET_SLOT from the GC's
491     * thread is safe when rt->gcRunning is set. See jsgc.c for details.
492     */
493     #define THREAD_IS_RUNNING_GC(rt, thread) \
494     ((rt)->gcRunning && (rt)->gcThread == (thread))
495    
496     #define CX_THREAD_IS_RUNNING_GC(cx) \
497     THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread)
498    
499     #else /* !JS_THREADSAFE */
500    
501     #define OBJ_GET_SLOT(cx,obj,slot) LOCKED_OBJ_GET_SLOT(obj,slot)
502 siliconforks 507 #define OBJ_SET_SLOT(cx,obj,slot,value) LOCKED_OBJ_WRITE_SLOT(cx,obj,slot,value)
503 siliconforks 332
504     #endif /* !JS_THREADSAFE */
505    
506     /*
507     * Class is invariant and comes from the fixed clasp member. Thus no locking
508     * is necessary to read it. Same for the private slot.
509     */
510     #define OBJ_GET_CLASS(cx,obj) STOBJ_GET_CLASS(obj)
511    
512 siliconforks 460 /*
513     * Test whether the object is native. FIXME bug 492938: consider how it would
514     * affect the performance to do just the !ops->objectMap check.
515     */
516     #define OPS_IS_NATIVE(ops) \
517     JS_LIKELY((ops) == &js_ObjectOps || !(ops)->objectMap)
518 siliconforks 332
519 siliconforks 460 #define OBJ_IS_NATIVE(obj) OPS_IS_NATIVE((obj)->map->ops)
520 siliconforks 332
521 siliconforks 507 #ifdef __cplusplus
522     inline void
523     OBJ_TO_INNER_OBJECT(JSContext *cx, JSObject *&obj)
524     {
525     JSClass *clasp = OBJ_GET_CLASS(cx, obj);
526     if (clasp->flags & JSCLASS_IS_EXTENDED) {
527     JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
528     if (xclasp->innerObject)
529     obj = xclasp->innerObject(cx, obj);
530     }
531     }
532    
533     /*
534     * The following function has been copied to jsd/jsd_val.c. If making changes to
535     * OBJ_TO_OUTER_OBJECT, please update jsd/jsd_val.c as well.
536     */
537     inline void
538     OBJ_TO_OUTER_OBJECT(JSContext *cx, JSObject *&obj)
539     {
540     JSClass *clasp = OBJ_GET_CLASS(cx, obj);
541     if (clasp->flags & JSCLASS_IS_EXTENDED) {
542     JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
543     if (xclasp->outerObject)
544     obj = xclasp->outerObject(cx, obj);
545     }
546     }
547     #endif
548    
549 siliconforks 332 extern JS_FRIEND_DATA(JSObjectOps) js_ObjectOps;
550     extern JS_FRIEND_DATA(JSObjectOps) js_WithObjectOps;
551     extern JSClass js_ObjectClass;
552     extern JSClass js_WithClass;
553     extern JSClass js_BlockClass;
554    
555     /*
556     * Block scope object macros. The slots reserved by js_BlockClass are:
557     *
558     * JSSLOT_PRIVATE JSStackFrame * active frame pointer or null
559     * JSSLOT_BLOCK_DEPTH int depth of block slots in frame
560     *
561     * After JSSLOT_BLOCK_DEPTH come one or more slots for the block locals.
562     *
563     * A With object is like a Block object, in that both have one reserved slot
564     * telling the stack depth of the relevant slots (the slot whose value is the
565     * object named in the with statement, the slots containing the block's local
566     * variables); and both have a private slot referring to the JSStackFrame in
567     * whose activation they were created (or null if the with or block object
568     * outlives the frame).
569     */
570     #define JSSLOT_BLOCK_DEPTH (JSSLOT_PRIVATE + 1)
571    
572 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
573     static inline bool
574     OBJ_IS_CLONED_BLOCK(JSObject *obj)
575     {
576     return obj->getProto() != NULL;
577     }
578     #else
579     static JSBool
580     OBJ_IS_CLONED_BLOCK(JSObject *obj)
581     {
582     return JSVAL_TO_OBJECT(obj->fslots[JSSLOT_PROTO]) != NULL;
583     }
584     #endif
585    
586     extern JSBool
587     js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, int16 index);
588    
589 siliconforks 332 #define OBJ_BLOCK_COUNT(cx,obj) \
590     (OBJ_SCOPE(obj)->entryCount)
591     #define OBJ_BLOCK_DEPTH(cx,obj) \
592     JSVAL_TO_INT(STOBJ_GET_SLOT(obj, JSSLOT_BLOCK_DEPTH))
593     #define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \
594     STOBJ_SET_SLOT(obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth))
595    
596     /*
597     * To make sure this slot is well-defined, always call js_NewWithObject to
598     * create a With object, don't call js_NewObject directly. When creating a
599     * With object that does not correspond to a stack slot, pass -1 for depth.
600     *
601     * When popping the stack across this object's "with" statement, client code
602 siliconforks 507 * must call withobj->setPrivate(NULL).
603 siliconforks 332 */
604 siliconforks 460 extern JS_REQUIRES_STACK JSObject *
605 siliconforks 332 js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth);
606    
607     /*
608     * Create a new block scope object not linked to any proto or parent object.
609     * Blocks are created by the compiler to reify let blocks and comprehensions.
610     * Only when dynamic scope is captured do they need to be cloned and spliced
611     * into an active scope chain.
612     */
613     extern JSObject *
614     js_NewBlockObject(JSContext *cx);
615    
616     extern JSObject *
617 siliconforks 507 js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp);
618 siliconforks 332
619 siliconforks 460 extern JS_REQUIRES_STACK JSBool
620 siliconforks 332 js_PutBlockObject(JSContext *cx, JSBool normalUnwind);
621    
622 siliconforks 460 JSBool
623     js_XDRBlockObject(JSXDRState *xdr, JSObject **objp);
624    
625 siliconforks 332 struct JSSharpObjectMap {
626     jsrefcount depth;
627     jsatomid sharpgen;
628     JSHashTable *table;
629     };
630    
631     #define SHARP_BIT ((jsatomid) 1)
632     #define BUSY_BIT ((jsatomid) 2)
633     #define SHARP_ID_SHIFT 2
634     #define IS_SHARP(he) (JS_PTR_TO_UINT32((he)->value) & SHARP_BIT)
635     #define MAKE_SHARP(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|SHARP_BIT))
636     #define IS_BUSY(he) (JS_PTR_TO_UINT32((he)->value) & BUSY_BIT)
637     #define MAKE_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)|BUSY_BIT))
638     #define CLEAR_BUSY(he) ((he)->value = JS_UINT32_TO_PTR(JS_PTR_TO_UINT32((he)->value)&~BUSY_BIT))
639    
640     extern JSHashEntry *
641     js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
642     jschar **sp);
643    
644     extern void
645     js_LeaveSharpObject(JSContext *cx, JSIdArray **idap);
646    
647     /*
648     * Mark objects stored in map if GC happens between js_EnterSharpObject
649     * and js_LeaveSharpObject. GC calls this when map->depth > 0.
650     */
651     extern void
652     js_TraceSharpMap(JSTracer *trc, JSSharpObjectMap *map);
653    
654     extern JSBool
655     js_HasOwnPropertyHelper(JSContext *cx, JSLookupPropOp lookup, uintN argc,
656     jsval *vp);
657    
658     extern JSBool
659     js_HasOwnProperty(JSContext *cx, JSLookupPropOp lookup, JSObject *obj, jsid id,
660     jsval *vp);
661    
662     extern JSBool
663     js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
664    
665     extern JSObject *
666     js_InitEval(JSContext *cx, JSObject *obj);
667    
668     extern JSObject *
669     js_InitObjectClass(JSContext *cx, JSObject *obj);
670    
671 siliconforks 460 extern JSObject *
672     js_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
673     JSClass *clasp, JSNative constructor, uintN nargs,
674     JSPropertySpec *ps, JSFunctionSpec *fs,
675     JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
676    
677     /*
678     * Select Object.prototype method names shared between jsapi.cpp and jsobj.cpp.
679     */
680 siliconforks 332 extern const char js_watch_str[];
681     extern const char js_unwatch_str[];
682     extern const char js_hasOwnProperty_str[];
683     extern const char js_isPrototypeOf_str[];
684     extern const char js_propertyIsEnumerable_str[];
685     extern const char js_defineGetter_str[];
686     extern const char js_defineSetter_str[];
687     extern const char js_lookupGetter_str[];
688     extern const char js_lookupSetter_str[];
689    
690     extern JSBool
691     js_GetClassId(JSContext *cx, JSClass *clasp, jsid *idp);
692    
693 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
694 siliconforks 332 extern JSObject *
695 siliconforks 507 js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto,
696     JSObject *parent, size_t objectSize = 0);
697     #else
698     extern JSObject *
699     js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto,
700     JSObject *parent, size_t objectSize);
701     #endif
702 siliconforks 332
703     /*
704     * See jsapi.h, JS_NewObjectWithGivenProto.
705     */
706 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
707 siliconforks 332 extern JSObject *
708     js_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto,
709 siliconforks 507 JSObject *parent, size_t objectSize = 0);
710     #else
711     extern JSObject *
712     js_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto,
713     JSObject *parent, size_t objectSize);
714     #endif
715 siliconforks 332
716     /*
717 siliconforks 507 * Allocate a new native object with the given value of the proto and private
718     * slots. The parent slot is set to the value of proto's parent slot.
719 siliconforks 460 *
720 siliconforks 507 * clasp must be a native class. proto must be the result of a call to
721     * js_InitClass(...clasp, ...).
722     *
723 siliconforks 460 * Note that this is the correct global object for native class instances, but
724     * not for user-defined functions called as constructors. Functions used as
725     * constructors must create instances parented by the parent of the function
726     * object, not by the parent of its .prototype object value.
727     */
728     extern JSObject*
729 siliconforks 507 js_NewObjectWithClassProto(JSContext *cx, JSClass *clasp, JSObject *proto,
730     jsval privateSlotValue);
731 siliconforks 460
732     /*
733 siliconforks 332 * Fast access to immutable standard objects (constructors and prototypes).
734     */
735     extern JSBool
736     js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
737     JSObject **objp);
738    
739     extern JSBool
740     js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj);
741    
742     extern JSBool
743     js_FindClassObject(JSContext *cx, JSObject *start, jsid id, jsval *vp);
744    
745     extern JSObject *
746     js_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
747     JSObject *parent, uintN argc, jsval *argv);
748    
749     extern JSBool
750     js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp);
751    
752     extern void
753     js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot);
754    
755 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
756     extern bool
757     #else
758     extern JSBool
759     #endif
760     js_GrowSlots(JSContext *cx, JSObject *obj, size_t nslots);
761 siliconforks 332
762 siliconforks 507 extern void
763     js_ShrinkSlots(JSContext *cx, JSObject *obj, size_t nslots);
764    
765     static inline void
766     js_FreeSlots(JSContext *cx, JSObject *obj)
767     {
768     if (obj->dslots)
769     js_ShrinkSlots(cx, obj, 0);
770     }
771    
772 siliconforks 460 /*
773 siliconforks 507 * Ensure that the object has at least JSCLASS_RESERVED_SLOTS(clasp)+nreserved
774     * slots. The function can be called only for native objects just created with
775     * js_NewObject or its forms. In particular, the object should not be shared
776     * between threads and its dslots array must be null. nreserved must match the
777     * value that JSClass.reserveSlots (if any) would return after the object is
778     * fully initialized.
779 siliconforks 460 */
780 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
781     bool
782     #else
783     JSBool
784     #endif
785     js_EnsureReservedSlots(JSContext *cx, JSObject *obj, size_t nreserved);
786 siliconforks 332
787     extern jsid
788 siliconforks 507 js_CheckForStringIndex(jsid id);
789 siliconforks 332
790     /*
791 siliconforks 460 * js_PurgeScopeChain does nothing if obj is not itself a prototype or parent
792     * scope, else it reshapes the scope and prototype chains it links. It calls
793     * js_PurgeScopeChainHelper, which asserts that obj is flagged as a delegate
794     * (i.e., obj has ever been on a prototype or parent chain).
795     */
796     extern void
797     js_PurgeScopeChainHelper(JSContext *cx, JSObject *obj, jsid id);
798    
799     #ifdef __cplusplus /* Aargh, libgjs, bug 492720. */
800     static JS_INLINE void
801     js_PurgeScopeChain(JSContext *cx, JSObject *obj, jsid id)
802     {
803 siliconforks 507 if (obj->isDelegate())
804 siliconforks 460 js_PurgeScopeChainHelper(cx, obj, id);
805     }
806     #endif
807    
808     /*
809 siliconforks 332 * Find or create a property named by id in obj's scope, with the given getter
810     * and setter, slot, attributes, and other members.
811     */
812     extern JSScopeProperty *
813     js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id,
814     JSPropertyOp getter, JSPropertyOp setter, uint32 slot,
815     uintN attrs, uintN flags, intN shortid);
816    
817     /*
818     * Change sprop to have the given attrs, getter, and setter in scope, morphing
819     * it into a potentially new JSScopeProperty. Return a pointer to the changed
820     * or identical property.
821     */
822     extern JSScopeProperty *
823     js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
824     JSScopeProperty *sprop, uintN attrs, uintN mask,
825     JSPropertyOp getter, JSPropertyOp setter);
826    
827     extern JSBool
828     js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
829 siliconforks 507 JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
830 siliconforks 332
831 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
832 siliconforks 460
833     /*
834     * Flags for the defineHow parameter of js_DefineNativeProperty.
835     */
836     const uintN JSDNP_CACHE_RESULT = 1; /* an interpreter call from JSOP_INITPROP */
837     const uintN JSDNP_DONT_PURGE = 2; /* suppress js_PurgeScopeChain */
838    
839 siliconforks 507 /*
840     * On error, return false. On success, if propp is non-null, return true with
841     * obj locked and with a held property in *propp; if propp is null, return true
842     * but release obj's lock first. Therefore all callers who pass non-null propp
843     * result parameters must later call obj->dropProperty(cx, *propp) both to drop
844     * the held property, and to release the lock on obj.
845     */
846 siliconforks 332 extern JSBool
847     js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value,
848     JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
849 siliconforks 460 uintN flags, intN shortid, JSProperty **propp,
850     uintN defineHow = 0);
851 siliconforks 507 #endif /* __cplusplus */
852 siliconforks 332
853     /*
854 siliconforks 507 * Unlike js_DefineNativeProperty, propp must be non-null. On success, and if
855     * id was found, return true with *objp non-null and locked, and with a held
856     * property stored in *propp. If successful but id was not found, return true
857     * with both *objp and *propp null. Therefore all callers who receive a
858     * non-null *propp must later call (*objp)->dropProperty(cx, *propp).
859 siliconforks 332 */
860     extern JS_FRIEND_API(JSBool)
861     js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
862     JSProperty **propp);
863    
864     /*
865     * Specialized subroutine that allows caller to preset JSRESOLVE_* flags and
866     * returns the index along the prototype chain in which *propp was found, or
867     * the last index if not found, or -1 on error.
868     */
869     extern int
870     js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
871     JSObject **objp, JSProperty **propp);
872    
873 siliconforks 507
874 siliconforks 460 /*
875 siliconforks 507 * We cache name lookup results only for the global object or for native
876     * non-global objects without prototype or with prototype that never mutates,
877     * see bug 462734 and bug 487039.
878     */
879     #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
880     static inline bool
881     js_IsCacheableNonGlobalScope(JSObject *obj)
882     {
883     extern JS_FRIEND_DATA(JSClass) js_CallClass;
884     extern JS_FRIEND_DATA(JSClass) js_DeclEnvClass;
885     JS_ASSERT(STOBJ_GET_PARENT(obj));
886    
887     JSClass *clasp = STOBJ_GET_CLASS(obj);
888     bool cacheable = (clasp == &js_CallClass ||
889     clasp == &js_BlockClass ||
890     clasp == &js_DeclEnvClass);
891    
892     JS_ASSERT_IF(cacheable, obj->map->ops->lookupProperty == js_LookupProperty);
893     return cacheable;
894     }
895     #endif
896    
897     /*
898 siliconforks 460 * If cacheResult is false, return JS_NO_PROP_CACHE_FILL on success.
899     */
900     extern JSPropCacheEntry *
901     js_FindPropertyHelper(JSContext *cx, jsid id, JSBool cacheResult,
902     JSObject **objp, JSObject **pobjp, JSProperty **propp);
903 siliconforks 332
904     /*
905     * Return the index along the scope chain in which id was found, or the last
906     * index if not found, or -1 on error.
907     */
908     extern JS_FRIEND_API(JSBool)
909     js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp,
910     JSProperty **propp);
911    
912 siliconforks 460 extern JS_REQUIRES_STACK JSObject *
913     js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id);
914 siliconforks 332
915     extern JSObject *
916     js_FindVariableScope(JSContext *cx, JSFunction **funp);
917    
918     /*
919     * NB: js_NativeGet and js_NativeSet are called with the scope containing sprop
920     * (pobj's scope for Get, obj's for Set) locked, and on successful return, that
921     * scope is again locked. But on failure, both functions return false with the
922     * scope containing sprop unlocked.
923     */
924     extern JSBool
925     js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj,
926     JSScopeProperty *sprop, jsval *vp);
927    
928     extern JSBool
929     js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *vp);
930    
931     extern JSBool
932 siliconforks 460 js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, JSBool cacheResult,
933     jsval *vp);
934 siliconforks 332
935     extern JSBool
936     js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
937    
938     extern JSBool
939 siliconforks 460 js_GetMethod(JSContext *cx, JSObject *obj, jsid id, JSBool cacheResult,
940     jsval *vp);
941 siliconforks 332
942 siliconforks 460 /*
943     * Check whether it is OK to assign an undeclared property of the global
944     * object at the current script PC.
945     */
946     extern JS_FRIEND_API(JSBool)
947     js_CheckUndeclaredVarAssignment(JSContext *cx);
948    
949 siliconforks 332 extern JSBool
950 siliconforks 460 js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, JSBool cacheResult,
951     jsval *vp);
952    
953     extern JSBool
954 siliconforks 332 js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
955    
956     extern JSBool
957     js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
958     uintN *attrsp);
959    
960     extern JSBool
961     js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
962     uintN *attrsp);
963    
964     extern JSBool
965     js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, jsval *rval);
966    
967     extern JSBool
968     js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp);
969    
970     extern JSBool
971     js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
972     jsval *statep, jsid *idp);
973    
974     extern void
975 siliconforks 507 js_MarkEnumeratorState(JSTracer *trc, JSObject *obj, jsval state);
976 siliconforks 332
977 siliconforks 507 extern void
978     js_PurgeCachedNativeEnumerators(JSContext *cx, JSThreadData *data);
979    
980 siliconforks 332 extern JSBool
981     js_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
982     jsval *vp, uintN *attrsp);
983    
984     extern JSBool
985     js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
986    
987     extern JSBool
988     js_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
989     jsval *rval);
990    
991     extern JSBool
992     js_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
993    
994     extern JSBool
995 siliconforks 460 js_SetProtoOrParent(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj,
996     JSBool checkForCycles);
997 siliconforks 332
998     extern JSBool
999     js_IsDelegate(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
1000    
1001     extern JSBool
1002     js_GetClassPrototype(JSContext *cx, JSObject *scope, jsid id,
1003     JSObject **protop);
1004    
1005     extern JSBool
1006     js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto,
1007     uintN attrs);
1008    
1009     /*
1010     * Wrap boolean, number or string as Boolean, Number or String object.
1011     * *vp must not be an object, null or undefined.
1012     */
1013     extern JSBool
1014     js_PrimitiveToObject(JSContext *cx, jsval *vp);
1015    
1016     extern JSBool
1017     js_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
1018    
1019     extern JSObject *
1020     js_ValueToNonNullObject(JSContext *cx, jsval v);
1021    
1022     extern JSBool
1023     js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval);
1024    
1025     extern JSBool
1026     js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
1027     uintN argc, jsval *argv, jsval *rval);
1028    
1029     extern JSBool
1030     js_XDRObject(JSXDRState *xdr, JSObject **objp);
1031    
1032     extern void
1033     js_TraceObject(JSTracer *trc, JSObject *obj);
1034    
1035     extern void
1036     js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
1037    
1038     extern void
1039     js_Clear(JSContext *cx, JSObject *obj);
1040    
1041 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
1042     extern bool
1043     #else
1044 siliconforks 332 extern JSBool
1045 siliconforks 507 #endif
1046     js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
1047 siliconforks 332
1048 siliconforks 507 #ifdef __cplusplus /* Allow inclusion from LiveConnect C files. */
1049     bool
1050     #else
1051     JSBool
1052     #endif
1053     js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v);
1054    
1055 siliconforks 332 /*
1056     * Precondition: obj must be locked.
1057     */
1058     extern JSBool
1059     js_ReallocSlots(JSContext *cx, JSObject *obj, uint32 nslots,
1060     JSBool exactAllocation);
1061    
1062     extern JSObject *
1063     js_CheckScopeChainValidity(JSContext *cx, JSObject *scopeobj, const char *caller);
1064    
1065     extern JSBool
1066     js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
1067     JSPrincipals *principals, JSAtom *caller);
1068    
1069     /* Infallible -- returns its argument if there is no wrapped object. */
1070     extern JSObject *
1071     js_GetWrappedObject(JSContext *cx, JSObject *obj);
1072    
1073     /* NB: Infallible. */
1074     extern const char *
1075     js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
1076     JSPrincipals *principals, uintN *linenop);
1077    
1078 siliconforks 460 /* Infallible, therefore cx is last parameter instead of first. */
1079     extern JSBool
1080     js_IsCallable(JSObject *obj, JSContext *cx);
1081    
1082     void
1083     js_ReportGetterOnlyAssignment(JSContext *cx);
1084    
1085     extern JS_FRIEND_API(JSBool)
1086     js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
1087    
1088 siliconforks 332 #ifdef DEBUG
1089     JS_FRIEND_API(void) js_DumpChars(const jschar *s, size_t n);
1090     JS_FRIEND_API(void) js_DumpString(JSString *str);
1091     JS_FRIEND_API(void) js_DumpAtom(JSAtom *atom);
1092     JS_FRIEND_API(void) js_DumpValue(jsval val);
1093     JS_FRIEND_API(void) js_DumpId(jsid id);
1094     JS_FRIEND_API(void) js_DumpObject(JSObject *obj);
1095 siliconforks 507 JS_FRIEND_API(void) js_DumpStackFrame(JSStackFrame *fp);
1096 siliconforks 332 #endif
1097    
1098 siliconforks 507 extern uintN
1099     js_InferFlags(JSContext *cx, uintN defaultFlags);
1100    
1101     /* Object constructor native. Exposed only so the JIT can know its address. */
1102     JSBool
1103     js_Object(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1104    
1105 siliconforks 332 JS_END_EXTERN_C
1106    
1107     #endif /* jsobj_h___ */

  ViewVC Help
Powered by ViewVC 1.1.24