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

Changeset 242365 in webkit


Ignore:
Timestamp:
Mar 4, 2019, 10:56:22 AM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Offer @makeTypeError instead of exposing @TypeError
https://bugs.webkit.org/show_bug.cgi?id=193858

Reviewed by Mark Lam.

Source/JavaScriptCore:

Instead of exposing @TypeError, we expose @makeTypeError function.
And we make TypeError and Error lazily-allocated objects in non JIT environment.
In JIT environment, only TypeError becomes lazily-allocated since WebAssembly errors
touch Error prototype anyway. But we can make them lazy in a subsequent patch.

  • builtins/AsyncFromSyncIteratorPrototype.js:
  • builtins/AsyncGeneratorPrototype.js:

(globalPrivate.asyncGeneratorEnqueue):

  • builtins/BuiltinNames.h:
  • builtins/PromiseOperations.js:

(globalPrivate.createResolvingFunctions.resolve):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::initializeErrorConstructor):
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::errorPrototype const):
(JSC::JSGlobalObject::errorStructure const):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncMakeTypeError):

  • runtime/JSGlobalObjectFunctions.h:

Source/WebCore:

Use @makeTypeError instead.

  • Modules/mediastream/RTCPeerConnection.js:
  • Modules/mediastream/RTCPeerConnectionInternals.js:
  • Modules/streams/ReadableByteStreamInternals.js:

(readableByteStreamControllerClose):
(readableByteStreamControllerPullInto):

  • Modules/streams/ReadableStream.js:

(cancel):
(pipeTo):

  • Modules/streams/ReadableStreamBYOBReader.js:

(cancel):
(read):

  • Modules/streams/ReadableStreamDefaultReader.js:

(cancel):
(read):

  • Modules/streams/ReadableStreamInternals.js:

(readableStreamReaderGenericRelease):

  • Modules/streams/WritableStream.js:

