From ec0f0ef8ef7aa3501394b9d40542838673ac51e0 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 27 Apr 2021 10:05:32 -0700 Subject: [PATCH] deps: V8: cherry-pick 5f4413194480 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [promises] Change context promise hooks to Callable The previously added perf-context Promise-hooks take a v8::Function as arguments. However, the builtin code was only accepting JSFunctions which causes cast errors. Drive-by-fix: Directly pass nativeContext in more places. Bug: chromium:1201465 Change-Id: Ic8bed11253a1f18a84e71eb9ea809b1ec1c3f428 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2850162 Reviewed-by: Jakob Gruber Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#74223} Refs: https://github.com/v8/v8/commit/5f44131944800f16c4dc6768acb67561e3746384 PR-URL: https://github.com/nodejs/node/pull/36394 Backport-PR-URL: https://github.com/nodejs/node/pull/38577 Reviewed-By: Bryan English Reviewed-By: Gus Caplan Reviewed-By: Vladimir de Turckheim Reviewed-By: Gerhard Stöbich Reviewed-By: James M Snell --- common.gypi | 2 +- deps/v8/src/builtins/promise-misc.tq | 4 ++-- deps/v8/test/mjsunit/promise-hooks.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common.gypi b/common.gypi index a8bb1142f41662..bb3a78dd74ef00 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.78', + 'v8_embedder_string': '-node.79', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/promise-misc.tq b/deps/v8/src/builtins/promise-misc.tq index 1962167067456a..97b5657570663f 100644 --- a/deps/v8/src/builtins/promise-misc.tq +++ b/deps/v8/src/builtins/promise-misc.tq @@ -103,7 +103,7 @@ macro NewPromiseRejectReactionJobTask(implicit context: Context)( transitioning macro RunContextPromiseHookInit(implicit context: Context)( promise: JSPromise, parent: Object) { const nativeContext: NativeContext = LoadNativeContext(context); - const hook = Cast( + const hook = Cast( nativeContext[NativeContextSlot::PROMISE_HOOK_INIT_FUNCTION_INDEX]) otherwise return; const parentObject = Is(parent) ? Cast(parent) @@ -168,7 +168,7 @@ transitioning macro RunContextPromiseHook(implicit context: Context)( promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) { if (!IsContextPromiseHookEnabled(flags)) return; const nativeContext: NativeContext = LoadNativeContext(context); - const hook = Cast(nativeContext[slot]) otherwise return; + const hook = Cast(nativeContext[slot]) otherwise return; let promise: JSPromise; typeswitch (promiseOrCapability) { diff --git a/deps/v8/test/mjsunit/promise-hooks.js b/deps/v8/test/mjsunit/promise-hooks.js index db7041a8f5de97..bf51777dcecd8d 100644 --- a/deps/v8/test/mjsunit/promise-hooks.js +++ b/deps/v8/test/mjsunit/promise-hooks.js @@ -252,3 +252,13 @@ exceptions(); } __f_16(async () => { await Promise.resolve()}); })(); + +(function boundFunction() { + function hook() {}; + const bound = hook.bind(this); + d8.promise.setHooks(bound, bound, bound, bound); + Promise.resolve(); + Promise.reject(); + %PerformMicrotaskCheckpoint(); + d8.promise.setHooks(); +})();