Search completed in 1.18 seconds.
39 results for "jsobject*":
Your results are loading. Please wait...
GC Rooting Guide
. Since SpiderMonkey has a moving GC, it is very important that it knows about each and every pointer to a GC thing in the system. SpiderMonkey's rooting API tries to make this task as simple as possible. What is a GC thing pointer? "GC thing" is the term used to refer to memory allocated and managed by the SpiderMonkey garbage collector. The main types of GC thing pointer are: JS::Value JSObject* JSString* JSScript* jsid Note that JS::Value and jsid can contain pointers internally even though they are not a normal pointer type, hence their inclusion in this list. If you use these types directly, or create classes, structs or arrays that contain them, you must follow the rules set out in this guide. If you do not your program will not work correctly - if it works at all. GC things ...
...re the underlying pointer. JS::Rooted must be constructed with a JSContext*, and optionally an initial value. There are typedefs available for the main types. ...
... JS::Handle<T> All GC...
...And 9 more matches
WebIDL bindings
ouble double double double float float float float interface: non-nullable Foo& already_addRefed<Foo> Foo* OwningNonNull<Foo> interface: nullable Foo* already_addRefed<Foo> Foo* RefPtr<Foo> long int32_t int32_t int32_t long long int64_t int64_t int64_t object JS::Handle<JSObject*> JS::MutableHandle<JSObject*> JSObject* octet uint8_t uint8_t uint8_t sequence const Sequence<T>& nsTArray<T>& (outparam) short int16_t int16_t int16_t unrestricted double double double double unrestricted float float float float unsigned long uint32_t uint32_t uint32_t unsi...
... sequences, dictionaries, owning unions, and variadic arguments becomes nsCString. Nullable ByteString are represented by the same types as non-nullable ones, but the string will return true for IsVoid(). Returning null as a string value can be done using SetIsVoid() on the out param. object object is represented in three different ways, depending on use: object arguments become JS::Handle<JSObject*>. They will be in the compartment of the passed-in JSContext. object return values become a JS::MutableHandle<JSObject*> out param appended to the argument list. This comes after all IDL arguments, but before the ErrorResult&, if any, for the method. The return value is allowed to be in any compartment; bindings will wrap it into the context compartment as needed. object dictionary members an...
...The dictionary members and sequence elements are guaranteed to be marked by whoever puts the sequence or dictionary on the stack, using SequenceRooter and DictionaryRooter. Methods using object always get a JSContext* argument. ...
...And 9 more matches
JS_NewFunction
Requires request. In a JS_THREADSAFE build, the caller must...
...Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. call JSNative Native C/C++ implementation of this function. nargs unsigned Number of arguments th...
...ion. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. call JSNative Native C/C++ implementation of this function. nargs unsigned Number of arguments the function expects. flags unsigned Pass JSFUN_CONSTRUCTOR to make a native that can be called as a constructor, otherwise 0. parent JS::Handle&lt;JSObject*&gt; Pointer to the parent object for this function. If this is NULL, a default parent object is used. Obsolete since JSAPI 39 name const char * Name to assign to the new function. If this is NULL, the new function has no name. id JS::Handle&lt;jsid&gt; A pointer to jsid of the name to assign to the new function. Added in SpiderMonkey 17 Description JS_NewF...
JS_NewObject
Creates a new JavaScript object. Syntax // Added in SpiderMonkey 45 JSObject * JS_NewObject(JSContext *cx, const JSClass *clasp); bool JS_NewObjectWithGivenProto(JSContext *cx, const JSClass *clasp, JS::Handle<JSObject*> proto); // Obsolete since SpiderMonkey 38 JSObject * JS_NewObject(JSContext *cx, const JSClass *clasp, JS::Handle<JSObject*> proto, JS::Handle<JSObject*> parent); JSObject * JS_NewObjectWithGivenProto(JSContext *cx, const JSClass *clasp, JS::Handle<JSObject*> proto, JS::Handle<JSObject*> parent); // Added in SpiderMonkey 1.8 Name Type Description cx JSContext * The context in which to create the new object. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. ...
...d in SpiderMonkey 1.8.1 clasp->flags must not have the JSCLASS_GLOBAL_FLAGS bits set (use JS_NewGlobalObject instead). If clasp is non-null, the caller must ensure that the JSClass remains alive throughout the lifetime of the new object, including the garbage collection cycle that finally frees it. The usual way to do this is to make JSClasses global or static. proto JS::Handle&lt;JSObject*&gt; Pointer to the prototype object to use for the new object. The new object will inherit all of the prototype object's properties and methods, and the new object's __proto__ property will be a reference to the prototype object. JS_NewObject: If this is NULL, a default prototype object is used. Obsolete since JSAPI 38 JS_NewObject now always uses a default prototype object. ...
...and the new object's __proto__ property will be a reference to the prototype object. JS_NewObject: If this is NULL, a default prototype object is used. Obsolete since JSAPI 38 JS_NewObject now always uses a default prototype object. JS_NewObjectWithGivenProto: If this is NULL, the new object has no prototype; its __proto__ property is undefined. parent JS::Handle&lt;JSObject*&gt; Pointer to the parent of the new object. The new object's __parent__ property will be a reference to this object. If parent is NULL, a default parent object is used. Obsolete since JSAPI 39 Description JS_NewObject creates a new object based on a specified class. cx is a pointer to a context associated with the runtime in which to establish the new object. clasp is a pointer to an ...
JS::ObjectOrNullValue
Description JS::ObjectValue converts a given JSObject to JS::Value. ...
... Description JS::ObjectValue converts a given JSObject to JS::Value. ...
JS::Value
The different representations are visible using the separate int32/double methods but do not affect observable semantics (ignoring performance). The number mu...
...on was required. Any double value may be stored in a JS::Value, in one of these two representations. The only exception is that only a single NaN value can be represented. (Note that both -0 and +0 are allowed, and the latter may sometimes be stored using the int32_t representation.) JS::Value further provides these methods combining various aspects of the above methods: JS::ObjectOrNullValue(JSObject*) returns an object value corresponding to the given non-null pointer, or a null value if the pointer is null. val.setObjectOrNull(JSObject *) sets the given value to the specified object, or to null if the pointer was null. val.isObjectOrNull() returns true if the value is either an object or undefined. Correspondingly, val.toObjectOrNull() returns a non-null JSObject * if the value is an obje...
JS_DeepFreezeObject
Description JS_DeepFreezeObject freezes obj, and all objects it refers to, recursively. ...
... Description JS_DeepFreezeObject freezes obj, and all objects it refers to, recursively. ...
JS_DefineFunction
Create a native function and assign it as a property to a specified JS object. Syntax JSFunction * JS_DefineFunction(JSContext *cx, JS::Handle<JSObject*> obj, const char *name, JSNative call, unsigned nargs, unsigned attrs); JSFunction * JS_DefineUCFunction(JSContext *cx, JS::Handle<JSObject*> obj, const char16_t *name, size_t namelen, JSNative call, unsigned nargs, unsigned attrs); JSFunction * JS_DefineFunctionById(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSNative call, unsigned nargs, unsigned attrs); // Added in SpiderMonkey 17 Name Type Description cx JSContext * The context in which to define the function. ...
... name const char * or const char16_t * Name to assign to the function. id JS::Handle&lt;jsid&gt; A pointer to jsid for name to assign to the function. Added in SpiderMonkey 17 call JSNative The native C/C++ function to be wrapped by the new function. ...
JS_DefineFunctions
fs const JSFunctionSpec * A NULL-terminated array of function specifications. ...
...ionSpec *fs, PropertyDefinitionBehavior behavior = DefineAllProperties); In SpiderMonkey versions prior to SpiderMonkey 24, fs was not const. Name Type Description cx JSContext * The context in which to define functions. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::Handle&lt;JSObject*&gt; The object on which functions are to be defined. fs const JSFunctionSpec * A NULL-terminated array of function specifications. Each element of the array defines an individual function. behavior PropertyDefinitionBehavior See below. Added in SpiderMonkey 38 enum PropertyDefinitionBehavior { DefineAllProperties, OnlyDefineLateProperties, DontD...
JS_FreezeObject
Description Freezes an object. This means that other code cannot delete, add or change any properties on the object. See ES5's Object.freeze method. ...
... Description Freezes an object. This means that other code cannot delete, add or change any properties on the object. See ES5's Object.freeze method. ...
JS_GetArrayLength
lengthp uint32_t * Out parameter. On success, *lengthp receives the length of the array. ...
... lengthp uint32_t * Out parameter. On success, *lengthp receives the length of the array. Description JS_GetArrayLength gets the .length property of obj as though by calling JS_GetProperty and converts it to a 32-bit unsigned integer. ...
JS_GetClassObject
If successful, receive the class constructor. Description JS_GetClassObject gets the builtin class costructor for the specified prototype key. ...
...If successful, receive the class constructor. Description JS_GetClassObject gets the builtin class costructor for the specified prototype key. ...
JS_GetClassPrototype
If successful, receive the class prototype object. Description JS_GetClassPrototype gets the builtin class costructor for the specified prototype key. ...
...If successful, receive the class prototype object. Description JS_GetClassPrototype gets the builtin class costructor for the specified prototype key. ...
JS_GetConstructor
Description JS_GetConstructor retrieves the constructor property of a given object, obj. If the result is a Function object, JS_GetConstructor returns a pointer to that object. Otherwise, it reports an error and returns NULL. To get an object's prototype, use JS_GetPrototype. ...
... Description JS_GetConstructor retrieves the constructor property of a given object, obj. If the result is a Function object, JS_GetConstructor returns a pointer to that object. Otherwise, it reports an error and returns NULL. To get an object's prototype, use JS_GetPrototype. ...
JS_HasInstance
v JS::Handle&lt;JS::Value&gt; The value to test. bp bool * Out parameter. On success, *bp receives the result of the test. ...
... v JS::Handle&lt;JS::Value&gt; The value to test. bp bool * Out parameter. On success, *bp receives the result of the test. Description JS_HasInstance determines if a specified JS value, v, is an instance of JS object, obj. ...
JS_InitStandardClasses
This object must be of a JSClass that has the JSCLASS_GLOBAL_FLAGS bits set. ...
...This object must be of a JSClass that has the JSCLASS_GLOBAL_FLAGS bits set. Description JS_InitStandardClasses initializes the built-in JavaScript global properties. ...
JS_SetArrayLength
length uint32_t Number of array elements to set. Description JS_SetArrayLength sets the .length property of an object obj. length indicates the number of elements. ...
... length uint32_t Number of array elements to set. Description JS_SetArrayLength sets the .length property of an object obj. length indicates the number of elements. ...
JS::PerfMeasurement
e the results available to JavaScript, you can declare a bare jsval argument in your .idl file and have JavaScript pass a PerfMeasurement object that it created in that argument slot. The jsval you receive points to a JavaScript wrapper object. To extract the C++-level PerfMeasurement object, call this function. It will return NULL if JavaScript passed in something with the wrong dynamic type. JSObject* JS::RegisterPerfMeasurement(JSContext* cx, JSObject* global) You shouldn't need to use this function, but we mention it for completeness. It initializes the JavaScript wrapper interface for this API and pokes the constructor function into the global object you provide. ...
Hacking Tips
ignore OOM For example if you are performing a speculative optimisation you might abandon it and continue anyway. But in this case you may have to call cx->recoverFromOutOfMemory() if something further down the stack has already reported the failure. Debugging GC marking/rooting The js::debug namespace contains some functions that are useful for watching mark bits for an individual JSObject* (or any Cell*). js/src/gc/Heap.h contains a comment describing an example usage. Reproduced here: // Sample usage from gdb: // // (gdb) p $word = js::debug::GetMarkWordAddress(obj) // $1 = (uintptr_t *) 0x7fa56d5fe360 // (gdb) p/x $mask = js::debug::GetMarkMask(obj, js::gc::GRAY) // $2 = 0x200000000 // (gdb) watch *$word // Hardware watchpoint 7: *$word // (gdb) cond 7 *$word & $ma...
Garbage collection
he weak ref will be marked. Implementation details Write barriers have a runtime cost, so SpiderMonkey tries to skip them when an incremental GC cycle is not active. Each Zone has a flag needsIncrementalBarrier() that indicates whether barriers are required. For each type T such that fields of type T* need a write barrier, there is a functionT::writeBarrierPre(old). For example, fields of type JSObject* need a write barrier, so there is a function JSObject::writeBarrierPre(JSObject* old). If zone->needsIncrementalBarrier(), then writeBarrierPre() marks old. That's it. The class Heap<T> is provided to make it easy to invoke write barriers. A Heap<T> encapsulates a T* and invokes the write barrier whenever assigned to. Thus, object fields of GC-pointer type should normally be defined as type Heap...
JS::Handle
nerated, which is quicker and easier to fix than when relying on a separate rooting analysis. If you want to add additional methods to JS::Handle for a specific specialization, define a js::HandleBase<T> specialization containing them. ...
JS::MutableHandle
T&gt; by using |JS::Rooted<T>::operator&()|. If you want to add additional methods to JS::MutableHandle for a specific specialization, define a js::MutableHandleBase<T> specialization containing them. ...
JS::PersistentRooted
nkey 38, PersistentRooted<T> itself cannot be a global variable, but from SpiderMonkey38, it can be declared as a global variable, and initialized later with init() method (bug 1107639). ...
JS::Rooted
ed<T> may be automatically coerced to a JS::Handle&lt;T&gt;. JS::Rooted<T> should be used whenever a local variable's value may be held live across a call which can trigger a GC. If you want to add additional methods to Rooted for a specific specialization, define a js::RootedBase<T> specialization containing them. ...
JS_Add*Root
SAFE build, the caller must be in a request on this JSContext. vp jsval * (In JS_AddValueRoot and JS_AddNamedValueRoot) The address of the jsval variable to root spp JSString ** (In JS_AddStringRoot and JS_AddNamedStringRoot) The address of the JSString* variable to root opp JSObject ** (In JS_AddObjectRoot and JS_AddNamedObjectRoot) The address of the JSObject* variable to root rp void ** (In JS_AddGCThingRoot and JS_AddNamedGCThingRoot) The address of the JSString* or JSObject* (not jsval) variable to root name const char * (in JS_AddNamedRoot and JS_AddNamedRootRT) The name of the new root, or NULL. Description The JS_Add*Root and functions add a C/C++ variable to the garbage collector's root set, the set of varia...
JS_BindCallable
This article covers features introduced in SpiderMonkey 17 Bind the given callable to use the given object as this. Syntax JSObject* JS_BindCallable(JSContext *cx, JS::Handle<JSObject*> callable, JS::Handle<JSObject*> newThis); Name Type Description cx JSContext * Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. callable JS::Handle&lt;JSObject*&gt; Pointer to the function object to bind new this. newThis JS::Handle&lt;JSObject*&gt; Pointer to the new this value for callable. Description JS_BindCallable binds the given callable to use the given object as this. If callable is not callable, wil...
JS_BufferIsCompilableUnit
Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::HandleObject The global object, or NULL. utf8 const char * String containing the script to compile. length size_t The length of utf8 in characters. ...
JS_DefaultValue
work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. This article covers features introduced in SpiderMonkey 1.8.6 Converts a JavaScript object to a primitive value, using the semantics of that object's internal [[DefaultValue]] hook. Renamed to JS::ToPrimitive from JSAPI 44. Syntax bool JS_DefaultValue(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::MutableHandle<JS::Value> vp); Name Type Description cx JSContext * The context in which to perform the conversion. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::Handle&lt;JSObject*&gt; The object to convert. hint JSType The hint to pass to t...
JS_ExecuteScript
Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::HandleObject The scope in which to execute the...
JS_GET_CLASS
LASS(cx,obj) JS_GetClass(cx, obj) #else #define JS_GET_CLASS(cx,obj) JS_GetClass(obj) #endif Parameter Type Description cx JSContext * Any context associated with the runtime in which obj exists. obj JSObject * Object to get the class from. Note: In SpiderMonkey versions prior to SpiderMonkey 1.8.8, JS_GetClass took both a JSContext* and a JSObject* as arguments in thread-safe builds, and in non-thread-safe builds it took only a JSObject*. The JS_GET_CLASS(cx, obj) macro abstracted away this detail. Newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe. Description JS_GET_CLASS returns a pointer to the JSClass associated with a specified JS object, obj. The a...
JS_GetClass
Retrieves the class associated with an object. Syntax const JSClass * JS_GetClass(JSObject *obj); Name Type Description cx JSContext * Any context associated with the runtime in which obj exists. obj JSObject * Object to get the class from. In SpiderMonkey versions prior to SpiderMonkey 1.8.8, JS_GetClass took both a JSContext* and a JSObject* as arguments in thread-safe builds, and in non-thread-safe builds it took only a JSObject*. The JS_GET_CLASS(cx, obj) macro abstracted away this detail. Newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe. Description JS_GetClass returns a pointer to the JSClass associated with a specified JS object, obj. The ap...
JS_GetInstancePrivate
Retrieve the private data associated with an object, if that object is an instance of a specified class. Syntax void * JS_GetInstancePrivate(JSContext *cx, JS::Handle<JSObject*> obj, const JSClass *clasp, JS::CallArgs *args); // Added in JSAPI 32 void * JS_GetInstancePrivate(JSContext *cx, JS::Handle<JSObject*> obj, const JSClass *clasp, jsval *argv); // Obsolete since JSAPI 32 Name Type Description cx JSContext * A context. obj JS::Handle&lt;JSObject*&gt; The object for which to retrieve private data. clasp JSClass * Class against which to test the object. args JS::CallArgs * Optional argument, used for error reporting. Added in SpiderMonkey 32 argv jsval * ...
JS_InstanceOf
Determine if an object is an instance of a specified JSClass. Syntax bool JS_InstanceOf(JSContext *cx, JS::Handle<JSObject*> obj, const JSClass *clasp, JS::CallArgs *args); // Added in SpiderMonkey 38 bool JS_InstanceOf(JSContext *cx, JS::Handle<JSObject*> obj, const JSClass *clasp, jsval *argv); // Obsolete since JSAPI 32 Name Type Description cx JSContext * Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::Handle&lt;JSObject*&gt; Object to test. clasp JSClass * Class against which to test the object. args JS::CallArgs * Optional pointer to arguments. If non-null, report ...
JS_LinkConstructorAndPrototype
This article covers features introduced in SpiderMonkey 17 Set up ctor.prototype = proto and proto.constructor = ctor with the right property flags. Syntax bool JS_LinkConstructorAndPrototype(JSContext *cx, JS::Handle<JSObject*> ctor, JS::Handle<JSObject*> proto); Name Type Description cx JSContext * Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. ctor JS::Handle&lt;JSObject*&gt; Pointer to the constructor object. proto JS::Handle&lt;JSObject*&gt; Pointer to the prototype object. Description JS_LinkConstructorAndPrototype sets the prototype property of class constructor functi...
JS_NewPropertyIterator
Obsolete since JSAPI 36This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. Crate an iterator object for use with JS_NextProperty. Syntax JSObject * JS_NewPropertyIterator(JSContext *cx, JS::Handle<JSObject*> obj); Name Type Description cx JSContext * The JS context in which to enumerate properties. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::Handle&lt;JSObject*&gt; The object whose properties are to be enumerated. Description Create an object to iterate over the enumerable own properties of obj, in arbitrary order. (This differs from longstanding for..in loop order, which uses the o...
JS_Remove*Root
this JSContext. vp jsval * Address of the jsval variable to remove from the root set. This must have been passed to either JS_AddValueRoot or JS_AddNamedValueRoot. spp JSString * Address of the JSString* variable to remove from the root set. This must have been passed to either JS_AddStringRoot or JS_AddNamedStringRoot. opp JSObject * Address of the JSObject* variable to remove from the root set. This must have been passed to either JS_AddObjectRoot or JS_AddNamedObjectRoot. rp void ** Address of the pointer variable to remove from the root set. This must have been passed to either JS_AddGCThingRoot or JS_AddNamedGCThingRoot. Description JS_RemoveRoot removes the variable that rp points to from the garbage collector's root set. ...
SpiderMonkey 1.8.8
pe has changed A number of optional members have been removed from the JSCLass Prototype. JSClass Callback changes Many of the JSClass callbacks such as JSResolveOP, JSEnumerateOp and JSPropertyOp, have a type change on their arguments to JSHandleObject, JSHandleId, JSHandleMutableObject etc. Atleast for the C API this wraps an extra pointer around these objects, so you would cast the argument to JSObject**, in the callback function. Removal of JSContext* parameters to many methods The JS_GetClass method now takes only a JSObject*, where previously it also required a JSContext* in threadsafe builds. (The JS_GET_CLASS macro abstracting away this difference has accordingly been removed.) JavaScript shell changes Detail added/removed methods here... Known Issues Detail any known issues here... Future...
SpiderMonkey 17
pe has changed A number of optional members have been removed from the JSCLass Prototype. JSClass Callback changes Many of the JSClass callbacks such as JSResolveOP, JSEnumerateOp and JSPropertyOp, have a type change on their arguments to JSHandleObject, JSHandleId, JSHandleMutableObject etc. Atleast for the C API this wraps an extra pointer around these objects, so you would cast the argument to JSObject**, in the callback function. Removal of JSContext* parameters to many methods The JS_GetClass method now takes only a JSObject*, where previously it also required a JSContext* in threadsafe builds. (The JS_GET_CLASS macro abstracting away this difference has accordingly been removed.) Garbage Collection functions now take runtime argument Most garbage collection functions now take a runtime argum...
Interfacing with the XPCOM cycle collector
nsISupports or non-nsISupports objects, as well as arrays of these pointers. Handling JSObjects fields If your class needs to store a pointer to a JSObject then you need to tell the cycle collector about it. The approach you should take is as follows. Firstly it must be held in a JS::Heap<JSObject *> field. For example, suppose your class nsFoo has field mSomeObj: private: ... JS::Heap<JSObject*> mSomeObj; ... When you have something in the JS object pointer you need to use mozilla::HoldJSObjects to tell the GC to trace it and keep the object alive: ... mSomeObj = ... ; mozilla::HoldJSObjects(this); ... In the Unlink method (or destructor) you need to set the object pointer to NULL: NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFoo) ... NS_IMPL_CYCLE_COLLECTION_UNLINK(mSomeMember) ...