<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Support for promise rejection events (unhandledrejection)"
href="https://bugs.webkit.org/show_bug.cgi?id=150358#c8">Comment # 8</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Support for promise rejection events (unhandledrejection)"
href="https://bugs.webkit.org/show_bug.cgi?id=150358">bug 150358</a>
from <span class="vcard"><a class="email" href="mailto:utatane.tea@gmail.com" title="Yusuke Suzuki <utatane.tea@gmail.com>"> <span class="fn">Yusuke Suzuki</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=295505&action=diff" name="attach_295505" title="[PATCH] Work in Progress">attachment 295505</a> <a href="attachment.cgi?id=295505&action=edit" title="[PATCH] Work in Progress">[details]</a></span>
[PATCH] Work in Progress
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=295505&action=review">https://bugs.webkit.org/attachment.cgi?id=295505&action=review</a>
Awesome. Early stage review.
<span class="quote">> Source/JavaScriptCore/builtins/PromiseOperations.js:109
> + @hostPromiseRejectionTracker(promise, "reject");</span >
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.
<span class="quote">> Source/JavaScriptCore/builtins/PromisePrototype.js:62
> + @hostPromiseRejectionTracker(promise, "handle");</span >
Ditto.
<span class="quote">> 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.
> +};</span >
You can expose these enums directly to the JS world through bytecode intrinsic constants.
<span class="quote">> Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:940
> + JSPromiseRejectionOperation operation;
> + if (operationString == "reject")
> + operation = JSPromiseRejectionOperation::Reject;
> + else {
> + ASSERT(operationString == "handle");
> + operation = JSPromiseRejectionOperation::Handle;
> + }</span >
And then, you can just `static_cast<>()` the argument's number to the enum.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>