[Webkit-unassigned] [Bug 150358] Support for promise rejection events (unhandledrejection)
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Dec 7 05:38:08 PST 2016
https://bugs.webkit.org/show_bug.cgi?id=150358
--- Comment #8 from Yusuke Suzuki <utatane.tea at gmail.com> ---
Comment on attachment 295505
--> https://bugs.webkit.org/attachment.cgi?id=295505
[PATCH] Work in Progress
View in context: https://bugs.webkit.org/attachment.cgi?id=295505&action=review
Awesome. Early stage review.
> Source/JavaScriptCore/builtins/PromiseOperations.js:109
> + @hostPromiseRejectionTracker(promise, "reject");
I recommend using some bytecode intrinsic constants instead of the string `"reject"`.
For example, @promiseStatePending is represented as a bytecode intrinsic constant.
The benefit of the bytecode intrinsic constant is we can share the same value in C++ and JS.
You can see how to define it in bytecode/BytecodeIntrinsicRegistry.h.
> Source/JavaScriptCore/builtins/PromisePrototype.js:62
> + @hostPromiseRejectionTracker(promise, "handle");
Ditto.
> Source/JavaScriptCore/runtime/JSGlobalObject.h:167
> +enum class JSPromiseRejectionOperation {
> + Reject, // When a promise is rejected without any handlers.
> + Handle, // When a handler is added to a rejected promise for the first time.
> +};
You can expose these enums directly to the JS world through bytecode intrinsic constants.
> Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:940
> + JSPromiseRejectionOperation operation;
> + if (operationString == "reject")
> + operation = JSPromiseRejectionOperation::Reject;
> + else {
> + ASSERT(operationString == "handle");
> + operation = JSPromiseRejectionOperation::Handle;
> + }
And then, you can just `static_cast<>()` the argument's number to the enum.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20161207/9c130306/attachment.html>
More information about the webkit-unassigned
mailing list