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: callfunc_objwiththis_objasthis.- JS_
Call ⚠Constructor JS_CallConstructor:new func_obj(...).- JS_
Call ⚠Constructor2 JS_CallConstructor2:Reflect.construct(func_obj, args, new_target).- JS_
Create ⚠From Constructor JS_CreateFromConstructor: an instance ofclass_idwhose prototype comes fromctor.- JS_
Enqueue ⚠Job JS_EnqueueJob: runjob_funcat the next job checkpoint.- JS_
Eval ⚠Function JS_EvalFunction: run a function object’s bytecode, returning its value.- JS_
Execute ⚠Pending Job JS_ExecutePendingJob: run queued jobs, answering1when one ran.- JS_
GetAny ⚠Opaque JS_NewObjectProtoClass’s companion: the class id of a value, or 0.- JS_
GetIterator ⚠ JS_GetIterator: the iterator object forobj.- JS_
Invoke ⚠ JS_Invoke: readthis_val[atom]and call it.- JS_
IsArray ⚠ JS_IsArray: whether the value is an array.- JS_
IsArray ⚠Buffer JS_IsArrayBuffer: whether the value is anArrayBuffer(not a view of one).- JS_
IsCFunction ⚠ JS_IsCFunction: whether the value is this C function (same pointer, same magic).- JS_
IsConstructor ⚠ JS_IsConstructor: whethernewis allowed.- JS_
IsError ⚠ JS_IsError: whether the value is anErrorinstance.- JS_
IsFunction ⚠ JS_IsFunction: whether the value is callable.- JS_
IsImmutable ⚠Array Buffer JS_IsImmutableArrayBuffer: whether the buffer is frozen against writes.- JS_
IsInstance ⚠Of JS_IsInstanceOf:val instanceof obj, going throughSymbol.hasInstance.- JS_
IsJob ⚠Pending JS_IsJobPending: whether a job is waiting forJS_ExecutePendingJob.- JS_
IsLive ⚠Object JS_IsLiveObject: whetherobjis still reachable.- JS_
Iterator ⚠Close JS_IteratorClose: close the iterator, optionally while an exception is pending.- JS_
Iterator ⚠Next JS_IteratorNext: advance the iterator, fillingpdone.- JS_
NewC ⚠Constructor JS_NewCConstructor: the one-call constructor registration.- JS_
NewC ⚠Function Data JS_NewCFunctionData: a function carryingdata_lencaptured values.- JS_
NewPromise ⚠Capability JS_NewPromiseCapability: a promise plus its resolve/reject functions.- JS_
Ordinary ⚠IsInstance Of JS_OrdinaryIsInstanceOf:instanceofignoringSymbol.hasInstance.- JS_
Promise ⚠Result JS_PromiseResult: the value a settled promise settled with.- JS_
Promise ⚠State JS_PromiseState:JS_PROMISE_PENDING(0),FULFILLED(1) orREJECTED(2).- JS_
SetHost ⚠Promise Rejection Tracker JS_SetHostPromiseRejectionTracker: be told about rejected promises.- JS_
SetImmutable ⚠Array Buffer JS_SetImmutableArrayBuffer: accepted and ignored, for the reason above.