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

Changeset 245411 in webkit


Ignore:
Timestamp:
May 16, 2019, 3:47:59 PM (7 years ago)
Author:
Kocsen Chung
Message:

Revert "Cherry-pick r244996. rdar://problem/50754980"

Location:
branches/safari-607.2.1.2-branch
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-607.2.1.2-branch/JSTests/ChangeLog

    r245410 r245411  
    1 2019-05-15  Alan Coon  <alancoon@apple.com>
    2 
    3         Cherry-pick r244996. rdar://problem/50754980
    4 
    5     [JSC] We should check OOM for description string of Symbol
    6     https://bugs.webkit.org/show_bug.cgi?id=197634
    7    
    8     Reviewed by Keith Miller.
    9    
    10     JSTests:
    11    
    12     * stress/check-symbol-description-oom.js: Added.
    13     (shouldThrow):
    14    
    15     Source/JavaScriptCore:
    16    
    17     When resoling JSString for description of Symbol, we should check OOM error.
    18     We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value
    19     without description, (1) to simplify the code and (2) give a way for JSC API
    20     to create a symbol value without description.
    21    
    22     * API/JSValueRef.cpp:
    23     (JSValueMakeSymbol):
    24     * API/tests/testapi.cpp:
    25     (TestAPI::symbolsTypeof):
    26     (TestAPI::symbolsDescription):
    27     (testCAPIViaCpp):
    28     * dfg/DFGOperations.cpp:
    29     * runtime/Symbol.cpp:
    30     (JSC::Symbol::createWithDescription):
    31     * runtime/Symbol.h:
    32     * runtime/SymbolConstructor.cpp:
    33     (JSC::callSymbol):
    34    
    35     git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    36 
    37     2019-05-06  Yusuke Suzuki  <ysuzuki@apple.com>
    38 
    39             [JSC] We should check OOM for description string of Symbol
    40             https://bugs.webkit.org/show_bug.cgi?id=197634
    41 
    42             Reviewed by Keith Miller.
    43 
    44             * stress/check-symbol-description-oom.js: Added.
    45             (shouldThrow):
    46 
    4712019-05-15  Alan Coon  <alancoon@apple.com>
    482
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/API/JSValueRef.cpp

    r245332 r245411  
    331331    }
    332332    ExecState* exec = toJS(ctx);
    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()));
     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));
    339340}
    340341
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/API/tests/testapi.cpp

    r245332 r245411  
    130130    void basicSymbol();
    131131    void symbolsTypeof();
    132     void symbolsDescription();
    133132    void symbolsGetPropertyForKey();
    134133    void symbolsSetPropertyForKey();
     
    269268
    270269static const char* isSymbolFunction = "(function isSymbol(symbol) { return typeof(symbol) === 'symbol'; })";
    271 static const char* getSymbolDescription = "(function getSymbolDescription(symbol) { return symbol.description; })";
    272270static const char* getFunction = "(function get(object, key) { return object[key]; })";
    273271static const char* setFunction = "(function set(object, key, value) { object[key] = value; })";
     
    283281void TestAPI::symbolsTypeof()
    284282{
    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 
    296 void 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     }
     283    APIString description("dope");
     284    JSValueRef symbol = JSValueMakeSymbol(context, description);
     285    check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value");
    309286}
    310287
     
    518495    RUN(basicSymbol());
    519496    RUN(symbolsTypeof());
    520     RUN(symbolsDescription());
    521497    RUN(symbolsGetPropertyForKey());
    522498    RUN(symbolsSetPropertyForKey());
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/ChangeLog

    r245410 r245411  
    1 2019-05-15  Alan Coon  <alancoon@apple.com>
    2 
    3         Cherry-pick r244996. rdar://problem/50754980
    4 
    5     [JSC] We should check OOM for description string of Symbol
    6     https://bugs.webkit.org/show_bug.cgi?id=197634
    7    
    8     Reviewed by Keith Miller.
    9    
    10     JSTests:
    11    
    12     * stress/check-symbol-description-oom.js: Added.
    13     (shouldThrow):
    14    
    15     Source/JavaScriptCore:
    16    
    17     When resoling JSString for description of Symbol, we should check OOM error.
    18     We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value
    19     without description, (1) to simplify the code and (2) give a way for JSC API
    20     to create a symbol value without description.
    21    
    22     * API/JSValueRef.cpp:
    23     (JSValueMakeSymbol):
    24     * API/tests/testapi.cpp:
    25     (TestAPI::symbolsTypeof):
    26     (TestAPI::symbolsDescription):
    27     (testCAPIViaCpp):
    28     * dfg/DFGOperations.cpp:
    29     * runtime/Symbol.cpp:
    30     (JSC::Symbol::createWithDescription):
    31     * runtime/Symbol.h:
    32     * runtime/SymbolConstructor.cpp:
    33     (JSC::callSymbol):
    34    
    35     git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    36 
    37     2019-05-06  Yusuke Suzuki  <ysuzuki@apple.com>
    38 
    39             [JSC] We should check OOM for description string of Symbol
    40             https://bugs.webkit.org/show_bug.cgi?id=197634
    41 
    42             Reviewed by Keith Miller.
    43 
    44             When resoling JSString for description of Symbol, we should check OOM error.
    45             We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value
    46             without description, (1) to simplify the code and (2) give a way for JSC API
    47             to create a symbol value without description.
    48 
    49             * API/JSValueRef.cpp:
    50             (JSValueMakeSymbol):
    51             * API/tests/testapi.cpp:
    52             (TestAPI::symbolsTypeof):
    53             (TestAPI::symbolsDescription):
    54             (testCAPIViaCpp):
    55             * dfg/DFGOperations.cpp:
    56             * runtime/Symbol.cpp:
    57             (JSC::Symbol::createWithDescription):
    58             * runtime/Symbol.h:
    59             * runtime/SymbolConstructor.cpp:
    60             (JSC::callSymbol):
    61 
    6212019-05-15  Alan Coon  <alancoon@apple.com>
    632
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r245332 r245411  
    22732273    VM& vm = exec->vm();
    22742274    NativeCallFrameTracer tracer(&vm, exec);
    2275     auto scope = DECLARE_THROW_SCOPE(vm);
    2276 
    2277     String string = description->value(exec);
    2278     RETURN_IF_EXCEPTION(scope, nullptr);
    2279 
    2280     return Symbol::createWithDescription(vm, string);
     2275
     2276    return Symbol::create(exec, description);
    22812277}
    22822278
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/Symbol.cpp

    r245332 r245411  
    117117}
    118118
    119 Symbol* Symbol::createWithDescription(VM& vm, const String& description)
     119Symbol* Symbol::create(ExecState* exec, JSString* description)
    120120{
    121     Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, description);
     121    VM& vm = exec->vm();
     122    String desc = description->value(exec);
     123    Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, desc);
    122124    symbol->finishCreation(vm);
    123125    return symbol;
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/Symbol.h

    r245332 r245411  
    5353
    5454    static Symbol* create(VM&);
    55     static Symbol* createWithDescription(VM&, const String&);
     55    static Symbol* create(ExecState*, JSString* description);
    5656    JS_EXPORT_PRIVATE static Symbol* create(VM&, SymbolImpl& uid);
    5757
  • branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/SymbolConstructor.cpp

    r245332 r245411  
    8080static EncodedJSValue JSC_HOST_CALL callSymbol(ExecState* exec)
    8181{
    82     VM& vm = exec->vm();
    83     auto scope = DECLARE_THROW_SCOPE(vm);
    84 
    8582    JSValue description = exec->argument(0);
    8683    if (description.isUndefined())
    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));
     84        return JSValue::encode(Symbol::create(exec->vm()));
     85    return JSValue::encode(Symbol::create(exec, description.toString(exec)));
    9286}
    9387
Note: See TracChangeset for help on using the changeset viewer.