Changeset 263006 in webkit


Ignore:
Timestamp:
Jun 13, 2020 1:40:10 PM (4 years ago)
Author:
Devin Rousso
Message:

Make errors an own property of AggregateError instead of a prototype accessor
https://bugs.webkit.org/show_bug.cgi?id=212677

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/AggregateError-own-property-errors.js: Added.
  • test262/expectations.yaml:

Mark 9 tests as failing while waiting for test262 to update to match the spec.

Source/JavaScriptCore:

  • runtime/AggregateError.h:

(JSC::AggregateError::destroy): Deleted.
(JSC::AggregateError::subspaceFor): Deleted.
(JSC::AggregateError::errors): Deleted.

  • runtime/AggregateError.cpp:

(JSC::AggregateError::AggregateError):
(JSC::AggregateError::finishCreation): Added.
(JSC::AggregateError::visitChildren): Deleted.

  • runtime/AggregateErrorPrototype.h:
  • runtime/AggregateErrorPrototype.cpp:

(JSC::AggregateErrorPrototype::finishCreation):
(JSC::aggregateErrorPrototypeAccessorErrors): Deleted.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::initializeAggregateErrorConstructor):

  • runtime/VM.h:
  • runtime/VM.cpp:

(JSC::VM::VM):

  • heap/Heap.cpp:

(JSC::Heap::finalizeUnconditionalFinalizers):
Remove aggregateErrorSpace since AggregateError doesn't add any new member variables.
Ensure that it can share an IsoSubspace with ErrorInstance.

  • runtime/CommonIdentifiers.h:

Add errors.

