@@ -68,6 +68,7 @@ A number of concepts are involved in putting together Node.js on top of V8 and
6868libuv. This section aims to explain some of them and how they work together.
6969
7070<a id =" isolate " ></a >
71+
7172### ` Isolate `
7273
7374The ` v8::Isolate ` class represents a single JavaScript engine instance, in
@@ -102,6 +103,7 @@ subclasses such as `v8::Number` (which in turn has subclasses like `v8::Int32`),
102103of ` v8::Object ` , e.g. ` v8::Uint8Array ` or ` v8::Date ` .
103104
104105<a id =" internal-fields " ></a >
106+
105107### Internal fields
106108
107109V8 provides the ability to store data in so-called “internal fields” inside
@@ -128,12 +130,14 @@ Typical ways of working with internal fields are:
128130[ ` Context ` ] [ ] s provide the same feature under the name “embedder data”.
129131
130132<a id =" js-handles " ></a >
133+
131134### JavaScript value handles
132135
133136All JavaScript values are accessed through the V8 API through so-called handles,
134137of which there are two types: [ ` Local ` ] [ ] s and [ ` Global ` ] [ ] s.
135138
136139<a id =" local-handles " ></a >
140+
137141#### ` Local ` handles
138142
139143A ` v8::Local ` handle is a temporary pointer to a JavaScript object, where
@@ -210,6 +214,7 @@ any functions that are called from the event loop and want to run or access
210214JavaScript code to create ` HandleScope ` s.
211215
212216<a id =" global-handles " ></a >
217+
213218#### ` Global ` handles
214219
215220A ` v8::Global ` handle (sometimes also referred to by the name of its parent
@@ -246,6 +251,7 @@ the `v8::Eternal` itself is destroyed at some point. This type of handle
246251is rarely used.
247252
248253<a id="context"></a>
254+
249255### `Context`
250256
251257JavaScript allows multiple global objects and sets of built-in JavaScript
@@ -270,6 +276,7 @@ Typical ways of accessing the current `Context` in the Node.js code are:
270276 main context.
271277
272278<a id="event-loop"></a>
279+
273280### Event loop
274281
275282The main abstraction for an event loop inside Node.js is the `uv_loop_t` struct.
@@ -284,6 +291,7 @@ could restructure Node.js to provide e.g. the ability to run parts of Node.js
284291inside an event loop separate from the active thread’s event loop.
285292
286293<a id="environment"></a>
294+
287295### `Environment`
288296
289297Node.js instances are represented by the `Environment` class.
@@ -315,6 +323,7 @@ Typical ways of accessing the current `Environment` in the Node.js code are:
315323 up the current [`Context`][] and then uses that.
316324
317325<a id="isolate-data"></a>
326+
318327### `IsolateData`
319328
320329Every Node.js instance ([`Environment`][]) is associated with one `IsolateData`
@@ -346,6 +355,7 @@ The platform can be accessed through `isolate_data->platform()` given an
346355 and who passed this to Node.js.
347356
348357<a id="binding-functions"></a>
358+
349359### Binding functions
350360
351361C++ functions exposed to JS follow a specific signature. The following example
@@ -463,6 +473,7 @@ Which explains that the unregistered external reference is
463473` node::util::GetHiddenValue ` defined in ` node_util.cc ` .
464474
465475<a id =" per-binding-state " ></a >
476+
466477#### Per-binding state
467478
468479Some internal bindings, such as the HTTP parser, maintain internal state that
@@ -519,6 +530,7 @@ of `SnapshotableObject` on how to implement its serialization and
519530deserialization.
520531
521532<a id="exception-handling"></a>
533+
522534### Exception handling
523535
524536The V8 engine provides multiple features to work with JavaScript exceptions,
@@ -554,7 +566,7 @@ The most common reasons for this are:
554566* Calls to functions like `object->Get(...)` or `object->Set(...)` may fail on
555567 most objects, if the `Object.prototype` object has been modified from userland
556568 code that added getters or setters.
557- * Calls that invoke *any* JavaScript code, including JavaScript code that is
569+ * Calls that invoke _any_ JavaScript code, including JavaScript code that is
558570 provided from Node.js internals or V8 internals, will fail when JavaScript
559571 execution is being terminated. This typically happens inside Workers when
560572 `worker.terminate()` is called, but it can also affect the main thread when
@@ -661,6 +673,7 @@ and the exception object will not be a meaningful JavaScript value.
661673`try_catch.ReThrow()` should not be used in this case .
662674
663675<a id=" libuv-handles-and-requests" ></a>
676+
664677### libuv handles and requests
665678
666679Two central concepts when working with libuv are handles and requests.
@@ -682,6 +695,7 @@ When a Node.js [`Environment`][] is destroyed, it generally needs to clean up
682695any resources owned by it, e.g. memory or libuv requests/handles.
683696
684697<a id="cleanup-hooks"></a >
698+
685699#### Cleanup hooks
686700
687701Cleanup hooks are provided that run before the [ ` Environment ` ] [ ]
@@ -690,7 +704,7 @@ is destroyed. They can be added and removed through by using
690704` env->RemoveCleanupHook(callback, hint); ` , where callback takes a ` void* hint `
691705argument.
692706
693- Inside these cleanup hooks, new asynchronous operations * may * be started on the
707+ Inside these cleanup hooks, new asynchronous operations _ may _ be started on the
694708event loop, although ideally that is avoided as much as possible.
695709
696710Every [ ` BaseObject ` ] [ ] has its own cleanup hook that deletes it. For
@@ -742,6 +756,7 @@ This can be useful for debugging memory leaks.
742756The [ ` memory_tracker.h ` ] [ ] header file explains how to use this class.
743757
744758<a id="baseobject"></a >
759+
745760### ` BaseObject `
746761
747762A frequently recurring situation is that a JavaScript object and a C++ object
@@ -819,6 +834,7 @@ called. This can be useful when one `BaseObject` fully owns another
819834`BaseObject`.
820835
821836<a id="asyncwrap"></a>
837+
822838### `AsyncWrap`
823839
824840`AsyncWrap` is a subclass of `BaseObject` that additionally provides tracking
@@ -837,6 +853,7 @@ See the [`async_hooks` module][] documentation for more information about how
837853this information is provided to async tracking tools.
838854
839855<a id="makecallback"></a>
856+
840857#### `MakeCallback`
841858
842859The `AsyncWrap` class has a set of methods called `MakeCallback()`, with the
@@ -876,6 +893,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
876893See [ Callback scopes] [ ] for more information.
877894
878895<a id =" handlewrap " ></a >
896+
879897### ` HandleWrap `
880898
881899` HandleWrap ` is a subclass of ` AsyncWrap ` specifically designed to make working
@@ -890,6 +908,7 @@ current Node.js [`Environment`][] is destroyed, e.g. when a Worker thread stops.
890908overview over libuv handles managed by Node.js.
891909
892910<a id =" reqwrap " ></a >
911+
893912### ` ReqWrap `
894913
895914` ReqWrap ` is a subclass of ` AsyncWrap ` specifically designed to make working
@@ -902,6 +921,7 @@ track of the current count of active libuv requests.
902921overview over libuv handles managed by Node.js.
903922
904923<a id =" callback-scopes " ></a >
924+
905925### Callback scopes
906926
907927The public ` CallbackScope ` and the internally used ` InternalCallbackScope `
0 commit comments