diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-15 22:57:44 +0100 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2019-03-28 16:37:11 -0400 |
commit | 53ea813d5c0029d3ee90230054d5407a6864cb08 (patch) | |
tree | e9d372bfdf4df505b1d6d65f14eb7014a95e65dc /deps | |
parent | cc75ba3f140c4584a776c163a365fedd4ea5ef63 (diff) | |
download | android-node-v8-53ea813d5c0029d3ee90230054d5407a6864cb08.tar.gz android-node-v8-53ea813d5c0029d3ee90230054d5407a6864cb08.tar.bz2 android-node-v8-53ea813d5c0029d3ee90230054d5407a6864cb08.zip |
deps: V8: cherry-pick 2f79d68
Original commit message:
Deprecate MicrotasksCompletedCallback in favor to use *WithData version
This adds overloads of v8::Isolate::{Add,Remove}MicrotaskCompletedCallback,
that use MicrotasksCompletedCallbackWithData, and marks the original one
as V8_DEPRECATE_SOON for transition.
Bug: v8:8124
Change-Id: I124c3108545e1a2b29cd95620f36901431663c65
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1493766
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60045}
Refs: https://github.com/v8/v8/commit/2f79d68664ba113b69f62c29ce85fd29dcf87df3
PR-URL: https://github.com/nodejs/node/pull/26685
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/v8/include/v8.h | 15 | ||||
-rw-r--r-- | deps/v8/src/api.cc | 15 | ||||
-rw-r--r-- | deps/v8/src/inspector/v8-debugger.cc | 12 | ||||
-rw-r--r-- | deps/v8/src/inspector/v8-debugger.h | 2 | ||||
-rw-r--r-- | deps/v8/src/microtask-queue.h | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-api.cc | 4 |
6 files changed, 38 insertions, 12 deletions
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 6ecc48af33..987748ca00 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -6744,7 +6744,8 @@ class PromiseRejectMessage { typedef void (*PromiseRejectCallback)(PromiseRejectMessage message); // --- Microtasks Callbacks --- -typedef void (*MicrotasksCompletedCallback)(Isolate*); +V8_DEPRECATE_SOON("Use *WithData version.", + typedef void (*MicrotasksCompletedCallback)(Isolate*)); typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*); typedef void (*MicrotaskCallback)(void* data); @@ -8231,12 +8232,20 @@ class V8_EXPORT Isolate { * Executing scripts inside the callback will not re-trigger microtasks and * the callback. */ - void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); + V8_DEPRECATE_SOON("Use *WithData version.", + void AddMicrotasksCompletedCallback( + MicrotasksCompletedCallback callback)); + void AddMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data = nullptr); /** * Removes callback that was installed by AddMicrotasksCompletedCallback. */ - void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); + V8_DEPRECATE_SOON("Use *WithData version.", + void RemoveMicrotasksCompletedCallback( + MicrotasksCompletedCallback callback)); + void RemoveMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data = nullptr); /** * Sets a callback for counting the number of times a feature of V8 is used. diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 168522f8c3..8375f13ba5 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -8574,7 +8574,7 @@ MicrotasksPolicy Isolate::GetMicrotasksPolicy() const { namespace { void MicrotasksCompletedCallbackAdapter(v8::Isolate* isolate, void* data) { - auto callback = reinterpret_cast<MicrotasksCompletedCallback>(data); + auto callback = reinterpret_cast<void (*)(v8::Isolate*)>(data); callback(isolate); } @@ -8588,6 +8588,13 @@ void Isolate::AddMicrotasksCompletedCallback( &MicrotasksCompletedCallbackAdapter, reinterpret_cast<void*>(callback)); } +void Isolate::AddMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data) { + DCHECK(callback); + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); + isolate->default_microtask_queue()->AddMicrotasksCompletedCallback(callback, + data); +} void Isolate::RemoveMicrotasksCompletedCallback( MicrotasksCompletedCallback callback) { @@ -8596,6 +8603,12 @@ void Isolate::RemoveMicrotasksCompletedCallback( &MicrotasksCompletedCallbackAdapter, reinterpret_cast<void*>(callback)); } +void Isolate::RemoveMicrotasksCompletedCallback( + MicrotasksCompletedCallbackWithData callback, void* data) { + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); + isolate->default_microtask_queue()->RemoveMicrotasksCompletedCallback( + callback, data); +} void Isolate::SetUseCounterCallback(UseCounterCallback callback) { reinterpret_cast<i::Isolate*>(this)->SetUseCounterCallback(callback); diff --git a/deps/v8/src/inspector/v8-debugger.cc b/deps/v8/src/inspector/v8-debugger.cc index ccc5676058..0f8e52f7cd 100644 --- a/deps/v8/src/inspector/v8-debugger.cc +++ b/deps/v8/src/inspector/v8-debugger.cc @@ -59,6 +59,7 @@ class MatchPrototypePredicate : public v8::debug::QueryObjectPredicate { v8::Local<v8::Context> m_context; v8::Local<v8::Value> m_prototype; }; + } // namespace V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) @@ -76,7 +77,7 @@ V8Debugger::~V8Debugger() { m_isolate->RemoveCallCompletedCallback( &V8Debugger::terminateExecutionCompletedCallback); m_isolate->RemoveMicrotasksCompletedCallback( - &V8Debugger::terminateExecutionCompletedCallback); + &V8Debugger::terminateExecutionCompletedCallbackIgnoringData); } void V8Debugger::enable() { @@ -302,7 +303,7 @@ void V8Debugger::terminateExecution( m_isolate->AddCallCompletedCallback( &V8Debugger::terminateExecutionCompletedCallback); m_isolate->AddMicrotasksCompletedCallback( - &V8Debugger::terminateExecutionCompletedCallback); + &V8Debugger::terminateExecutionCompletedCallbackIgnoringData); m_isolate->TerminateExecution(); } @@ -311,7 +312,7 @@ void V8Debugger::reportTermination() { m_isolate->RemoveCallCompletedCallback( &V8Debugger::terminateExecutionCompletedCallback); m_isolate->RemoveMicrotasksCompletedCallback( - &V8Debugger::terminateExecutionCompletedCallback); + &V8Debugger::terminateExecutionCompletedCallbackIgnoringData); m_isolate->CancelTerminateExecution(); m_terminateExecutionCallback->sendSuccess(); m_terminateExecutionCallback.reset(); @@ -324,6 +325,11 @@ void V8Debugger::terminateExecutionCompletedCallback(v8::Isolate* isolate) { debugger->reportTermination(); } +void V8Debugger::terminateExecutionCompletedCallbackIgnoringData( + v8::Isolate* isolate, void*) { + terminateExecutionCompletedCallback(isolate); +} + Response V8Debugger::continueToLocation( int targetContextGroupId, V8DebuggerScript* script, std::unique_ptr<protocol::Debugger::Location> location, diff --git a/deps/v8/src/inspector/v8-debugger.h b/deps/v8/src/inspector/v8-debugger.h index 91d8c7e248..7315c96964 100644 --- a/deps/v8/src/inspector/v8-debugger.h +++ b/deps/v8/src/inspector/v8-debugger.h @@ -144,6 +144,8 @@ class V8Debugger : public v8::debug::DebugDelegate, static size_t nearHeapLimitCallback(void* data, size_t current_heap_limit, size_t initial_heap_limit); static void terminateExecutionCompletedCallback(v8::Isolate* isolate); + static void terminateExecutionCompletedCallbackIgnoringData( + v8::Isolate* isolate, void*); void handleProgramBreak( v8::Local<v8::Context> pausedContext, v8::Local<v8::Value> exception, const std::vector<v8::debug::BreakpointId>& hitBreakpoints, diff --git a/deps/v8/src/microtask-queue.h b/deps/v8/src/microtask-queue.h index 7224794c1d..ce09088526 100644 --- a/deps/v8/src/microtask-queue.h +++ b/deps/v8/src/microtask-queue.h @@ -87,8 +87,6 @@ class V8_EXPORT_PRIVATE MicrotaskQueue final : public v8::MicrotaskQueue { } v8::MicrotasksPolicy microtasks_policy() const { return microtasks_policy_; } - void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); - void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); void FireMicrotasksCompletedCallback(Isolate* isolate) const; intptr_t capacity() const { return capacity_; } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 9dfe1155d9..bd8180fb12 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -21680,12 +21680,10 @@ TEST(RunMicrotasksIgnoresThrownExceptionsFromApi) { uint8_t microtasks_completed_callback_count = 0; - -static void MicrotasksCompletedCallback(v8::Isolate* isolate) { +static void MicrotasksCompletedCallback(v8::Isolate* isolate, void*) { ++microtasks_completed_callback_count; } - TEST(SetAutorunMicrotasks) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); |