Location:
trunk
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r262995 r263006  
     12020-06-13  Devin Rousso  <drousso@apple.com>
     2
     3        Make `errors` an own property of `AggregateError` instead of a prototype accessor
     4        https://bugs.webkit.org/show_bug.cgi?id=212677
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/AggregateError-own-property-errors.js: Added.
     9
     10        * test262/expectations.yaml:
     11        Mark 9 tests as failing while waiting for test262 to update to match the spec.
     12
    1132020-06-12  Robin Morisset  <rmorisset@apple.com>
    214
  • trunk/JSTests/test262/expectations.yaml

    r262979 r263006  
    922922  default: 'Test262Error: Expected SameValue(«22», «2») to be true'
    923923  strict mode: 'Test262Error: Expected SameValue(«22», «2») to be true'
     924test/built-ins/NativeErrors/AggregateError/prototype/errors/invoked-as-accessor.js:
     925  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
     926  strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
     927test/built-ins/NativeErrors/AggregateError/prototype/errors/invoked-as-func.js:
     928  default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
     929  strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
     930test/built-ins/NativeErrors/AggregateError/prototype/errors/length.js:
     931  default: "TypeError: undefined is not an object (evaluating 'desc.get')"
     932  strict mode: "TypeError: undefined is not an object (evaluating 'desc.get')"
     933test/built-ins/NativeErrors/AggregateError/prototype/errors/name.js:
     934  default: "TypeError: undefined is not an object (evaluating 'desc.get')"
     935  strict mode: "TypeError: undefined is not an object (evaluating 'desc.get')"
     936test/built-ins/NativeErrors/AggregateError/prototype/errors/prop-desc.js:
     937  default: "TypeError: undefined is not an object (evaluating 'desc.set')"
     938  strict mode: "TypeError: undefined is not an object (evaluating 'desc.set')"
     939test/built-ins/NativeErrors/AggregateError/prototype/errors/return-from-iterable-errors.js:
     940  default: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«3,6», «3,6») to be false'
     941  strict mode: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«3,6», «3,6») to be false'
     942test/built-ins/NativeErrors/AggregateError/prototype/errors/return-new-array-from-list.js:
     943  default: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«», «») to be false'
     944  strict mode: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«», «») to be false'
     945test/built-ins/NativeErrors/AggregateError/prototype/errors/this-has-no-typedarrayname-internal.js:
     946  default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
     947  strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
     948test/built-ins/NativeErrors/AggregateError/prototype/errors/this-is-not-object.js:
     949  default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
     950  strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
    924951test/built-ins/Object/assign/strings-and-symbol-order-proxy.js:
    925952  default: 'Test262Error: Expected [foo, 0, Symbol()] and [Symbol(), foo, 0] to have the same contents. '
  • trunk/Source/JavaScriptCore/ChangeLog

    r262995 r263006  
     12020-06-13  Devin Rousso  <drousso@apple.com>
     2
     3        Make `errors` an own property of `AggregateError` instead of a prototype accessor
     4        https://bugs.webkit.org/show_bug.cgi?id=212677
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * runtime/AggregateError.h:
     9        (JSC::AggregateError::destroy): Deleted.
     10        (JSC::AggregateError::subspaceFor): Deleted.
     11        (JSC::AggregateError::errors): Deleted.
     12        * runtime/AggregateError.cpp:
     13        (JSC::AggregateError::AggregateError):
     14        (JSC::AggregateError::finishCreation): Added.
     15        (JSC::AggregateError::visitChildren): Deleted.
     16
     17        * runtime/AggregateErrorPrototype.h:
     18        * runtime/AggregateErrorPrototype.cpp:
     19        (JSC::AggregateErrorPrototype::finishCreation):
     20        (JSC::aggregateErrorPrototypeAccessorErrors): Deleted.
     21        * runtime/JSGlobalObject.cpp:
     22        (JSC::JSGlobalObject::initializeAggregateErrorConstructor):
     23
     24        * runtime/VM.h:
     25        * runtime/VM.cpp:
     26        (JSC::VM::VM):
     27        * heap/Heap.cpp:
     28        (JSC::Heap::finalizeUnconditionalFinalizers):
     29        Remove `aggregateErrorSpace` since `AggregateError` doesn't add any new member variables.
     30        Ensure that it can share an `IsoSubspace` with `ErrorInstance`.
     31
     32        * runtime/CommonIdentifiers.h:
     33        Add `errors`.
     34
    1352020-06-12  Robin Morisset  <rmorisset@apple.com>
    236
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r262928 r263006  
    612612    if (vm().m_errorInstanceSpace)
    613613        finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_errorInstanceSpace);
    614     if (vm().m_aggregateErrorSpace)
    615         finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_aggregateErrorSpace);
    616614
    617615#if ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/runtime/AggregateError.cpp

    r261755 r263006  
    3636const ClassInfo AggregateError::s_info = { "AggregateError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AggregateError) };
    3737
    38 AggregateError::AggregateError(VM& vm, Structure* structure, const MarkedArgumentBuffer& errors)
     38AggregateError::AggregateError(VM& vm, Structure* structure)
    3939    : Base(vm, structure)
    40     , m_errors(errors.size())
    4140{
    42     for (size_t i = 0; i < errors.size(); ++i)
    43         m_errors[i].setWithoutWriteBarrier(errors.at(i));
    4441}
    4542
    46 void AggregateError::visitChildren(JSCell* cell, SlotVisitor& visitor)
     43void AggregateError::finishCreation(VM& vm, JSGlobalObject* globalObject, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender, RuntimeType type, bool useCurrentFrame)
    4744{
    48     auto* thisObject = jsCast<AggregateError*>(cell);
    49     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    50     Base::visitChildren(thisObject, visitor);
     45    Base::finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
     46    ASSERT(inherits(vm, info()));
    5147
    52     visitor.appendValues(thisObject->m_errors.data(), thisObject->m_errors.size());
     48    auto scope = DECLARE_THROW_SCOPE(vm);
     49    putDirect(vm, vm.propertyNames->errors, constructArray(globalObject, static_cast<ArrayAllocationProfile*>(nullptr), errors), static_cast<unsigned>(PropertyAttribute::DontEnum));
     50    RETURN_IF_EXCEPTION(scope, void());
    5351}
    5452
  • trunk/Source/JavaScriptCore/runtime/AggregateError.h

    r260415 r263006  
    3131#include "JSCell.h"
    3232#include "JSGlobalObject.h"
    33 #include "SlotVisitor.h"
    3433#include "Structure.h"
    35 #include "SubspaceAccess.h"
    3634#include "VM.h"
    37 #include "WriteBarrier.h"
    38 #include <wtf/Vector.h>
    3935#include <wtf/text/WTFString.h>
    4036
     
    4743    static constexpr bool needsDestruction = Base::needsDestruction;
    4844
    49     static void destroy(JSCell* cell)
    50     {
    51         static_cast<AggregateError*>(cell)->AggregateError::~AggregateError();
    52     }
    53 
    54     template<typename CellType, SubspaceAccess mode>
    55     static IsoSubspace* subspaceFor(VM& vm)
    56     {
    57         return vm.aggregateErrorSpace<mode>();
    58     }
    59 
    6045    DECLARE_EXPORT_INFO;
    6146
     
    6550    }
    6651
    67     static void visitChildren(JSCell*, SlotVisitor&);
    68 
    6952    static AggregateError* create(JSGlobalObject* globalObject, VM& vm, Structure* structure, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, bool useCurrentFrame = true)
    7053    {
    71         auto* instance = new (NotNull, allocateCell<AggregateError>(vm.heap)) AggregateError(vm, structure, errors);
    72         instance->finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
     54        auto* instance = new (NotNull, allocateCell<AggregateError>(vm.heap)) AggregateError(vm, structure);
     55        instance->finishCreation(vm, globalObject, errors, message, appender, type, useCurrentFrame);
    7356        return instance;
    7457    }
     
    7659    static AggregateError* create(JSGlobalObject*, VM&, Structure*, JSValue errors, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
    7760
    78     const Vector<WriteBarrier<Unknown>>& errors() const
    79     {
    80         // This should never be modified after construction.
    81         return m_errors;
    82     }
     61    void finishCreation(VM&, JSGlobalObject*, const MarkedArgumentBuffer& errors, const String& message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
    8362
    8463private:
    85     explicit AggregateError(VM&, Structure*, const MarkedArgumentBuffer& errors);
    86 
    87     Vector<WriteBarrier<Unknown>> m_errors;
     64    explicit AggregateError(VM&, Structure*);
    8865};
    8966
     67STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(AggregateError, AggregateError::Base);
     68
    9069} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/AggregateErrorPrototype.cpp

    r261895 r263006  
    3434namespace JSC {
    3535
    36 static EncodedJSValue JSC_HOST_CALL aggregateErrorPrototypeAccessorErrors(JSGlobalObject*, CallFrame*);
    37 
    3836AggregateErrorPrototype::AggregateErrorPrototype(VM& vm, Structure* structure)
    3937    : Base(vm, structure)
     
    4139}
    4240
    43 void AggregateErrorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     41void AggregateErrorPrototype::finishCreation(VM& vm)
    4442{
    4543    Base::finishCreation(vm, errorTypeName(ErrorType::AggregateError));
    4644    ASSERT(inherits(vm, info()));
    47 
    48     JSC_NATIVE_GETTER_WITHOUT_TRANSITION("errors", aggregateErrorPrototypeAccessorErrors, PropertyAttribute::DontEnum | PropertyAttribute::Accessor);
    49 }
    50 
    51 EncodedJSValue JSC_HOST_CALL aggregateErrorPrototypeAccessorErrors(JSGlobalObject* globalObject, CallFrame* callFrame)
    52 {
    53     VM& vm = globalObject->vm();
    54     auto scope = DECLARE_THROW_SCOPE(vm);
    55 
    56     JSValue thisValue = callFrame->thisValue();
    57     auto* aggregateError = jsDynamicCast<AggregateError*>(vm, thisValue);
    58     if (!aggregateError)
    59         return throwVMTypeError(globalObject, scope, "The AggregateError.prototype.errors getter can only be called on a AggregateError object"_s);
    60 
    61     auto* result = constructEmptyArray(globalObject, nullptr);
    62     RETURN_IF_EXCEPTION(scope, { });
    63 
    64     unsigned index = 0;
    65     for (const auto& error : aggregateError->errors()) {
    66         result->putDirectIndex(globalObject, index++, error.get());
    67         RETURN_IF_EXCEPTION(scope, { });
    68     }
    69 
    70     return JSValue::encode(result);
    7145}
    7246
  • trunk/Source/JavaScriptCore/runtime/AggregateErrorPrototype.h

    r260415 r263006  
    5353    }
    5454
    55     static AggregateErrorPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
     55    static AggregateErrorPrototype* create(VM& vm, Structure* structure)
    5656    {
    5757        AggregateErrorPrototype* prototype = new (NotNull, allocateCell<AggregateErrorPrototype>(vm.heap)) AggregateErrorPrototype(vm, structure);
    58         prototype->finishCreation(vm, globalObject);
     58        prototype->finishCreation(vm);
    5959        return prototype;
    6060    }
     
    6262private:
    6363    AggregateErrorPrototype(VM&, Structure*);
    64     void finishCreation(VM&, JSGlobalObject*);
     64    void finishCreation(VM&);
    6565};
    6666
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r262613 r263006  
    102102    macro(enumerable) \
    103103    macro(era) \
     104    macro(errors) \
    104105    macro(eval) \
    105106    macro(events) \
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r262613 r263006  
    540540void JSGlobalObject::initializeAggregateErrorConstructor(LazyClassStructure::Initializer& init)
    541541{
    542     init.setPrototype(AggregateErrorPrototype::create(init.vm, this, AggregateErrorPrototype::createStructure(init.vm, this, m_errorStructure.prototype(this))));
     542    init.setPrototype(AggregateErrorPrototype::create(init.vm, AggregateErrorPrototype::createStructure(init.vm, this, m_errorStructure.prototype(this))));
    543543    init.setStructure(AggregateError::createStructure(init.vm, this, init.prototype));
    544544    init.setConstructor(AggregateErrorConstructor::create(init.vm, AggregateErrorConstructor::createStructure(init.vm, this, m_errorStructure.constructor(this)), jsCast<AggregateErrorPrototype*>(init.prototype)));
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r262535 r263006  
    286286    , cellHeapCellType(makeUnique<HeapCellType>(CellAttributes(DoesNotNeedDestruction, HeapCell::JSCell)))
    287287    , destructibleCellHeapCellType(makeUnique<HeapCellType>(CellAttributes(NeedsDestruction, HeapCell::JSCell)))
    288     , aggregateErrorHeapCellType(IsoHeapCellType::create<AggregateError>())
    289288    , apiGlobalObjectHeapCellType(IsoHeapCellType::create<JSAPIGlobalObject>())
    290289    , callbackConstructorHeapCellType(IsoHeapCellType::create<JSCallbackConstructor>())
     
    14211420
    14221421
    1423 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(aggregateErrorSpace, aggregateErrorHeapCellType.get(), AggregateError)
    14241422DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiGlobalObjectSpace, apiGlobalObjectHeapCellType.get(), JSAPIGlobalObject)
    14251423DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiValueWrapperSpace, cellHeapCellType.get(), JSAPIValueWrapper)
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r262535 r263006  
    373373    std::unique_ptr<HeapCellType> cellHeapCellType;
    374374    std::unique_ptr<HeapCellType> destructibleCellHeapCellType;
    375     std::unique_ptr<IsoHeapCellType> aggregateErrorHeapCellType;
    376375    std::unique_ptr<IsoHeapCellType> apiGlobalObjectHeapCellType;
    377376    std::unique_ptr<IsoHeapCellType> callbackConstructorHeapCellType;
     
    499498    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(callbackAPIWrapperGlobalObjectSpace)
    500499#endif
    501     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(aggregateErrorSpace)
    502500    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiGlobalObjectSpace)
    503501    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiValueWrapperSpace)
Note: See TracChangeset for help on using the changeset viewer.