Changeset 209906 in webkit


Ignore:
Timestamp:
Dec 15, 2016 8:52:20 PM (7 years ago)
Author:
Darin Adler
Message:

Use asString instead of toWTFString, toString, or getString when we already checked isString
https://bugs.webkit.org/show_bug.cgi?id=165895

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

Once we have called isString, we should always use asString and value rather than using
functions that have to deal with non-JSString objects. This leads to slightly fewer branches,
slightly less reference count churn, since the string is stored right inside the JSString,
and obviates the need for exception handling.

  • bindings/ScriptValue.cpp:

(Inspector::jsToInspectorValue): Use asString/value instead of getString.

  • dfg/DFGOperations.cpp:

(JSC::DFG::operationMapHash): Call jsMapHash with its new arguments.

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension): Use asString/value instead
of toWTFString.

  • inspector/JSJavaScriptCallFrame.cpp:

(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension): Ditto.

  • inspector/agents/InspectorHeapAgent.cpp:

(Inspector::InspectorHeapAgent::getPreview): Use asString/tryGetValue, instead of the
peculiar getString(nullptr) that was here before.

  • jsc.cpp:

(functionGetGetterSetter): Use asString/toIdentifier instead of the much less efficient
toWTFString/Identifier::fromString.
(functionIsRope): Use asString instead of jsCast<JSString*>; same thing, but we should
prefer the asString function, since it exists.
(functionFindTypeForExpression): Use asString/value instead of getString.
(functionHasBasicBlockExecuted): Ditto.
(functionBasicBlockExecutionCount): Ditto.
(functionCreateBuiltin): Use asString/value instead of toWTFString and removed
unneeded RETURN_IF_EXCEPTION.
(valueWithTypeOfWasmValue): Use asString instead of jsCast<String*>.
(box): Ditto.

  • runtime/DateConstructor.cpp:

(JSC::constructDate): Use asString/values instead of getString.

  • runtime/ExceptionHelpers.cpp:

(JSC::errorDescriptionForValue): Tweaked formatting.

  • runtime/HashMapImpl.h:

(JSC::jsMapHash): Changed this function to use asString/value.

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::dumpInContextAssumingStructure): Use asString instead of
jsCast<JSString*>.
(JSC::JSValue::dumpForBacktrace): Ditto.

  • runtime/JSCJSValueInlines.h:

(JSC::toPreferredPrimitiveType): Ditto.

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval): Use asString/value instead of toWTFString.

  • runtime/JSString.cpp:

(JSC::JSString::destroy): Streamlined by removing local variable.
(JSC::JSString::estimatedSize): Use asString instead of jsCast<JSString*>.
(JSC::JSString::visitChildren): Ditto.
(JSC::JSString::toThis): Ditto.

  • runtime/JSString.h:

(JSC::JSValue::toString): Ditto.
(JSC::JSValue::toStringOrNull): Ditto.

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncValueOf): Ditto.

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncToString): Ditto.

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncRepeatCharacter): Ditto.
(JSC::stringProtoFuncSubstr): Ditto.
(JSC::builtinStringSubstrInternal): Simplified assertion by removing local variable.

Source/WebCore:

  • Modules/fetch/FetchBody.cpp:

(WebCore::FetchBody::extract): Use asString/value instead of toWTFString.

  • Modules/mediastream/SDPProcessor.cpp:

(WebCore::SDPProcessor::callScript): Use asString/value instead of getString.

  • bindings/js/ArrayValue.cpp:

(WebCore::ArrayValue::get): Use asString/value instead of toWTFString.

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::get): Use asString/length instead of toString/length.
(WebCore::createIDBKeyFromValue): Use asString/value instead of toWTFString.

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier): Ditto.

  • bindings/js/JSDataCueCustom.cpp:

(WebCore::constructJSDataCue): Use asString/value instead of getString.

  • bindings/js/JSInspectorFrontendHostCustom.cpp:

(WebCore::populateContextMenuItems): Use asString/value instead of toWTFString.

  • bindings/js/ScriptController.cpp:

(WebCore::jsValueToModuleKey): Use asString/toIdentifier instead of
jsCast<JSString*>/value/Identifier::fromString.

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::dumpIfTerminal): Streamline by getting rid of local variable.

  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::getDomainList): Use asString instead of jsCast<JSString*>.
