Changeset 202890 in webkit
- Timestamp:
- Jul 6, 2016, 8:12:37 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 46 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/inspector/JSInjectedScriptHost.cpp (modified) (1 diff)
-
JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp (modified) (1 diff)
-
JavaScriptCore/interpreter/Interpreter.cpp (modified) (2 diffs)
-
JavaScriptCore/jit/JITOperations.cpp (modified) (3 diffs)
-
JavaScriptCore/runtime/DatePrototype.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/Error.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/Error.h (modified) (2 diffs)
-
JavaScriptCore/runtime/JSArrayBufferPrototype.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/JSCJSValue.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/JSCJSValueInlines.h (modified) (2 diffs)
-
JavaScriptCore/runtime/JSDataViewPrototype.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/JSFunction.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h (modified) (5 diffs)
-
JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h (modified) (8 diffs)
-
JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/JSONObject.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/JSObject.cpp (modified) (10 diffs)
-
JavaScriptCore/runtime/JSTypedArrayViewConstructor.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp (modified) (15 diffs)
-
JavaScriptCore/runtime/ObjectConstructor.cpp (modified) (8 diffs)
-
JavaScriptCore/runtime/ObjectPrototype.cpp (modified) (2 diffs)
-
JavaScriptCore/runtime/RegExpPrototype.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/Symbol.cpp (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp (modified) (2 diffs)
-
WebCore/bindings/js/JSBlobCustom.cpp (modified) (2 diffs)
-
WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp (modified) (13 diffs)
-
WebCore/bindings/js/JSCryptoOperationData.cpp (modified) (1 diff)
-
WebCore/bindings/js/JSDOMBinding.cpp (modified) (7 diffs)
-
WebCore/bindings/js/JSDataCueCustom.cpp (modified) (1 diff)
-
WebCore/bindings/js/JSDocumentCustom.cpp (modified) (1 diff)
-
WebCore/bindings/js/JSFileCustom.cpp (modified) (3 diffs)
-
WebCore/bindings/js/JSModuleLoader.cpp (modified) (1 diff)
-
WebCore/bindings/js/JSMutationObserverCustom.cpp (modified) (1 diff)
-
WebCore/bindings/js/JSOscillatorNodeCustom.cpp (modified) (2 diffs)
-
WebCore/bindings/js/JSPannerNodeCustom.cpp (modified) (4 diffs)
-
WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp (modified) (2 diffs)
-
WebCore/bindings/js/JSSubtleCryptoCustom.cpp (modified) (7 diffs)
-
WebCore/bindings/js/ReadableStreamController.cpp (modified) (1 diff)
-
WebCore/bindings/js/SerializedScriptValue.cpp (modified) (2 diffs)
-
WebCore/bridge/c/c_instance.cpp (modified) (1 diff)
-
WebCore/bridge/objc/objc_instance.mm (modified) (1 diff)
-
WebCore/bridge/objc/objc_runtime.mm (modified) (1 diff)
-
WebKit/mac/ChangeLog (modified) (1 diff)
-
WebKit/mac/Plugins/Hosted/ProxyInstance.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202866 r202890 1 2016-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 1 97 2016-07-06 Saam Barati <sbarati@apple.com> 2 98 -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
r202280 r202890 98 98 JSValue scriptValue = exec->argument(0); 99 99 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.")); 101 101 102 102 String program = scriptValue.toString(exec)->value(exec); -
trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
r202717 r202890 80 80 JSValue scriptValue = exec->argument(0); 81 81 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.")); 83 83 84 84 String script = scriptValue.toString(exec)->value(exec); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r202588 r202890 1186 1186 PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry); 1187 1187 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()), "'"))); 1190 1189 } 1191 1190 } … … 1195 1194 PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry); 1196 1195 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()), "'"))); 1199 1197 } 1200 1198 } -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r202588 r202890 1173 1173 vm.throwException(exec, createReferenceError(exec, errorMessage)); 1174 1174 else 1175 vm.throwException(exec, createTypeError(exec, errorMessage));1175 throwTypeError(exec, errorMessage); 1176 1176 } 1177 1177 … … 1874 1874 bool couldDelete = baseObj->methodTable(vm)->deleteProperty(baseObj, exec, Identifier::fromUid(&vm, uid)); 1875 1875 if (!couldDelete && exec->codeBlock()->isStrictMode()) 1876 vm.throwException(exec, createTypeError(exec, ASCIILiteral("Unable to delete property.")));1876 throwTypeError(exec, ASCIILiteral("Unable to delete property.")); 1877 1877 return couldDelete; 1878 1878 } … … 1906 1906 } 1907 1907 if (!couldDelete && exec->codeBlock()->isStrictMode()) 1908 vm.throwException(exec, createTypeError(exec, ASCIILiteral("Unable to delete property.")));1908 throwTypeError(exec, ASCIILiteral("Unable to delete property.")); 1909 1909 return couldDelete; 1910 1910 } -
trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp
r202752 r202890 1113 1113 CallType callType = getCallData(toISOValue, callData); 1114 1114 if (callType == CallType::None) 1115 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("toISOString is not a function")));1115 return throwVMTypeError(exec, ASCIILiteral("toISOString is not a function")); 1116 1116 1117 1117 JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList()); … … 1119 1119 return JSValue::encode(jsNull()); 1120 1120 if (result.isObject()) 1121 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("toISOString did not return a primitive value")));1121 return throwVMTypeError(exec, ASCIILiteral("toISOString did not return a primitive value")); 1122 1122 return JSValue::encode(result); 1123 1123 } -
trunk/Source/JavaScriptCore/runtime/Error.cpp
r201976 r202890 209 209 JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState* exec, const char* constructorName) 210 210 { 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")); 212 212 } 213 213 … … 217 217 } 218 218 219 JSObject* throwTypeError(ExecState* exec, ASCIILiteral errorMessage) 220 { 221 return throwTypeError(exec, String(errorMessage)); 222 } 223 219 224 JSObject* throwTypeError(ExecState* exec, const String& message) 220 225 { -
trunk/Source/JavaScriptCore/runtime/Error.h
r201830 r202890 75 75 JS_EXPORT_PRIVATE JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState*, const char* constructorName); 76 76 JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*); 77 JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, ASCIILiteral errorMessage); 77 78 JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*, const String& errorMessage); 78 79 JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*); … … 84 85 inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(exec->vm().throwException(exec, error)); } 85 86 inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); } 87 inline EncodedJSValue throwVMTypeError(ExecState* exec, ASCIILiteral errorMessage) { return JSValue::encode(throwTypeError(exec, errorMessage)); } 86 88 inline EncodedJSValue throwVMTypeError(ExecState* exec, const String& errorMessage) { return JSValue::encode(throwTypeError(exec, errorMessage)); } 87 89 inline EncodedJSValue throwVMRangeError(ExecState* state, const String& errorMessage) { return JSValue::encode(throwRangeError(state, errorMessage)); } -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp
r195528 r202890 42 42 JSArrayBuffer* thisObject = jsDynamicCast<JSArrayBuffer*>(exec->thisValue()); 43 43 if (!thisObject) 44 return throwVM Error(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.")); 45 45 46 46 if (!exec->argumentCount()) 47 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("Slice requires at least one argument.")));47 return throwVMTypeError(exec, ASCIILiteral("Slice requires at least one argument.")); 48 48 49 49 int32_t begin = exec->argument(0).toInt32(exec); -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp
r201964 r202890 158 158 if (attributes & ReadOnly) { 159 159 if (slot.isStrictMode()) 160 exec->vm().throwException(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));160 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 161 161 return false; 162 162 } … … 347 347 return vm.smallStrings.undefinedString(); 348 348 if (isSymbol()) { 349 throwTypeError(exec, "Cannot convert a symbol to a string");349 throwTypeError(exec, ASCIILiteral("Cannot convert a symbol to a string")); 350 350 return errorValue(); 351 351 } -
trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
r201964 r202890 633 633 { 634 634 if (!value.isString()) { 635 throwTypeError(exec, "Primitive hint is not a string.");635 throwTypeError(exec, ASCIILiteral("Primitive hint is not a string.")); 636 636 return NoPreference; 637 637 } … … 648 648 return PreferString; 649 649 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'.")); 651 651 return NoPreference; 652 652 } -
trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
r201448 r202890 125 125 JSDataView* dataView = jsDynamicCast<JSDataView*>(exec->thisValue()); 126 126 if (!dataView) 127 return throwVM Error(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")); 128 128 129 129 if (!exec->argumentCount()) 130 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("Need at least one argument (the byteOffset)")));130 return throwVMTypeError(exec, ASCIILiteral("Need at least one argument (the byteOffset)")); 131 131 132 132 unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec); … … 170 170 JSDataView* dataView = jsDynamicCast<JSDataView*>(exec->thisValue()); 171 171 if (!dataView) 172 return throwVM Error(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")); 173 173 174 174 if (exec->argumentCount() < 2) 175 return throwVM Error(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)")); 176 176 177 177 unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec); -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r202027 r202890 507 507 if (descriptor.configurablePresent() && descriptor.configurable()) { 508 508 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.")); 510 510 return false; 511 511 } 512 512 if (descriptor.enumerablePresent() && descriptor.enumerable()) { 513 513 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.")); 515 515 return false; 516 516 } 517 517 if (descriptor.isAccessorDescriptor()) { 518 518 if (throwException) 519 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));519 throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)); 520 520 return false; 521 521 } 522 522 if (descriptor.writablePresent() && descriptor.writable()) { 523 523 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.")); 525 525 return false; 526 526 } 527 527 if (!valueCheck) { 528 528 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.")); 530 530 return false; 531 531 } -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
r202667 r202890 82 82 { 83 83 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.")); 85 85 86 86 MarkedArgumentBuffer storage; … … 140 140 141 141 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.")); 143 143 144 144 // For everything but DataView, we allow construction with any of: … … 175 175 CallType callType = getCallData(iteratorFunc, callData); 176 176 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.")); 178 178 179 179 ArgList arguments; … … 207 207 length = firstValue.asInt32(); 208 208 else if (!firstValue.isNumber()) 209 return throwTypeError(exec, "Invalid array length argument");209 return throwTypeError(exec, ASCIILiteral("Invalid array length argument")); 210 210 else { 211 211 length = static_cast<int>(firstValue.asNumber()); 212 212 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)")); 214 214 } 215 215 … … 235 235 if (!argCount) { 236 236 if (ViewClass::TypedArrayStorageType == TypeDataView) 237 return throwVM Error(exec, createTypeError(exec,"DataView constructor requires at least one argument."));237 return throwVMTypeError(exec, ASCIILiteral("DataView constructor requires at least one argument.")); 238 238 239 239 return JSValue::encode(ViewClass::create(exec, structure, 0)); -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
r202280 r202890 57 57 return defaultConstructor(); 58 58 if (!constructor.isObject()) { 59 throwTypeError(exec, "constructor Property should not be null");59 throwTypeError(exec, ASCIILiteral("constructor Property should not be null")); 60 60 return nullptr; 61 61 } … … 75 75 return view; 76 76 77 throwTypeError(exec, "species constructor did not return a TypedArray View");77 throwTypeError(exec, ASCIILiteral("species constructor did not return a TypedArray View")); 78 78 return nullptr; 79 79 } … … 100 100 101 101 if (!exec->argumentCount()) 102 return throwVM Error(exec, createTypeError(exec,"Expected at least one argument"));102 return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument")); 103 103 104 104 unsigned offset; … … 118 118 JSObject* sourceArray = jsDynamicCast<JSObject*>(exec->uncheckedArgument(0)); 119 119 if (!sourceArray) 120 return throwVM Error(exec, createTypeError(exec,"First argument should be an object"));120 return throwVMTypeError(exec, ASCIILiteral("First argument should be an object")); 121 121 122 122 unsigned length; … … 146 146 147 147 if (exec->argumentCount() < 2) 148 return throwVM Error(exec, createTypeError(exec,"Expected at least two arguments"));148 return throwVMTypeError(exec, ASCIILiteral("Expected at least two arguments")); 149 149 150 150 if (exec->hadException()) … … 201 201 202 202 if (!exec->argumentCount()) 203 return throwVM Error(exec, createTypeError(exec,"Expected at least one argument"));203 return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument")); 204 204 205 205 unsigned length = thisObject->length(); … … 265 265 266 266 if (!exec->argumentCount()) 267 return throwVM Error(exec, createTypeError(exec,"Expected at least one argument"));267 return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument")); 268 268 269 269 unsigned length = thisObject->length(); … … 443 443 444 444 if (!exec->argumentCount()) 445 return throwVM Error(exec, createTypeError(exec,"Expected at least one argument"));445 return throwVMTypeError(exec, ASCIILiteral("Expected at least one argument")); 446 446 447 447 // Get the length here; later assert that the length didn't change. -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r202680 r202890 889 889 { 890 890 if (exec->thisValue().isUndefinedOrNull()) 891 return throwVM Error(exec, createTypeError(exec,"Can't convert undefined or null to object"));891 return throwVMTypeError(exec, ASCIILiteral("Can't convert undefined or null to object")); 892 892 893 893 JSObject* thisObject = jsDynamicCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode)); … … 946 946 { 947 947 if (exec->thisValue().isUndefinedOrNull()) 948 return throwVM Error(exec, createTypeError(exec,"Can't convert undefined or null to object"));948 return throwVMTypeError(exec, ASCIILiteral("Can't convert undefined or null to object")); 949 949 950 950 JSValue value = exec->argument(0); -
trunk/Source/JavaScriptCore/runtime/JSONObject.cpp
r201703 r202890 369 369 for (unsigned i = 0; i < m_holderStack.size(); i++) { 370 370 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.")); 372 372 return StringifyFailed; 373 373 } -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r202832 r202890 1358 1358 if (!isExtensible) { 1359 1359 if (shouldThrowIfCantSet) 1360 throw VMError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));1360 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); 1361 1361 return false; 1362 1362 } … … 1641 1641 return exec->exception(); 1642 1642 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")); 1644 1644 return result; 1645 1645 } … … 1671 1671 ASSERT(!exec->hadException()); 1672 1672 1673 return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("No default value")));1673 return throwTypeError(exec, ASCIILiteral("No default value")); 1674 1674 } 1675 1675 … … 1757 1757 1758 1758 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.")); 1760 1760 return false; 1761 1761 } … … 2944 2944 if (!isExtensible) { 2945 2945 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.")); 2947 2947 return false; 2948 2948 } … … 2967 2967 if (descriptor.configurable()) { 2968 2968 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.")); 2970 2970 return false; 2971 2971 } 2972 2972 if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) { 2973 2973 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.")); 2975 2975 return false; 2976 2976 } … … 2992 2992 if (!current.configurable()) { 2993 2993 if (throwException) 2994 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));2994 throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)); 2995 2995 return false; 2996 2996 } … … 3009 3009 if (!current.writable() && descriptor.writable()) { 3010 3010 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.")); 3012 3012 return false; 3013 3013 } … … 3015 3015 if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) { 3016 3016 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.")); 3018 3018 return false; 3019 3019 } … … 3034 3034 if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) { 3035 3035 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.")); 3037 3037 return false; 3038 3038 } 3039 3039 if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) { 3040 3040 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.")); 3042 3042 return false; 3043 3043 } 3044 3044 if (current.attributes() & CustomAccessor) { 3045 3045 if (throwException) 3046 exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)));3046 throwTypeError(exec, ASCIILiteral(UnconfigurablePropertyChangeAccessMechanismError)); 3047 3047 return false; 3048 3048 } -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewConstructor.cpp
r197648 r202890 72 72 JSObject* object = jsDynamicCast<JSObject*>(value); 73 73 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."))); 75 75 76 76 ConstructData data; 77 77 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."))); 79 79 80 80 for (; !value.isNull(); value = jsCast<JSObject*>(value)->getPrototypeDirect()) { 81 81 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."))); 83 83 if (jsDynamicCast<JSGenericTypedArrayViewConstructor<JSInt8Array>*>(value)) 84 84 return constructGenericTypedArrayView<JSInt8Array>(exec); … … 101 101 } 102 102 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."))); 104 104 } 105 105 -
trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp
r202673 r202890 59 59 case NotTypedArray: \ 60 60 case TypeDataView: \ 61 return throwVM Error(exec, createTypeError(exec,\62 "Receiver should be a typed array view"));\61 return throwVMTypeError(exec, \ 62 ASCIILiteral("Receiver should be a typed array view")); \ 63 63 } \ 64 64 RELEASE_ASSERT_NOT_REACHED(); \ … … 79 79 JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(argument); 80 80 if (!thisObject || thisObject->mode() == DataViewMode) 81 return throwVM Error(exec, createTypeError(exec,"Receiver should be a typed array view"));81 return throwVMTypeError(exec, ASCIILiteral("Receiver should be a typed array view")); 82 82 if (thisObject->isNeutered()) 83 83 return throwVMTypeError(exec, "Underlying ArrayBuffer has been detached from the view"); … … 104 104 JSValue thisValue = exec->thisValue(); 105 105 if (!thisValue.isObject()) 106 return throwVM Error(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")); 107 107 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSet); 108 108 } … … 112 112 JSValue thisValue = exec->thisValue(); 113 113 if (!thisValue.isObject()) 114 return throwVM Error(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")); 115 115 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncCopyWithin); 116 116 } … … 120 120 JSValue thisValue = exec->thisValue(); 121 121 if (!thisValue.isObject()) 122 return throwVM Error(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")); 123 123 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncFill); 124 124 } … … 128 128 JSValue thisValue = exec->thisValue(); 129 129 if (!thisValue.isObject()) 130 return throwVM Error(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")); 131 131 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncLastIndexOf); 132 132 } … … 136 136 JSValue thisValue = exec->thisValue(); 137 137 if (!thisValue.isObject()) 138 return throwVM Error(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")); 139 139 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncIndexOf); 140 140 } … … 144 144 JSValue thisValue = exec->thisValue(); 145 145 if (!thisValue.isObject()) 146 return throwVM Error(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")); 147 147 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncJoin); 148 148 } … … 152 152 JSValue thisValue = exec->thisValue(); 153 153 if (!thisValue.isObject()) 154 return throwVM Error(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")); 155 155 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncBuffer); 156 156 } … … 160 160 JSValue thisValue = exec->thisValue(); 161 161 if (!thisValue.isObject()) 162 return throwVM Error(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")); 163 163 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncLength); 164 164 } … … 168 168 JSValue thisValue = exec->thisValue(); 169 169 if (!thisValue.isObject()) 170 return throwVM Error(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")); 171 171 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncByteLength); 172 172 } … … 176 176 JSValue thisValue = exec->thisValue(); 177 177 if (!thisValue.isObject()) 178 return throwVM Error(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")); 179 179 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoGetterFuncByteOffset); 180 180 } … … 184 184 JSValue thisValue = exec->thisValue(); 185 185 if (!thisValue.isObject()) 186 return throwVM Error(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")); 187 187 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncReverse); 188 188 } … … 192 192 JSValue thisValue = exec->thisValue(); 193 193 if (!thisValue.isObject()) 194 return throwVM Error(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")); 195 195 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSubarray); 196 196 } … … 200 200 JSValue thisValue = exec->thisValue(); 201 201 if (!thisValue.isObject()) 202 return throwVM Error(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")); 203 203 CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSlice); 204 204 } -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r202280 r202890 336 336 VM& vm = exec->vm(); 337 337 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.")); 339 339 return false; 340 340 } … … 381 381 CallData callData; 382 382 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.")); 384 384 return false; 385 385 } … … 396 396 CallData callData; 397 397 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.")); 399 399 return false; 400 400 } … … 408 408 409 409 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.")); 411 411 return false; 412 412 } 413 413 414 414 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.")); 416 416 return false; 417 417 } … … 422 422 { 423 423 if (!exec->argument(0).isObject()) 424 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));424 return throwVMTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")); 425 425 JSObject* O = asObject(exec->argument(0)); 426 426 auto propertyName = exec->argument(1).toPropertyKey(exec); … … 477 477 { 478 478 if (!exec->argument(0).isObject()) 479 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));479 return throwVMTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")); 480 480 JSObject* targetObj = asObject(exec->argument(0)); 481 481 JSObject* props = exec->argument(1).toObject(exec); … … 489 489 JSValue proto = exec->argument(0); 490 490 if (!proto.isObject() && !proto.isNull()) 491 return throwVM Error(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.")); 492 492 JSObject* newObject = proto.isObject() 493 493 ? constructEmptyObject(exec, asObject(proto)) … … 496 496 return JSValue::encode(newObject); 497 497 if (!exec->argument(1).isObject()) 498 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("Property descriptor list must be an Object.")));498 return throwVMTypeError(exec, ASCIILiteral("Property descriptor list must be an Object.")); 499 499 return JSValue::encode(defineProperties(exec, newObject, asObject(exec->argument(1)))); 500 500 } -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r202796 r202890 135 135 CallData callData; 136 136 if (getCallData(get, callData) == CallType::None) 137 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("invalid getter usage")));137 return throwVMTypeError(exec, ASCIILiteral("invalid getter usage")); 138 138 139 139 auto propertyName = exec->argument(0).toPropertyKey(exec); … … 161 161 CallData callData; 162 162 if (getCallData(set, callData) == CallType::None) 163 return throwVM Error(exec, createTypeError(exec, ASCIILiteral("invalid setter usage")));163 return throwVMTypeError(exec, ASCIILiteral("invalid setter usage")); 164 164 165 165 auto propertyName = exec->argument(0).toPropertyKey(exec); -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r202770 r202890 144 144 if (arg0.inherits(RegExpObject::info())) { 145 145 if (!arg1.isUndefined()) 146 return throwVM Error(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.")); 147 147 regExp = asRegExpObject(arg0)->regExp(); 148 148 } else { -
trunk/Source/JavaScriptCore/runtime/Symbol.cpp
r200402 r202890 80 80 double Symbol::toNumber(ExecState* exec) const 81 81 { 82 throwTypeError(exec, "Cannot convert a symbol to a number");82 throwTypeError(exec, ASCIILiteral("Cannot convert a symbol to a number")); 83 83 return 0.0; 84 84 } -
trunk/Source/WebCore/ChangeLog
r202889 r202890 1 2016-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 1 67 2016-07-06 Tim Horton <timothy_horton@apple.com> 2 68 -
trunk/Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp
r191887 r202890 44 44 uint32_t type = value.toUInt32(&state); 45 45 if (!wrapped().setType(type)) 46 state.vm().throwException(&state, createTypeError(&state, "Illegal BiquadFilterNode type"));46 throwTypeError(&state, "Illegal BiquadFilterNode type"); 47 47 return; 48 48 } … … 57 57 } 58 58 59 state.vm().throwException(&state, createTypeError(&state, "Illegal BiquadFilterNode type"));59 throwTypeError(&state, "Illegal BiquadFilterNode type"); 60 60 } 61 61 -
trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp
r201129 r202890 85 85 86 86 if (!blobPropertyBagValue.isObject()) 87 return throwVM Error(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"); 88 88 89 89 // Given the above test, this will always yield an object. … … 100 100 if (containsEndings) { 101 101 if (endings != "transparent" && endings != "native") 102 return throwVM Error(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\""); 103 103 } 104 104 -
trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp
r201787 r202890 118 118 119 119 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")); 121 121 return false; 122 122 } 123 123 124 124 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")); 126 126 return false; 127 127 } … … 138 138 139 139 if (!jsonValue || !jsonValue.isObject()) { 140 throwTypeError(exec, "Invalid JWK serialization");140 throwTypeError(exec, ASCIILiteral("Invalid JWK serialization")); 141 141 return; 142 142 } … … 254 254 if (operation == tryOperation) { 255 255 if (usages & tryUsage) { 256 throwTypeError(exec, "JWK key_ops contains a duplicate operation");256 throwTypeError(exec, ASCIILiteral("JWK key_ops contains a duplicate operation")); 257 257 return false; 258 258 } … … 273 273 if (!jsValue.getString(m_exec, operation)) { 274 274 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")); 276 276 return; 277 277 } … … 363 363 if (!getStringFromJSON(m_exec, m_json.get(), "k", keyBase64URL)) { 364 364 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")); 366 366 return nullptr; 367 367 } … … 369 369 Vector<uint8_t> octetSequence; 370 370 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")); 372 372 return nullptr; 373 373 } … … 389 389 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "n", modulus)) { 390 390 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")); 392 392 return nullptr; 393 393 } … … 400 400 if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "e", exponent)) { 401 401 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")); 403 403 return nullptr; 404 404 } … … 456 456 return nullptr; 457 457 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")); 459 459 return nullptr; 460 460 } 461 461 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "r", info.primeFactor)) { 462 462 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")); 464 464 return nullptr; 465 465 } 466 466 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "d", info.factorCRTExponent)) { 467 467 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")); 469 469 return nullptr; 470 470 } 471 471 if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "t", info.factorCRTCoefficient)) { 472 472 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")); 474 474 return nullptr; 475 475 } … … 485 485 if (!getStringFromJSON(m_exec, m_json.get(), "kty", jwkKeyType)) { 486 486 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")); 488 488 return nullptr; 489 489 } … … 650 650 if (jwkAlgorithm.isNull()) { 651 651 // 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")); 653 653 return; 654 654 } … … 690 690 if (!keyData) { 691 691 // 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")); 693 693 return String(); 694 694 } … … 711 711 buildJSONForRSAComponents(exec, downcast<CryptoKeyDataRSAComponents>(*keyData), result); 712 712 else { 713 throwTypeError(exec, "Key doesn't support exportKey");713 throwTypeError(exec, ASCIILiteral("Key doesn't support exportKey")); 714 714 return String(); 715 715 } -
trunk/Source/WebCore/bindings/js/JSCryptoOperationData.cpp
r159637 r202890 42 42 result = std::make_pair(static_cast<uint8_t*>(bufferView->baseAddress()), bufferView->byteLength()); 43 43 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")); 45 45 return false; 46 46 } -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r202460 r202890 375 375 { 376 376 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)); 378 378 return 0; 379 379 } 380 380 x = trunc(x); 381 381 if (x < minimum || x > maximum) { 382 state.vm().throwException(&state, createTypeError(&state, rangeErrorString(x, minimum, maximum)));382 throwTypeError(&state, rangeErrorString(x, minimum, maximum)); 383 383 return 0; 384 384 } … … 737 737 static EncodedJSValue throwTypeError(JSC::ExecState& state, const String& errorMessage) 738 738 { 739 return throwVM Error(&state, createTypeError(&state, errorMessage));739 return throwVMTypeError(&state, errorMessage); 740 740 } 741 741 … … 792 792 builder.appendLiteral("one of: "); 793 793 builder.append(expectedValues); 794 return throw TypeError(state, builder.toString());794 return throwVMTypeError(&state, builder.toString()); 795 795 } 796 796 … … 800 800 appendArgumentMustBe(builder, argumentIndex, argumentName, interfaceName, functionName); 801 801 builder.appendLiteral("a function"); 802 return throw TypeError(state, builder.toString());802 return throwVMTypeError(&state, builder.toString()); 803 803 } 804 804 … … 809 809 builder.appendLiteral("an instance of "); 810 810 builder.append(expectedType); 811 return throw TypeError(state, builder.toString());811 return throwVMTypeError(&state, builder.toString()); 812 812 } 813 813 814 814 void throwArrayElementTypeError(JSC::ExecState& state) 815 815 { 816 throwTypeError(state, "Invalid Array element type");816 throwTypeError(state, ASCIILiteral("Invalid Array element type")); 817 817 } 818 818 … … 830 830 JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName) 831 831 { 832 return throw TypeError(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)); 833 833 } 834 834 … … 851 851 EncodedJSValue throwThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* functionName) 852 852 { 853 return throw TypeError(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)); 854 854 } 855 855 -
trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp
r200316 r202890 70 70 if (exec->argumentCount() > 3) { 71 71 if (!exec->argument(3).isString()) 72 return throwVM Error(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")); 73 73 type = exec->argument(3).getString(exec); 74 74 } -
trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r201793 r202890 155 155 ConstructData callData; 156 156 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")); 158 158 159 159 Document& document = wrapped(); -
trunk/Source/WebCore/bindings/js/JSFileCustom.cpp
r200934 r202890 50 50 JSValue arg = exec->argument(0); 51 51 if (arg.isUndefinedOrNull()) 52 return throwVM Error(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")); 53 53 54 54 unsigned blobPartsLength = 0; … … 60 60 arg = exec->argument(1); 61 61 if (arg.isUndefined()) 62 return throwVM Error(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")); 63 63 64 64 String filename = arg.toWTFString(exec).replace('/', ':'); … … 73 73 JSObject* filePropertyBagObject = arg.getObject(); 74 74 if (!filePropertyBagObject) 75 return throwVM Error(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")); 76 76 77 77 // Create the dictionary wrapper from the initializer object. -
trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp
r190272 r202890 117 117 sourceUrl = URL(URL(), asString(moduleKeyValue)->value(exec)); 118 118 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.")); 120 120 121 121 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.")); 123 123 124 124 // FIXME: Implement evaluating module code. -
trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp
r200552 r202890 51 51 CallData callData; 52 52 if (!object || object->methodTable()->getCallData(object, callData) == CallType::None) 53 return throwVM Error(exec, createTypeError(exec,"Callback argument must be a function"));53 return throwVMTypeError(exec, ASCIILiteral("Callback argument must be a function")); 54 54 55 55 DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee()); -
trunk/Source/WebCore/bindings/js/JSOscillatorNodeCustom.cpp
r191887 r202890 46 46 uint32_t type = value.toUInt32(&state); 47 47 if (!imp.setType(type)) 48 state.vm().throwException(&state, createTypeError(&state,"Illegal OscillatorNode type"));48 throwTypeError(&state, ASCIILiteral("Illegal OscillatorNode type")); 49 49 return; 50 50 } … … 59 59 } 60 60 61 state.vm().throwException(&state, createTypeError(&state,"Illegal OscillatorNode type"));61 throwTypeError(&state, ASCIILiteral("Illegal OscillatorNode type")); 62 62 } 63 63 -
trunk/Source/WebCore/bindings/js/JSPannerNodeCustom.cpp
r191887 r202890 46 46 uint32_t model = value.toUInt32(&state); 47 47 if (!imp.setPanningModel(model)) 48 state.vm().throwException(&state, createTypeError(&state,"Illegal panningModel"));48 throwTypeError(&state, ASCIILiteral("Illegal panningModel")); 49 49 return; 50 50 } … … 59 59 } 60 60 61 state.vm().throwException(&state, createTypeError(&state,"Illegal panningModel"));61 throwTypeError(&state, ASCIILiteral("Illegal panningModel")); 62 62 } 63 63 … … 70 70 uint32_t model = value.toUInt32(&state); 71 71 if (!imp.setDistanceModel(model)) 72 state.vm().throwException(&state, createTypeError(&state,"Illegal distanceModel"));72 throwTypeError(&state, ASCIILiteral("Illegal distanceModel")); 73 73 return; 74 74 } … … 83 83 } 84 84 85 state.vm().throwException(&state, createTypeError(&state,"Illegal distanceModel"));85 throwTypeError(&state, ASCIILiteral("Illegal distanceModel")); 86 86 } 87 87 -
trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp
r197642 r202890 37 37 EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState* state) 38 38 { 39 return throwVM Error(state, createTypeError(state, ASCIILiteral("ReadableStreamController constructor should not be called directly")));39 return throwVMTypeError(state, ASCIILiteral("ReadableStreamController constructor should not be called directly")); 40 40 } 41 41 … … 44 44 JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(state->argument(0)); 45 45 if (!stream) 46 return throwVM Error(state, createTypeError(state, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream")));46 return throwVMTypeError(state, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream")); 47 47 48 48 JSValue jsFunction = stream->get(state, Identifier::fromString(state, "getReader")); -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r201013 r202890 90 90 result = CryptoKeyFormat::JWK; 91 91 else { 92 throwTypeError(&state, "Unknown key format");92 throwTypeError(&state, ASCIILiteral("Unknown key format")); 93 93 return false; 94 94 } … … 454 454 String jwkString = String::fromUTF8(data.first, data.second); 455 455 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")); 457 457 return; 458 458 } … … 463 463 } 464 464 default: 465 throwTypeError(&state, "Unsupported key format for import");465 throwTypeError(&state, ASCIILiteral("Unsupported key format for import")); 466 466 return; 467 467 } … … 471 471 if (!keySerialization->reconcileAlgorithm(algorithm, parameters)) { 472 472 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")); 474 474 return; 475 475 } … … 478 478 479 479 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")); 481 481 return; 482 482 } … … 567 567 { 568 568 if (!key.extractable()) { 569 throwTypeError(&state, "Key is not extractable");569 throwTypeError(&state, ASCIILiteral("Key is not extractable")); 570 570 return; 571 571 } … … 591 591 } 592 592 default: 593 throwTypeError(&state, "Unsupported key format for export");593 throwTypeError(&state, ASCIILiteral("Unsupported key format for export")); 594 594 break; 595 595 } -
trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp
r200775 r202890 56 56 if (!function.isFunction()) { 57 57 if (!function.isUndefined()) 58 throw VMError(&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")); 59 59 return JSC::jsUndefined(); 60 60 } -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r202439 r202890 1570 1570 void throwValidationError() 1571 1571 { 1572 m_exec->vm().throwException(m_exec, createTypeError(m_exec,"Unable to deserialize data."));1572 throwTypeError(m_exec, ASCIILiteral("Unable to deserialize data.")); 1573 1573 } 1574 1574 … … 2764 2764 break; 2765 2765 case ValidationError: 2766 exec->vm().throwException(exec, createTypeError(exec,"Unable to deserialize data."));2766 throwTypeError(exec, ASCIILiteral("Unable to deserialize data.")); 2767 2767 break; 2768 2768 case DataCloneError: -
trunk/Source/WebCore/bridge/c/c_instance.cpp
r194819 r202890 156 156 { 157 157 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."); 159 159 160 160 CMethod* method = static_cast<CMethod*>(runtimeMethod->method()); -
trunk/Source/WebCore/bridge/objc/objc_instance.mm
r199834 r202890 207 207 { 208 208 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.")); 210 210 211 211 ObjcMethod *method = static_cast<ObjcMethod*>(runtimeMethod->method()); -
trunk/Source/WebCore/bridge/objc/objc_runtime.mm
r198023 r202890 158 158 { 159 159 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.")); 161 161 return false; 162 162 } -
trunk/Source/WebKit/mac/ChangeLog
r202728 r202890 1 2016-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 1 11 2016-07-01 Youenn Fablet <youennf@gmail.com> 2 12 -
trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
r198023 r202890 221 221 { 222 222 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.")); 224 224 225 225 ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
Note:
See TracChangeset
for help on using the changeset viewer.