⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245446 in webkit


Ignore:
Timestamp:
May 17, 2019, 4:24:49 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r244996 - [JSC] We should check OOM for description string of Symbol
https://bugs.webkit.org/show_bug.cgi?id=197634

Reviewed by Keith Miller.

JSTests:

  • stress/check-symbol-description-oom.js: Added.

(shouldThrow):

Source/JavaScriptCore:

When resoling JSString for description of Symbol, we should check OOM error.
We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value
without description, (1) to simplify the code and (2) give a way for JSC API
to create a symbol value without description.

  • API/JSValueRef.cpp:

(JSValueMakeSymbol):

  • API/tests/testapi.cpp:

(TestAPI::symbolsTypeof):
(TestAPI::symbolsDescription):
(testCAPIViaCpp):

  • dfg/DFGOperations.cpp:
  • runtime/Symbol.cpp:

(JSC::Symbol::createWithDescription):

  • runtime/Symbol.h:
  • runtime/SymbolConstructor.cpp:

(JSC::callSymbol):

Location:
releases/WebKitGTK/webkit-2.24
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.24/JSTests/ChangeLog

    r245445 r245446  
     12019-05-06  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] We should check OOM for description string of Symbol
     4        https://bugs.webkit.org/show_bug.cgi?id=197634
     5
     6        Reviewed by Keith Miller.
     7
     8        * stress/check-symbol-description-oom.js: Added.
     9        (shouldThrow):
     10
    1112019-05-04  Tadeu Zagallo  <tzagallo@apple.com>
    212
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/API/JSValueRef.cpp

    r237009 r245446  
    331331    }
    332332    ExecState* exec = toJS(ctx);
    333     JSLockHolder locker(exec);
    334     auto scope = DECLARE_CATCH_SCOPE(exec->vm());
    335 
    336     JSString* jsDescription = jsString(exec, description ? description->string() : String());
    337     RETURN_IF_EXCEPTION(scope, nullptr);
    338 
    339     return toRef(exec, Symbol::create(exec, jsDescription));
     333    VM& vm = exec->vm();
     334    JSLockHolder locker(exec);
     335
     336    if (!description)
     337        return toRef(exec, Symbol::create(vm));
     338    return toRef(exec, Symbol::createWithDescription(vm, description->string()));
    340339}
    341340
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/API/tests/testapi.cpp

    r236805 r245446  
    130130    void basicSymbol();
    131131    void symbolsTypeof();
     132    void symbolsDescription();
    132133    void symbolsGetPropertyForKey();
    133134    void symbolsSetPropertyForKey();
     
    268269
    269270static const char* isSymbolFunction = "(function isSymbol(symbol) { return typeof(symbol) === 'symbol'; })";
     271static const char* getSymbolDescription = "(function getSymbolDescription(symbol) { return symbol.description; })";
    270272static const char* getFunction = "(function get(object, key) { return object[key]; })";
    271273static const char* setFunction = "(function set(object, key, value) { object[key] = value; })";
     
    281283void TestAPI::symbolsTypeof()
    282284{
    283     APIString description("dope");
    284     JSValueRef symbol = JSValueMakeSymbol(context, description);
    285     check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value");
     285    {
     286        JSValueRef symbol = JSValueMakeSymbol(context, nullptr);
     287        check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value");
     288    }
     289    {
     290        APIString description("dope");
     291        JSValueRef symbol = JSValueMakeSymbol(context, description);
     292        check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value");
     293    }
     294}
     295
     296void TestAPI::symbolsDescription()
     297{
     298    {
     299        JSValueRef symbol = JSValueMakeSymbol(context, nullptr);
     300        auto result = callFunction(getSymbolDescription, symbol);
     301        check(JSValueIsStrictEqual(context, result.value(), JSValueMakeUndefined(context)), "JSValueMakeSymbol with nullptr description produces a symbol value without description");
     302    }
     303    {
     304        APIString description("dope");
     305        JSValueRef symbol = JSValueMakeSymbol(context, description);
     306        auto result = callFunction(getSymbolDescription, symbol);
     307        check(JSValueIsStrictEqual(context, result.value(), JSValueMakeString(context, description)), "JSValueMakeSymbol with description string produces a symbol value with description");
     308    }
    286309}
    287310
     
    495518    RUN(basicSymbol());
    496519    RUN(symbolsTypeof());
     520    RUN(symbolsDescription());
    497521    RUN(symbolsGetPropertyForKey());
    498522    RUN(symbolsSetPropertyForKey());
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/ChangeLog

    r245445 r245446  
     12019-05-06  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] We should check OOM for description string of Symbol
     4        https://bugs.webkit.org/show_bug.cgi?id=197634
     5
     6        Reviewed by Keith Miller.
     7
     8        When resoling JSString for description of Symbol, we should check OOM error.
     9        We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value
     10        without description, (1) to simplify the code and (2) give a way for JSC API
     11        to create a symbol value without description.
     12
     13        * API/JSValueRef.cpp:
     14        (JSValueMakeSymbol):
     15        * API/tests/testapi.cpp:
     16        (TestAPI::symbolsTypeof):
     17        (TestAPI::symbolsDescription):
     18        (testCAPIViaCpp):
     19        * dfg/DFGOperations.cpp:
     20        * runtime/Symbol.cpp:
     21        (JSC::Symbol::createWithDescription):
     22        * runtime/Symbol.h:
     23        * runtime/SymbolConstructor.cpp:
     24        (JSC::callSymbol):
     25
    1262019-05-04  Tadeu Zagallo  <tzagallo@apple.com>
    227
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r244010 r245446  
    22802280    VM& vm = exec->vm();
    22812281    NativeCallFrameTracer tracer(&vm, exec);
    2282 
    2283     return Symbol::create(exec, description);
     2282    auto scope = DECLARE_THROW_SCOPE(vm);
     2283
     2284    String string = description->value(exec);
     2285    RETURN_IF_EXCEPTION(scope, nullptr);
     2286
     2287    return Symbol::createWithDescription(vm, string);
    22842288}
    22852289
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/runtime/Symbol.cpp

    r235712 r245446  
    117117}
    118118
    119 Symbol* Symbol::create(ExecState* exec, JSString* description)
     119Symbol* Symbol::createWithDescription(VM& vm, const String& description)
    120120{
    121     VM& vm = exec->vm();
    122     String desc = description->value(exec);
    123     Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, desc);
     121    Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, description);
    124122    symbol->finishCreation(vm);
    125123    return symbol;
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/runtime/Symbol.h

    r240766 r245446  
    4747
    4848    static Symbol* create(VM&);
    49     static Symbol* create(ExecState*, JSString* description);
     49    static Symbol* createWithDescription(VM&, const String&);
    5050    JS_EXPORT_PRIVATE static Symbol* create(VM&, SymbolImpl& uid);
    5151
  • releases/WebKitGTK/webkit-2.24/Source/JavaScriptCore/runtime/SymbolConstructor.cpp

    r233122 r245446  
    8080static EncodedJSValue JSC_HOST_CALL callSymbol(ExecState* exec)
    8181{
     82    VM& vm = exec->vm();
     83    auto scope = DECLARE_THROW_SCOPE(vm);
     84
    8285    JSValue description = exec->argument(0);
    8386    if (description.isUndefined())
    84         return JSValue::encode(Symbol::create(exec->vm()));
    85     return JSValue::encode(Symbol::create(exec, description.toString(exec)));
     87        return JSValue::encode(Symbol::create(vm));
     88
     89    String string = description.toWTFString(exec);
     90    RETURN_IF_EXCEPTION(scope, { });
     91    return JSValue::encode(Symbol::createWithDescription(vm, string));
    8692}
    8793
Note: See TracChangeset for help on using the changeset viewer.