Changeset 208410 in webkit


Ignore:
Timestamp:
Nov 4, 2016 5:48:01 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

Error description code should be able to handle Symbol values.
https://bugs.webkit.org/show_bug.cgi?id=164436
<rdar://problem/29115583>

Reviewed by Filip Pizlo and Saam Barati.

JSTests:

  • stress/error-description-on-symbols-should-not-crash.js: Added.

Source/JavaScriptCore:

Previously, we try to toString() the Symbol value, resulting in it throwing an
exception in errorDescriptionForValue() which breaks the invariant that
errorDescriptionForValue() should not throw.

We fixed this by making errorDescriptionForValue() aware of the Symbol type, and
not so a toString() on Symbol values. Also fixed notAFunctionSourceAppender()
to build a nicer message for Symbol values.

  • runtime/ExceptionHelpers.cpp:

(JSC::errorDescriptionForValue):
(JSC::notAFunctionSourceAppender):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r208404 r208410  
     12016-11-04  Mark Lam  <mark.lam@apple.com>
     2
     3        Error description code should be able to handle Symbol values.
     4        https://bugs.webkit.org/show_bug.cgi?id=164436
     5        <rdar://problem/29115583>
     6
     7        Reviewed by Filip Pizlo and Saam Barati.
     8
     9        * stress/error-description-on-symbols-should-not-crash.js: Added.
     10
    1112016-11-03  Geoffrey Garen  <ggaren@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r208404 r208410  
     12016-11-04  Mark Lam  <mark.lam@apple.com>
     2
     3        Error description code should be able to handle Symbol values.
     4        https://bugs.webkit.org/show_bug.cgi?id=164436
     5        <rdar://problem/29115583>
     6
     7        Reviewed by Filip Pizlo and Saam Barati.
     8
     9        Previously, we try to toString() the Symbol value, resulting in it throwing an
     10        exception in errorDescriptionForValue() which breaks the invariant that
     11        errorDescriptionForValue() should not throw.
     12
     13        We fixed this by making errorDescriptionForValue() aware of the Symbol type, and
     14        not so a toString() on Symbol values.  Also fixed notAFunctionSourceAppender()
     15        to build a nicer message for Symbol values.
     16
     17        * runtime/ExceptionHelpers.cpp:
     18        (JSC::errorDescriptionForValue):
     19        (JSC::notAFunctionSourceAppender):
     20
    1212016-11-02  Geoffrey Garen  <ggaren@apple.com>
    222
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r207825 r208410  
    8787    if (v.isString())
    8888        return jsNontrivialString(exec, makeString('"',  asString(v)->value(exec), '"'));
     89    if (v.isSymbol())
     90        return jsNontrivialString(exec, asSymbol(v)->descriptiveString());
    8991    if (v.isObject()) {
    9092        CallData callData;
     
    183185    builder.append(base);
    184186    builder.appendLiteral("' is ");
    185     if (type == TypeObject)
    186         builder.appendLiteral("an instance of ");
    187     builder.append(displayValue);
     187    if (type == TypeSymbol)
     188        builder.appendLiteral("a Symbol");
     189    else {
     190        if (type == TypeObject)
     191            builder.appendLiteral("an instance of ");
     192        builder.append(displayValue);
     193    }
    188194    builder.append(')');
    189195
Note: See TracChangeset for help on using the changeset viewer.