Skip to content

Commit

Permalink
deps: V8: cherry-pick 5f4413194480
Browse files Browse the repository at this point in the history
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 <jgruber@chromium.org>
    Commit-Queue: Camillo Bruni <cbruni@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#74223}

Refs: v8/v8@5f44131

PR-URL: #36394
Backport-PR-URL: #38577
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Stephen Belanger authored and MylesBorins committed Aug 31, 2021
1 parent 3e7238e commit ec0f0ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####

Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/builtins/promise-misc.tq
Original file line number Diff line number Diff line change
Expand Up @@ -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<JSFunction>(
const hook = Cast<Callable>(
nativeContext[NativeContextSlot::PROMISE_HOOK_INIT_FUNCTION_INDEX])
otherwise return;
const parentObject = Is<JSPromise>(parent) ? Cast<JSPromise>(parent)
Expand Down Expand Up @@ -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<JSFunction>(nativeContext[slot]) otherwise return;
const hook = Cast<Callable>(nativeContext[slot]) otherwise return;

let promise: JSPromise;
typeswitch (promiseOrCapability) {
Expand Down
10 changes: 10 additions & 0 deletions deps/v8/test/mjsunit/promise-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})();

0 comments on commit ec0f0ef

Please sign in to comment.