Changeset 263006 in webkit
- Timestamp:
- Jun 13, 2020 1:40:10 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r262995 r263006 1 2020-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 1 13 2020-06-12 Robin Morisset <rmorisset@apple.com> 2 14 -
trunk/JSTests/test262/expectations.yaml
r262979 r263006 922 922 default: 'Test262Error: Expected SameValue(«22», «2») to be true' 923 923 strict mode: 'Test262Error: Expected SameValue(«22», «2») to be true' 924 test/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' 927 test/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(" 930 test/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')" 933 test/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')" 936 test/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')" 939 test/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' 942 test/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' 945 test/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(" 948 test/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(" 924 951 test/built-ins/Object/assign/strings-and-symbol-order-proxy.js: 925 952 default: 'Test262Error: Expected [foo, 0, Symbol()] and [Symbol(), foo, 0] to have the same contents. ' -
trunk/Source/JavaScriptCore/ChangeLog
r262995 r263006 1 2020-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 1 35 2020-06-12 Robin Morisset <rmorisset@apple.com> 2 36 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r262928 r263006 612 612 if (vm().m_errorInstanceSpace) 613 613 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_errorInstanceSpace); 614 if (vm().m_aggregateErrorSpace)615 finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_aggregateErrorSpace);616 614 617 615 #if ENABLE(WEBASSEMBLY) -
trunk/Source/JavaScriptCore/runtime/AggregateError.cpp
r261755 r263006 36 36 const ClassInfo AggregateError::s_info = { "AggregateError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AggregateError) }; 37 37 38 AggregateError::AggregateError(VM& vm, Structure* structure , const MarkedArgumentBuffer& errors)38 AggregateError::AggregateError(VM& vm, Structure* structure) 39 39 : Base(vm, structure) 40 , m_errors(errors.size())41 40 { 42 for (size_t i = 0; i < errors.size(); ++i)43 m_errors[i].setWithoutWriteBarrier(errors.at(i));44 41 } 45 42 46 void AggregateError:: visitChildren(JSCell* cell, SlotVisitor& visitor)43 void AggregateError::finishCreation(VM& vm, JSGlobalObject* globalObject, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender, RuntimeType type, bool useCurrentFrame) 47 44 { 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())); 51 47 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()); 53 51 } 54 52 -
trunk/Source/JavaScriptCore/runtime/AggregateError.h
r260415 r263006 31 31 #include "JSCell.h" 32 32 #include "JSGlobalObject.h" 33 #include "SlotVisitor.h"34 33 #include "Structure.h" 35 #include "SubspaceAccess.h"36 34 #include "VM.h" 37 #include "WriteBarrier.h"38 #include <wtf/Vector.h>39 35 #include <wtf/text/WTFString.h> 40 36 … … 47 43 static constexpr bool needsDestruction = Base::needsDestruction; 48 44 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 60 45 DECLARE_EXPORT_INFO; 61 46 … … 65 50 } 66 51 67 static void visitChildren(JSCell*, SlotVisitor&);68 69 52 static AggregateError* create(JSGlobalObject* globalObject, VM& vm, Structure* structure, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, bool useCurrentFrame = true) 70 53 { 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); 73 56 return instance; 74 57 } … … 76 59 static AggregateError* create(JSGlobalObject*, VM&, Structure*, JSValue errors, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true); 77 60 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); 83 62 84 63 private: 85 explicit AggregateError(VM&, Structure*, const MarkedArgumentBuffer& errors); 86 87 Vector<WriteBarrier<Unknown>> m_errors; 64 explicit AggregateError(VM&, Structure*); 88 65 }; 89 66 67 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(AggregateError, AggregateError::Base); 68 90 69 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/AggregateErrorPrototype.cpp
r261895 r263006 34 34 namespace JSC { 35 35 36 static EncodedJSValue JSC_HOST_CALL aggregateErrorPrototypeAccessorErrors(JSGlobalObject*, CallFrame*);37 38 36 AggregateErrorPrototype::AggregateErrorPrototype(VM& vm, Structure* structure) 39 37 : Base(vm, structure) … … 41 39 } 42 40 43 void AggregateErrorPrototype::finishCreation(VM& vm , JSGlobalObject* globalObject)41 void AggregateErrorPrototype::finishCreation(VM& vm) 44 42 { 45 43 Base::finishCreation(vm, errorTypeName(ErrorType::AggregateError)); 46 44 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);71 45 } 72 46 -
trunk/Source/JavaScriptCore/runtime/AggregateErrorPrototype.h
r260415 r263006 53 53 } 54 54 55 static AggregateErrorPrototype* create(VM& vm, JSGlobalObject* globalObject,Structure* structure)55 static AggregateErrorPrototype* create(VM& vm, Structure* structure) 56 56 { 57 57 AggregateErrorPrototype* prototype = new (NotNull, allocateCell<AggregateErrorPrototype>(vm.heap)) AggregateErrorPrototype(vm, structure); 58 prototype->finishCreation(vm , globalObject);58 prototype->finishCreation(vm); 59 59 return prototype; 60 60 } … … 62 62 private: 63 63 AggregateErrorPrototype(VM&, Structure*); 64 void finishCreation(VM& , JSGlobalObject*);64 void finishCreation(VM&); 65 65 }; 66 66 -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r262613 r263006 102 102 macro(enumerable) \ 103 103 macro(era) \ 104 macro(errors) \ 104 105 macro(eval) \ 105 106 macro(events) \ -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r262613 r263006 540 540 void JSGlobalObject::initializeAggregateErrorConstructor(LazyClassStructure::Initializer& init) 541 541 { 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)))); 543 543 init.setStructure(AggregateError::createStructure(init.vm, this, init.prototype)); 544 544 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 286 286 , cellHeapCellType(makeUnique<HeapCellType>(CellAttributes(DoesNotNeedDestruction, HeapCell::JSCell))) 287 287 , destructibleCellHeapCellType(makeUnique<HeapCellType>(CellAttributes(NeedsDestruction, HeapCell::JSCell))) 288 , aggregateErrorHeapCellType(IsoHeapCellType::create<AggregateError>())289 288 , apiGlobalObjectHeapCellType(IsoHeapCellType::create<JSAPIGlobalObject>()) 290 289 , callbackConstructorHeapCellType(IsoHeapCellType::create<JSCallbackConstructor>()) … … 1421 1420 1422 1421 1423 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(aggregateErrorSpace, aggregateErrorHeapCellType.get(), AggregateError)1424 1422 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiGlobalObjectSpace, apiGlobalObjectHeapCellType.get(), JSAPIGlobalObject) 1425 1423 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiValueWrapperSpace, cellHeapCellType.get(), JSAPIValueWrapper) -
trunk/Source/JavaScriptCore/runtime/VM.h
r262535 r263006 373 373 std::unique_ptr<HeapCellType> cellHeapCellType; 374 374 std::unique_ptr<HeapCellType> destructibleCellHeapCellType; 375 std::unique_ptr<IsoHeapCellType> aggregateErrorHeapCellType;376 375 std::unique_ptr<IsoHeapCellType> apiGlobalObjectHeapCellType; 377 376 std::unique_ptr<IsoHeapCellType> callbackConstructorHeapCellType; … … 499 498 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(callbackAPIWrapperGlobalObjectSpace) 500 499 #endif 501 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(aggregateErrorSpace)502 500 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiGlobalObjectSpace) 503 501 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiValueWrapperSpace)
Note: See TracChangeset
for help on using the changeset viewer.