| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac9b8f7 commit 2b2ad96
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -448,10 +448,25 @@ class Reference : private Finalizer { | |||
| 448 | 448 | } | |
| 449 | 449 | ||
| 450 | 450 | private: | |
| 451 | + // The N-API finalizer callback may make calls into the engine. V8's heap is | ||
| 452 | + // not in a consistent state during the weak callback, and therefore it does | ||
| 453 | + // not support calls back into it. However, it provides a mechanism for adding | ||
| 454 | + // a finalizer which may make calls back into the engine by allowing us to | ||
| 455 | + // attach such a second-pass finalizer from the first pass finalizer. Thus, | ||
| 456 | + // we do that here to ensure that the N-API finalizer callback is free to call | ||
| 457 | + // into the engine. | ||
| 451 | 458 | static void FinalizeCallback(const v8::WeakCallbackInfo<Reference>& data) { | |
| 452 | 459 | Reference* reference = data.GetParameter(); | |
| 460 | + | ||
| 461 | + // The reference must be reset during the first pass. | ||
| 453 | 462 | reference->_persistent.Reset(); | |
| 454 | 463 | ||
| 464 | + data.SetSecondPassCallback(SecondPassCallback); | ||
| 465 | + } | ||
| 466 | + | ||
| 467 | + static void SecondPassCallback(const v8::WeakCallbackInfo<Reference>& data) { | ||
| 468 | + Reference* reference = data.GetParameter(); | ||
| 469 | + | ||
| 455 | 470 | // Check before calling the finalize callback, because the callback might | |
| 456 | 471 | // delete it. | |
| 457 | 472 | bool delete_self = reference->_delete_self; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments