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

Changeset 202890 in webkit


Ignore:
Timestamp:
Jul 6, 2016, 8:12:37 PM (10 years ago)
Author:
benjamin@webkit.org
Message:

[JSC] Unify how we throw TypeError from C++
https://bugs.webkit.org/show_bug.cgi?id=159500

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-06
Reviewed by Saam Barati.

Source/JavaScriptCore:

Throwing a TypeError is an uncommon case. We should minimize the impact
on the call sites.

This patch does that by:
-Replace the 2 calls createTypeError()->throwException() by throwTypeError().
-Use ASCIILiteral when possible.
-Add an overload of throwTypeError() taking ASCIILiteral directly

(that way, the String creation and destruction is done by the callee).

On x86_64, this reduces the TEXT segment by 29kb.

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):

  • inspector/JSJavaScriptCallFrame.cpp:

(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • jit/JITOperations.cpp:
  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncToJSON):

  • runtime/Error.cpp:

(JSC::throwConstructorCannotBeCalledAsFunctionTypeError):
(JSC::throwTypeError):

  • runtime/Error.h:

(JSC::throwVMTypeError):

  • runtime/JSArrayBufferPrototype.cpp:

(JSC::arrayBufferProtoFuncSlice):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::putToPrimitive):
(JSC::JSValue::toStringSlowCase):

  • runtime/JSCJSValueInlines.h:

(JSC::toPreferredPrimitiveType):

  • runtime/JSDataViewPrototype.cpp:

(JSC::getData):
(JSC::setData):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::constructGenericTypedArrayViewFromIterator):
(JSC::constructGenericTypedArrayViewWithArguments):
(JSC::constructGenericTypedArrayView):

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::speciesConstruct):
(JSC::genericTypedArrayViewProtoFuncSet):
(JSC::genericTypedArrayViewProtoFuncCopyWithin):
(JSC::genericTypedArrayViewProtoFuncIndexOf):
(JSC::genericTypedArrayViewProtoFuncLastIndexOf):
(JSC::genericTypedArrayViewProtoFuncSubarray):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoGetter):
(JSC::globalFuncProtoSetter):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendStringifiedValue):

  • runtime/JSObject.cpp:

(JSC::JSObject::setPrototypeWithCycleCheck):
(JSC::callToPrimitiveFunction):
(JSC::JSObject::ordinaryToPrimitive):
(JSC::JSObject::defaultHasInstance):
(JSC::validateAndApplyPropertyDescriptor):

  • runtime/JSTypedArrayViewConstructor.cpp:

(JSC::constructTypedArrayView):

  • runtime/JSTypedArrayViewPrototype.cpp:

(JSC::typedArrayViewPrivateFuncLength):
(JSC::typedArrayViewProtoFuncSet):
(JSC::typedArrayViewProtoFuncCopyWithin):
(JSC::typedArrayViewProtoFuncFill):
(JSC::typedArrayViewProtoFuncLastIndexOf):
(JSC::typedArrayViewProtoFuncIndexOf):
(JSC::typedArrayViewProtoFuncJoin):
(JSC::typedArrayViewProtoGetterFuncBuffer):
(JSC::typedArrayViewProtoGetterFuncLength):
(JSC::typedArrayViewProtoGetterFuncByteLength):
(JSC::typedArrayViewProtoGetterFuncByteOffset):
(JSC::typedArrayViewProtoFuncReverse):
(JSC::typedArrayViewProtoFuncSubarray):
(JSC::typedArrayViewProtoFuncSlice):

  • runtime/ObjectConstructor.cpp:

(JSC::toPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncCompile):

  • runtime/Symbol.cpp:

(JSC::Symbol::toNumber):

Source/WebCore:

  • bindings/js/JSBiquadFilterNodeCustom.cpp:

(WebCore::JSBiquadFilterNode::setType):

  • bindings/js/JSBlobCustom.cpp:

(WebCore::constructJSBlob):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::getBigIntegerVectorFromJSON):
(WebCore::JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK):
(WebCore::tryJWKKeyOpsValue):
(WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
(WebCore::JSCryptoKeySerializationJWK::keyDataOctetSequence):
(WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents):
(WebCore::JSCryptoKeySerializationJWK::keyData):
(WebCore::addJWKAlgorithmToJSON):
(WebCore::JSCryptoKeySerializationJWK::serialize):

  • bindings/js/JSCryptoOperationData.cpp:

(WebCore::cryptoOperationDataFromJSValue):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::enforceRange):
(WebCore::throwTypeError):
(WebCore::throwArgumentMustBeEnumError):
(WebCore::throwArgumentMustBeFunctionError):
(WebCore::throwArgumentTypeError):
(WebCore::throwArrayElementTypeError):
(WebCore::throwGetterTypeError):
(WebCore::throwThisTypeError):

  • bindings/js/JSDataCueCustom.cpp:

(WebCore::constructJSDataCue):

  • bindings/js/JSDocumentCustom.cpp:

(WebCore::JSDocument::defineElement):

  • bindings/js/JSFileCustom.cpp:

(WebCore::constructJSFile):

  • bindings/js/JSModuleLoader.cpp:

(WebCore::JSModuleLoader::evaluate):

  • bindings/js/JSMutationObserverCustom.cpp:

(WebCore::constructJSMutationObserver):

  • bindings/js/JSOscillatorNodeCustom.cpp:

(WebCore::JSOscillatorNode::setType):

  • bindings/js/JSPannerNodeCustom.cpp:

(WebCore::JSPannerNode::setPanningModel):
(WebCore::JSPannerNode::setDistanceModel):

  • bindings/js/JSReadableStreamPrivateConstructors.cpp:

(WebCore::constructJSReadableStreamController):
(WebCore::constructJSReadableStreamReader):

  • bindings/js/JSSubtleCryptoCustom.cpp:

(WebCore::cryptoKeyFormatFromJSValue):
(WebCore::importKey):
(WebCore::exportKey):

  • bindings/js/ReadableStreamController.cpp:

(WebCore::ReadableStreamController::invoke):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::throwValidationError):
(WebCore::SerializedScriptValue::maybeThrowExceptionIfSerializationFailed):

  • bridge/c/c_instance.cpp:

(JSC::Bindings::CInstance::invokeMethod):

  • bridge/objc/objc_instance.mm:

(ObjcInstance::invokeMethod):

  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::ObjcArray::setValueAt):

Source/WebKit/mac:

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyInstance::invokeMethod):

Location:
trunk/Source
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r202866 r202890  
     12016-07-06  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Unify how we throw TypeError from C++
     4        https://bugs.webkit.org/show_bug.cgi?id=159500
     5
     6        Reviewed by Saam Barati.
     7
     8        Throwing a TypeError is an uncommon case. We should minimize the impact
     9        on the call sites.
     10
     11        This patch does that by:
     12        -Replace the 2 calls createTypeError()->throwException() by throwTypeError().
     13        -Use ASCIILiteral when possible.
     14        -Add an overload of throwTypeError() taking ASCIILiteral directly
     15         (that way, the String creation and destruction is done by the callee).
     16
     17        On x86_64, this reduces the __TEXT__ segment by 29kb.
     18
     19        * inspector/JSInjectedScriptHost.cpp:
     20        (Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
     21        * inspector/JSJavaScriptCallFrame.cpp:
     22        (Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
     23        * interpreter/Interpreter.cpp:
     24        (JSC::Interpreter::execute):
     25        * jit/JITOperations.cpp:
     26        * runtime/DatePrototype.cpp:
     27        (JSC::dateProtoFuncToJSON):
     28        * runtime/Error.cpp:
     29        (JSC::throwConstructorCannotBeCalledAsFunctionTypeError):
     30        (JSC::throwTypeError):
     31        * runtime/Error.h:
     32        (JSC::throwVMTypeError):
     33        * runtime/JSArrayBufferPrototype.cpp:
     34        (JSC::arrayBufferProtoFuncSlice):
     35        * runtime/JSCJSValue.cpp:
     36        (JSC::JSValue::putToPrimitive):
     37        (JSC::JSValue::toStringSlowCase):
     38        * runtime/JSCJSValueInlines.h:
     39        (JSC::toPreferredPrimitiveType):
     40        * runtime/JSDataViewPrototype.cpp:
     41        (JSC::getData):
     42        (JSC::setData):
     43        * runtime/JSFunction.cpp:
     44        (JSC::JSFunction::defineOwnProperty):
     45        * runtime/JSGenericTypedArrayViewConstructorInlines.h:
     46        (JSC::constructGenericTypedArrayViewFromIterator):
     47        (JSC::constructGenericTypedArrayViewWithArguments):
     48        (JSC::constructGenericTypedArrayView):
     49        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
     50        (JSC::speciesConstruct):
     51        (JSC::genericTypedArrayViewProtoFuncSet):
     52        (JSC::genericTypedArrayViewProtoFuncCopyWithin):
     53        (JSC::genericTypedArrayViewProtoFuncIndexOf):
     54        (JSC::genericTypedArrayViewProtoFuncLastIndexOf):
     55        (JSC::genericTypedArrayViewProtoFuncSubarray):
     56        * runtime/JSGlobalObjectFunctions.cpp:
     57        (JSC::globalFuncProtoGetter):
     58        (JSC::globalFuncProtoSetter):
     59        * runtime/JSONObject.cpp:
     60        (JSC::Stringifier::appendStringifiedValue):
     61        * runtime/JSObject.cpp:
     62        (JSC::JSObject::setPrototypeWithCycleCheck):
     63        (JSC::callToPrimitiveFunction):
     64        (JSC::JSObject::ordinaryToPrimitive):
     65        (JSC::JSObject::defaultHasInstance):
     66        (JSC::validateAndApplyPropertyDescriptor):
     67        * runtime/JSTypedArrayViewConstructor.cpp:
     68        (JSC::constructTypedArrayView):
     69        * runtime/JSTypedArrayViewPrototype.cpp:
     70        (JSC::typedArrayViewPrivateFuncLength):
     71        (JSC::typedArrayViewProtoFuncSet):
     72        (JSC::typedArrayViewProtoFuncCopyWithin):
     73        (JSC::typedArrayViewProtoFuncFill):
     74        (JSC::typedArrayViewProtoFuncLastIndexOf):
     75        (JSC::typedArrayViewProtoFuncIndexOf):
     76        (JSC::typedArrayViewProtoFuncJoin):
     77        (JSC::typedArrayViewProtoGetterFuncBuffer):
     78        (JSC::typedArrayViewProtoGetterFuncLength):
     79        (JSC::typedArrayViewProtoGetterFuncByteLength):
     80        (JSC::typedArrayViewProtoGetterFuncByteOffset):
     81        (JSC::typedArrayViewProtoFuncReverse):
     82        (JSC::typedArrayViewProtoFuncSubarray):
     83        (JSC::typedArrayViewProtoFuncSlice):
     84        * runtime/ObjectConstructor.cpp:
     85        (JSC::toPropertyDescriptor):
     86        (JSC::objectConstructorDefineProperty):
     87        (JSC::objectConstructorDefineProperties):
     88        (JSC::objectConstructorCreate):
     89        * runtime/ObjectPrototype.cpp:
     90        (JSC::objectProtoFuncDefineGetter):
     91        (JSC::objectProtoFuncDefineSetter):
     92        * runtime/RegExpPrototype.cpp:
     93        (JSC::regExpProtoFuncCompile):
     94        * runtime/Symbol.cpp:
     95        (JSC::Symbol::toNumber):
     96
    1972016-07-06  Saam Barati  <sbarati@apple.com>
    298
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r202280 r202890  
    9898    JSValue scriptValue = exec->argument(0);
    9999    if (!scriptValue.isString())
    100         return throwTypeError(exec, "InjectedScriptHost.evaluateWithScopeExtension first argument must be a string.");
     100        return throwTypeError(exec, ASCIILiteral("InjectedScriptHost.evaluateWithScopeExtension first argument must be a string."));
    101101
    102102    String program = scriptValue.toString(exec)->value(exec);
  • trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp

    r202717 r202890  
    8080    JSValue scriptValue = exec->argument(0);
    8181    if (!scriptValue.isString())
    82         return throwTypeError(exec, "JSJavaScriptCallFrame.evaluateWithScopeExtension first argument must be a string.");
     82        return throwTypeError(exec, ASCIILiteral("JSJavaScriptCallFrame.evaluateWithScopeExtension first argument must be a string."));
    8383
    8484    String script = scriptValue.toString(exec)->value(exec);
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r202588 r202890  
    11861186            PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry);
    11871187            if (JSGlobalLexicalEnvironment::getOwnPropertySlot(globalLexicalEnvironment, callFrame, ident, slot)) {
    1188                 return checkedReturn(callFrame->vm().throwException(callFrame,
    1189                     createTypeError(callFrame, makeString("Can't create duplicate global variable in eval: '", String(ident.impl()), "'"))));
     1188                return checkedReturn(throwTypeError(callFrame, makeString("Can't create duplicate global variable in eval: '", String(ident.impl()), "'")));
    11901189            }
    11911190        }
     
    11951194            PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry);
    11961195            if (JSGlobalLexicalEnvironment::getOwnPropertySlot(globalLexicalEnvironment, callFrame, function->name(), slot)) {
    1197                 return checkedReturn(callFrame->vm().throwException(callFrame,
    1198                     createTypeError(callFrame, makeString("Can't create duplicate global variable in eval: '", String(function->name().impl()), "'"))));
     1196                return checkedReturn(throwTypeError(callFrame, makeString("Can't create duplicate global variable in eval: '", String(function->name().impl()), "'")));
    11991197            }
    12001198        }
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r202588 r202890  
    11731173        vm.throwException(exec, createReferenceError(exec, errorMessage));
    11741174    else
    1175         vm.throwException(exec, createTypeError(exec, errorMessage));
     1175        throwTypeError(exec, errorMessage);
    11761176}
    11771177
     
    18741874    bool couldDelete = baseObj->methodTable(vm)->deleteProperty(baseObj, exec, Identifier::fromUid(&vm, uid));
    18751875    if (!couldDelete && exec->codeBlock()->isStrictMode())
    1876         vm.throwException(exec, createTypeError(exec, ASCIILiteral("Unable to delete property.")));
     1876        throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    18771877    return couldDelete;
    18781878}
     
    19061906    }
    19071907    if (!couldDelete && exec->codeBlock()->isStrictMode())
    1908         vm.throwException(exec, createTypeError(exec, ASCIILiteral("Unable to delete property.")));
     1908        throwTypeError(exec, ASCIILiteral("Unable to delete property."));
    19091909    return couldDelete;
    19101910}
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r202752 r202890  
    11131113    CallType callType = getCallData(toISOValue, callData);
    11141114    if (callType == CallType::None)
    1115         return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString is not a function")));
     1115        return throwVMTypeError(exec, ASCIILiteral("toISOString is not a function"));
    11161116
    11171117    JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
     
    11191119        return JSValue::encode(jsNull());
    11201120    if (result.isObject())
    1121         return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString did not return a primitive value")));
     1121        return throwVMTypeError(exec, ASCIILiteral("toISOString did not return a primitive value"));
    11221122    return JSValue::encode(result);
    11231123}
  • trunk/Source/JavaScriptCore/runtime/Error.cpp

    r201976 r202890  
    209209JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState* exec, const char* constructorName)
    210210{
    211     return exec->vm().throwException(exec, createTypeError(exec, makeString("calling ", constructorName, " constructor without new is invalid")));
     211    return throwTypeError(exec, makeString("calling ", constructorName, " constructor without new is invalid"));
    212212}
    213213
     
    217217}
    218218
     219JSObject* throwTypeError(ExecState* exec, ASCIILiteral errorMessage)
     220{
     221    return throwTypeError(exec, String(errorMessage));
     222}
     223
    219224JSObject* throwTypeError(ExecState* exec, const String& message)
    220225{
  • trunk/Source/JavaScriptCore/runtime/Error.h

    r201830 r202890  
    7575JS_EXPORT_PRIVATE JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState*, const char* constructorName);
    7676JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*);
     77JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, ASCIILiteral errorMessage);
    7778JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, const String& errorMessage);
    7879JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*);
     
    8485inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(exec->vm().throwException(exec, error)); }
    8586inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); }
     87inline EncodedJSValue throwVMTypeError(ExecState* exec, ASCIILiteral errorMessage) { return JSValue::encode(throwTypeError(exec, errorMessage)); }
    8688inline EncodedJSValue throwVMTypeError(ExecState* exec, const String& errorMessage) { return JSValue::encode(throwTypeError(exec, errorMessage)); }
    8789inline EncodedJSValue throwVMRangeError(ExecState* state, const String& errorMessage) { return JSValue::encode(throwRangeError(state, errorMessage)); }
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp

    r195528 r202890  
    4242    JSArrayBuffer* thisObject = jsDynamicCast<JSArrayBuffer*>(exec->thisValue());
    4343    if (!thisObject)
    44         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Receiver of slice must be an array buffer.")));
     44        return throwVMTypeError(exec, ASCIILiteral("Receiver of slice must be an array buffer."));
    4545   
    4646    if (!exec->argumentCount())
    47         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Slice requires at least one argument.")));
     47        return throwVMTypeError(exec, ASCIILiteral("Slice requires at least one argument."));
    4848   
    4949    int32_t begin = exec->argument(0).toInt32(exec);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r201964 r202890  
    158158            if (attributes & ReadOnly) {
    159159                if (slot.isStrictMode())
    160                     exec->vm().throwException(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
     160                    throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
    161161                return false;
    162162            }
     
    347347        return vm.smallStrings.undefinedString();
    348348    if (isSymbol()) {
    349         throwTypeError(exec, "Cannot convert a symbol to a string");
     349        throwTypeError(exec, ASCIILiteral("Cannot convert a symbol to a string"));
    350350        return errorValue();
    351351    }
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r201964 r202890  
    633633{
    634634    if (!value.isString()) {
    635         throwTypeError(exec, "Primitive hint is not a string.");
     635        throwTypeError(exec, ASCIILiteral("Primitive hint is not a string."));
    636636        return NoPreference;
    637637    }
     
    648648        return PreferString;
    649649
    650     throwTypeError(exec, "Expected primitive hint to match one of 'default', 'number', 'string'.");
     650    throwTypeError(exec, ASCIILiteral("Expected primitive hint to match one of 'default', 'number', 'string'."));
    651651    return NoPreference;
    652652}
  • trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp

    r201448 r202890  
    125125    JSDataView* dataView = jsDynamicCast<JSDataView*>(exec->thisValue());
    126126    if (!dataView)
    127         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Receiver of DataView method must be a DataView")));
     127        return throwVMTypeError(exec, ASCIILiteral("Receiver of DataView method must be a DataView"));
    128128   
    129129    if (!exec->argumentCount())
    130         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Need at least one argument (the byteOffset)")));
     130        return throwVMTypeError(exec, ASCIILiteral("Need at least one argument (the byteOffset)"));
    131131   
    132132    unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
     
    170170    JSDataView* dataView = jsDynamicCast<JSDataView*>(exec->thisValue());
    171171    if (!dataView)
    172         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Receiver of DataView method must be a DataView")));
     172        return throwVMTypeError(exec, ASCIILiteral("Receiver of DataView method must be a DataView"));
    173173   
    174174    if (exec->argumentCount() < 2)
    175         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Need at least two argument (the byteOffset and value)")));
     175        return throwVMTypeError(exec, ASCIILiteral("Need at least two argument (the byteOffset and value)"));
    176176   
    177177    unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r202027 r202890  
    507507    if (descriptor.configurablePresent() && descriptor.configurable()) {
    508508        if (throwException)
    509             exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change configurable attribute of unconfigurable property.")));
     509            throwTypeError(exec, ASCIILiteral("Attempting to change configurable attribute of unconfigurable property."));
    510510        return false;
    511511    }
    512512    if (descriptor.enumerablePresent() && descriptor.enumerable()) {
    513513        if (throwException)
    514             exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
     514            throwTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property."));
    515515        return false;
    516516    }
    517517    if (descriptor.isAccessorDescriptor()) {
    518518        if (throwException)
    519             exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));
     519            throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError));
    520520        return false;
    521521    }
    522522    if (descriptor.writablePresent() && descriptor.writable()) {
    523523        if (throwException)
    524             exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
     524            throwTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property."));
    525525        return false;
    526526    }
    527527    if (!valueCheck) {
    528528        if (throwException)
    529             exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
     529            throwTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property."));
    530530        return false;
    531531    }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r202667 r202890  
    8282{
    8383    if (!iterator.isObject())
    84         return throwTypeError(exec, "Symbol.Iterator for the first argument did not return an object.");
     84        return throwTypeError(exec, ASCIILiteral("Symbol.Iterator for the first argument did not return an object."));
    8585
    8686    MarkedArgumentBuffer storage;
     
    140140   
    141141    if (ViewClass::TypedArrayStorageType == TypeDataView)
    142         return throwTypeError(exec, "Expected ArrayBuffer for the first argument.");
     142        return throwTypeError(exec, ASCIILiteral("Expected ArrayBuffer for the first argument."));
    143143   
    144144    // For everything but DataView, we allow construction with any of:
     
    175175                    CallType callType = getCallData(iteratorFunc, callData);
    176176                    if (callType == CallType::None)
    177                         return throwTypeError(exec, "Symbol.Iterator for the first argument cannot be called.");
     177                        return throwTypeError(exec, ASCIILiteral("Symbol.Iterator for the first argument cannot be called."));
    178178
    179179                    ArgList arguments;
     
    207207        length = firstValue.asInt32();
    208208    else if (!firstValue.isNumber())
    209         return throwTypeError(exec, "Invalid array length argument");
     209        return throwTypeError(exec, ASCIILiteral("Invalid array length argument"));
    210210    else {
    211211        length = static_cast<int>(firstValue.asNumber());
    212212        if (length != firstValue.asNumber())
    213             return throwTypeError(exec, "Invalid array length argument (fractional lengths not allowed)");
     213            return throwTypeError(exec, ASCIILiteral("Invalid array length argument (fractional lengths not allowed)"));
    214214    }
    215215
     
    235235    if (!argCount) {
    236236        if (ViewClass::TypedArrayStorageType == TypeDataView)
    237             return throwVMError(exec, createTypeError(exec, "DataView constructor requires at least one argument."));
     237            return throwVMTypeError(exec, ASCIILiteral("DataView constructor requires at least one argument."));
    238238
    239239        return JSValue::encode(ViewClass::create(exec, structure, 0));
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

    r202280 r202890  
    5757        return defaultConstructor();
    5858    if (!constructor.isObject()) {
    59         throwTypeError(exec, "constructor Property should not be null");
     59        throwTypeError(exec, ASCIILiteral("constructor Property should not be null"));
    6060        return nullptr;
    6161    }
     
    7575        return view;
    7676
    77     throwTypeError(exec, "species constructor did not return a TypedArray View");
     77    throwTypeError(exec, ASCIILiteral("species constructor did not return a TypedArray View"));
    7878    return nullptr;
    7979}
     
    100100
    101101    if (!exec->argumentCount())
    102         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
     102        return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument"));
    103103
    104104    unsigned offset;
     
    118118    JSObject* sourceArray = jsDynamicCast<JSObject*>(exec->uncheckedArgument(0));
    119119    if (!sourceArray)
    120         return throwVMError(exec, createTypeError(exec, "First argument should be an object"));
     120        return throwVMTypeError(exec, ASCIILiteral("First argument should be an object"));
    121121
    122122    unsigned length;
     
    146146
    147147    if (exec->argumentCount() < 2)
    148         return throwVMError(exec, createTypeError(exec, "Expected at least two arguments"));
     148        return throwVMTypeError(exec, ASCIILiteral("Expected at least two arguments"));
    149149
    150150    if (exec->hadException())
     
    201201
    202202    if (!exec->argumentCount())
    203         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
     203        return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument"));
    204204
    205205    unsigned length = thisObject->length();
     
    265265
    266266    if (!exec->argumentCount())
    267         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
     267        return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument"));
    268268
    269269    unsigned length = thisObject->length();
     
    443443
    444444    if (!exec->argumentCount())
    445         return throwVMError(exec, createTypeError(exec, "Expected at least one argument"));
     445        return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument"));
    446446
    447447    // Get the length here; later assert that the length didn't change.
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r202680 r202890  
    889889{
    890890    if (exec->thisValue().isUndefinedOrNull())
    891         return throwVMError(exec, createTypeError(exec, "Can't convert undefined or null to object"));
     891        return throwVMTypeError(exec, ASCIILiteral("Can't convert undefined or null to object"));
    892892
    893893    JSObject* thisObject = jsDynamicCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode));
     
    946946{
    947947    if (exec->thisValue().isUndefinedOrNull())
    948         return throwVMError(exec, createTypeError(exec, "Can't convert undefined or null to object"));
     948        return throwVMTypeError(exec, ASCIILiteral("Can't convert undefined or null to object"));
    949949
    950950    JSValue value = exec->argument(0);
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r201703 r202890  
    369369    for (unsigned i = 0; i < m_holderStack.size(); i++) {
    370370        if (m_holderStack[i].object() == object) {
    371             m_exec->vm().throwException(m_exec, createTypeError(m_exec, ASCIILiteral("JSON.stringify cannot serialize cyclic structures.")));
     371            throwTypeError(m_exec, ASCIILiteral("JSON.stringify cannot serialize cyclic structures."));
    372372            return StringifyFailed;
    373373        }
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r202832 r202890  
    13581358    if (!isExtensible) {
    13591359        if (shouldThrowIfCantSet)
    1360             throwVMError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
     1360            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
    13611361        return false;
    13621362    }
     
    16411641        return exec->exception();
    16421642    if (result.isObject())
    1643         return mode == TypeHintMode::DoesNotTakeHint ? JSValue() : throwTypeError(exec, "Symbol.toPrimitive returned an object");
     1643        return mode == TypeHintMode::DoesNotTakeHint ? JSValue() : throwTypeError(exec, ASCIILiteral("Symbol.toPrimitive returned an object"));
    16441644    return result;
    16451645}
     
    16711671    ASSERT(!exec->hadException());
    16721672
    1673     return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("No default value")));
     1673    return throwTypeError(exec, ASCIILiteral("No default value"));
    16741674}
    16751675
     
    17571757
    17581758    if (!proto.isObject()) {
    1759         exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
     1759        throwTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property."));
    17601760        return false;
    17611761    }
     
    29442944        if (!isExtensible) {
    29452945            if (throwException)
    2946                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
     2946                throwTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible."));
    29472947            return false;
    29482948        }
     
    29672967        if (descriptor.configurable()) {
    29682968            if (throwException)
    2969                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change configurable attribute of unconfigurable property.")));
     2969                throwTypeError(exec, ASCIILiteral("Attempting to change configurable attribute of unconfigurable property."));
    29702970            return false;
    29712971        }
    29722972        if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
    29732973            if (throwException)
    2974                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
     2974                throwTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property."));
    29752975            return false;
    29762976        }
     
    29922992        if (!current.configurable()) {
    29932993            if (throwException)
    2994                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));
     2994                throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError));
    29952995            return false;
    29962996        }
     
    30093009            if (!current.writable() && descriptor.writable()) {
    30103010                if (throwException)
    3011                     exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
     3011                    throwTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property."));
    30123012                return false;
    30133013            }
     
    30153015                if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) {
    30163016                    if (throwException)
    3017                         exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
     3017                        throwTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property."));
    30183018                    return false;
    30193019                }
     
    30343034        if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) {
    30353035            if (throwException)
    3036                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
     3036                throwTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property."));
    30373037            return false;
    30383038        }
    30393039        if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) {
    30403040            if (throwException)
    3041                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
     3041                throwTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property."));
    30423042            return false;
    30433043        }
    30443044        if (current.attributes() & CustomAccessor) {
    30453045            if (throwException)
    3046                 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));
     3046                throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError));
    30473047            return false;
    30483048        }
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewConstructor.cpp

    r197648 r202890  
    7272    JSObject* object = jsDynamicCast<JSObject*>(value);
    7373    if (!object)
    74         return JSValue::encode(throwTypeError(exec, "new.target passed to TypedArray is not an object."));
     74        return JSValue::encode(throwTypeError(exec, ASCIILiteral("new.target passed to TypedArray is not an object.")));
    7575
    7676    ConstructData data;
    7777    if (object->methodTable()->getConstructData(object, data) == ConstructType::None)
    78         return JSValue::encode(throwTypeError(exec, "new.target passed to TypedArray is not a valid constructor."));
     78        return JSValue::encode(throwTypeError(exec, ASCIILiteral("new.target passed to TypedArray is not a valid constructor.")));
    7979
    8080    for (; !value.isNull(); value = jsCast<JSObject*>(value)->getPrototypeDirect()) {
    8181        if (jsDynamicCast<JSTypedArrayViewConstructor*>(value))
    82             return JSValue::encode(throwTypeError(exec, "Unable to find TypedArray constructor that inherits from TypedArray."));
     82            return JSValue::encode(throwTypeError(exec, ASCIILiteral("Unable to find TypedArray constructor that inherits from TypedArray.")));
    8383        if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSInt8Array>*>(value))
    8484            return constructGenericTypedArrayView<JSInt8Array>(exec);
     
    101101    }
    102102   
    103     return JSValue::encode(throwTypeError(exec, "Unable to find TypedArray constructor in prototype-chain, hit null."));
     103    return JSValue::encode(throwTypeError(exec, ASCIILiteral("Unable to find TypedArray constructor in prototype-chain, hit null.")));
    104104}
    105105
  • trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp

    r202673 r202890  
    5959    case NotTypedArray:                                                                         \
    6060    case TypeDataView:                                                                          \
    61         return throwVMError(exec, createTypeError(exec,                                         \
    62             "Receiver should be a typed array view"));                                          \
     61        return throwVMTypeError(exec,                                                           \
     62            ASCIILiteral("Receiver should be a typed array view"));                             \
    6363    }                                                                                           \
    6464    RELEASE_ASSERT_NOT_REACHED();                                                               \
     
    7979    JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(argument);
    8080    if (!thisObject || thisObject->mode() == DataViewMode)
    81         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view"));
     81        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view"));
    8282    if (thisObject->isNeutered())
    8383        return throwVMTypeError(exec, "Underlying ArrayBuffer has been detached from the view");
     
    104104    JSValue thisValue = exec->thisValue();
    105105    if (!thisValue.isObject())
    106         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     106        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    107107    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSet);
    108108}
     
    112112    JSValue thisValue = exec->thisValue();
    113113    if (!thisValue.isObject())
    114         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     114        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    115115    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncCopyWithin);
    116116}
     
    120120    JSValue thisValue = exec->thisValue();
    121121    if (!thisValue.isObject())
    122         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     122        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    123123    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncFill);
    124124}
     
    128128    JSValue thisValue = exec->thisValue();
    129129    if (!thisValue.isObject())
    130         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     130        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    131131    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncLastIndexOf);
    132132}
     
    136136    JSValue thisValue = exec->thisValue();
    137137    if (!thisValue.isObject())
    138         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     138        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    139139    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncIndexOf);
    140140}
     
    144144    JSValue thisValue = exec->thisValue();
    145145    if (!thisValue.isObject())
    146         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     146        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    147147    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncJoin);
    148148}
     
    152152    JSValue thisValue = exec->thisValue();
    153153    if (!thisValue.isObject())
    154         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     154        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    155155    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncBuffer);
    156156}
     
    160160    JSValue thisValue = exec->thisValue();
    161161    if (!thisValue.isObject())
    162         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     162        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    163163    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncLength);
    164164}
     
    168168    JSValue thisValue = exec->thisValue();
    169169    if (!thisValue.isObject())
    170         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     170        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    171171    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncByteLength);
    172172}
     
    176176    JSValue thisValue = exec->thisValue();
    177177    if (!thisValue.isObject())
    178         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     178        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    179179    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncByteOffset);
    180180}
     
    184184    JSValue thisValue = exec->thisValue();
    185185    if (!thisValue.isObject())
    186         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     186        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    187187    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncReverse);
    188188}
     
    192192    JSValue thisValue = exec->thisValue();
    193193    if (!thisValue.isObject())
    194         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     194        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    195195    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSubarray);
    196196}
     
    200200    JSValue thisValue = exec->thisValue();
    201201    if (!thisValue.isObject())
    202         return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
     202        return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view but was not an object"));
    203203    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSlice);
    204204}
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r202280 r202890  
    336336    VM& vm = exec->vm();
    337337    if (!in.isObject()) {
    338         vm.throwException(exec, createTypeError(exec, ASCIILiteral("Property description must be an object.")));
     338        throwTypeError(exec, ASCIILiteral("Property description must be an object."));
    339339        return false;
    340340    }
     
    381381            CallData callData;
    382382            if (getCallData(get, callData) == CallType::None) {
    383                 vm.throwException(exec, createTypeError(exec, ASCIILiteral("Getter must be a function.")));
     383                throwTypeError(exec, ASCIILiteral("Getter must be a function."));
    384384                return false;
    385385            }
     
    396396            CallData callData;
    397397            if (getCallData(set, callData) == CallType::None) {
    398                 vm.throwException(exec, createTypeError(exec, ASCIILiteral("Setter must be a function.")));
     398                throwTypeError(exec, ASCIILiteral("Setter must be a function."));
    399399                return false;
    400400            }
     
    408408
    409409    if (desc.value()) {
    410         vm.throwException(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'value' present on property with getter or setter.")));
     410        throwTypeError(exec, ASCIILiteral("Invalid property.  'value' present on property with getter or setter."));
    411411        return false;
    412412    }
    413413
    414414    if (desc.writablePresent()) {
    415         vm.throwException(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'writable' present on property with getter or setter.")));
     415        throwTypeError(exec, ASCIILiteral("Invalid property.  'writable' present on property with getter or setter."));
    416416        return false;
    417417    }
     
    422422{
    423423    if (!exec->argument(0).isObject())
    424         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
     424        return throwVMTypeError(exec, ASCIILiteral("Properties can only be defined on Objects."));
    425425    JSObject* O = asObject(exec->argument(0));
    426426    auto propertyName = exec->argument(1).toPropertyKey(exec);
     
    477477{
    478478    if (!exec->argument(0).isObject())
    479         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
     479        return throwVMTypeError(exec, ASCIILiteral("Properties can only be defined on Objects."));
    480480    JSObject* targetObj = asObject(exec->argument(0));
    481481    JSObject* props = exec->argument(1).toObject(exec);
     
    489489    JSValue proto = exec->argument(0);
    490490    if (!proto.isObject() && !proto.isNull())
    491         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Object prototype may only be an Object or null.")));
     491        return throwVMTypeError(exec, ASCIILiteral("Object prototype may only be an Object or null."));
    492492    JSObject* newObject = proto.isObject()
    493493        ? constructEmptyObject(exec, asObject(proto))
     
    496496        return JSValue::encode(newObject);
    497497    if (!exec->argument(1).isObject())
    498         return throwVMError(exec, createTypeError(exec, ASCIILiteral("Property descriptor list must be an Object.")));
     498        return throwVMTypeError(exec, ASCIILiteral("Property descriptor list must be an Object."));
    499499    return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1))));
    500500}
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r202796 r202890  
    135135    CallData callData;
    136136    if (getCallData(get, callData) == CallType::None)
    137         return throwVMError(exec, createTypeError(exec, ASCIILiteral("invalid getter usage")));
     137        return throwVMTypeError(exec, ASCIILiteral("invalid getter usage"));
    138138
    139139    auto propertyName = exec->argument(0).toPropertyKey(exec);
     
    161161    CallData callData;
    162162    if (getCallData(set, callData) == CallType::None)
    163         return throwVMError(exec, createTypeError(exec, ASCIILiteral("invalid setter usage")));
     163        return throwVMTypeError(exec, ASCIILiteral("invalid setter usage"));
    164164
    165165    auto propertyName = exec->argument(0).toPropertyKey(exec);
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r202770 r202890  
    144144    if (arg0.inherits(RegExpObject::info())) {
    145145        if (!arg1.isUndefined())
    146             return throwVMError(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
     146            return throwVMTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another."));
    147147        regExp = asRegExpObject(arg0)->regExp();
    148148    } else {
  • trunk/Source/JavaScriptCore/runtime/Symbol.cpp

    r200402 r202890  
    8080double Symbol::toNumber(ExecState* exec) const
    8181{
    82     throwTypeError(exec, "Cannot convert a symbol to a number");
     82    throwTypeError(exec, ASCIILiteral("Cannot convert a symbol to a number"));
    8383    return 0.0;
    8484}
  • trunk/Source/WebCore/ChangeLog

    r202889 r202890  
     12016-07-06  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Unify how we throw TypeError from C++
     4        https://bugs.webkit.org/show_bug.cgi?id=159500
     5
     6        Reviewed by Saam Barati.
     7
     8        * bindings/js/JSBiquadFilterNodeCustom.cpp:
     9        (WebCore::JSBiquadFilterNode::setType):
     10        * bindings/js/JSBlobCustom.cpp:
     11        (WebCore::constructJSBlob):
     12        * bindings/js/JSCryptoKeySerializationJWK.cpp:
     13        (WebCore::getBigIntegerVectorFromJSON):
     14        (WebCore::JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK):
     15        (WebCore::tryJWKKeyOpsValue):
     16        (WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
     17        (WebCore::JSCryptoKeySerializationJWK::keyDataOctetSequence):
     18        (WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents):
     19        (WebCore::JSCryptoKeySerializationJWK::keyData):
     20        (WebCore::addJWKAlgorithmToJSON):
     21        (WebCore::JSCryptoKeySerializationJWK::serialize):
     22        * bindings/js/JSCryptoOperationData.cpp:
     23        (WebCore::cryptoOperationDataFromJSValue):
     24        * bindings/js/JSDOMBinding.cpp:
     25        (WebCore::enforceRange):
     26        (WebCore::throwTypeError):
     27        (WebCore::throwArgumentMustBeEnumError):
     28        (WebCore::throwArgumentMustBeFunctionError):
     29        (WebCore::throwArgumentTypeError):
     30        (WebCore::throwArrayElementTypeError):
     31        (WebCore::throwGetterTypeError):
     32        (WebCore::throwThisTypeError):
     33        * bindings/js/JSDataCueCustom.cpp:
     34        (WebCore::constructJSDataCue):
     35        * bindings/js/JSDocumentCustom.cpp:
     36        (WebCore::JSDocument::defineElement):
     37        * bindings/js/JSFileCustom.cpp:
     38        (WebCore::constructJSFile):
     39        * bindings/js/JSModuleLoader.cpp:
     40        (WebCore::JSModuleLoader::evaluate):
     41        * bindings/js/JSMutationObserverCustom.cpp:
     42        (WebCore::constructJSMutationObserver):
     43        * bindings/js/JSOscillatorNodeCustom.cpp:
     44        (WebCore::JSOscillatorNode::setType):
     45        * bindings/js/JSPannerNodeCustom.cpp:
     46        (WebCore::JSPannerNode::setPanningModel):
     47        (WebCore::JSPannerNode::setDistanceModel):
     48        * bindings/js/JSReadableStreamPrivateConstructors.cpp:
     49        (WebCore::constructJSReadableStreamController):
     50        (WebCore::constructJSReadableStreamReader):
     51        * bindings/js/JSSubtleCryptoCustom.cpp:
     52        (WebCore::cryptoKeyFormatFromJSValue):
     53        (WebCore::importKey):
     54        (WebCore::exportKey):
     55        * bindings/js/ReadableStreamController.cpp:
     56        (WebCore::ReadableStreamController::invoke):
     57        * bindings/js/SerializedScriptValue.cpp:
     58        (WebCore::CloneDeserializer::throwValidationError):
     59        (WebCore::SerializedScriptValue::maybeThrowExceptionIfSerializationFailed):
     60        * bridge/c/c_instance.cpp:
     61        (JSC::Bindings::CInstance::invokeMethod):
     62        * bridge/objc/objc_instance.mm:
     63        (ObjcInstance::invokeMethod):
     64        * bridge/objc/objc_runtime.mm:
     65        (JSC::Bindings::ObjcArray::setValueAt):
     66
    1672016-07-06  Tim Horton  <timothy_horton@apple.com>
    268
  • trunk/Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp

    r191887 r202890  
    4444        uint32_t type = value.toUInt32(&state);
    4545        if (!wrapped().setType(type))
    46             state.vm().throwException(&state, createTypeError(&state, "Illegal BiquadFilterNode type"));
     46            throwTypeError(&state, "Illegal BiquadFilterNode type");
    4747        return;
    4848    }
     
    5757    }
    5858   
    59     state.vm().throwException(&state, createTypeError(&state, "Illegal BiquadFilterNode type"));
     59    throwTypeError(&state, "Illegal BiquadFilterNode type");
    6060}
    6161
  • trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp

    r201129 r202890  
    8585
    8686        if (!blobPropertyBagValue.isObject())
    87             return throwVMError(exec, createTypeError(exec, "Second argument of the constructor is not of type Object"));
     87            return throwVMTypeError(exec, "Second argument of the constructor is not of type Object");
    8888
    8989        // Given the above test, this will always yield an object.
     
    100100        if (containsEndings) {
    101101            if (endings != "transparent" && endings != "native")
    102                 return throwVMError(exec, createTypeError(exec, "The endings property must be either \"transparent\" or \"native\""));
     102                return throwVMTypeError(exec, "The endings property must be either \"transparent\" or \"native\"");
    103103        }
    104104
  • trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp

    r201787 r202890  
    118118
    119119    if (!base64URLDecode(base64urlEncodedNumber, result)) {
    120         throwTypeError(exec, "Cannot decode base64url key data in JWK");
     120        throwTypeError(exec, ASCIILiteral("Cannot decode base64url key data in JWK"));
    121121        return false;
    122122    }
    123123
    124124    if (result[0] == 0) {
    125         throwTypeError(exec, "JWK BigInteger must utilize the minimum number of octets to represent the value");
     125        throwTypeError(exec, ASCIILiteral("JWK BigInteger must utilize the minimum number of octets to represent the value"));
    126126        return false;
    127127    }
     
    138138
    139139    if (!jsonValue || !jsonValue.isObject()) {
    140         throwTypeError(exec, "Invalid JWK serialization");
     140        throwTypeError(exec, ASCIILiteral("Invalid JWK serialization"));
    141141        return;
    142142    }
     
    254254    if (operation == tryOperation) {
    255255        if (usages & tryUsage) {
    256             throwTypeError(exec, "JWK key_ops contains a duplicate operation");
     256            throwTypeError(exec, ASCIILiteral("JWK key_ops contains a duplicate operation"));
    257257            return false;
    258258        }
     
    273273            if (!jsValue.getString(m_exec, operation)) {
    274274                if (!m_exec->hadException())
    275                     throwTypeError(m_exec, "JWK key_ops attribute could not be processed");
     275                    throwTypeError(m_exec, ASCIILiteral("JWK key_ops attribute could not be processed"));
    276276                return;
    277277            }
     
    363363    if (!getStringFromJSON(m_exec, m_json.get(), "k", keyBase64URL)) {
    364364        if (!m_exec->hadException())
    365             throwTypeError(m_exec, "Secret key data is not present is JWK");
     365            throwTypeError(m_exec, ASCIILiteral("Secret key data is not present is JWK"));
    366366        return nullptr;
    367367    }
     
    369369    Vector<uint8_t> octetSequence;
    370370    if (!base64URLDecode(keyBase64URL, octetSequence)) {
    371         throwTypeError(m_exec, "Cannot decode base64url key data in JWK");
     371        throwTypeError(m_exec, ASCIILiteral("Cannot decode base64url key data in JWK"));
    372372        return nullptr;
    373373    }
     
    389389    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "n", modulus)) {
    390390        if (!m_exec->hadException())
    391             throwTypeError(m_exec, "Required JWK \"n\" member is missing");
     391            throwTypeError(m_exec, ASCIILiteral("Required JWK \"n\" member is missing"));
    392392        return nullptr;
    393393    }
     
    400400    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "e", exponent)) {
    401401        if (!m_exec->hadException())
    402             throwTypeError(m_exec, "Required JWK \"e\" member is missing");
     402            throwTypeError(m_exec, ASCIILiteral("Required JWK \"e\" member is missing"));
    403403        return nullptr;
    404404    }
     
    456456            return nullptr;
    457457        if (!element.isObject()) {
    458             throwTypeError(m_exec, "JWK \"oth\" array member is not an object");
     458            throwTypeError(m_exec, ASCIILiteral("JWK \"oth\" array member is not an object"));
    459459            return nullptr;
    460460        }
    461461        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "r", info.primeFactor)) {
    462462            if (!m_exec->hadException())
    463                 throwTypeError(m_exec, "Cannot get prime factor for a prime in \"oth\" dictionary");
     463                throwTypeError(m_exec, ASCIILiteral("Cannot get prime factor for a prime in \"oth\" dictionary"));
    464464            return nullptr;
    465465        }
    466466        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "d", info.factorCRTExponent)) {
    467467            if (!m_exec->hadException())
    468                 throwTypeError(m_exec, "Cannot get factor CRT exponent for a prime in \"oth\" dictionary");
     468                throwTypeError(m_exec, ASCIILiteral("Cannot get factor CRT exponent for a prime in \"oth\" dictionary"));
    469469            return nullptr;
    470470        }
    471471        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "t", info.factorCRTCoefficient)) {
    472472            if (!m_exec->hadException())
    473                 throwTypeError(m_exec, "Cannot get factor CRT coefficient for a prime in \"oth\" dictionary");
     473                throwTypeError(m_exec, ASCIILiteral("Cannot get factor CRT coefficient for a prime in \"oth\" dictionary"));
    474474            return nullptr;
    475475        }
     
    485485    if (!getStringFromJSON(m_exec, m_json.get(), "kty", jwkKeyType)) {
    486486        if (!m_exec->hadException())
    487             throwTypeError(m_exec, "Required JWK \"kty\" member is missing");
     487            throwTypeError(m_exec, ASCIILiteral("Required JWK \"kty\" member is missing"));
    488488        return nullptr;
    489489    }
     
    650650    if (jwkAlgorithm.isNull()) {
    651651        // The spec doesn't currently tell whether export should fail, or just skip "alg" (which is an optional key in JWK).
    652         throwTypeError(exec, "Key algorithm and size do not map to any JWK algorithm identifier");
     652        throwTypeError(exec, ASCIILiteral("Key algorithm and size do not map to any JWK algorithm identifier"));
    653653        return;
    654654    }
     
    690690    if (!keyData) {
    691691        // This generally shouldn't happen as long as all key types implement exportData(), but as underlying libraries return errors, there may be some rare failure conditions.
    692         throwTypeError(exec, "Couldn't export key material");
     692        throwTypeError(exec, ASCIILiteral("Couldn't export key material"));
    693693        return String();
    694694    }
     
    711711        buildJSONForRSAComponents(exec, downcast<CryptoKeyDataRSAComponents>(*keyData), result);
    712712    else {
    713         throwTypeError(exec, "Key doesn't support exportKey");
     713        throwTypeError(exec, ASCIILiteral("Key doesn't support exportKey"));
    714714        return String();
    715715    }
  • trunk/Source/WebCore/bindings/js/JSCryptoOperationData.cpp

    r159637 r202890  
    4242        result = std::make_pair(static_cast<uint8_t*>(bufferView->baseAddress()), bufferView->byteLength());
    4343    else {
    44         throwTypeError(exec, "Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData");
     44        throwTypeError(exec, ASCIILiteral("Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData"));
    4545        return false;
    4646    }
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r202460 r202890  
    375375{
    376376    if (std::isnan(x) || std::isinf(x)) {
    377         state.vm().throwException(&state, createTypeError(&state, rangeErrorString(x, minimum, maximum)));
     377        throwTypeError(&state, rangeErrorString(x, minimum, maximum));
    378378        return 0;
    379379    }
    380380    x = trunc(x);
    381381    if (x < minimum || x > maximum) {
    382         state.vm().throwException(&state, createTypeError(&state, rangeErrorString(x, minimum, maximum)));
     382        throwTypeError(&state, rangeErrorString(x, minimum, maximum));
    383383        return 0;
    384384    }
     
    737737static EncodedJSValue throwTypeError(JSC::ExecState& state, const String& errorMessage)
    738738{
    739     return throwVMError(&state, createTypeError(&state, errorMessage));
     739    return throwVMTypeError(&state, errorMessage);
    740740}
    741741
     
    792792    builder.appendLiteral("one of: ");
    793793    builder.append(expectedValues);
    794     return throwTypeError(state, builder.toString());
     794    return throwVMTypeError(&state, builder.toString());
    795795}
    796796
     
    800800    appendArgumentMustBe(builder, argumentIndex, argumentName, interfaceName, functionName);
    801801    builder.appendLiteral("a function");
    802     return throwTypeError(state, builder.toString());
     802    return throwVMTypeError(&state, builder.toString());
    803803}
    804804
     
    809809    builder.appendLiteral("an instance of ");
    810810    builder.append(expectedType);
    811     return throwTypeError(state, builder.toString());
     811    return throwVMTypeError(&state, builder.toString());
    812812}
    813813
    814814void throwArrayElementTypeError(JSC::ExecState& state)
    815815{
    816     throwTypeError(state, "Invalid Array element type");
     816    throwTypeError(state, ASCIILiteral("Invalid Array element type"));
    817817}
    818818
     
    830830JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
    831831{
    832     return throwTypeError(state, makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName));
     832    return throwVMTypeError(&state, makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName));
    833833}
    834834
     
    851851EncodedJSValue throwThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* functionName)
    852852{
    853     return throwTypeError(state, makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName));
     853    return throwVMTypeError(&state, makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName));
    854854}
    855855
  • trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp

    r200316 r202890  
    7070    if (exec->argumentCount() > 3) {
    7171        if (!exec->argument(3).isString())
    72             return throwVMError(exec, createTypeError(exec, "Second argument of the constructor is not of type String"));
     72            return throwVMTypeError(exec, ASCIILiteral("Second argument of the constructor is not of type String"));
    7373        type = exec->argument(3).getString(exec);
    7474    }
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r201793 r202890  
    155155    ConstructData callData;
    156156    if (!object || object->methodTable()->getConstructData(object, callData) == ConstructType::None)
    157         return throwTypeError(&state, "The second argument must be a constructor");
     157        return throwTypeError(&state, ASCIILiteral("The second argument must be a constructor"));
    158158
    159159    Document& document = wrapped();
  • trunk/Source/WebCore/bindings/js/JSFileCustom.cpp

    r200934 r202890  
    5050    JSValue arg = exec->argument(0);
    5151    if (arg.isUndefinedOrNull())
    52         return throwVMError(exec, createTypeError(exec, "First argument to File constructor must be a valid sequence, was undefined or null"));
     52        return throwVMTypeError(exec, ASCIILiteral("First argument to File constructor must be a valid sequence, was undefined or null"));
    5353
    5454    unsigned blobPartsLength = 0;
     
    6060    arg = exec->argument(1);
    6161    if (arg.isUndefined())
    62         return throwVMError(exec, createTypeError(exec, "Second argument to File constructor must be a valid string, was undefined"));
     62        return throwVMTypeError(exec, ASCIILiteral("Second argument to File constructor must be a valid string, was undefined"));
    6363
    6464    String filename = arg.toWTFString(exec).replace('/', ':');
     
    7373        JSObject* filePropertyBagObject = arg.getObject();
    7474        if (!filePropertyBagObject)
    75             return throwVMError(exec, createTypeError(exec, "Third argument of the constructor is not of type Object"));
     75            return throwVMTypeError(exec, ASCIILiteral("Third argument of the constructor is not of type Object"));
    7676
    7777        // Create the dictionary wrapper from the initializer object.
  • trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp

    r190272 r202890  
    117117        sourceUrl = URL(URL(), asString(moduleKeyValue)->value(exec));
    118118    else
    119         return JSC::throwTypeError(exec, "Module key is not Symbol or String.");
     119        return JSC::throwTypeError(exec, ASCIILiteral("Module key is not Symbol or String."));
    120120
    121121    if (!sourceUrl.isValid())
    122         return JSC::throwTypeError(exec, "Module key is an invalid URL.");
     122        return JSC::throwTypeError(exec, ASCIILiteral("Module key is an invalid URL."));
    123123
    124124    // FIXME: Implement evaluating module code.
  • trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp

    r200552 r202890  
    5151    CallData callData;
    5252    if (!object || object->methodTable()->getCallData(object, callData) == CallType::None)
    53         return throwVMError(exec, createTypeError(exec, "Callback argument must be a function"));
     53        return throwVMTypeError(exec, ASCIILiteral("Callback argument must be a function"));
    5454
    5555    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
  • trunk/Source/WebCore/bindings/js/JSOscillatorNodeCustom.cpp

    r191887 r202890  
    4646        uint32_t type = value.toUInt32(&state);
    4747        if (!imp.setType(type))
    48             state.vm().throwException(&state, createTypeError(&state, "Illegal OscillatorNode type"));
     48            throwTypeError(&state, ASCIILiteral("Illegal OscillatorNode type"));
    4949        return;
    5050    }
     
    5959    }
    6060   
    61     state.vm().throwException(&state, createTypeError(&state, "Illegal OscillatorNode type"));
     61    throwTypeError(&state, ASCIILiteral("Illegal OscillatorNode type"));
    6262}
    6363
  • trunk/Source/WebCore/bindings/js/JSPannerNodeCustom.cpp

    r191887 r202890  
    4646        uint32_t model = value.toUInt32(&state);
    4747        if (!imp.setPanningModel(model))
    48             state.vm().throwException(&state, createTypeError(&state, "Illegal panningModel"));
     48            throwTypeError(&state, ASCIILiteral("Illegal panningModel"));
    4949        return;
    5050    }
     
    5959    }
    6060   
    61     state.vm().throwException(&state, createTypeError(&state, "Illegal panningModel"));
     61    throwTypeError(&state, ASCIILiteral("Illegal panningModel"));
    6262}
    6363
     
    7070        uint32_t model = value.toUInt32(&state);
    7171        if (!imp.setDistanceModel(model))
    72             state.vm().throwException(&state, createTypeError(&state, "Illegal distanceModel"));
     72            throwTypeError(&state, ASCIILiteral("Illegal distanceModel"));
    7373        return;
    7474    }
     
    8383    }
    8484   
    85     state.vm().throwException(&state, createTypeError(&state, "Illegal distanceModel"));
     85    throwTypeError(&state, ASCIILiteral("Illegal distanceModel"));
    8686}
    8787
  • trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp

    r197642 r202890  
    3737EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState* state)
    3838{
    39     return throwVMError(state, createTypeError(state, ASCIILiteral("ReadableStreamController constructor should not be called directly")));
     39    return throwVMTypeError(state, ASCIILiteral("ReadableStreamController constructor should not be called directly"));
    4040}
    4141
     
    4444    JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(state->argument(0));
    4545    if (!stream)
    46         return throwVMError(state, createTypeError(state, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream")));
     46        return throwVMTypeError(state, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream"));
    4747
    4848    JSValue jsFunction = stream->get(state, Identifier::fromString(state, "getReader"));
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r201013 r202890  
    9090        result = CryptoKeyFormat::JWK;
    9191    else {
    92         throwTypeError(&state, "Unknown key format");
     92        throwTypeError(&state, ASCIILiteral("Unknown key format"));
    9393        return false;
    9494    }
     
    454454        String jwkString = String::fromUTF8(data.first, data.second);
    455455        if (jwkString.isNull()) {
    456             throwTypeError(&state, "JWK JSON serialization is not valid UTF-8");
     456            throwTypeError(&state, ASCIILiteral("JWK JSON serialization is not valid UTF-8"));
    457457            return;
    458458        }
     
    463463    }
    464464    default:
    465         throwTypeError(&state, "Unsupported key format for import");
     465        throwTypeError(&state, ASCIILiteral("Unsupported key format for import"));
    466466        return;
    467467    }
     
    471471    if (!keySerialization->reconcileAlgorithm(algorithm, parameters)) {
    472472        if (!state.hadException())
    473             throwTypeError(&state, "Algorithm specified in key is not compatible with one passed to importKey as argument");
     473            throwTypeError(&state, ASCIILiteral("Algorithm specified in key is not compatible with one passed to importKey as argument"));
    474474        return;
    475475    }
     
    478478
    479479    if (!algorithm) {
    480         throwTypeError(&state, "Neither key nor function argument has crypto algorithm specified");
     480        throwTypeError(&state, ASCIILiteral("Neither key nor function argument has crypto algorithm specified"));
    481481        return;
    482482    }
     
    567567{
    568568    if (!key.extractable()) {
    569         throwTypeError(&state, "Key is not extractable");
     569        throwTypeError(&state, ASCIILiteral("Key is not extractable"));
    570570        return;
    571571    }
     
    591591    }
    592592    default:
    593         throwTypeError(&state, "Unsupported key format for export");
     593        throwTypeError(&state, ASCIILiteral("Unsupported key format for export"));
    594594        break;
    595595    }
  • trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp

    r200775 r202890  
    5656    if (!function.isFunction()) {
    5757        if (!function.isUndefined())
    58             throwVMError(&state, createTypeError(&state, ASCIILiteral("ReadableStream trying to call a property that is not callable")));
     58            throwTypeError(&state, ASCIILiteral("ReadableStream trying to call a property that is not callable"));
    5959        return JSC::jsUndefined();
    6060    }
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r202439 r202890  
    15701570    void throwValidationError()
    15711571    {
    1572         m_exec->vm().throwException(m_exec, createTypeError(m_exec, "Unable to deserialize data."));
     1572        throwTypeError(m_exec, ASCIILiteral("Unable to deserialize data."));
    15731573    }
    15741574
     
    27642764        break;
    27652765    case ValidationError:
    2766         exec->vm().throwException(exec, createTypeError(exec, "Unable to deserialize data."));
     2766        throwTypeError(exec, ASCIILiteral("Unable to deserialize data."));
    27672767        break;
    27682768    case DataCloneError:
  • trunk/Source/WebCore/bridge/c/c_instance.cpp

    r194819 r202890  
    156156{
    157157    if (!asObject(runtimeMethod)->inherits(CRuntimeMethod::info()))
    158         return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
     158        return throwTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object.");
    159159
    160160    CMethod* method = static_cast<CMethod*>(runtimeMethod->method());
  • trunk/Source/WebCore/bridge/objc/objc_instance.mm

    r199834 r202890  
    207207{
    208208    if (!asObject(runtimeMethod)->inherits(ObjCRuntimeMethod::info()))
    209         return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
     209        return throwTypeError(exec, ASCIILiteral("Attempt to invoke non-plug-in method on plug-in object."));
    210210
    211211    ObjcMethod *method = static_cast<ObjcMethod*>(runtimeMethod->method());
  • trunk/Source/WebCore/bridge/objc/objc_runtime.mm

    r198023 r202890  
    158158{
    159159    if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) {
    160         exec->vm().throwException(exec, createTypeError(exec, "Array is not mutable."));
     160        throwTypeError(exec, ASCIILiteral("Array is not mutable."));
    161161        return false;
    162162    }
  • trunk/Source/WebKit/mac/ChangeLog

    r202728 r202890  
     12016-07-06  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] Unify how we throw TypeError from C++
     4        https://bugs.webkit.org/show_bug.cgi?id=159500
     5
     6        Reviewed by Saam Barati.
     7
     8        * Plugins/Hosted/ProxyInstance.mm:
     9        (WebKit::ProxyInstance::invokeMethod):
     10
    1112016-07-01  Youenn Fablet  <youennf@gmail.com>
    212
  • trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm

    r198023 r202890  
    221221{
    222222    if (!asObject(runtimeMethod)->inherits(ProxyRuntimeMethod::info()))
    223         return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
     223        return throwTypeError(exec, ASCIILiteral("Attempt to invoke non-plug-in method on plug-in object."));
    224224
    225225    ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
Note: See TracChangeset for help on using the changeset viewer.