<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>185083</bug_id>
          
          <creation_ts>2018-04-27 10:57:38 -0700</creation_ts>
          <short_desc>Remove unneeded exception check from String.fromCharCode</short_desc>
          <delta_ts>2018-04-30 14:39:43 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Keith Miller">keith_miller</reporter>
          <assigned_to name="Keith Miller">keith_miller</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1418548</commentid>
    <comment_count>0</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-04-27 10:57:38 -0700</bug_when>
    <thetext>Remove unneeded exception check from String.fromCharCode</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1418559</commentid>
    <comment_count>1</comment_count>
      <attachid>339007</attachid>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-04-27 11:14:49 -0700</bug_when>
    <thetext>Created attachment 339007
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1418569</commentid>
    <comment_count>2</comment_count>
      <attachid>339008</attachid>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-04-27 11:32:56 -0700</bug_when>
    <thetext>Created attachment 339008
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419001</commentid>
    <comment_count>3</comment_count>
      <attachid>339008</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2018-04-30 09:41:46 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339008&amp;action=review

&gt; Source/JavaScriptCore/runtime/StringConstructor.cpp:80
&gt;          scope.release();

Can we move the declarations of &quot;vm&quot; and &quot;scope&quot; after the if statement and remove this line of code too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419007</commentid>
    <comment_count>4</comment_count>
      <attachid>339008</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2018-04-30 09:45:43 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339008&amp;action=review

&gt;&gt; Source/JavaScriptCore/runtime/StringConstructor.cpp:80
&gt;&gt;          scope.release();
&gt; 
&gt; Can we move the declarations of &quot;vm&quot; and &quot;scope&quot; after the if statement and remove this line of code too?

Wouldn&apos;t the compiler know that vm and scope is not used until after this anyway?  scope.release() is a no-op on release builds.  I suspect that this move is unnecessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419017</commentid>
    <comment_count>5</comment_count>
      <attachid>339008</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2018-04-30 09:57:42 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339008&amp;action=review

&gt;&gt;&gt; Source/JavaScriptCore/runtime/StringConstructor.cpp:80
&gt;&gt;&gt;          scope.release();
&gt;&gt; 
&gt;&gt; Can we move the declarations of &quot;vm&quot; and &quot;scope&quot; after the if statement and remove this line of code too?
&gt; 
&gt; Wouldn&apos;t the compiler know that vm and scope is not used until after this anyway?  scope.release() is a no-op on release builds.  I suspect that this move is unnecessary.

Sure, it’s unnecessary to generate optimal code if it has no effect on the generated code.

But it’s also unnecessary to write the code the way it currently is; I think it’s clearer the way I suggest, and that’s how it was until a recent change, too. The fast case is clearly separated from the rest of the code with no exception handling code in it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419027</commentid>
    <comment_count>6</comment_count>
      <attachid>339008</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2018-04-30 10:08:46 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339008&amp;action=review

&gt;&gt;&gt;&gt; Source/JavaScriptCore/runtime/StringConstructor.cpp:80
&gt;&gt;&gt;&gt;          scope.release();
&gt;&gt;&gt; 
&gt;&gt;&gt; Can we move the declarations of &quot;vm&quot; and &quot;scope&quot; after the if statement and remove this line of code too?
&gt;&gt; 
&gt;&gt; Wouldn&apos;t the compiler know that vm and scope is not used until after this anyway?  scope.release() is a no-op on release builds.  I suspect that this move is unnecessary.
&gt; 
&gt; Sure, it’s unnecessary to generate optimal code if it has no effect on the generated code.
&gt; 
&gt; But it’s also unnecessary to write the code the way it currently is; I think it’s clearer the way I suggest, and that’s how it was until a recent change, too. The fast case is clearly separated from the rest of the code with no exception handling code in it.

Actually, there&apos;s a need to declare the ThrowScope at the very top, and by convention we always do this where a ThrowScope is needed, unless there is a special reasons to make an exception from this rule (more on this below).

The reason for always declaring the ThrowScope at the top is because the purpose of a ThrowScope is to communicate to its caller that this function &quot;may&quot; throw an exception regardless which path is taken during the current invocation (fast, or slow).  This allows us to assert in the parent that a potential exception could have been thrown, and add an exception there if needed.  By declaring the ThrowScope later, we will cease to notify the caller that this function can potentially throw an exception, thereby defeating its purpose.

The only times we don&apos;t declare a ThrowScope at the top (and there should be very few of these) is if the function will actually eat / handle all exceptions that it encounters (i.e. it should have a CatchScope at the top), but in an embedded block, it needs a ThrowScope for various reasons.  There may be other reasons for not declaring the ThrowScope at the top. but this is the most obvious one I can think of at the moment.  In the case of stringFromCharCode(), I see no special reason why we should not declare ThrowScope at the top.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419109</commentid>
    <comment_count>7</comment_count>
      <attachid>339008</attachid>
    <who name="Mark Lam">mark.lam</who>
    <bug_when>2018-04-30 14:06:42 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419111</commentid>
    <comment_count>8</comment_count>
      <attachid>339008</attachid>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-04-30 14:11:31 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=339008&amp;action=review

