Skip to main content

Module calls

Module calls 

Source
Expand description

Calling JavaScript from C: JS_Call, JS_Invoke, JS_CallConstructor, the JS_Is* predicates, and JS_NewCFunctionData.

§Why every call goes through with_context

A C caller that calls a script function which in turn calls a C function arrives back in this file one frame deeper. The interpreter is held mutably by the engine for the whole outer call, so the nested entry point cannot borrow it again — it has to find the one the engine is using, which is what JsContext::with_current_interp does. A call that skipped the guard would work at top level and deadlock one level down, which is the kind of bug this file is written to make impossible rather than to find later.

Functions§

JS_Call⚠
JS_Call: call func_obj with this_obj as this.
JS_CallConstructor⚠
JS_CallConstructor: new func_obj(...).
JS_CallConstructor2⚠
JS_CallConstructor2: Reflect.construct(func_obj, args, new_target).
JS_CreateFromConstructor⚠
JS_CreateFromConstructor: an instance of class_id whose prototype comes from ctor.
JS_EnqueueJob⚠
JS_EnqueueJob: run job_func at the next job checkpoint.
JS_EvalFunction⚠
JS_EvalFunction: run a function object’s bytecode, returning its value.
JS_ExecutePendingJob⚠
JS_ExecutePendingJob: run queued jobs, answering 1 when one ran.
JS_GetAnyOpaque⚠
JS_NewObjectProtoClass’s companion: the class id of a value, or 0.
JS_GetIterator⚠
JS_GetIterator: the iterator object for obj.
JS_Invoke⚠
JS_Invoke: read this_val[atom] and call it.
JS_IsArray⚠
JS_IsArray: whether the value is an array.
JS_IsArrayBuffer⚠
JS_IsArrayBuffer: whether the value is an ArrayBuffer (not a view of one).
JS_IsCFunction⚠
JS_IsCFunction: whether the value is this C function (same pointer, same magic).
JS_IsConstructor⚠
JS_IsConstructor: whether new is allowed.
JS_IsError⚠
JS_IsError: whether the value is an Error instance.
JS_IsFunction⚠
JS_IsFunction: whether the value is callable.
JS_IsImmutableArrayBuffer⚠
JS_IsImmutableArrayBuffer: whether the buffer is frozen against writes.
JS_IsInstanceOf⚠
JS_IsInstanceOf: val instanceof obj, going through Symbol.hasInstance.
JS_IsJobPending⚠
JS_IsJobPending: whether a job is waiting for JS_ExecutePendingJob.
JS_IsLiveObject⚠
JS_IsLiveObject: whether obj is still reachable.
JS_IteratorClose⚠
JS_IteratorClose: close the iterator, optionally while an exception is pending.
JS_IteratorNext⚠
JS_IteratorNext: advance the iterator, filling pdone.
JS_NewCConstructor⚠
JS_NewCConstructor: the one-call constructor registration.
JS_NewCFunctionData⚠
JS_NewCFunctionData: a function carrying data_len captured values.
JS_NewPromiseCapability⚠
JS_NewPromiseCapability: a promise plus its resolve/reject functions.
JS_OrdinaryIsInstanceOf⚠
JS_OrdinaryIsInstanceOf: instanceof ignoring Symbol.hasInstance.
JS_PromiseResult⚠
JS_PromiseResult: the value a settled promise settled with.
JS_PromiseState⚠
JS_PromiseState: JS_PROMISE_PENDING (0), FULFILLED (1) or REJECTED (2).
JS_SetHostPromiseRejectionTracker⚠
JS_SetHostPromiseRejectionTracker: be told about rejected promises.
JS_SetImmutableArrayBuffer⚠
JS_SetImmutableArrayBuffer: accepted and ignored, for the reason above.