Skip to content

Commit ec0f0ef

Browse files
Stephen BelangerMylesBorins
Stephen Belanger
authored andcommittedAug 31, 2021
deps: V8: cherry-pick 5f4413194480
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>
1 parent 3e7238e commit ec0f0ef

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.78',
39+
'v8_embedder_string': '-node.79',
4040

4141
##### V8 defaults for Node.js #####
4242

‎deps/v8/src/builtins/promise-misc.tq

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ macro NewPromiseRejectReactionJobTask(implicit context: Context)(
103103
transitioning macro RunContextPromiseHookInit(implicit context: Context)(
104104
promise: JSPromise, parent: Object) {
105105
const nativeContext: NativeContext = LoadNativeContext(context);
106-
const hook = Cast<JSFunction>(
106+
const hook = Cast<Callable>(
107107
nativeContext[NativeContextSlot::PROMISE_HOOK_INIT_FUNCTION_INDEX])
108108
otherwise return;
109109
const parentObject = Is<JSPromise>(parent) ? Cast<JSPromise>(parent)
@@ -168,7 +168,7 @@ transitioning macro RunContextPromiseHook(implicit context: Context)(
168168
promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) {
169169
if (!IsContextPromiseHookEnabled(flags)) return;
170170
const nativeContext: NativeContext = LoadNativeContext(context);
171-
const hook = Cast<JSFunction>(nativeContext[slot]) otherwise return;
171+
const hook = Cast<Callable>(nativeContext[slot]) otherwise return;
172172

173173
let promise: JSPromise;
174174
typeswitch (promiseOrCapability) {

‎deps/v8/test/mjsunit/promise-hooks.js

+10
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,13 @@ exceptions();
252252
}
253253
__f_16(async () => { await Promise.resolve()});
254254
})();
255+
256+
(function boundFunction() {
257+
function hook() {};
258+
const bound = hook.bind(this);
259+
d8.promise.setHooks(bound, bound, bound, bound);
260+
Promise.resolve();
261+
Promise.reject();
262+
%PerformMicrotaskCheckpoint();
263+
d8.promise.setHooks();
264+
})();

0 commit comments

Comments
 (0)