(abort):
(close):
(write):
(getter.closed):
(getter.ready):

Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r242349 r242365  
     12019-03-04  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Offer @makeTypeError instead of exposing @TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=193858
     5
     6        Reviewed by Mark Lam.
     7
     8        Instead of exposing @TypeError, we expose @makeTypeError function.
     9        And we make TypeError and Error lazily-allocated objects in non JIT environment.
     10        In JIT environment, only TypeError becomes lazily-allocated since WebAssembly errors
     11        touch Error prototype anyway. But we can make them lazy in a subsequent patch.
     12
     13        * builtins/AsyncFromSyncIteratorPrototype.js:
     14        * builtins/AsyncGeneratorPrototype.js:
     15        (globalPrivate.asyncGeneratorEnqueue):
     16        * builtins/BuiltinNames.h:
     17        * builtins/PromiseOperations.js:
     18        (globalPrivate.createResolvingFunctions.resolve):
     19        * runtime/JSGlobalObject.cpp:
     20        (JSC::JSGlobalObject::initializeErrorConstructor):
     21        (JSC::JSGlobalObject::init):
     22        (JSC::JSGlobalObject::visitChildren):
     23        * runtime/JSGlobalObject.h:
     24        (JSC::JSGlobalObject::errorPrototype const):
     25        (JSC::JSGlobalObject::errorStructure const):
     26        * runtime/JSGlobalObjectFunctions.cpp:
     27        (JSC::globalFuncMakeTypeError):
     28        * runtime/JSGlobalObjectFunctions.h:
     29
    1302019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
    231
  • trunk/Source/JavaScriptCore/builtins/AsyncFromSyncIteratorPrototype.js

    r233740 r242365  
    3131
    3232    if (!@isObject(this) || !@isObject(@getByIdDirectPrivate(this, "syncIterator"))) {
    33         promiseCapability.@reject.@call(@undefined, new @TypeError('Iterator is not an object.'));
     33        promiseCapability.@reject.@call(@undefined, @makeTypeError('Iterator is not an object.'));
    3434        return promiseCapability.@promise;
    3535    }
     
    5858
    5959    if (!@isObject(this) || !@isObject(@getByIdDirectPrivate(this, "syncIterator"))) {
    60         promiseCapability.@reject.@call(@undefined, new @TypeError('Iterator is not an object.'));
     60        promiseCapability.@reject.@call(@undefined, @makeTypeError('Iterator is not an object.'));
    6161        return promiseCapability.@promise;
    6262    }
     
    8282
    8383        if (!@isObject(returnResult)) {
    84             promiseCapability.@reject.@call(@undefined, new @TypeError('Iterator result interface is not an object.'));
     84            promiseCapability.@reject.@call(@undefined, @makeTypeError('Iterator result interface is not an object.'));
    8585            return promiseCapability.@promise;
    8686        }
     
    107107
    108108    if (!@isObject(this) || !@isObject(@getByIdDirectPrivate(this, "syncIterator"))) {
    109         promiseCapability.@reject.@call(@undefined, new @TypeError('Iterator is not an object.'));
     109        promiseCapability.@reject.@call(@undefined, @makeTypeError('Iterator is not an object.'));
    110110        return promiseCapability.@promise;
    111111    }
     
    131131       
    132132        if (!@isObject(throwResult)) {
    133             promiseCapability.@reject.@call(@undefined, new @TypeError('Iterator result interface is not an object.'));
     133            promiseCapability.@reject.@call(@undefined, @makeTypeError('Iterator result interface is not an object.'));
    134134            return promiseCapability.@promise;
    135135        }
  • trunk/Source/JavaScriptCore/builtins/AsyncGeneratorPrototype.js

    r233740 r242365  
    266266    const promiseCapability = @newPromiseCapability(@Promise);
    267267    if (!@isObject(generator) || typeof @getByIdDirectPrivate(generator, "asyncGeneratorSuspendReason") !== 'number') {
    268         promiseCapability.@reject.@call(@undefined, new @TypeError('|this| should be an async generator'));
     268        promiseCapability.@reject.@call(@undefined, @makeTypeError('|this| should be an async generator'));
    269269        return promiseCapability.@promise;
    270270    }
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r242047 r242365  
    7575    macro(ownKeys) \
    7676    macro(Set) \
    77     macro(TypeError) \
    7877    macro(typedArrayLength) \
    7978    macro(typedArraySort) \
     
    144143    macro(replaceUsingRegExp) \
    145144    macro(replaceUsingStringSearch) \
     145    macro(makeTypeError) \
    146146    macro(mapBucket) \
    147147    macro(mapBucketHead) \
  • trunk/Source/JavaScriptCore/builtins/PromiseOperations.js

    r233377 r242365  
    149149
    150150        if (resolution === promise)
    151             return @rejectPromise(promise, new @TypeError("Resolve a promise with itself"));
     151            return @rejectPromise(promise, @makeTypeError("Resolve a promise with itself"));
    152152
    153153        if (!@isObject(resolution))
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r242064 r242365  
    336336  DataView              JSGlobalObject::m_typedArrayDataView         DontEnum|ClassStructure
    337337  Date                  JSGlobalObject::m_dateStructure              DontEnum|ClassStructure
     338  Error                 JSGlobalObject::m_errorStructure             DontEnum|ClassStructure
    338339  Boolean               JSGlobalObject::m_booleanObjectStructure     DontEnum|ClassStructure
    339340  Number                JSGlobalObject::m_numberObjectStructure      DontEnum|ClassStructure
     
    410411void JSGlobalObject::initializeErrorConstructor(LazyClassStructure::Initializer& init)
    411412{
    412     init.setPrototype(NativeErrorPrototype::create(init.vm, NativeErrorPrototype::createStructure(init.vm, this, m_errorPrototype.get()), errorTypeName(errorType)));
     413    init.setPrototype(NativeErrorPrototype::create(init.vm, NativeErrorPrototype::createStructure(init.vm, this, m_errorStructure.prototype(this)), errorTypeName(errorType)));
    413414    init.setStructure(ErrorInstance::createStructure(init.vm, this, init.prototype));
    414     init.setConstructor(NativeErrorConstructor<errorType>::create(init.vm, NativeErrorConstructor<errorType>::createStructure(init.vm, this, m_errorConstructor.get()), jsCast<NativeErrorPrototype*>(init.prototype)));
     415    init.setConstructor(NativeErrorConstructor<errorType>::create(init.vm, NativeErrorConstructor<errorType>::createStructure(init.vm, this, m_errorStructure.constructor(this)), jsCast<NativeErrorPrototype*>(init.prototype)));
    415416}
    416417
     
    727728    m_internalPromiseConstructor.set(vm, this, internalPromiseConstructor);
    728729   
    729     m_errorConstructor.set(vm, this, errorConstructor);
    730730    m_evalErrorStructure.initLater(
    731731        [] (LazyClassStructure::Initializer& init) {
     
    855855    JSFunction* privateFuncPropertyIsEnumerable = JSFunction::create(vm, this, 0, String(), globalFuncPropertyIsEnumerable);
    856856    JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
     857    JSFunction* privateFuncMakeTypeError = JSFunction::create(vm, this, 0, String(), globalFuncMakeTypeError);
    857858    JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
    858859    JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
     
    926927        GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    927928        GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    928         // FIXME: Offer @makeTypeError function instead of exposing @TypeError here.
    929         // https://bugs.webkit.org/show_bug.cgi?id=193858
    930         GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorStructure.constructor(this), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
     929        GlobalPropertyInfo(vm.propertyNames->builtinNames().makeTypeErrorPrivateName(), privateFuncMakeTypeError, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    931930        GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayLengthPrivateName(), privateFuncTypedArrayLength, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    932931        GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayGetOriginalConstructorPrivateName(), privateFuncTypedArrayGetOriginalConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
     
    10321031        typedef capitalName ## Constructor Constructor; \
    10331032        typedef JS ## capitalName JSObj; \
    1034         auto* base = m_ ## prototypeBase ## Prototype.get(); \
     1033        auto* base = prototypeBase ## Prototype(); \
    10351034        auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
    10361035        auto* structure = JSObj::createStructure(vm, this, prototype); \
     
    15881587    visitor.append(thisObject->m_globalCallee);
    15891588    visitor.append(thisObject->m_stackOverflowFrameCallee);
    1590     visitor.append(thisObject->m_errorConstructor);
    15911589    thisObject->m_evalErrorStructure.visit(visitor);
    15921590    thisObject->m_rangeErrorStructure.visit(visitor);
     
    16311629    visitor.append(thisObject->m_functionPrototype);
    16321630    visitor.append(thisObject->m_arrayPrototype);
    1633     visitor.append(thisObject->m_errorPrototype);
    16341631    visitor.append(thisObject->m_iteratorPrototype);
    16351632    visitor.append(thisObject->m_generatorFunctionPrototype);
     
    16651662#endif
    16661663    visitor.append(thisObject->m_nullPrototypeObjectStructure);
    1667     visitor.append(thisObject->m_errorStructure);
    16681664    visitor.append(thisObject->m_calleeStructure);
    16691665
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r242123 r242365  
    129129#define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    130130    macro(String, string, stringObject, StringObject, String, object) \
    131     macro(Error, error, error, ErrorInstance, Error, object) \
    132131    macro(Map, map, map, JSMap, Map, object) \
    133132    macro(Set, set, set, JSSet, Set, object) \
     
    147146    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object) \
    148147    macro(Date, date, date, DateInstance, Date, object) \
     148    macro(Error, error, error, ErrorInstance, Error, object) \
    149149    macro(Number, number, numberObject, NumberObject, Number, object) \
    150150    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object) \
     
    632632    JSObject* symbolPrototype() const { return m_symbolObjectStructure.prototypeInitializedOnMainThread(this); }
    633633    RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
    634     ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); }
     634    JSObject* errorPrototype() const { return m_errorStructure.prototype(this); }
    635635    IteratorPrototype* iteratorPrototype() const { return m_iteratorPrototype.get(); }
    636636    AsyncIteratorPrototype* asyncIteratorPrototype() const { return m_asyncIteratorPrototype.get(); }
     
    693693    Structure* symbolObjectStructure() const { return m_symbolObjectStructure.get(this); }
    694694    Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); }
    695     Structure* errorStructure() const { return m_errorStructure.get(); }
     695    Structure* errorStructure() const { return m_errorStructure.get(this); }
    696696    Structure* errorStructure(ErrorType errorType) const
    697697    {
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r242064 r242365  
    699699}
    700700
     701EncodedJSValue JSC_HOST_CALL globalFuncMakeTypeError(ExecState* exec)
     702{
     703    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     704    Structure* errorStructure = globalObject->errorStructure(ErrorType::TypeError);
     705    return JSValue::encode(ErrorInstance::create(exec, errorStructure, exec->argument(0), nullptr, TypeNothing, false));
     706}
     707
    701708EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState* exec)
    702709{
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h

    r242047 r242365  
    4949EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeError(ExecState*);
    5050EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeErrorArgumentsCalleeAndCaller(ExecState*);
     51EncodedJSValue JSC_HOST_CALL globalFuncMakeTypeError(ExecState*);
    5152EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
    5253EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
  • trunk/Source/WebCore/ChangeLog

    r242359 r242365  
     12019-03-04  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Offer @makeTypeError instead of exposing @TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=193858
     5
     6        Reviewed by Mark Lam.
     7
     8        Use @makeTypeError instead.
     9
     10        * Modules/mediastream/RTCPeerConnection.js:
     11        * Modules/mediastream/RTCPeerConnectionInternals.js:
     12        * Modules/streams/ReadableByteStreamInternals.js:
     13        (readableByteStreamControllerClose):
     14        (readableByteStreamControllerPullInto):
     15        * Modules/streams/ReadableStream.js:
     16        (cancel):
     17        (pipeTo):
     18        * Modules/streams/ReadableStreamBYOBReader.js:
     19        (cancel):
     20        (read):
     21        * Modules/streams/ReadableStreamDefaultReader.js:
     22        (cancel):
     23        (read):
     24        * Modules/streams/ReadableStreamInternals.js:
     25        (readableStreamReaderGenericRelease):
     26        * Modules/streams/WritableStream.js:
     27        (abort):
     28        (close):
     29        (write):
     30        (getter.closed):
     31        (getter.ready):
     32
    1332019-03-04  Simon Fraser  <simon.fraser@apple.com>
    234
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.js

    r238230 r242365  
    8080
    8181    if (arguments.length < 1)
    82         return @Promise.@reject(new @TypeError("Not enough arguments"));
     82        return @Promise.@reject(@makeTypeError("Not enough arguments"));
    8383
    8484    // FIXME 169644: According the spec, we should throw when receiving a RTCSessionDescription.
     
    104104
    105105    if (arguments.length < 1)
    106         return @Promise.@reject(new @TypeError("Not enough arguments"));
     106        return @Promise.@reject(@makeTypeError("Not enough arguments"));
    107107
    108108    // FIXME: According the spec, we should only expect RTCSessionDescriptionInit.
     
    128128
    129129    if (arguments.length < 1)
    130         return @Promise.@reject(new @TypeError("Not enough arguments"));
     130        return @Promise.@reject(@makeTypeError("Not enough arguments"));
    131131
    132132    const objectInfo = {
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnectionInternals.js

    r238230 r242365  
    7777
    7878    if (!objectArgOk)
    79         return @Promise.@reject(new @TypeError(`Argument 1 ('${objectInfo.argName}') to RTCPeerConnection.${functionName} must be an instance of ${objectInfo.argType}`));
     79        return @Promise.@reject(@makeTypeError(`Argument 1 ('${objectInfo.argName}') to RTCPeerConnection.${functionName} must be an instance of ${objectInfo.argType}`));
    8080
    8181    return promiseMode(objectArg);
  • trunk/Source/WebCore/Modules/streams/ReadableByteStreamInternals.js

    r241637 r242365  
    150150    if (pendingPullIntos.length > 0) {
    151151        if (pendingPullIntos[0].bytesFilled > 0) {
    152             const e = new @TypeError("Close requested while there remain pending bytes");
     152            const e = @makeTypeError("Close requested while there remain pending bytes");
    153153            @readableByteStreamControllerError(controller, e);
    154154            throw e;
     
    649649        }
    650650        if (@getByIdDirectPrivate(controller, "closeRequested")) {
    651             const e = new @TypeError("Closing stream has been requested");
     651            const e = @makeTypeError("Closing stream has been requested");
    652652            @readableByteStreamControllerError(controller, e);
    653653            return @Promise.@reject(e);
  • trunk/Source/WebCore/Modules/streams/ReadableStream.js

    r239472 r242365  
    8181
    8282    if (@isReadableStreamLocked(this))
    83         return @Promise.@reject(new @TypeError("ReadableStream is locked"));
     83        return @Promise.@reject(@makeTypeError("ReadableStream is locked"));
    8484
    8585    return @readableStreamCancel(this, reason);
     
    199199        function() {
    200200            if (!closedPurposefully)
    201                 cancelSource(new @TypeError('destination is closing or closed and cannot be piped to anymore'));
     201                cancelSource(@makeTypeError('destination is closing or closed and cannot be piped to anymore'));
    202202        },
    203203        cancelSource
  • trunk/Source/WebCore/Modules/streams/ReadableStreamBYOBReader.js

    r239472 r242365  
    5050
    5151    if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
    52         return @Promise.@reject(new @TypeError("cancel() called on a reader owned by no readable stream"));
     52        return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
    5353
    5454    return @readableStreamReaderGenericCancel(this, reason);
     
    6363
    6464    if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
    65         return @Promise.@reject(new @TypeError("read() called on a reader owned by no readable stream"));
     65        return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
    6666
    6767    if (!@isObject(view))
    68         return @Promise.@reject(new @TypeError("Provided view is not an object"));
     68        return @Promise.@reject(@makeTypeError("Provided view is not an object"));
    6969
    7070    if (!@ArrayBuffer.@isView(view))
    71         return @Promise.@reject(new @TypeError("Provided view is not an ArrayBufferView"));
     71        return @Promise.@reject(@makeTypeError("Provided view is not an ArrayBufferView"));
    7272
    7373    if (view.byteLength === 0)
    74         return @Promise.@reject(new @TypeError("Provided view cannot have a 0 byteLength"));
     74        return @Promise.@reject(@makeTypeError("Provided view cannot have a 0 byteLength"));
    7575
    7676    return @readableStreamBYOBReaderRead(this, view);
  • trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultReader.js

    r239472 r242365  
    4949
    5050    if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
    51         return @Promise.@reject(new @TypeError("cancel() called on a reader owned by no readable stream"));
     51        return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
    5252
    5353    return @readableStreamReaderGenericCancel(this, reason);
     
    6161        return @Promise.@reject(@makeThisTypeError("ReadableStreamDefaultReader", "read"));
    6262    if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
    63         return @Promise.@reject(new @TypeError("read() called on a reader owned by no readable stream"));
     63        return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
    6464
    6565    return @readableStreamDefaultReaderRead(this);
  • trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js

    r239472 r242365  
    515515
    516516    if (@getByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "state") === @streamReadable)
    517         @getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, new @TypeError("releasing lock of reader whose stream is still in readable state"));
     517        @getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, @makeTypeError("releasing lock of reader whose stream is still in readable state"));
    518518    else
    519         @putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(new @TypeError("reader released lock")) });
     519        @putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(@makeTypeError("reader released lock")) });
    520520
    521521    @putByIdDirectPrivate(@getByIdDirectPrivate(reader, "closedPromiseCapability").@promise, "promiseIsHandled", true);
  • trunk/Source/WebCore/Modules/streams/WritableStream.js

    r230637 r242365  
    7171
    7272    if (!@isWritableStream(this))
    73         return @Promise.@reject(new @TypeError("The WritableStream.abort method can only be used on instances of WritableStream"));
     73        return @Promise.@reject(@makeTypeError("The WritableStream.abort method can only be used on instances of WritableStream"));
    7474
    7575    const state = @getByIdDirectPrivate(this, "state");
     
    9090
    9191    if (!@isWritableStream(this))
    92         return @Promise.@reject(new @TypeError("The WritableStream.close method can only be used on instances of WritableStream"));
     92        return @Promise.@reject(@makeTypeError("The WritableStream.close method can only be used on instances of WritableStream"));
    9393
    9494    const state = @getByIdDirectPrivate(this, "state");
    9595    if (state === @streamClosed || state === @streamClosing)
    96         return @Promise.@reject(new @TypeError("Cannot close a WritableString that is closed or closing"));
     96        return @Promise.@reject(@makeTypeError("Cannot close a WritableString that is closed or closing"));
    9797
    9898    if (state === @streamErrored)
     
    114114
    115115    if (!@isWritableStream(this))
    116         return @Promise.@reject(new @TypeError("The WritableStream.write method can only be used on instances of WritableStream"));
     116        return @Promise.@reject(@makeTypeError("The WritableStream.write method can only be used on instances of WritableStream"));
    117117
    118118    const state = @getByIdDirectPrivate(this, "state");
    119119    if (state === @streamClosed || state === @streamClosing)
    120         return @Promise.@reject(new @TypeError("Cannot write on a WritableString that is closed or closing"));
     120        return @Promise.@reject(@makeTypeError("Cannot write on a WritableString that is closed or closing"));
    121121
    122122    if (state === @streamErrored)
     
    155155
    156156    if (!@isWritableStream(this))
    157         return @Promise.@reject(new @TypeError("The WritableStream.closed getter can only be used on instances of WritableStream"));
     157        return @Promise.@reject(@makeTypeError("The WritableStream.closed getter can only be used on instances of WritableStream"));
    158158
    159159    return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
     
    166166
    167167    if (!@isWritableStream(this))
    168         return @Promise.@reject(new @TypeError("The WritableStream.ready getter can only be used on instances of WritableStream"));
     168        return @Promise.@reject(@makeTypeError("The WritableStream.ready getter can only be used on instances of WritableStream"));
    169169
    170170    return @getByIdDirectPrivate(this, "readyPromiseCapability").@promise;
Note: See TracChangeset for help on using the changeset viewer.