-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HandleScope enter/exit callbacks for peoper integration into uv loop
- Loading branch information
1 parent
9791658
commit f698522
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
diff --git forkSrcPrefix/deps/v8/src/api/api.cc forkDstPrefix/deps/v8/src/api/api.cc | ||
index 2dd476dda34f1cfe3a75b7895009af24963372f2..6476204733a8aa87c4681dbeb5fee12db54e529d 100644 | ||
--- forkSrcPrefix/deps/v8/src/api/api.cc | ||
+++ forkDstPrefix/deps/v8/src/api/api.cc | ||
@@ -883,7 +883,21 @@ void InternalFieldOutOfBounds(int index) { | ||
|
||
// --- H a n d l e s --- | ||
|
||
-HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); } | ||
+static std::function<void(Isolate*)> g_enterScopeCB; | ||
+static std::function<void(Isolate*)> g_leaveScopeCB; | ||
+ | ||
+V8_EXPORT void SetScopeHandler(const std::function<void(Isolate*)>& enter, | ||
+ const std::function<void(Isolate*)>& exit) { | ||
+ g_enterScopeCB = enter; | ||
+ g_leaveScopeCB = exit; | ||
+} | ||
+ | ||
+HandleScope::HandleScope(Isolate* v8_isolate) { | ||
+ if(g_enterScopeCB) { | ||
+ g_enterScopeCB(v8_isolate); | ||
+ } | ||
+ Initialize(v8_isolate); | ||
+} | ||
|
||
void HandleScope::Initialize(Isolate* v8_isolate) { | ||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | ||
@@ -908,6 +922,9 @@ void HandleScope::Initialize(Isolate* v8_isolate) { | ||
} | ||
|
||
HandleScope::~HandleScope() { | ||
+ if(g_leaveScopeCB) { | ||
+ g_leaveScopeCB(reinterpret_cast<Isolate*>(i_isolate_)); | ||
+ } | ||
#ifdef V8_ENABLE_CHECKS | ||
CHECK_EQ(scope_level_, i_isolate_->handle_scope_data()->level); | ||
#endif | ||
@@ -938,6 +955,9 @@ i::Address* HandleScope::CreateHandleForCurrentIsolate(i::Address value) { | ||
#endif // V8_ENABLE_DIRECT_LOCAL | ||
|
||
EscapableHandleScopeBase::EscapableHandleScopeBase(Isolate* v8_isolate) { | ||
+ if(g_enterScopeCB) { | ||
+ g_enterScopeCB(v8_isolate); | ||
+ } | ||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | ||
escape_slot_ = CreateHandle( | ||
i_isolate, i::ReadOnlyRoots(i_isolate).the_hole_value().ptr()); |