1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sw=4 et tw=78:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
17 * The Original Code is Mozilla Communicator client code, released
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.
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.
39 * ***** END LICENSE BLOCK ***** */
44 * JS object definitions.
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.
52 #include "jshash.h" /* Added by JSIFY */
61 class AutoPropDescArrayRooter
;
63 static inline PropertyOp
64 CastAsPropertyOp(JSObject
*object
)
66 return JS_DATA_TO_FUNC_PTR(PropertyOp
, object
);
69 static inline JSPropertyOp
70 CastAsJSPropertyOp(JSObject
*object
)
72 return JS_DATA_TO_FUNC_PTR(JSPropertyOp
, object
);
76 CastAsObject(PropertyOp op
)
78 return JS_FUNC_TO_DATA_PTR(JSObject
*, op
);
82 CastAsObjectJsval(PropertyOp op
)
84 return ObjectOrNullValue(CastAsObject(op
));
90 * A representation of ECMA-262 ed. 5's internal property descriptor data
94 friend class js::AutoPropDescArrayRooter
;
99 /* 8.10.5 ToPropertyDescriptor(Obj) */
100 bool initialize(JSContext
* cx
, jsid id
, const js::Value
&v
);
102 /* 8.10.1 IsAccessorDescriptor(desc) */
103 bool isAccessorDescriptor() const {
104 return hasGet
|| hasSet
;
107 /* 8.10.2 IsDataDescriptor(desc) */
108 bool isDataDescriptor() const {
109 return hasValue
|| hasWritable
;
112 /* 8.10.3 IsGenericDescriptor(desc) */
113 bool isGenericDescriptor() const {
114 return !isAccessorDescriptor() && !isDataDescriptor();
117 bool configurable() const {
118 return (attrs
& JSPROP_PERMANENT
) == 0;
121 bool enumerable() const {
122 return (attrs
& JSPROP_ENUMERATE
) != 0;
125 bool writable() const {
126 return (attrs
& JSPROP_READONLY
) == 0;
129 JSObject
* getterObject() const {
130 return get
.isUndefined() ? NULL
: &get
.toObject();
132 JSObject
* setterObject() const {
133 return set
.isUndefined() ? NULL
: &set
.toObject();
136 const js::Value
&getterValue() const {
139 const js::Value
&setterValue() const {
143 js::PropertyOp
getter() const {
144 return js::CastAsPropertyOp(getterObject());
146 js::PropertyOp
setter() const {
147 return js::CastAsPropertyOp(setterObject());
150 static void traceDescriptorArray(JSTracer
* trc
, JSObject
* obj
);
151 static void finalizeDescriptorArray(JSContext
* cx
, JSObject
* obj
);
155 js::Value value
, get
, set
;
157 /* Property descriptor boolean fields. */
160 /* Bits indicating which values are set. */
164 bool hasWritable
: 1;
165 bool hasEnumerable
: 1;
166 bool hasConfigurable
: 1;
171 typedef Vector
<PropDesc
, 1> PropDescArray
;
176 static JS_FRIEND_DATA(const JSObjectMap
) sharedNonNative
;
178 uint32 shape
; /* shape identifier */
180 explicit JSObjectMap(uint32 shape
) : shape(shape
) {}
182 enum { SHAPELESS
= 0xffffffff };
184 bool isNative() const { return this != &sharedNonNative
; }
187 /* No copy or assignment semantics. */
188 JSObjectMap(JSObjectMap
&);
189 void operator=(JSObjectMap
&);
193 * Unlike js_DefineNativeProperty, propp must be non-null. On success, and if
194 * id was found, return true with *objp non-null and locked, and with a held
195 * property stored in *propp. If successful but id was not found, return true
196 * with both *objp and *propp null. Therefore all callers who receive a
197 * non-null *propp must later call (*objp)->dropProperty(cx, *propp).
199 extern JS_FRIEND_API(JSBool
)
200 js_LookupProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, JSObject
**objp
,
204 js_DefineProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, const js::Value
*value
,
205 js::PropertyOp getter
, js::PropertyOp setter
, uintN attrs
);
208 js_GetProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, js::Value
*vp
);
211 js_SetProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, js::Value
*vp
);
214 js_GetAttributes(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN
*attrsp
);
217 js_SetAttributes(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN
*attrsp
);
220 js_DeleteProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, js::Value
*rval
);
222 extern JS_FRIEND_API(JSBool
)
223 js_Enumerate(JSContext
*cx
, JSObject
*obj
, JSIterateOp enum_op
,
224 js::Value
*statep
, jsid
*idp
);
227 js_TypeOf(JSContext
*cx
, JSObject
*obj
);
229 struct NativeIterator
;
231 const uint32 JS_INITIAL_NSLOTS
= 3;
234 * The first available slot to store generic value. For JSCLASS_HAS_PRIVATE
235 * classes the slot stores a pointer to private data stuffed in a Value.
236 * Such pointer is stored as is without an overhead of PRIVATE_TO_JSVAL
237 * tagging and should be accessed using the (get|set)Private methods of
240 const uint32 JSSLOT_PRIVATE
= 0;
245 * JSObject struct, with members sized to fit in 32 bytes on 32-bit targets,
246 * 64 bytes on 64-bit systems. The JSFunction struct is an extension of this
247 * struct allocated from a larger GC size-class.
249 * An object is a delegate if it is on another object's prototype (the proto
250 * field) or scope chain (the parent field), and therefore the delegate might
251 * be asked implicitly to get or set a property on behalf of another object.
252 * Delegates may be accessed directly too, as may any object, but only those
253 * objects linked after the head of any prototype or scope chain are flagged
254 * as delegates. This definition helps to optimize shape-based property cache
255 * invalidation (see Purge{Scope,Proto}Chain in jsobj.cpp).
257 * The meaning of the system object bit is defined by the API client. It is
258 * set in JS_NewSystemObject and is queried by JS_IsSystemObject (jsdbgapi.h),
259 * but it has no intrinsic meaning to SpiderMonkey. Further, JSFILENAME_SYSTEM
260 * and JS_FlagScriptFilenamePrefix (also exported via jsdbgapi.h) are intended
261 * to be complementary to this bit, but it is up to the API client to implement
262 * any such association.
264 * Both these flags are initially zero; they may be set or queried using the
265 * (is|set)(Delegate|System) inline methods.
267 * The dslots member is null or a pointer into a dynamically allocated vector
268 * of Values for reserved and dynamic slots. If dslots is not null, dslots[-1]
269 * records the number of available slots.
273 * TraceRecorder must be a friend because it generates code that
274 * manipulates JSObjects, which requires peeking under any encapsulation.
276 friend class js::TraceRecorder
;
278 JSObjectMap
*map
; /* property map, see jsscope.h */
279 js::Class
*clasp
; /* class pointer */
280 jsuword flags
; /* see above */
281 JSObject
*proto
; /* object's prototype */
282 JSObject
*parent
; /* object's parent */
283 js::Value
*dslots
; /* dynamically allocated slots */
284 js::Value fslots
[JS_INITIAL_NSLOTS
]; /* small number of fixed slots */
286 bool isNative() const {
287 return map
->isNative();
290 js::Class
*getClass() const {
294 JSClass
*getJSClass() const {
295 return Jsvalify(clasp
);
298 bool hasClass(const js::Class
*c
) const {
302 const js::ObjectOps
*getOps() const {
303 return &getClass()->ops
;
306 inline JSScope
*scope() const;
307 inline uint32
shape() const;
309 bool isDelegate() const {
310 return (flags
& jsuword(1)) != jsuword(0);
317 static void setDelegateNullSafe(JSObject
*obj
) {
322 bool isSystem() const {
323 return (flags
& jsuword(2)) != jsuword(0);
330 uint32
numSlots(void) const {
331 return dslots
? dslots
[-1].toPrivateUint32() : (uint32
)JS_INITIAL_NSLOTS
;
335 static size_t slotsToDynamicWords(size_t nslots
) {
336 JS_ASSERT(nslots
> JS_INITIAL_NSLOTS
);
337 return nslots
+ 1 - JS_INITIAL_NSLOTS
;
340 static size_t dynamicWordsToSlots(size_t nwords
) {
341 JS_ASSERT(nwords
> 1);
342 return nwords
- 1 + JS_INITIAL_NSLOTS
;
346 bool allocSlots(JSContext
*cx
, size_t nslots
);
347 bool growSlots(JSContext
*cx
, size_t nslots
);
348 void shrinkSlots(JSContext
*cx
, size_t nslots
);
350 js::Value
& getSlotRef(uintN slot
) {
351 return (slot
< JS_INITIAL_NSLOTS
)
353 : (JS_ASSERT(slot
< dslots
[-1].toPrivateUint32()),
354 dslots
[slot
- JS_INITIAL_NSLOTS
]);
357 const js::Value
&getSlot(uintN slot
) const {
358 return (slot
< JS_INITIAL_NSLOTS
)
360 : (JS_ASSERT(slot
< dslots
[-1].toPrivateUint32()),
361 dslots
[slot
- JS_INITIAL_NSLOTS
]);
364 void setSlot(uintN slot
, const js::Value
&value
) {
365 if (slot
< JS_INITIAL_NSLOTS
) {
366 fslots
[slot
] = value
;
368 JS_ASSERT(slot
< dslots
[-1].toPrivateUint32());
369 dslots
[slot
- JS_INITIAL_NSLOTS
] = value
;
373 inline const js::Value
&lockedGetSlot(uintN slot
) const;
374 inline void lockedSetSlot(uintN slot
, const js::Value
&value
);
377 * These ones are for multi-threaded ("MT") objects. Use getSlot(),
378 * getSlotRef(), setSlot() to directly manipulate slots in obj when only
379 * one thread can access obj, or when accessing read-only slots within
382 inline js::Value
getSlotMT(JSContext
*cx
, uintN slot
);
383 inline void setSlotMT(JSContext
*cx
, uintN slot
, const js::Value
&value
);
385 inline js::Value
getReservedSlot(uintN index
) const;
387 JSObject
*getProto() const {
395 void setProto(JSObject
*newProto
) {
397 for (JSObject
*obj
= newProto
; obj
; obj
= obj
->getProto())
398 JS_ASSERT(obj
!= this);
400 setDelegateNullSafe(newProto
);
404 JSObject
*getParent() const {
412 void setParent(JSObject
*newParent
) {
414 for (JSObject
*obj
= newParent
; obj
; obj
= obj
->getParent())
415 JS_ASSERT(obj
!= this);
417 setDelegateNullSafe(newParent
);
421 JSObject
*getGlobal() const;
423 bool isGlobal() const {
424 return !!(getClass()->flags
& JSCLASS_IS_GLOBAL
);
427 void *getPrivate() const {
428 JS_ASSERT(getClass()->flags
& JSCLASS_HAS_PRIVATE
);
429 void *priv
= fslots
[JSSLOT_PRIVATE
].toPrivate();
433 void setPrivate(void *data
) {
434 JS_ASSERT(getClass()->flags
& JSCLASS_HAS_PRIVATE
);
435 JS_ASSERT((size_t(data
) & 1) == 0);
436 fslots
[JSSLOT_PRIVATE
].setPrivate(data
);
439 static js::Value
defaultPrivate(js::Class
*clasp
) {
440 if (clasp
->flags
& JSCLASS_HAS_PRIVATE
)
441 return js::PrivateValue(NULL
);
442 return js::UndefinedValue();
446 * Primitive-specific getters and setters.
450 static const uint32 JSSLOT_PRIMITIVE_THIS
= JSSLOT_PRIVATE
;
453 inline const js::Value
&getPrimitiveThis() const;
454 inline void setPrimitiveThis(const js::Value
&pthis
);
457 * Array-specific getters and setters (for both dense and slow arrays).
461 // Used by dense and slow arrays.
462 static const uint32 JSSLOT_ARRAY_LENGTH
= JSSLOT_PRIVATE
;
464 static const uint32 JSSLOT_DENSE_ARRAY_CAPACITY
= JSSLOT_PRIVATE
+ 1;
466 // This assertion must remain true; see comment in js_MakeArraySlow().
467 // (Nb: This method is never called, it just contains a static assertion.
468 // The static assertion isn't inline because that doesn't work on Mac.)
469 inline void staticAssertArrayLengthIsInPrivateSlot();
472 static const uint32 DENSE_ARRAY_FIXED_RESERVED_SLOTS
= 3;
474 inline uint32
getArrayLength() const;
475 inline void setArrayLength(uint32 length
);
477 inline uint32
getDenseArrayCapacity() const;
478 inline void setDenseArrayCapacity(uint32 capacity
);
480 inline const js::Value
&getDenseArrayElement(uint32 i
) const;
481 inline js::Value
*addressOfDenseArrayElement(uint32 i
);
482 inline void setDenseArrayElement(uint32 i
, const js::Value
&v
);
484 inline js::Value
*getDenseArrayElements() const; // returns pointer to the Array's elements array
485 bool growDenseArrayElements(JSContext
*cx
, uint32 oldcap
, uint32 newcap
);
486 bool ensureDenseArrayElements(JSContext
*cx
, uint32 newcap
);
487 bool shrinkDenseArrayElements(JSContext
*cx
, uint32 newcap
);
488 inline void freeDenseArrayElements(JSContext
*cx
);
490 inline void voidDenseOnlyArraySlots(); // used when converting a dense array to a slow array
492 JSBool
makeDenseArraySlow(JSContext
*cx
);
495 * Arguments-specific getters and setters.
500 * Reserved slot structure for Arguments objects:
502 * JSSLOT_PRIVATE - the corresponding frame until the frame exits.
503 * JSSLOT_ARGS_LENGTH - the number of actual arguments and a flag
504 * indicating whether arguments.length was
505 * overwritten. This slot is not used to represent
506 * arguments.length after that property has been
507 * assigned, even if the new value is integral: it's
508 * always the original length.
509 * JSSLOT_ARGS_CALLEE - the arguments.callee value or JSVAL_HOLE if that
512 * Argument index i is stored in dslots[i], accessible via
513 * {get,set}ArgsElement().
515 static const uint32 JSSLOT_ARGS_LENGTH
= JSSLOT_PRIVATE
+ 1;
516 static const uint32 JSSLOT_ARGS_CALLEE
= JSSLOT_PRIVATE
+ 2;
519 /* Number of extra fixed slots besides JSSLOT_PRIVATE. */
520 static const uint32 ARGS_FIXED_RESERVED_SLOTS
= 2;
522 /* Lower-order bit stolen from the length slot. */
523 static const uint32 ARGS_LENGTH_OVERRIDDEN_BIT
= 0x1;
524 static const uint32 ARGS_PACKED_BITS_COUNT
= 1;
527 * Set the initial length of the arguments, and mark it as not overridden.
529 inline void setArgsLength(uint32 argc
);
532 * Return the initial length of the arguments. This may differ from the
533 * current value of arguments.length!
535 inline uint32
getArgsInitialLength() const;
537 inline void setArgsLengthOverridden();
538 inline bool isArgsLengthOverridden() const;
540 inline const js::Value
&getArgsCallee() const;
541 inline void setArgsCallee(const js::Value
&callee
);
543 inline const js::Value
&getArgsElement(uint32 i
) const;
544 inline js::Value
*addressOfArgsElement(uint32 i
) const;
545 inline void setArgsElement(uint32 i
, const js::Value
&v
);
548 * Date-specific getters and setters.
552 static const uint32 JSSLOT_DATE_UTC_TIME
= JSSLOT_PRIVATE
;
555 * Cached slots holding local properties of the date.
556 * These are undefined until the first actual lookup occurs
557 * and are reset to undefined whenever the date's time is modified.
559 static const uint32 JSSLOT_DATE_COMPONENTS_START
= JSSLOT_PRIVATE
+ 1;
561 static const uint32 JSSLOT_DATE_LOCAL_TIME
= JSSLOT_PRIVATE
+ 1;
562 static const uint32 JSSLOT_DATE_LOCAL_YEAR
= JSSLOT_PRIVATE
+ 2;
563 static const uint32 JSSLOT_DATE_LOCAL_MONTH
= JSSLOT_PRIVATE
+ 3;
564 static const uint32 JSSLOT_DATE_LOCAL_DATE
= JSSLOT_PRIVATE
+ 4;
565 static const uint32 JSSLOT_DATE_LOCAL_DAY
= JSSLOT_PRIVATE
+ 5;
566 static const uint32 JSSLOT_DATE_LOCAL_HOURS
= JSSLOT_PRIVATE
+ 6;
567 static const uint32 JSSLOT_DATE_LOCAL_MINUTES
= JSSLOT_PRIVATE
+ 7;
568 static const uint32 JSSLOT_DATE_LOCAL_SECONDS
= JSSLOT_PRIVATE
+ 8;
570 static const uint32 DATE_CLASS_RESERVED_SLOTS
= 9;
572 inline const js::Value
&getDateUTCTime() const;
573 inline void setDateUTCTime(const js::Value
&pthis
);
576 * Function-specific getters and setters.
580 friend struct JSFunction
;
582 static const uint32 JSSLOT_FUN_METHOD_ATOM
= JSSLOT_PRIVATE
+ 1;
583 static const uint32 JSSLOT_FUN_METHOD_OBJ
= JSSLOT_PRIVATE
+ 2;
585 static const uint32 JSSLOT_BOUND_FUNCTION_THIS
= JSSLOT_PRIVATE
+ 1;
586 static const uint32 JSSLOT_BOUND_FUNCTION_ARGS_COUNT
= JSSLOT_PRIVATE
+ 2;
589 static const uint32 FUN_FIXED_RESERVED_SLOTS
= 2;
591 inline bool hasMethodObj(const JSObject
& obj
) const;
592 inline void setMethodObj(JSObject
& obj
);
594 inline JSFunction
*getFunctionPrivate() const;
597 initBoundFunction(JSContext
*cx
, const js::Value
&thisArg
,
598 const js::Value
*args
, uintN argslen
);
600 inline JSObject
*getBoundFunctionTarget() const;
601 inline const js::Value
&getBoundFunctionThis() const;
602 inline const js::Value
*getBoundFunctionArguments(uintN
&argslen
) const;
605 * RegExp-specific getters and setters.
609 static const uint32 JSSLOT_REGEXP_LAST_INDEX
= JSSLOT_PRIVATE
+ 1;
612 static const uint32 REGEXP_FIXED_RESERVED_SLOTS
= 1;
614 inline const js::Value
&getRegExpLastIndex() const;
615 inline void setRegExpLastIndex(const js::Value
&v
);
616 inline void setRegExpLastIndex(jsdouble d
);
617 inline void zeroRegExpLastIndex();
620 * Iterator-specific getters and setters.
623 inline NativeIterator
*getNativeIterator() const;
624 inline void setNativeIterator(NativeIterator
*);
627 * XML-related getters and setters.
631 * Slots for XML-related classes are as follows:
632 * - js_NamespaceClass.base reserves the *_NAME_* and *_NAMESPACE_* slots.
633 * - js_QNameClass.base, js_AttributeNameClass, js_AnyNameClass reserve
634 * the *_NAME_* and *_QNAME_* slots.
635 * - Others (js_XMLClass, js_XMLFilterClass) don't reserve any slots.
638 static const uint32 JSSLOT_NAME_PREFIX
= JSSLOT_PRIVATE
; // shared
639 static const uint32 JSSLOT_NAME_URI
= JSSLOT_PRIVATE
+ 1; // shared
641 static const uint32 JSSLOT_NAMESPACE_DECLARED
= JSSLOT_PRIVATE
+ 2;
643 static const uint32 JSSLOT_QNAME_LOCAL_NAME
= JSSLOT_PRIVATE
+ 2;
646 static const uint32 NAMESPACE_FIXED_RESERVED_SLOTS
= 3;
647 static const uint32 QNAME_FIXED_RESERVED_SLOTS
= 3;
649 inline jsval
getNamePrefix() const;
650 inline void setNamePrefix(jsval prefix
);
652 inline jsval
getNameURI() const;
653 inline void setNameURI(jsval uri
);
655 inline jsval
getNamespaceDeclared() const;
656 inline void setNamespaceDeclared(jsval decl
);
658 inline jsval
getQNameLocalName() const;
659 inline void setQNameLocalName(jsval decl
);
662 * Proxy-specific getters and setters.
665 inline js::JSProxyHandler
*getProxyHandler() const;
666 inline const js::Value
&getProxyPrivate() const;
667 inline void setProxyPrivate(const js::Value
&priv
);
670 * With object-specific getters and setters.
672 inline JSObject
*getWithThis() const;
673 inline void setWithThis(JSObject
*thisp
);
676 * Back to generic stuff.
679 inline bool isCallable();
681 /* The map field is not initialized here and should be set separately. */
682 void init(js::Class
*aclasp
, JSObject
*proto
, JSObject
*parent
,
683 const js::Value
&privateSlotValue
) {
684 JS_STATIC_ASSERT(JSSLOT_PRIVATE
+ 3 == JS_INITIAL_NSLOTS
);
688 JS_ASSERT(!isDelegate());
689 JS_ASSERT(!isSystem());
693 fslots
[JSSLOT_PRIVATE
] = privateSlotValue
;
694 fslots
[JSSLOT_PRIVATE
+ 1].setUndefined();
695 fslots
[JSSLOT_PRIVATE
+ 2].setUndefined();
700 * Like init, but also initializes map. The catch: proto must be the result
701 * of a call to js_InitClass(...clasp, ...).
703 inline void initSharingEmptyScope(js::Class
*clasp
,
706 const js::Value
&privateSlotValue
);
708 inline bool hasSlotsArray() const { return !!dslots
; }
710 /* This method can only be called when hasSlotsArray() returns true. */
711 inline void freeSlotsArray(JSContext
*cx
);
713 JSBool
lookupProperty(JSContext
*cx
, jsid id
, JSObject
**objp
, JSProperty
**propp
) {
714 JSLookupPropOp op
= getOps()->lookupProperty
;
715 return (op
? op
: js_LookupProperty
)(cx
, this, id
, objp
, propp
);
718 JSBool
defineProperty(JSContext
*cx
, jsid id
, const js::Value
&value
,
719 js::PropertyOp getter
= js::PropertyStub
,
720 js::PropertyOp setter
= js::PropertyStub
,
721 uintN attrs
= JSPROP_ENUMERATE
) {
722 js::DefinePropOp op
= getOps()->defineProperty
;
723 return (op
? op
: js_DefineProperty
)(cx
, this, id
, &value
, getter
, setter
, attrs
);
726 JSBool
getProperty(JSContext
*cx
, jsid id
, js::Value
*vp
) {
727 js::PropertyIdOp op
= getOps()->getProperty
;
728 return (op
? op
: js_GetProperty
)(cx
, this, id
, vp
);
731 JSBool
setProperty(JSContext
*cx
, jsid id
, js::Value
*vp
) {
732 js::PropertyIdOp op
= getOps()->setProperty
;
733 return (op
? op
: js_SetProperty
)(cx
, this, id
, vp
);
736 JSBool
getAttributes(JSContext
*cx
, jsid id
, uintN
*attrsp
) {
737 JSAttributesOp op
= getOps()->getAttributes
;
738 return (op
? op
: js_GetAttributes
)(cx
, this, id
, attrsp
);
741 JSBool
setAttributes(JSContext
*cx
, jsid id
, uintN
*attrsp
) {
742 JSAttributesOp op
= getOps()->setAttributes
;
743 return (op
? op
: js_SetAttributes
)(cx
, this, id
, attrsp
);
746 JSBool
deleteProperty(JSContext
*cx
, jsid id
, js::Value
*rval
) {
747 js::PropertyIdOp op
= getOps()->deleteProperty
;
748 return (op
? op
: js_DeleteProperty
)(cx
, this, id
, rval
);
751 JSBool
enumerate(JSContext
*cx
, JSIterateOp iterop
, js::Value
*statep
, jsid
*idp
) {
752 js::NewEnumerateOp op
= getOps()->enumerate
;
753 return (op
? op
: js_Enumerate
)(cx
, this, iterop
, statep
, idp
);
756 JSType
typeOf(JSContext
*cx
) {
757 JSTypeOfOp op
= getOps()->typeOf
;
758 return (op
? op
: js_TypeOf
)(cx
, this);
761 JSObject
*wrappedObject(JSContext
*cx
) const;
763 /* These four are time-optimized to avoid stub calls. */
764 JSObject
*thisObject(JSContext
*cx
) {
765 JSObjectOp op
= getOps()->thisObject
;
766 return op
? op(cx
, this) : this;
769 static bool thisObject(JSContext
*cx
, const js::Value
&v
, js::Value
*vp
);
771 inline void dropProperty(JSContext
*cx
, JSProperty
*prop
);
773 JS_FRIEND_API(JSCompartment
*) getCompartment(JSContext
*cx
);
775 inline JSObject
*getThrowTypeError() const;
777 void swap(JSObject
*obj
);
779 inline bool canHaveMethodBarrier() const;
781 inline bool isArguments() const;
782 inline bool isNormalArguments() const;
783 inline bool isStrictArguments() const;
784 inline bool isArray() const;
785 inline bool isDenseArray() const;
786 inline bool isSlowArray() const;
787 inline bool isNumber() const;
788 inline bool isBoolean() const;
789 inline bool isString() const;
790 inline bool isPrimitive() const;
791 inline bool isDate() const;
792 inline bool isFunction() const;
793 inline bool isObject() const;
794 inline bool isWith() const;
795 inline bool isBlock() const;
796 inline bool isRegExp() const;
797 inline bool isXML() const;
798 inline bool isXMLId() const;
799 inline bool isNamespace() const;
800 inline bool isQName() const;
802 inline bool isProxy() const;
803 inline bool isObjectProxy() const;
804 inline bool isFunctionProxy() const;
806 JS_FRIEND_API(bool) isWrapper() const;
807 JS_FRIEND_API(JSObject
*) unwrap(uintN
*flagsp
= NULL
);
809 inline bool unbrand(JSContext
*cx
);
811 inline void initArrayClass();
814 JS_STATIC_ASSERT(offsetof(JSObject
, fslots
) % sizeof(js::Value
) == 0);
815 JS_STATIC_ASSERT(sizeof(JSObject
) % JS_GCTHING_ALIGN
== 0);
817 #define JSSLOT_START(clasp) (((clasp)->flags & JSCLASS_HAS_PRIVATE) \
818 ? JSSLOT_PRIVATE + 1 \
821 #define JSSLOT_FREE(clasp) (JSSLOT_START(clasp) \
822 + JSCLASS_RESERVED_SLOTS(clasp))
825 * Maximum capacity of the obj->dslots vector, net of the hidden slot at
826 * obj->dslots[-1] that is used to store the length of the vector biased by
827 * JS_INITIAL_NSLOTS (and again net of the slot at index -1).
829 #define MAX_DSLOTS_LENGTH (~size_t(0) / sizeof(js::Value) - 1)
830 #define MAX_DSLOTS_LENGTH32 (~uint32(0) / sizeof(js::Value) - 1)
832 #define OBJ_CHECK_SLOT(obj,slot) \
833 (JS_ASSERT((obj)->isNative()), JS_ASSERT(slot < (obj)->scope()->freeslot))
838 * The GC runs only when all threads except the one on which the GC is active
839 * are suspended at GC-safe points, so calling obj->getSlot() from the GC's
840 * thread is safe when rt->gcRunning is set. See jsgc.cpp for details.
842 #define THREAD_IS_RUNNING_GC(rt, thread) \
843 ((rt)->gcRunning && (rt)->gcThread == (thread))
845 #define CX_THREAD_IS_RUNNING_GC(cx) \
846 THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread)
848 #endif /* JS_THREADSAFE */
851 OBJ_TO_INNER_OBJECT(JSContext
*cx
, JSObject
*&obj
)
853 if (JSObjectOp op
= obj
->getClass()->ext
.innerObject
)
858 OBJ_TO_OUTER_OBJECT(JSContext
*cx
, JSObject
*&obj
)
860 if (JSObjectOp op
= obj
->getClass()->ext
.outerObject
)
869 JSValueArray(jsval
*v
, size_t c
) : array(v
), length(c
) {}
877 ValueArray(js::Value
*v
, size_t c
) : array(v
), length(c
) {}
880 extern js::Class js_ObjectClass
;
881 extern js::Class js_WithClass
;
882 extern js::Class js_BlockClass
;
884 inline bool JSObject::isObject() const { return getClass() == &js_ObjectClass
; }
885 inline bool JSObject::isWith() const { return getClass() == &js_WithClass
; }
886 inline bool JSObject::isBlock() const { return getClass() == &js_BlockClass
; }
889 * Block scope object macros. The slots reserved by js_BlockClass are:
891 * JSSLOT_PRIVATE JSStackFrame * active frame pointer or null
892 * JSSLOT_BLOCK_DEPTH int depth of block slots in frame
894 * After JSSLOT_BLOCK_DEPTH come one or more slots for the block locals.
896 * A With object is like a Block object, in that both have one reserved slot
897 * telling the stack depth of the relevant slots (the slot whose value is the
898 * object named in the with statement, the slots containing the block's local
899 * variables); and both have a private slot referring to the JSStackFrame in
900 * whose activation they were created (or null if the with or block object
901 * outlives the frame).
903 static const uint32 JSSLOT_BLOCK_DEPTH
= JSSLOT_PRIVATE
+ 1;
906 OBJ_IS_CLONED_BLOCK(JSObject
*obj
)
908 return obj
->getProto() != NULL
;
911 static const uint32 JSSLOT_WITH_THIS
= JSSLOT_PRIVATE
+ 2;
914 js_DefineBlockVariable(JSContext
*cx
, JSObject
*obj
, jsid id
, intN index
);
916 #define OBJ_BLOCK_COUNT(cx,obj) \
917 ((OBJ_IS_CLONED_BLOCK(obj) ? obj->getProto() : obj)->scope()->entryCount)
918 #define OBJ_BLOCK_DEPTH(cx,obj) \
919 obj->getSlot(JSSLOT_BLOCK_DEPTH).toInt32()
920 #define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \
921 obj->setSlot(JSSLOT_BLOCK_DEPTH, Value(Int32Value(depth)))
924 * To make sure this slot is well-defined, always call js_NewWithObject to
925 * create a With object, don't call js_NewObject directly. When creating a
926 * With object that does not correspond to a stack slot, pass -1 for depth.
928 * When popping the stack across this object's "with" statement, client code
929 * must call withobj->setPrivate(NULL).
931 extern JS_REQUIRES_STACK JSObject
*
932 js_NewWithObject(JSContext
*cx
, JSObject
*proto
, JSObject
*parent
, jsint depth
);
935 js_UnwrapWithObject(JSContext
*cx
, JSObject
*withobj
)
937 JS_ASSERT(withobj
->getClass() == &js_WithClass
);
938 return withobj
->getProto();
942 * Create a new block scope object not linked to any proto or parent object.
943 * Blocks are created by the compiler to reify let blocks and comprehensions.
944 * Only when dynamic scope is captured do they need to be cloned and spliced
945 * into an active scope chain.
948 js_NewBlockObject(JSContext
*cx
);
951 js_CloneBlockObject(JSContext
*cx
, JSObject
*proto
, JSStackFrame
*fp
);
953 extern JS_REQUIRES_STACK JSBool
954 js_PutBlockObject(JSContext
*cx
, JSBool normalUnwind
);
957 js_XDRBlockObject(JSXDRState
*xdr
, JSObject
**objp
);
959 struct JSSharpObjectMap
{
965 #define SHARP_BIT ((jsatomid) 1)
966 #define BUSY_BIT ((jsatomid) 2)
967 #define SHARP_ID_SHIFT 2
968 #define IS_SHARP(he) (uintptr_t((he)->value) & SHARP_BIT)
969 #define MAKE_SHARP(he) ((he)->value = (void *) (uintptr_t((he)->value)|SHARP_BIT))
970 #define IS_BUSY(he) (uintptr_t((he)->value) & BUSY_BIT)
971 #define MAKE_BUSY(he) ((he)->value = (void *) (uintptr_t((he)->value)|BUSY_BIT))
972 #define CLEAR_BUSY(he) ((he)->value = (void *) (uintptr_t((he)->value)&~BUSY_BIT))
975 js_EnterSharpObject(JSContext
*cx
, JSObject
*obj
, JSIdArray
**idap
,
979 js_LeaveSharpObject(JSContext
*cx
, JSIdArray
**idap
);
982 * Mark objects stored in map if GC happens between js_EnterSharpObject
983 * and js_LeaveSharpObject. GC calls this when map->depth > 0.
986 js_TraceSharpMap(JSTracer
*trc
, JSSharpObjectMap
*map
);
989 js_HasOwnPropertyHelper(JSContext
*cx
, JSLookupPropOp lookup
, uintN argc
,
993 js_HasOwnProperty(JSContext
*cx
, JSLookupPropOp lookup
, JSObject
*obj
, jsid id
,
994 JSObject
**objp
, JSProperty
**propp
);
997 js_NewPropertyDescriptorObject(JSContext
*cx
, jsid id
, uintN attrs
,
998 const js::Value
&getter
, const js::Value
&setter
,
999 const js::Value
&value
, js::Value
*vp
);
1002 js_PropertyIsEnumerable(JSContext
*cx
, JSObject
*obj
, jsid id
, js::Value
*vp
);
1004 #ifdef OLD_GETTER_SETTER_METHODS
1005 JS_FRIEND_API(JSBool
) js_obj_defineGetter(JSContext
*cx
, uintN argc
, js::Value
*vp
);
1006 JS_FRIEND_API(JSBool
) js_obj_defineSetter(JSContext
*cx
, uintN argc
, js::Value
*vp
);
1010 js_InitObjectClass(JSContext
*cx
, JSObject
*obj
);
1013 js_InitClass(JSContext
*cx
, JSObject
*obj
, JSObject
*parent_proto
,
1014 js::Class
*clasp
, js::Native constructor
, uintN nargs
,
1015 JSPropertySpec
*ps
, JSFunctionSpec
*fs
,
1016 JSPropertySpec
*static_ps
, JSFunctionSpec
*static_fs
);
1019 * Select Object.prototype method names shared between jsapi.cpp and jsobj.cpp.
1021 extern const char js_watch_str
[];
1022 extern const char js_unwatch_str
[];
1023 extern const char js_hasOwnProperty_str
[];
1024 extern const char js_isPrototypeOf_str
[];
1025 extern const char js_propertyIsEnumerable_str
[];
1027 #ifdef OLD_GETTER_SETTER_METHODS
1028 extern const char js_defineGetter_str
[];
1029 extern const char js_defineSetter_str
[];
1030 extern const char js_lookupGetter_str
[];
1031 extern const char js_lookupSetter_str
[];
1035 * Allocate a new native object with the given value of the proto and private
1036 * slots. The parent slot is set to the value of proto's parent slot.
1038 * clasp must be a native class. proto must be the result of a call to
1039 * js_InitClass(...clasp, ...).
1041 * Note that this is the correct global object for native class instances, but
1042 * not for user-defined functions called as constructors. Functions used as
1043 * constructors must create instances parented by the parent of the function
1044 * object, not by the parent of its .prototype object value.
1047 js_NewObjectWithClassProto(JSContext
*cx
, js::Class
*clasp
, JSObject
*proto
,
1048 const js::Value
&privateSlotValue
);
1051 js_PopulateObject(JSContext
*cx
, JSObject
*newborn
, JSObject
*props
);
1054 * Fast access to immutable standard objects (constructors and prototypes).
1057 js_GetClassObject(JSContext
*cx
, JSObject
*obj
, JSProtoKey key
,
1061 js_SetClassObject(JSContext
*cx
, JSObject
*obj
, JSProtoKey key
,
1062 JSObject
*cobj
, JSObject
*prototype
);
1065 * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
1066 * JSProto_Null, clasp must non-null.
1069 js_FindClassObject(JSContext
*cx
, JSObject
*start
, JSProtoKey key
,
1070 js::Value
*vp
, js::Class
*clasp
= NULL
);
1073 js_ConstructObject(JSContext
*cx
, js::Class
*clasp
, JSObject
*proto
,
1074 JSObject
*parent
, uintN argc
, js::Value
*argv
);
1077 js_AllocSlot(JSContext
*cx
, JSObject
*obj
, uint32
*slotp
);
1080 js_FreeSlot(JSContext
*cx
, JSObject
*obj
, uint32 slot
);
1083 * Ensure that the object has at least JSCLASS_RESERVED_SLOTS(clasp)+nreserved
1084 * slots. The function can be called only for native objects just created with
1085 * js_NewObject or its forms. In particular, the object should not be shared
1086 * between threads and its dslots array must be null.
1089 js_EnsureReservedSlots(JSContext
*cx
, JSObject
*obj
, size_t nreserved
);
1092 js_CheckForStringIndex(jsid id
);
1095 * js_PurgeScopeChain does nothing if obj is not itself a prototype or parent
1096 * scope, else it reshapes the scope and prototype chains it links. It calls
1097 * js_PurgeScopeChainHelper, which asserts that obj is flagged as a delegate
1098 * (i.e., obj has ever been on a prototype or parent chain).
1101 js_PurgeScopeChainHelper(JSContext
*cx
, JSObject
*obj
, jsid id
);
1104 js_PurgeScopeChain(JSContext
*cx
, JSObject
*obj
, jsid id
)
1106 if (obj
->isDelegate())
1107 js_PurgeScopeChainHelper(cx
, obj
, id
);
1111 * Find or create a property named by id in obj's scope, with the given getter
1112 * and setter, slot, attributes, and other members.
1114 extern JSScopeProperty
*
1115 js_AddNativeProperty(JSContext
*cx
, JSObject
*obj
, jsid id
,
1116 js::PropertyOp getter
, js::PropertyOp setter
, uint32 slot
,
1117 uintN attrs
, uintN flags
, intN shortid
);
1120 * Change sprop to have the given attrs, getter, and setter in scope, morphing
1121 * it into a potentially new JSScopeProperty. Return a pointer to the changed
1122 * or identical property.
1124 extern JSScopeProperty
*
1125 js_ChangeNativePropertyAttrs(JSContext
*cx
, JSObject
*obj
,
1126 JSScopeProperty
*sprop
, uintN attrs
, uintN mask
,
1127 js::PropertyOp getter
, js::PropertyOp setter
);
1130 js_DefineOwnProperty(JSContext
*cx
, JSObject
*obj
, jsid id
,
1131 const js::Value
&descriptor
, JSBool
*bp
);
1134 * Flags for the defineHow parameter of js_DefineNativeProperty.
1136 const uintN JSDNP_CACHE_RESULT
= 1; /* an interpreter call from JSOP_INITPROP */
1137 const uintN JSDNP_DONT_PURGE
= 2; /* suppress js_PurgeScopeChain */
1138 const uintN JSDNP_SET_METHOD
= 4; /* js_{DefineNativeProperty,SetPropertyHelper}
1139 must pass the JSScopeProperty::METHOD
1140 flag on to js_AddScopeProperty */
1141 const uintN JSDNP_UNQUALIFIED
= 8; /* Unqualified property set. Only used in
1142 the defineHow argument of
1143 js_SetPropertyHelper. */
1146 * On error, return false. On success, if propp is non-null, return true with
1147 * obj locked and with a held property in *propp; if propp is null, return true
1148 * but release obj's lock first. Therefore all callers who pass non-null propp
1149 * result parameters must later call obj->dropProperty(cx, *propp) both to drop
1150 * the held property, and to release the lock on obj.
1153 js_DefineNativeProperty(JSContext
*cx
, JSObject
*obj
, jsid id
, const js::Value
&value
,
1154 js::PropertyOp getter
, js::PropertyOp setter
, uintN attrs
,
1155 uintN flags
, intN shortid
, JSProperty
**propp
,
1156 uintN defineHow
= 0);
1159 * Specialized subroutine that allows caller to preset JSRESOLVE_* flags and
1160 * returns the index along the prototype chain in which *propp was found, or
1161 * the last index if not found, or -1 on error.
1164 js_LookupPropertyWithFlags(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN flags
,
1165 JSObject
**objp
, JSProperty
**propp
);
1169 * We cache name lookup results only for the global object or for native
1170 * non-global objects without prototype or with prototype that never mutates,
1171 * see bug 462734 and bug 487039.
1174 js_IsCacheableNonGlobalScope(JSObject
*obj
)
1176 extern JS_FRIEND_DATA(js::Class
) js_CallClass
;
1177 extern JS_FRIEND_DATA(js::Class
) js_DeclEnvClass
;
1178 JS_ASSERT(obj
->getParent());
1180 js::Class
*clasp
= obj
->getClass();
1181 bool cacheable
= (clasp
== &js_CallClass
||
1182 clasp
== &js_BlockClass
||
1183 clasp
== &js_DeclEnvClass
);
1185 JS_ASSERT_IF(cacheable
, !obj
->getOps()->lookupProperty
);
1190 * If cacheResult is false, return JS_NO_PROP_CACHE_FILL on success.
1192 extern js::PropertyCacheEntry
*
1193 js_FindPropertyHelper(JSContext
*cx
, jsid id
, JSBool cacheResult
,
1194 JSObject
**objp
, JSObject
**pobjp
, JSProperty
**propp
);
1197 * Return the index along the scope chain in which id was found, or the last
1198 * index if not found, or -1 on error.
1200 extern JS_FRIEND_API(JSBool
)
1201 js_FindProperty(JSContext
*cx
, jsid id
, JSObject
**objp
, JSObject
**pobjp
,
1202 JSProperty
**propp
);
1204 extern JS_REQUIRES_STACK JSObject
*
1205 js_FindIdentifierBase(JSContext
*cx
, JSObject
*scopeChain
, jsid id
);
1208 js_FindVariableScope(JSContext
*cx
, JSFunction
**funp
);
1211 * JSGET_CACHE_RESULT is the analogue of JSDNP_CACHE_RESULT for js_GetMethod.
1213 * JSGET_METHOD_BARRIER (the default, hence 0 but provided for documentation)
1214 * enables a read barrier that preserves standard function object semantics (by
1215 * default we assume our caller won't leak a joined callee to script, where it
1216 * would create hazardous mutable object sharing as well as observable identity
1217 * according to == and ===.
1219 * JSGET_NO_METHOD_BARRIER avoids the performance overhead of the method read
1220 * barrier, which is not needed when invoking a lambda that otherwise does not
1221 * leak its callee reference (via arguments.callee or its name).
1223 const uintN JSGET_CACHE_RESULT
= 1; // from a caching interpreter opcode
1224 const uintN JSGET_METHOD_BARRIER
= 0; // get can leak joined function object
1225 const uintN JSGET_NO_METHOD_BARRIER
= 2; // call to joined function can't leak
1228 * NB: js_NativeGet and js_NativeSet are called with the scope containing sprop
1229 * (pobj's scope for Get, obj's for Set) locked, and on successful return, that
1230 * scope is again locked. But on failure, both functions return false with the
1231 * scope containing sprop unlocked.
1234 js_NativeGet(JSContext
*cx
, JSObject
*obj
, JSObject
*pobj
,
1235 JSScopeProperty
*sprop
, uintN getHow
, js::Value
*vp
);
1238 js_NativeSet(JSContext
*cx
, JSObject
*obj
, JSScopeProperty
*sprop
, bool added
,
1242 js_GetPropertyHelper(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN getHow
,
1246 js_GetOwnPropertyDescriptor(JSContext
*cx
, JSObject
*obj
, jsid id
, js::Value
*vp
);
1249 js_GetMethod(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN getHow
, js::Value
*vp
);
1252 * Check whether it is OK to assign an undeclared property with name
1253 * propname of the global object in the current script on cx. Reports
1254 * an error if one needs to be reported (in particular in all cases
1255 * when it returns false).
1257 extern JS_FRIEND_API(bool)
1258 js_CheckUndeclaredVarAssignment(JSContext
*cx
, JSString
*propname
);
1261 js_SetPropertyHelper(JSContext
*cx
, JSObject
*obj
, jsid id
, uintN defineHow
,
1265 * Change attributes for the given native property. The caller must ensure
1266 * that obj is locked and this function always unlocks obj on return.
1269 js_SetNativeAttributes(JSContext
*cx
, JSObject
*obj
, JSScopeProperty
*sprop
,
1275 DefaultValue(JSContext
*cx
, JSObject
*obj
, JSType hint
, Value
*vp
);
1278 CheckAccess(JSContext
*cx
, JSObject
*obj
, jsid id
, JSAccessMode mode
,
1279 js::Value
*vp
, uintN
*attrsp
);
1281 } /* namespace js */
1284 js_IsDelegate(JSContext
*cx
, JSObject
*obj
, const js::Value
&v
);
1287 * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
1288 * JSProto_Null, clasp must non-null.
1290 extern JS_FRIEND_API(JSBool
)
1291 js_GetClassPrototype(JSContext
*cx
, JSObject
*scope
, JSProtoKey protoKey
,
1292 JSObject
**protop
, js::Class
*clasp
= NULL
);
1295 js_SetClassPrototype(JSContext
*cx
, JSObject
*ctor
, JSObject
*proto
,
1299 * Wrap boolean, number or string as Boolean, Number or String object.
1300 * *vp must not be an object, null or undefined.
1303 js_PrimitiveToObject(JSContext
*cx
, js::Value
*vp
);
1306 * v and vp may alias. On successful return, vp->isObjectOrNull(). If vp is not
1307 * rooted, the caller must root vp before the next possible GC.
1310 js_ValueToObjectOrNull(JSContext
*cx
, const js::Value
&v
, JSObject
**objp
);
1313 * v and vp may alias. On successful return, vp->isObject(). If vp is not
1314 * rooted, the caller must root vp before the next possible GC.
1317 js_ValueToNonNullObject(JSContext
*cx
, const js::Value
&v
);
1320 js_TryValueOf(JSContext
*cx
, JSObject
*obj
, JSType type
, js::Value
*rval
);
1323 js_TryMethod(JSContext
*cx
, JSObject
*obj
, JSAtom
*atom
,
1324 uintN argc
, js::Value
*argv
, js::Value
*rval
);
1327 js_XDRObject(JSXDRState
*xdr
, JSObject
**objp
);
1330 js_TraceObject(JSTracer
*trc
, JSObject
*obj
);
1333 js_PrintObjectSlotName(JSTracer
*trc
, char *buf
, size_t bufsize
);
1336 js_ClearNative(JSContext
*cx
, JSObject
*obj
);
1339 js_GetReservedSlot(JSContext
*cx
, JSObject
*obj
, uint32 index
, js::Value
*vp
);
1342 js_SetReservedSlot(JSContext
*cx
, JSObject
*obj
, uint32 index
, const js::Value
&v
);
1345 js_CheckPrincipalsAccess(JSContext
*cx
, JSObject
*scopeobj
,
1346 JSPrincipals
*principals
, JSAtom
*caller
);
1348 /* For CSP -- checks if eval() and friends are allowed to run. */
1350 js_CheckContentSecurityPolicy(JSContext
*cx
);
1352 /* Infallible -- returns its argument if there is no wrapped object. */
1354 js_GetWrappedObject(JSContext
*cx
, JSObject
*obj
);
1356 /* NB: Infallible. */
1358 js_ComputeFilename(JSContext
*cx
, JSStackFrame
*caller
,
1359 JSPrincipals
*principals
, uintN
*linenop
);
1362 js_ReportGetterOnlyAssignment(JSContext
*cx
);
1364 extern JS_FRIEND_API(JSBool
)
1365 js_GetterOnlyPropertyStub(JSContext
*cx
, JSObject
*obj
, jsid id
, jsval
*vp
);
1368 JS_FRIEND_API(void) js_DumpChars(const jschar
*s
, size_t n
);
1369 JS_FRIEND_API(void) js_DumpString(JSString
*str
);
1370 JS_FRIEND_API(void) js_DumpAtom(JSAtom
*atom
);
1371 JS_FRIEND_API(void) js_DumpObject(JSObject
*obj
);
1372 JS_FRIEND_API(void) js_DumpValue(const js::Value
&val
);
1373 JS_FRIEND_API(void) js_DumpId(jsid id
);
1374 JS_FRIEND_API(void) js_DumpStackFrame(JSContext
*cx
, JSStackFrame
*start
= NULL
);
1378 js_InferFlags(JSContext
*cx
, uintN defaultFlags
);
1380 /* Object constructor native. Exposed only so the JIT can know its address. */
1382 js_Object(JSContext
*cx
, uintN argc
, js::Value
*vp
);
1388 SetProto(JSContext
*cx
, JSObject
*obj
, JSObject
*proto
, bool checkForCycles
);
1395 obj_toStringHelper(JSContext
*cx
, JSObject
*obj
);
1398 #endif /* jsobj_h___ */