(WebCore::ContentExtensions::loadTrigger): Use asString/value instead of toWTFString.
(WebCore::ContentExtensions::loadAction): Ditto.

  • css/FontFace.cpp:

(WebCore::FontFace::create): Use asString/value instead of getString.

Source/WebKit/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::addValueToArray): Use asString/value instead of
toWTFString.

  • WebView/WebView.mm:

(aeDescFromJSValue): Use asString/value instead of getString.

Source/WebKit2:

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant): Use asString/value instead of toWTFString.

Location:
trunk/Source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209899 r209906  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Use asString instead of toWTFString, toString, or getString when we already checked isString
     4        https://bugs.webkit.org/show_bug.cgi?id=165895
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Once we have called isString, we should always use asString and value rather than using
     9        functions that have to deal with non-JSString objects. This leads to slightly fewer branches,
     10        slightly less reference count churn, since the string is stored right inside the JSString,
     11        and obviates the need for exception handling.
     12
     13        * bindings/ScriptValue.cpp:
     14        (Inspector::jsToInspectorValue): Use asString/value instead of getString.
     15        * dfg/DFGOperations.cpp:
     16        (JSC::DFG::operationMapHash): Call jsMapHash with its new arguments.
     17        * inspector/JSInjectedScriptHost.cpp:
     18        (Inspector::JSInjectedScriptHost::evaluateWithScopeExtension): Use asString/value instead
     19        of toWTFString.
     20        * inspector/JSJavaScriptCallFrame.cpp:
     21        (Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension): Ditto.
     22        * inspector/agents/InspectorHeapAgent.cpp:
     23        (Inspector::InspectorHeapAgent::getPreview): Use asString/tryGetValue, instead of the
     24        peculiar getString(nullptr) that was here before.
     25        * jsc.cpp:
     26        (functionGetGetterSetter): Use asString/toIdentifier instead of the much less efficient
     27        toWTFString/Identifier::fromString.
     28        (functionIsRope): Use asString instead of jsCast<JSString*>; same thing, but we should
     29        prefer the asString function, since it exists.
     30        (functionFindTypeForExpression): Use asString/value instead of getString.
     31        (functionHasBasicBlockExecuted): Ditto.
     32        (functionBasicBlockExecutionCount): Ditto.
     33        (functionCreateBuiltin): Use asString/value instead of toWTFString and removed
     34        unneeded RETURN_IF_EXCEPTION.
     35        (valueWithTypeOfWasmValue): Use asString instead of jsCast<String*>.
     36        (box): Ditto.
     37        * runtime/DateConstructor.cpp:
     38        (JSC::constructDate): Use asString/values instead of getString.
     39        * runtime/ExceptionHelpers.cpp:
     40        (JSC::errorDescriptionForValue): Tweaked formatting.
     41
     42        * runtime/HashMapImpl.h:
     43        (JSC::jsMapHash): Changed this function to use asString/value.
     44
     45        * runtime/JSCJSValue.cpp:
     46        (JSC::JSValue::dumpInContextAssumingStructure): Use asString instead of
     47        jsCast<JSString*>.
     48        (JSC::JSValue::dumpForBacktrace): Ditto.
     49        * runtime/JSCJSValueInlines.h:
     50        (JSC::toPreferredPrimitiveType): Ditto.
     51
     52        * runtime/JSGlobalObjectFunctions.cpp:
     53        (JSC::globalFuncEval): Use asString/value instead of toWTFString.
     54
     55        * runtime/JSString.cpp:
     56        (JSC::JSString::destroy): Streamlined by removing local variable.
     57        (JSC::JSString::estimatedSize): Use asString instead of jsCast<JSString*>.
     58        (JSC::JSString::visitChildren): Ditto.
     59        (JSC::JSString::toThis): Ditto.
     60        * runtime/JSString.h:
     61        (JSC::JSValue::toString): Ditto.
     62        (JSC::JSValue::toStringOrNull): Ditto.
     63        * runtime/NumberPrototype.cpp:
     64        (JSC::numberProtoFuncValueOf): Ditto.
     65        * runtime/ObjectPrototype.cpp:
     66        (JSC::objectProtoFuncToString): Ditto.
     67        * runtime/StringPrototype.cpp:
     68        (JSC::stringProtoFuncRepeatCharacter): Ditto.
     69        (JSC::stringProtoFuncSubstr): Ditto.
     70        (JSC::builtinStringSubstrInternal): Simplified assertion by removing local variable.
     71
    1722016-12-15  Keith Miller  <keith_miller@apple.com>
    273
  • trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp

    r209801 r209906  
    6262        return InspectorValue::create(static_cast<int>(value.asAnyInt()));
    6363    if (value.isString())
    64         return InspectorValue::create(value.getString(&scriptState));
     64        return InspectorValue::create(asString(value)->value(&scriptState));
    6565
    6666    if (value.isObject()) {
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r209801 r209906  
    103103        return throwTypeError(exec, scope, ASCIILiteral("InjectedScriptHost.evaluateWithScopeExtension first argument must be a string."));
    104104
    105     String program = scriptValue.toWTFString(exec);
     105    String program = asString(scriptValue)->value(exec);
    106106    RETURN_IF_EXCEPTION(scope, JSValue());
    107107
  • trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp

    r209801 r209906  
    8383        return throwTypeError(exec, scope, ASCIILiteral("JSJavaScriptCallFrame.evaluateWithScopeExtension first argument must be a string."));
    8484
    85     String script = scriptValue.toWTFString(exec);
     85    String script = asString(scriptValue)->value(exec);
    8686    RETURN_IF_EXCEPTION(scope, JSValue());
    8787
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp

    r209570 r209906  
    252252    JSCell* cell = optionalNode->cell;
    253253    if (cell->isString()) {
    254         *resultString = cell->getString(nullptr);
     254        *resultString = asString(cell)->tryGetValue();
    255255        return;
    256256    }
  • trunk/Source/JavaScriptCore/jsc.cpp

    r209897 r209906  
    18771877        return JSValue::encode(jsUndefined());
    18781878
    1879     Identifier ident = Identifier::fromString(&exec->vm(), property.toWTFString(exec));
    1880 
    18811879    PropertySlot slot(value, PropertySlot::InternalMethodType::VMInquiry);
    1882     value.getPropertySlot(exec, ident, slot);
     1880    value.getPropertySlot(exec, asString(property)->toIdentifier(exec), slot);
    18831881
    18841882    JSValue result;
     
    21052103    if (!argument.isString())
    21062104        return JSValue::encode(jsBoolean(false));
    2107     const StringImpl* impl = jsCast<JSString*>(argument)->tryGetValueImpl();
     2105    const StringImpl* impl = asString(argument)->tryGetValueImpl();
    21082106    return JSValue::encode(jsBoolean(!impl));
    21092107}
     
    22832281
    22842282    RELEASE_ASSERT(exec->argument(1).isString());
    2285     String substring = exec->argument(1).getString(exec);
     2283    String substring = asString(exec->argument(1))->value(exec);
    22862284    String sourceCodeText = executable->source().view().toString();
    22872285    unsigned offset = static_cast<unsigned>(sourceCodeText.find(substring) + executable->source().startOffset());
     
    23212319
    23222320    RELEASE_ASSERT(exec->argument(1).isString());
    2323     String substring = exec->argument(1).getString(exec);
     2321    String substring = asString(exec->argument(1))->value(exec);
    23242322    String sourceCodeText = executable->source().view().toString();
    23252323    RELEASE_ASSERT(sourceCodeText.contains(substring));
     
    23392337
    23402338    RELEASE_ASSERT(exec->argument(1).isString());
    2341     String substring = exec->argument(1).getString(exec);
     2339    String substring = asString(exec->argument(1))->value(exec);
    23422340    String sourceCodeText = executable->source().view().toString();
    23432341    RELEASE_ASSERT(sourceCodeText.contains(substring));
     
    24042402        return JSValue::encode(jsUndefined());
    24052403
    2406     String functionText = exec->argument(0).toWTFString(exec);
     2404    String functionText = asString(exec->argument(0))->value(exec);
    24072405    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    24082406
     
    25112509static CString valueWithTypeOfWasmValue(ExecState* exec, VM& vm, JSValue value, JSValue wasmValue)
    25122510{
    2513     JSString* type = jsCast<JSString*>(wasmValue.get(exec, makeIdentifier(vm, "type")));
     2511    JSString* type = asString(wasmValue.get(exec, makeIdentifier(vm, "type")));
    25142512
    25152513    const String& typeString = type->value(exec);
     
    25242522{
    25252523
    2526     JSString* type = jsCast<JSString*>(wasmValue.get(exec, makeIdentifier(vm, "type")));
     2524    JSString* type = asString(wasmValue.get(exec, makeIdentifier(vm, "type")));
    25272525    JSValue value = wasmValue.get(exec, makeIdentifier(vm, "value"));
    25282526
     
    25312529            return false;
    25322530
    2533         const char* str = toCString(jsCast<JSString*>(value)->value(exec)).data();
     2531        const char* str = toCString(asString(value)->value(exec)).data();
    25342532        int scanResult;
    25352533        int length = std::strlen(str);
  • trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp

    r209801 r209906  
    161161            RETURN_IF_EXCEPTION(scope, nullptr);
    162162            if (primitive.isString())
    163                 value = parseDate(vm, primitive.getString(exec));
     163                value = parseDate(vm, asString(primitive)->value(exec));
    164164            else
    165165                value = primitive.toNumber(exec);
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r208410 r209906  
    8686{
    8787    if (v.isString())
    88         return jsNontrivialString(exec, makeString('"',  asString(v)->value(exec), '"'));
     88        return jsNontrivialString(exec, makeString('"', asString(v)->value(exec), '"'));
    8989    if (v.isSymbol())
    9090        return jsNontrivialString(exec, asSymbol(v)->descriptiveString());
  • trunk/Source/JavaScriptCore/runtime/HashMapImpl.h

    r208985 r209906  
    241241    ASSERT_WITH_MESSAGE(normalizeMapKey(value) == value, "We expect normalized values flowing into this function.");
    242242
    243     auto scope = DECLARE_THROW_SCOPE(vm);
    244 
    245243    if (value.isString()) {
    246         JSString* string = asString(value);
    247         const String& wtfString = string->value(exec);
     244        auto scope = DECLARE_THROW_SCOPE(vm);
     245        const String& wtfString = asString(value)->value(exec);
    248246        RETURN_IF_EXCEPTION(scope, UINT_MAX);
    249247        return wtfString.impl()->hash();
    250248    }
    251249
    252     uint64_t rawValue = JSValue::encode(value);
    253     return wangsInt64Hash(rawValue);
     250    return wangsInt64Hash(JSValue::encode(value));
    254251}
    255252
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r209793 r209906  
    248248    } else if (isCell()) {
    249249        if (structure->classInfo()->isSubClassOf(JSString::info())) {
    250             JSString* string = jsCast<JSString*>(asCell());
     250            JSString* string = asString(asCell());
    251251            out.print("String");
    252252            if (string->isRope())
     
    300300    else if (isCell()) {
    301301        if (asCell()->inherits(JSString::info())) {
    302             JSString* string = jsCast<JSString*>(asCell());
     302            JSString* string = asString(asCell());
    303303            const StringImpl* impl = string->tryGetValueImpl();
    304304            if (impl)
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r208564 r209906  
    663663    }
    664664
    665     StringImpl* hintString = jsCast<JSString*>(value)->value(exec).impl();
     665    StringImpl* hintString = asString(value)->value(exec).impl();
    666666    RETURN_IF_EXCEPTION(scope, NoPreference);
    667667
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r209801 r209906  
    667667    }
    668668
    669     String s = x.toWTFString(exec);
     669    String s = asString(x)->value(exec);
    670670    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    671671
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r209897 r209906  
    5353void JSString::destroy(JSCell* cell)
    5454{
    55     JSString* thisObject = static_cast<JSString*>(cell);
    56     thisObject->JSString::~JSString();
     55    static_cast<JSString*>(cell)->JSString::~JSString();
    5756}
    5857
     
    8584size_t JSString::estimatedSize(JSCell* cell)
    8685{
    87     JSString* thisObject = jsCast<JSString*>(cell);
     86    JSString* thisObject = asString(cell);
    8887    if (thisObject->isRope())
    8988        return Base::estimatedSize(cell);
     
    9392void JSString::visitChildren(JSCell* cell, SlotVisitor& visitor)
    9493{
    95     JSString* thisObject = jsCast<JSString*>(cell);
     94    JSString* thisObject = asString(cell);
    9695    Base::visitChildren(thisObject, visitor);
    9796   
     
    422421    if (ecmaMode == StrictMode)
    423422        return cell;
    424     return StringObject::create(exec->vm(), exec->lexicalGlobalObject(), jsCast<JSString*>(cell));
     423    return StringObject::create(exec->vm(), exec->lexicalGlobalObject(), asString(cell));
    425424}
    426425
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r208985 r209906  
    756756{
    757757    if (isString())
    758         return jsCast<JSString*>(asCell());
     758        return asString(asCell());
    759759    bool returnEmptyStringOnError = true;
    760760    return toStringSlowCase(exec, returnEmptyStringOnError);
     
    764764{
    765765    if (isString())
    766         return jsCast<JSString*>(asCell());
     766        return asString(asCell());
    767767    bool returnEmptyStringOnError = false;
    768768    return toStringSlowCase(exec, returnEmptyStringOnError);
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp

    r205198 r209906  
    540540    JSValue thisValue = exec->thisValue();
    541541    if (!toThisNumber(thisValue, x))
    542         return throwVMTypeError(exec, scope, WTF::makeString("thisNumberValue called on incompatible ", jsCast<JSString*>(jsTypeStringForValue(exec, thisValue))->value(exec)));
     542        return throwVMTypeError(exec, scope, WTF::makeString("thisNumberValue called on incompatible ", asString(jsTypeStringForValue(exec, thisValue))->value(exec)));
    543543    return JSValue::encode(jsNumber(x));
    544544}
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r209761 r209906  
    327327                JSRopeString::RopeBuilder ropeBuilder(vm);
    328328                ropeBuilder.append(vm.smallStrings.objectStringStart());
    329                 ropeBuilder.append(jsCast<JSString*>(stringTag));
     329                ropeBuilder.append(asString(stringTag));
    330330                ropeBuilder.append(vm.smallStrings.singleCharacterString(']'));
    331331                JSString* result = ropeBuilder.release();
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r209801 r209906  
    811811
    812812    ASSERT(exec->uncheckedArgument(0).isString());
    813     JSString* string = jsCast<JSString*>(exec->uncheckedArgument(0));
     813    JSString* string = asString(exec->uncheckedArgument(0));
    814814    ASSERT(string->length() == 1);
    815815
     
    13221322    String uString;
    13231323    if (thisValue.isString()) {
    1324         jsString = jsCast<JSString*>(thisValue.asCell());
     1324        jsString = asString(thisValue);
    13251325        len = jsString->length();
    13261326    } else {
     
    13611361    // will not need to call toString() on the thisValue, and there will be no observable
    13621362    // side-effects.
    1363 #if !ASSERT_DISABLED
    1364     JSValue thisValue = exec->thisValue();
    1365     ASSERT(thisValue.isString());
    1366 #endif
     1363    ASSERT(exec->thisValue().isString());
    13671364    return stringProtoFuncSubstr(exec);
    13681365}
  • trunk/Source/WebCore/ChangeLog

    r209903 r209906  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Use asString instead of toWTFString, toString, or getString when we already checked isString
     4        https://bugs.webkit.org/show_bug.cgi?id=165895
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * Modules/fetch/FetchBody.cpp:
     9        (WebCore::FetchBody::extract): Use asString/value instead of toWTFString.
     10
     11        * Modules/mediastream/SDPProcessor.cpp:
     12        (WebCore::SDPProcessor::callScript): Use asString/value instead of getString.
     13
     14        * bindings/js/ArrayValue.cpp:
     15        (WebCore::ArrayValue::get): Use asString/value instead of toWTFString.
     16
     17        * bindings/js/IDBBindingUtilities.cpp:
     18        (WebCore::get): Use asString/length instead of toString/length.
     19        (WebCore::createIDBKeyFromValue): Use asString/value instead of toWTFString.
     20        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     21        (WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier): Ditto.
     22        * bindings/js/JSDataCueCustom.cpp:
     23        (WebCore::constructJSDataCue): Use asString/value instead of getString.
     24        * bindings/js/JSInspectorFrontendHostCustom.cpp:
     25        (WebCore::populateContextMenuItems): Use asString/value instead of toWTFString.
     26
     27        * bindings/js/ScriptController.cpp:
     28        (WebCore::jsValueToModuleKey): Use asString/toIdentifier instead of
     29        jsCast<JSString*>/value/Identifier::fromString.
     30
     31        * bindings/js/SerializedScriptValue.cpp:
     32        (WebCore::CloneSerializer::dumpIfTerminal): Streamline by getting rid of local variable.
     33
     34        * contentextensions/ContentExtensionParser.cpp:
     35        (WebCore::ContentExtensions::getDomainList): Use asString instead of jsCast<JSString*>.
     36        (WebCore::ContentExtensions::loadTrigger): Use asString/value instead of toWTFString.
     37        (WebCore::ContentExtensions::loadAction): Ditto.
     38
     39        * css/FontFace.cpp:
     40        (WebCore::FontFace::create): Use asString/value instead of getString.
     41
    1422016-12-15  Zalan Bujtas  <zalan@apple.com>
    243
  • trunk/Source/WebCore/Modules/fetch/FetchBody.cpp

    r209390 r209906  
    6363    if (value.isString()) {
    6464        contentType = HTTPHeaderValues::textPlainContentType();
    65         return FetchBody(value.toWTFString(&state));
     65        return FetchBody(String { asString(value)->value(&state) });
    6666    }
    6767    if (value.inherits(JSURLSearchParams::info())) {
  • trunk/Source/WebCore/Modules/mediastream/SDPProcessor.cpp

    r209683 r209906  
    539539        return false;
    540540
    541     outResult = result.getString(exec);
     541    outResult = asString(result)->value(exec);
    542542    return true;
    543543}
  • trunk/Source/WebCore/bindings/js/ArrayValue.cpp

    r206386 r209906  
    9494        return false;
    9595
    96     value = indexedValue.toWTFString(m_exec);
     96    value = asString(indexedValue)->value(m_exec);
    9797    RETURN_IF_EXCEPTION(scope, false);
    9898
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r209801 r209906  
    5757{
    5858    if (object.isString() && keyPathElement == "length") {
    59         result = jsNumber(object.toString(&exec)->length());
     59        result = jsNumber(asString(object)->length());
    6060        return true;
    6161    }
     
    149149
    150150    if (value.isString())
    151         return IDBKey::createString(value.toWTFString(&exec));
     151        return IDBKey::createString(asString(value)->value(&exec));
    152152
    153153    if (value.inherits(DateInstance::info()) && !std::isnan(valueToDate(&exec, value)))
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r209900 r209906  
    6767
    6868    if (value.isString()) {
    69         algorithmName = value.toWTFString(&state);
     69        algorithmName = asString(value)->value(&state);
    7070        RETURN_IF_EXCEPTION(scope, false);
    7171    } else if (value.isObject()) {
  • trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp

    r209229 r209906  
    7373        if (!exec.uncheckedArgument(3).isString())
    7474            return throwArgumentTypeError(exec, scope, 3, "type", "DataCue", nullptr, "DOMString");
    75         type = exec.uncheckedArgument(3).getString(&exec);
     75        type = asString(exec.uncheckedArgument(3))->value(&exec);
    7676    }
    7777#endif
  • trunk/Source/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp

    r209801 r209906  
    6363            continue;
    6464
    65         String typeString = type.toWTFString(exec);
     65        String typeString = asString(type)->value(exec);
    6666        if (typeString == "separator") {
    6767            ContextMenuItem item(SeparatorType, ContextMenuItemTagNoAction, String());
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r209683 r209906  
    356356        return Identifier::fromUid(jsCast<Symbol*>(value)->privateName());
    357357    ASSERT(value.isString());
    358     return Identifier::fromString(exec, jsCast<JSString*>(value)->value(exec));
     358    return asString(value)->toIdentifier(exec);
    359359}
    360360
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r209400 r209906  
    750750
    751751        if (value.isString()) {
    752             String str = asString(value)->value(m_exec);
    753             dumpString(str);
     752            dumpString(asString(value)->value(m_exec));
    754753            return true;
    755754        }
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r209679 r209906  
    7676       
    7777        // Domains should be punycode encoded lower case.
    78         const String& domain = jsCast<JSString*>(value)->value(&exec);
     78        const String& domain = asString(value)->value(&exec);
    7979        if (domain.isEmpty())
    8080            return ContentExtensionError::JSONInvalidDomainList;
     
    131131        return ContentExtensionError::JSONInvalidURLFilterInTrigger;
    132132
    133     String urlFilter = urlFilterObject.toWTFString(&exec);
     133    String urlFilter = asString(urlFilterObject)->value(&exec);
    134134    if (urlFilter.isEmpty())
    135135        return ContentExtensionError::JSONInvalidURLFilterInTrigger;
     
    208208        return ContentExtensionError::JSONInvalidActionType;
    209209
    210     String actionType = typeObject.toWTFString(&exec);
     210    String actionType = asString(typeObject)->value(&exec);
    211211
    212212    if (actionType == "block")
     
    221221            return ContentExtensionError::JSONInvalidCSSDisplayNoneActionType;
    222222
    223         String s = selector.toWTFString(&exec);
    224         if (!isValidSelector(s)) {
     223        String selectorString = asString(selector)->value(&exec);
     224        if (!isValidSelector(selectorString)) {
    225225            // Skip rules with invalid selectors to be backwards-compatible.
    226226            validSelector = false;
    227227            return { };
    228228        }
    229         action = Action(ActionType::CSSDisplayNoneSelector, s);
     229        action = Action(ActionType::CSSDisplayNoneSelector, selectorString);
    230230    } else if (actionType == "make-https") {
    231231        action = ActionType::MakeHTTPS;
  • trunk/Source/WebCore/css/FontFace.cpp

    r209826 r209906  
    5858
    5959    if (source.isString()) {
    60         auto value = FontFace::parseString(source.getString(&state), CSSPropertySrc);
     60        auto value = FontFace::parseString(asString(source)->value(&state), CSSPropertySrc);
    6161        if (!is<CSSValueList>(value.get()))
    6262            return Exception { SYNTAX_ERR };
  • trunk/Source/WebKit/mac/ChangeLog

    r209901 r209906  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Use asString instead of toWTFString, toString, or getString when we already checked isString
     4        https://bugs.webkit.org/show_bug.cgi?id=165895
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     9        (WebKit::NetscapePluginInstanceProxy::addValueToArray): Use asString/value instead of
     10        toWTFString.
     11        * WebView/WebView.mm:
     12        (aeDescFromJSValue): Use asString/value instead of getString.
     13
    1142016-12-15  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r208985 r209906  
    13211321    if (value.isString()) {
    13221322        [array addObject:[NSNumber numberWithInt:StringValueType]];
    1323         [array addObject:value.toWTFString(exec)];
     1323        [array addObject:asString(value)->value(exec)];
    13241324    } else if (value.isNumber()) {
    13251325        [array addObject:[NSNumber numberWithInt:DoubleValueType]];
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r209865 r209906  
    73707370        return [NSAppleEventDescriptor descriptorWithBoolean:jsValue.asBoolean()];
    73717371    if (jsValue.isString())
    7372         return [NSAppleEventDescriptor descriptorWithString:jsValue.getString(exec)];
     7372        return [NSAppleEventDescriptor descriptorWithString:asString(jsValue)->value(exec)];
    73737373    if (jsValue.isNumber()) {
    73747374        double value = jsValue.asNumber();
  • trunk/Source/WebKit2/ChangeLog

    r209901 r209906  
     12016-12-15  Darin Adler  <darin@apple.com>
     2
     3        Use asString instead of toWTFString, toString, or getString when we already checked isString
     4        https://bugs.webkit.org/show_bug.cgi?id=165895
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
     9        (WebKit::NPRuntimeObjectMap::convertJSValueToNPVariant): Use asString/value instead of toWTFString.
     10
    1112016-12-15  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

    r209801 r209906  
    169169
    170170    if (value.isString()) {
    171         NPString npString = createNPString(value.toWTFString(exec).utf8());
     171        NPString npString = createNPString(asString(value)->value(exec).utf8());
    172172        STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, variant);
    173173        return;
Note: See TracChangeset for help on using the changeset viewer.