Diff
Modified: trunk/JSTests/ChangeLog (263005 => 263006)
--- trunk/JSTests/ChangeLog 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/JSTests/ChangeLog 2020-06-13 20:40:10 UTC (rev 263006)
@@ -1,3 +1,15 @@
+2020-06-13 Devin Rousso <[email protected]>
+
+ 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.
+
+ * 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.
+
2020-06-12 Robin Morisset <[email protected]>
The ||= operator (and similar ones) should produce valid bytecode even if the right side is a static error
Added: trunk/JSTests/stress/AggregateError-own-property-errors.js (0 => 263006)
--- trunk/JSTests/stress/AggregateError-own-property-errors.js (rev 0)
+++ trunk/JSTests/stress/AggregateError-own-property-errors.js 2020-06-13 20:40:10 UTC (rev 263006)
@@ -0,0 +1,17 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+let aggregateError = new AggregateError([0, 1, 2]);
+
+let descriptor = Object.getOwnPropertyDescriptor(aggregateError, "errors");
+shouldBe(descriptor.writable, true);
+shouldBe(descriptor.enumerable, false);
+shouldBe(descriptor.configurable, true);
+shouldBe(Array.isArray(descriptor.value), true);
+shouldBe(descriptor.value.length, 3);
+for (let i = 0; i < descriptor.value.length; ++i)
+ shouldBe(descriptor.value[i], i);
+
+shouldBe("errors" in AggregateError.prototype, false);
Modified: trunk/JSTests/test262/expectations.yaml (263005 => 263006)
--- trunk/JSTests/test262/expectations.yaml 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/JSTests/test262/expectations.yaml 2020-06-13 20:40:10 UTC (rev 263006)
@@ -921,6 +921,33 @@
test/built-ins/JSON/parse/reviver-object-non-configurable-prop-create.js:
default: 'Test262Error: Expected SameValue(«22», «2») to be true'
strict mode: 'Test262Error: Expected SameValue(«22», «2») to be true'
+test/built-ins/NativeErrors/AggregateError/prototype/errors/invoked-as-accessor.js:
+ default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
+ strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
+test/built-ins/NativeErrors/AggregateError/prototype/errors/invoked-as-func.js:
+ default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
+ strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
+test/built-ins/NativeErrors/AggregateError/prototype/errors/length.js:
+ default: "TypeError: undefined is not an object (evaluating 'desc.get')"
+ strict mode: "TypeError: undefined is not an object (evaluating 'desc.get')"
+test/built-ins/NativeErrors/AggregateError/prototype/errors/name.js:
+ default: "TypeError: undefined is not an object (evaluating 'desc.get')"
+ strict mode: "TypeError: undefined is not an object (evaluating 'desc.get')"
+test/built-ins/NativeErrors/AggregateError/prototype/errors/prop-desc.js:
+ default: "TypeError: undefined is not an object (evaluating 'desc.set')"
+ strict mode: "TypeError: undefined is not an object (evaluating 'desc.set')"
+test/built-ins/NativeErrors/AggregateError/prototype/errors/return-from-iterable-errors.js:
+ default: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«3,6», «3,6») to be false'
+ strict mode: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«3,6», «3,6») to be false'
+test/built-ins/NativeErrors/AggregateError/prototype/errors/return-new-array-from-list.js:
+ default: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«», «») to be false'
+ strict mode: 'Test262Error: creates a new array everytime it gets the values Expected SameValue(«», «») to be false'
+test/built-ins/NativeErrors/AggregateError/prototype/errors/this-has-no-typedarrayname-internal.js:
+ default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
+ strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
+test/built-ins/NativeErrors/AggregateError/prototype/errors/this-is-not-object.js:
+ default: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
+ strict mode: "TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor("
test/built-ins/Object/assign/strings-and-symbol-order-proxy.js:
default: 'Test262Error: Expected [foo, 0, Symbol()] and [Symbol(), foo, 0] to have the same contents. '
strict mode: 'Test262Error: Expected [foo, 0, Symbol()] and [Symbol(), foo, 0] to have the same contents. '
Modified: trunk/Source/_javascript_Core/ChangeLog (263005 => 263006)
--- trunk/Source/_javascript_Core/ChangeLog 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-06-13 20:40:10 UTC (rev 263006)
@@ -1,3 +1,37 @@
+2020-06-13 Devin Rousso <[email protected]>
+
+ 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.
+
+ * 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`.
+
2020-06-12 Robin Morisset <[email protected]>
The ||= operator (and similar ones) should produce valid bytecode even if the right side is a static error
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (263005 => 263006)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2020-06-13 20:40:10 UTC (rev 263006)
@@ -611,8 +611,6 @@
finalizeMarkedUnconditionalFinalizers<JSWeakObjectRef>(*vm().m_weakObjectRefSpace);
if (vm().m_errorInstanceSpace)
finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_errorInstanceSpace);
- if (vm().m_aggregateErrorSpace)
- finalizeMarkedUnconditionalFinalizers<ErrorInstance>(*vm().m_aggregateErrorSpace);
#if ENABLE(WEBASSEMBLY)
if (vm().m_webAssemblyCodeBlockSpace)
Modified: trunk/Source/_javascript_Core/runtime/AggregateError.cpp (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/AggregateError.cpp 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/AggregateError.cpp 2020-06-13 20:40:10 UTC (rev 263006)
@@ -35,21 +35,19 @@
const ClassInfo AggregateError::s_info = { "AggregateError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AggregateError) };
-AggregateError::AggregateError(VM& vm, Structure* structure, const MarkedArgumentBuffer& errors)
+AggregateError::AggregateError(VM& vm, Structure* structure)
: Base(vm, structure)
- , m_errors(errors.size())
{
- for (size_t i = 0; i < errors.size(); ++i)
- m_errors[i].setWithoutWriteBarrier(errors.at(i));
}
-void AggregateError::visitChildren(JSCell* cell, SlotVisitor& visitor)
+void AggregateError::finishCreation(VM& vm, JSGlobalObject* globalObject, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender, RuntimeType type, bool useCurrentFrame)
{
- auto* thisObject = jsCast<AggregateError*>(cell);
- ASSERT_GC_OBJECT_INHERITS(thisObject, info());
- Base::visitChildren(thisObject, visitor);
+ Base::finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
+ ASSERT(inherits(vm, info()));
- visitor.appendValues(thisObject->m_errors.data(), thisObject->m_errors.size());
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ putDirect(vm, vm.propertyNames->errors, constructArray(globalObject, static_cast<ArrayAllocationProfile*>(nullptr), errors), static_cast<unsigned>(PropertyAttribute::DontEnum));
+ RETURN_IF_EXCEPTION(scope, void());
}
AggregateError* AggregateError::create(JSGlobalObject* globalObject, VM& vm, Structure* structure, JSValue errors, JSValue message, SourceAppender appender, RuntimeType type, bool useCurrentFrame)
Modified: trunk/Source/_javascript_Core/runtime/AggregateError.h (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/AggregateError.h 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/AggregateError.h 2020-06-13 20:40:10 UTC (rev 263006)
@@ -30,12 +30,8 @@
#include "JSCJSValue.h"
#include "JSCell.h"
#include "JSGlobalObject.h"
-#include "SlotVisitor.h"
#include "Structure.h"
-#include "SubspaceAccess.h"
#include "VM.h"
-#include "WriteBarrier.h"
-#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace JSC {
@@ -46,17 +42,6 @@
static constexpr unsigned StructureFlags = Base::StructureFlags;
static constexpr bool needsDestruction = Base::needsDestruction;
- static void destroy(JSCell* cell)
- {
- static_cast<AggregateError*>(cell)->AggregateError::~AggregateError();
- }
-
- template<typename CellType, SubspaceAccess mode>
- static IsoSubspace* subspaceFor(VM& vm)
- {
- return vm.aggregateErrorSpace<mode>();
- }
-
DECLARE_EXPORT_INFO;
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
@@ -64,27 +49,21 @@
return Structure::create(vm, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), info());
}
- static void visitChildren(JSCell*, SlotVisitor&);
-
static AggregateError* create(JSGlobalObject* globalObject, VM& vm, Structure* structure, const MarkedArgumentBuffer& errors, const String& message, SourceAppender appender = nullptr, RuntimeType type = TypeNothing, bool useCurrentFrame = true)
{
- auto* instance = new (NotNull, allocateCell<AggregateError>(vm.heap)) AggregateError(vm, structure, errors);
- instance->finishCreation(vm, globalObject, message, appender, type, useCurrentFrame);
+ auto* instance = new (NotNull, allocateCell<AggregateError>(vm.heap)) AggregateError(vm, structure);
+ instance->finishCreation(vm, globalObject, errors, message, appender, type, useCurrentFrame);
return instance;
}
static AggregateError* create(JSGlobalObject*, VM&, Structure*, JSValue errors, JSValue message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
- const Vector<WriteBarrier<Unknown>>& errors() const
- {
- // This should never be modified after construction.
- return m_errors;
- }
+ void finishCreation(VM&, JSGlobalObject*, const MarkedArgumentBuffer& errors, const String& message, SourceAppender = nullptr, RuntimeType = TypeNothing, bool useCurrentFrame = true);
private:
- explicit AggregateError(VM&, Structure*, const MarkedArgumentBuffer& errors);
-
- Vector<WriteBarrier<Unknown>> m_errors;
+ explicit AggregateError(VM&, Structure*);
};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(AggregateError, AggregateError::Base);
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.cpp (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.cpp 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.cpp 2020-06-13 20:40:10 UTC (rev 263006)
@@ -33,41 +33,15 @@
namespace JSC {
-static EncodedJSValue JSC_HOST_CALL aggregateErrorPrototypeAccessorErrors(JSGlobalObject*, CallFrame*);
-
AggregateErrorPrototype::AggregateErrorPrototype(VM& vm, Structure* structure)
: Base(vm, structure)
{
}
-void AggregateErrorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
+void AggregateErrorPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm, errorTypeName(ErrorType::AggregateError));
ASSERT(inherits(vm, info()));
-
- JSC_NATIVE_GETTER_WITHOUT_TRANSITION("errors", aggregateErrorPrototypeAccessorErrors, PropertyAttribute::DontEnum | PropertyAttribute::Accessor);
}
-EncodedJSValue JSC_HOST_CALL aggregateErrorPrototypeAccessorErrors(JSGlobalObject* globalObject, CallFrame* callFrame)
-{
- VM& vm = globalObject->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- JSValue thisValue = callFrame->thisValue();
- auto* aggregateError = jsDynamicCast<AggregateError*>(vm, thisValue);
- if (!aggregateError)
- return throwVMTypeError(globalObject, scope, "The AggregateError.prototype.errors getter can only be called on a AggregateError object"_s);
-
- auto* result = constructEmptyArray(globalObject, nullptr);
- RETURN_IF_EXCEPTION(scope, { });
-
- unsigned index = 0;
- for (const auto& error : aggregateError->errors()) {
- result->putDirectIndex(globalObject, index++, error.get());
- RETURN_IF_EXCEPTION(scope, { });
- }
-
- return JSValue::encode(result);
-}
-
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.h (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.h 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/AggregateErrorPrototype.h 2020-06-13 20:40:10 UTC (rev 263006)
@@ -52,16 +52,16 @@
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
- static AggregateErrorPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
+ static AggregateErrorPrototype* create(VM& vm, Structure* structure)
{
AggregateErrorPrototype* prototype = new (NotNull, allocateCell<AggregateErrorPrototype>(vm.heap)) AggregateErrorPrototype(vm, structure);
- prototype->finishCreation(vm, globalObject);
+ prototype->finishCreation(vm);
return prototype;
}
private:
AggregateErrorPrototype(VM&, Structure*);
- void finishCreation(VM&, JSGlobalObject*);
+ void finishCreation(VM&);
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h 2020-06-13 20:40:10 UTC (rev 263006)
@@ -101,6 +101,7 @@
macro(dotAll) \
macro(enumerable) \
macro(era) \
+ macro(errors) \
macro(eval) \
macro(events) \
macro(exec) \
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2020-06-13 20:40:10 UTC (rev 263006)
@@ -539,7 +539,7 @@
void JSGlobalObject::initializeAggregateErrorConstructor(LazyClassStructure::Initializer& init)
{
- init.setPrototype(AggregateErrorPrototype::create(init.vm, this, AggregateErrorPrototype::createStructure(init.vm, this, m_errorStructure.prototype(this))));
+ init.setPrototype(AggregateErrorPrototype::create(init.vm, AggregateErrorPrototype::createStructure(init.vm, this, m_errorStructure.prototype(this))));
init.setStructure(AggregateError::createStructure(init.vm, this, init.prototype));
init.setConstructor(AggregateErrorConstructor::create(init.vm, AggregateErrorConstructor::createStructure(init.vm, this, m_errorStructure.constructor(this)), jsCast<AggregateErrorPrototype*>(init.prototype)));
}
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2020-06-13 20:40:10 UTC (rev 263006)
@@ -285,7 +285,6 @@
, immutableButterflyHeapCellType(makeUnique<HeapCellType>(CellAttributes(DoesNotNeedDestruction, HeapCell::JSCellWithInteriorPointers)))
, cellHeapCellType(makeUnique<HeapCellType>(CellAttributes(DoesNotNeedDestruction, HeapCell::JSCell)))
, destructibleCellHeapCellType(makeUnique<HeapCellType>(CellAttributes(NeedsDestruction, HeapCell::JSCell)))
- , aggregateErrorHeapCellType(IsoHeapCellType::create<AggregateError>())
, apiGlobalObjectHeapCellType(IsoHeapCellType::create<JSAPIGlobalObject>())
, callbackConstructorHeapCellType(IsoHeapCellType::create<JSCallbackConstructor>())
, callbackGlobalObjectHeapCellType(IsoHeapCellType::create<JSCallbackObject<JSGlobalObject>>())
@@ -1420,7 +1419,6 @@
}
-DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(aggregateErrorSpace, aggregateErrorHeapCellType.get(), AggregateError)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiGlobalObjectSpace, apiGlobalObjectHeapCellType.get(), JSAPIGlobalObject)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(apiValueWrapperSpace, cellHeapCellType.get(), JSAPIValueWrapper)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(arrayBufferSpace, cellHeapCellType.get(), JSArrayBuffer)
Modified: trunk/Source/_javascript_Core/runtime/VM.h (263005 => 263006)
--- trunk/Source/_javascript_Core/runtime/VM.h 2020-06-13 20:20:34 UTC (rev 263005)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2020-06-13 20:40:10 UTC (rev 263006)
@@ -372,7 +372,6 @@
std::unique_ptr<HeapCellType> immutableButterflyHeapCellType;
std::unique_ptr<HeapCellType> cellHeapCellType;
std::unique_ptr<HeapCellType> destructibleCellHeapCellType;
- std::unique_ptr<IsoHeapCellType> aggregateErrorHeapCellType;
std::unique_ptr<IsoHeapCellType> apiGlobalObjectHeapCellType;
std::unique_ptr<IsoHeapCellType> callbackConstructorHeapCellType;
std::unique_ptr<IsoHeapCellType> callbackGlobalObjectHeapCellType;
@@ -498,7 +497,6 @@
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(jscCallbackFunctionSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(callbackAPIWrapperGlobalObjectSpace)
#endif
- DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(aggregateErrorSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiGlobalObjectSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(apiValueWrapperSpace)
DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(arrayBufferSpace)