• Home
  • Raw
  • Download

Lines Matching +full:vm +full:- +full:pointer

17 new projects [N-API][] is typically the better alternative.
52 The `-inl.h` header files contain definitions of inline functions from the
55 `.h` header file, and can include other `.h` and `-inl.h` header files as
57 into an `-inl.h` file, but it becomes necessary when there are multiple
58 definitions and contents of other `-inl.h` files start being used. Therefore, it
59 is recommended to split a `-inl.h` file when inline functions become longer than
61 definitions from the `-inl.h` file should be declared in the corresponding `.h`
64 The `.cc` files contain definitions of non-inline functions from the
66 header file, and can include other `.h` and `-inl.h` header files as needed.
85 V8 APIs are not thread-safe unless explicitly specified. In a typical Node.js
91 happen on a per-`Isolate` basis.
97 * Given a [`Context`][], using `context->GetIsolate()`.
98 * Given a [`Environment`][], using `env->isolate()`.
99 * Given a [`Realm`][], using `realm->isolate()`.
109 <a id="internal-fields"></a>
113 V8 provides the ability to store data in so-called “internal fields” inside
114 `v8::Object`s that were created as instances of C++-backed classes. The number
119 pointer to a [`BaseObject`][] subclass, which then contains all relevant
124 * `obj->InternalFieldCount()` to look up the number of internal fields for an
126 * `obj->GetInternalField(i)` to get a JavaScript value from an internal field.
127 * `obj->SetInternalField(i, v)` to store a JavaScript value in an
129 * `obj->GetAlignedPointerFromInternalField(i)` to get a `void*` pointer from an
131 * `obj->SetAlignedPointerInInternalField(i, p)` to store a `void*` pointer in an
136 <a id="js-handles"></a>
140 All JavaScript values are accessed through the V8 API through so-called handles,
143 <a id="local-handles"></a>
147 A `v8::Local` handle is a temporary pointer to a JavaScript object, where
175 v8::Isolate* isolate = context->GetIsolate();
184 if (obj->Get(context, foo_string).ToLocal(&return_value)) {
204 CHECK(some_value->IsUint8Array());
208 Generally, using `val.As<v8::X>()` is only valid if `val->IsX()` is true, and
220 <a id="global-handles"></a>
229 Global handles can be either strong or weak. Strong global handles are so-called
233 is garbage-collected.
253 garbage-collected while the JavaScript Engine instance is alive, even if
261 JavaScript allows multiple global objects and sets of built-in JavaScript
263 heap. Node.js exposes this ability through the [`vm` module][].
270 subsidiary `Context`s that are created with `vm.Context` or associated with
276 sufficiently committed person could restructure Node.js to provide built-in
277 modules inside of `vm.Context`s.
282 * Given an [`Isolate`][], using `isolate->GetCurrentContext()`.
283 * Given an [`Environment`][], using `env->context()` to get the `Environment`'s
285 * Given a [`Realm`][], using `realm->context()` to get the `Realm`'s
288 <a id="event-loop"></a>
297 The current event loop can be accessed using `env->event_loop()` given an
316 different built-in modules that can be shared across different `Realm`
323 * Given a [`BaseObject`][], using `env()` or `self->env()`.
327 `vm.Context`s.
346 `Realm` is created for the [`Context`][] of a `vm.Context`.
348 Native bindings and built-in modules can be evaluated in either a principal
352 different built-in modules, for example the memory for a `Uint32Array` that
363 * Given a [`BaseObject`][], using `realm()` or `self->realm()`.
370 <a id="isolate-data"></a>
382 string “name” can be accessed through `env->name_string()` without actually
394 The platform can be accessed through `isolate_data->platform()` given an
402 <a id="binding-functions"></a>
411 CHECK(args[0]->IsArrayBufferView());
412 args.GetReturnValue().Set(args[0].As<ArrayBufferView>()->HasBuffer());
419 `args[n]` is a `Local<Value>` that represents the n-th argument passed to the
426 floating-point number or a `Local<Value>` to set the return value.
429 C++ functions to the exports of a built-in module:
447 Isolate* isolate = env->isolate();
452 channel_wrap->InstanceTemplate()->SetInternalFieldCount(1);
453 channel_wrap->Inherit(AsyncWrap::GetConstructorTemplate(env));
468 // `internalBinding('cares_wrap')` in Node.js's built-in JavaScript code:
479 registry->Register(GetHiddenValue);
480 registry->Register(SetHiddenValue);
504 with lldb's `image lookup --address` command (with gdb it's `info symbol`):
507 $ lldb -- out/Release/node_mksnapshot out/Release/gen/node_snapshot.cc
513 (lldb) image lookup --address 0x1004c8200
521 <a id="per-binding-state"></a>
523 #### Per-binding state
536 fully-specified class name should be added to the `SERIALIZABLE_BINDING_TYPES`
546 // usually the fully-specified class name.
578 realm->AddBindingData<BindingData>(context, target);
581 Local<FunctionTemplate> t = NewFunctionTemplate(realm->isolate(), Parser::New);
586 <a id="exception-handling"></a>
604 being empty) and taking a pointer to a `T` to store the value if there is one.
620 * Calls to functions like `object->Get(...)` or `object->Set(...)` may fail on
630 to unexpected getters and setters, accessing some types of built-in objects
631 like `Map`s and `Set`s can also run V8-internal JavaScript code.
640 | -------------------- | ------------------------------ |
669 v8::Isolate* isolate = context->GetIsolate();
674 for (uint32_t i = 0; i < array_of_integers->Length(); i++) {
676 if (!array_of_integers->Get(context, i).ToLocal(&entry)) {
682 if (!entry->IsNumber()) {
683 // Let's just skip any non-numbers. It would also be reasonable to throw
692 sum += entry_as_number->Value();
702 CHECK(args[0]->IsArray());
705 if (!SumNumbers(args.GetIsolate()->GetCurrentContext(),
729 <a id="libuv-handles-and-requests"></a>
736 long-lived objects that can emit events multiple times, such as network sockets
741 Requests are one-time asynchronous function calls on the event loop, such as
751 <a id="cleanup-hooks"></a>
757 `env->AddCleanupHook(callback, hint);` and
758 `env->RemoveCleanupHook(callback, hint);`, or
759 `realm->AddCleanupHook(callback, hint);` and
760 `realm->RemoveCleanupHook(callback, hint);` respectively, where callback takes
775 `env->CloseHandle()`, which works the same way but keeps track of the number
782 `env->IncreaseWaitingRequestCounter()` and
783 `env->DecreaseWaitingRequestCounter()` functions need to be used to keep track
793 `env->can_call_into_js()` flag and do not proceed if it is set to `false`.
825 that is used for storing the pointer to the C++ object. In order to ensure this,
830 `self->object()`, given a `BaseObject` named `self`.
843 Environment* env = session->env();
844 Local<Context> context = env->context();
845 Isolate* isolate = env->isolate();
888 it is destroyed. There must be at least one such pointer when `Detach()` is
906 instance, and only changes when the object is re-used in some way.
937 Environment* env = wrap->env();
938 HandleScope handle_scope(env->isolate());
939 Context::Scope context_scope(env->context());
944 Local<Value> argv[] = { Integer::New(env->isolate(), status), arr };
945 wrap->MakeCallback(env->onchange_string(), arraysize(argv), argv);
979 <a id="callback-scopes"></a>
1006 (As V8 does not handle out-of-memory situations gracefully, it does not make
1012 #### Optional stack-based memory allocation
1019 The `Utf8Value`, `TwoByteValue` (i.e. UTF-16 value) and `BufferValue`
1028 CHECK(args[0]->IsString());
1029 Utf8Value path(env->isolate(), args[0]);
1057 ### Scope-based cleanup
1083 [C++ coding style]: ../doc/contributing/cpp-style-guide.md
1084 [Callback scopes]: #callback-scopes
1085 [ECMAScript realm]: https://tc39.es/ecma262/#sec-code-realms
1086 [JavaScript value handles]: #js-handles
1087 [N-API]: https://nodejs.org/api/n-api.html
1091 [`Global`]: #global-handles
1093 [`IsolateData`]: #isolate-data
1095 [`Local`]: #local-handles
1100 [`ShadowRealm`]: https://github.com/tc39/proposal-shadowrealm
1111 [`vm` module]: https://nodejs.org/api/vm.html
1112 [binding function]: #binding-functions
1113 [cleanup hooks]: #cleanup-hooks
1114 [event loop]: #event-loop
1115 [exception handling]: #exception-handling
1116 [fast API calls]: ../doc/contributing/adding-v8-fast-api.md
1117 [internal field]: #internal-fields
1120 [libuv handles]: #libuv-handles-and-requests
1121 [libuv requests]: #libuv-handles-and-requests