Thanks for the review!

&gt;&gt;&gt;&gt;&gt; Source/JavaScriptCore/runtime/StringConstructor.cpp:80
&gt;&gt;&gt;&gt;&gt;          scope.release();
&gt;&gt;&gt;&gt; 
&gt;&gt;&gt;&gt; Can we move the declarations of &quot;vm&quot; and &quot;scope&quot; after the if statement and remove this line of code too?
&gt;&gt;&gt; 
&gt;&gt;&gt; Wouldn&apos;t the compiler know that vm and scope is not used until after this anyway?  scope.release() is a no-op on release builds.  I suspect that this move is unnecessary.
&gt;&gt; 
&gt;&gt; Sure, it’s unnecessary to generate optimal code if it has no effect on the generated code.
&gt;&gt; 
&gt;&gt; But it’s also unnecessary to write the code the way it currently is; I think it’s clearer the way I suggest, and that’s how it was until a recent change, too. The fast case is clearly separated from the rest of the code with no exception handling code in it.
&gt; 
&gt; Actually, there&apos;s a need to declare the ThrowScope at the very top, and by convention we always do this where a ThrowScope is needed, unless there is a special reasons to make an exception from this rule (more on this below).
&gt; 
&gt; The reason for always declaring the ThrowScope at the top is because the purpose of a ThrowScope is to communicate to its caller that this function &quot;may&quot; throw an exception regardless which path is taken during the current invocation (fast, or slow).  This allows us to assert in the parent that a potential exception could have been thrown, and add an exception there if needed.  By declaring the ThrowScope later, we will cease to notify the caller that this function can potentially throw an exception, thereby defeating its purpose.
&gt; 
&gt; The only times we don&apos;t declare a ThrowScope at the top (and there should be very few of these) is if the function will actually eat / handle all exceptions that it encounters (i.e. it should have a CatchScope at the top), but in an embedded block, it needs a ThrowScope for various reasons.  There may be other reasons for not declaring the ThrowScope at the top. but this is the most obvious one I can think of at the moment.  In the case of stringFromCharCode(), I see no special reason why we should not declare ThrowScope at the top.

I agree with Mark here. Knowing which functions can throw exceptions is very useful. Given that the compiler will not emit any extra code in release there&apos;s really no reason to not have the ThrowScope at the top of the function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419118</commentid>
    <comment_count>9</comment_count>
      <attachid>339008</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-04-30 14:38:32 -0700</bug_when>
    <thetext>Comment on attachment 339008
Patch

Clearing flags on attachment: 339008

Committed r231171: &lt;https://trac.webkit.org/changeset/231171&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419119</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-04-30 14:38:33 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1419120</commentid>
    <comment_count>11</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-04-30 14:39:43 -0700</bug_when>
    <thetext>&lt;rdar://problem/39849327&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>339007</attachid>
            <date>2018-04-27 11:14:49 -0700</date>
            <delta_ts>2018-04-27 11:32:54 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-185083-20180427111448.patch</filename>
            <type>text/plain</type>
            <size>1544</size>
            <attacher name="Keith Mi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obsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>339008</attachid>
            <date>2018-04-27 11:32:56 -0700</date>
            <delta_ts>2018-04-30 14:38:32 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-185083-20180427113255.patch</filename>
            <type>text/plain</type>
            <size>1644</size>
            <attacher name="Keith Miller">keith_miller</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMxMTAxCmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBk
ZTJhYTQ0OWNhNTc5MmE4MTMyMGYxMWZmZjVjNzJiYmZlOGM0ZGUxLi5iZTJiNDg4Mzk4MDM4OGM0
ZmVhMDE4ZTk2NGY3N2E1YWM4MWFkYTJmIDEwMDY0NAotLS0gYS9Tb3VyY2UvSmF2YVNjcmlwdENv
cmUvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxMyBAQAorMjAxOC0wNC0yNyAgS2VpdGggTWlsbGVyICA8a2VpdGhfbWlsbGVyQGFwcGxl
LmNvbT4KKworICAgICAgICBSZW1vdmUgdW5uZWVkZWQgZXhjZXB0aW9uIGNoZWNrIGZyb20gU3Ry
aW5nLmZyb21DaGFyQ29kZQorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1
Zy5jZ2k/aWQ9MTg1MDgzCisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisK
KyAgICAgICAgKiBydW50aW1lL1N0cmluZ0NvbnN0cnVjdG9yLmNwcDoKKyAgICAgICAgKEpTQzo6
c3RyaW5nRnJvbUNoYXJDb2RlKToKKwogMjAxOC0wNC0yNiAgQ2FpbyBMaW1hICA8dGljYWlvbGlt
YUBnbWFpbC5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