<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&#64;gmail.com" title="Yusuke Suzuki &lt;utatane.tea&#64;gmail.com&gt;"> <span class="fn">Yusuke Suzuki</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=295505&amp;action=diff" name="attach_295505" title="[PATCH] Work in Progress">attachment 295505</a> <a href="attachment.cgi?id=295505&amp;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&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=295505&amp;action=review</a>

Awesome. Early stage review.

<span class="quote">&gt; Source/JavaScriptCore/builtins/PromiseOperations.js:109
&gt; +        &#64;hostPromiseRejectionTracker(promise, &quot;reject&quot;);</span >

I recommend using some bytecode intrinsic constants instead of the string `&quot;reject&quot;`.
For example, &#64;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">&gt; Source/JavaScriptCore/builtins/PromisePrototype.js:62
&gt; +            &#64;hostPromiseRejectionTracker(promise, &quot;handle&quot;);</span >

Ditto.

<span class="quote">&gt; Source/JavaScriptCore/runtime/JSGlobalObject.h:167
&gt; +enum class JSPromiseRejectionOperation {
&gt; +    Reject, // When a promise is rejected without any handlers.
&gt; +    Handle, // When a handler is added to a rejected promise for the first time.
&gt; +};</span >

You can expose these enums directly to the JS world through bytecode intrinsic constants.

<span class="quote">&gt; Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp:940
&gt; +    JSPromiseRejectionOperation operation;
&gt; +    if (operationString == &quot;reject&quot;)
&gt; +        operation = JSPromiseRejectionOperation::Reject;
&gt; +    else {
&gt; +        ASSERT(operationString == &quot;handle&quot;);
&gt; +        operation = JSPromiseRejectionOperation::Handle;
&gt; +    }</span >

And then, you can just `static_cast&lt;&gt;()` 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>