haikuwebkit/LayoutTests/js/dom/basic-weakset-expected.txt

47 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

[ES6] Implement WeakSet https://bugs.webkit.org/show_bug.cgi?id=142408 Reviewed by Darin Adler. Source/JavaScriptCore: This patch implements ES6 WeakSet. Current implementation simply leverages WeakMapData with undefined value. This WeakMapData should be optimized in the same manner as MapData/SetData in the subsequent patch[1]. And in this patch, we also fix WeakMap/WeakSet behavior to conform the ES6 spec. Except for adders (WeakMap.prototype.set/WeakSet.prototype.add), methods return false (or undefined for WeakMap.prototype.get) when a key is not Object instead of throwing a type error. [1]: https://bugs.webkit.org/show_bug.cgi?id=143919 * CMakeLists.txt: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/CommonIdentifiers.h: * runtime/JSGlobalObject.cpp: * runtime/JSGlobalObject.h: * runtime/JSWeakSet.cpp: Added. (JSC::JSWeakSet::finishCreation): (JSC::JSWeakSet::visitChildren): * runtime/JSWeakSet.h: Added. (JSC::JSWeakSet::createStructure): (JSC::JSWeakSet::create): (JSC::JSWeakSet::weakMapData): (JSC::JSWeakSet::JSWeakSet): * runtime/WeakMapPrototype.cpp: (JSC::getWeakMapData): (JSC::protoFuncWeakMapDelete): (JSC::protoFuncWeakMapGet): (JSC::protoFuncWeakMapHas): * runtime/WeakSetConstructor.cpp: Added. (JSC::WeakSetConstructor::finishCreation): (JSC::callWeakSet): (JSC::constructWeakSet): (JSC::WeakSetConstructor::getConstructData): (JSC::WeakSetConstructor::getCallData): * runtime/WeakSetConstructor.h: Added. (JSC::WeakSetConstructor::create): (JSC::WeakSetConstructor::createStructure): (JSC::WeakSetConstructor::WeakSetConstructor): * runtime/WeakSetPrototype.cpp: Added. (JSC::WeakSetPrototype::finishCreation): (JSC::getWeakMapData): (JSC::protoFuncWeakSetDelete): (JSC::protoFuncWeakSetHas): (JSC::protoFuncWeakSetAdd): * runtime/WeakSetPrototype.h: Added. (JSC::WeakSetPrototype::create): (JSC::WeakSetPrototype::createStructure): (JSC::WeakSetPrototype::WeakSetPrototype): * tests/stress/weak-set-constructor-adder.js: Added. (WeakSet.prototype.add): * tests/stress/weak-set-constructor.js: Added. LayoutTests: Add basic-weakset test and fix WeakMap behavior to conform the latest spec. * js/dom/basic-weakmap-expected.txt: * js/dom/basic-weakset-expected.txt: Added. * js/dom/basic-weakset.html: Added. * js/dom/script-tests/basic-weakmap.js: * js/dom/script-tests/basic-weakset.js: Added. Canonical link: https://commits.webkit.org/161919@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182994 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-19 18:08:14 +00:00
Tests basic correctness of ES WeakSet object
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS WeakSet instanceof WeakSet is false
PASS WeakSet.prototype instanceof WeakSet is false
PASS new WeakSet() instanceof WeakSet is true
Debug assertion failure while loading http://kangax.github.io/compat-table/es6/. https://bugs.webkit.org/show_bug.cgi?id=154542 Reviewed by Saam Barati. Source/JavaScriptCore: According to the spec, the constructors of the following types "are not intended to be called as a function and will throw an exception". These types are: TypedArrays - https://tc39.github.io/ecma262/#sec-typedarray-constructors Map - https://tc39.github.io/ecma262/#sec-map-constructor Set - https://tc39.github.io/ecma262/#sec-set-constructor WeakMap - https://tc39.github.io/ecma262/#sec-weakmap-constructor WeakSet - https://tc39.github.io/ecma262/#sec-weakset-constructor ArrayBuffer - https://tc39.github.io/ecma262/#sec-arraybuffer-constructor DataView - https://tc39.github.io/ecma262/#sec-dataview-constructor Promise - https://tc39.github.io/ecma262/#sec-promise-constructor Proxy - https://tc39.github.io/ecma262/#sec-proxy-constructor This patch does the foillowing: 1. Ensures that these constructors can be called but will throw a TypeError when called. 2. Makes all these objects use throwConstructorCannotBeCalledAsFunctionTypeError() in their implementation to be consistent. 3. Change the error message to "calling XXX constructor without new is invalid". This is clearer because the error is likely due to the user forgetting to use the new operator on these constructors. * runtime/Error.h: * runtime/Error.cpp: (JSC::throwConstructorCannotBeCalledAsFunctionTypeError): - Added a convenience function to throw the TypeError. * runtime/JSArrayBufferConstructor.cpp: (JSC::constructArrayBuffer): (JSC::callArrayBuffer): (JSC::JSArrayBufferConstructor::getCallData): * runtime/JSGenericTypedArrayViewConstructorInlines.h: (JSC::callGenericTypedArrayView): (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::getCallData): * runtime/JSPromiseConstructor.cpp: (JSC::callPromise): * runtime/MapConstructor.cpp: (JSC::callMap): * runtime/ProxyConstructor.cpp: (JSC::callProxy): (JSC::ProxyConstructor::getCallData): * runtime/SetConstructor.cpp: (JSC::callSet): * runtime/WeakMapConstructor.cpp: (JSC::callWeakMap): * runtime/WeakSetConstructor.cpp: (JSC::callWeakSet): * tests/es6.yaml: - The typed_arrays_%TypedArray%[Symbol.species].js test now passes. * tests/stress/call-non-calleable-constructors-as-function.js: Added. (test): * tests/stress/map-constructor.js: (testCallTypeError): * tests/stress/promise-cannot-be-called.js: (shouldThrow): * tests/stress/proxy-basic.js: * tests/stress/set-constructor.js: * tests/stress/throw-from-ftl-call-ic-slow-path-cells.js: (i.catch): * tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js: (i.catch): * tests/stress/throw-from-ftl-call-ic-slow-path.js: (i.catch): * tests/stress/weak-map-constructor.js: (testCallTypeError): * tests/stress/weak-set-constructor.js: - Updated error message string. LayoutTests: * js/Promise-types-expected.txt: * js/basic-map-expected.txt: * js/basic-set-expected.txt: * js/dom/basic-weakmap-expected.txt: * js/dom/basic-weakset-expected.txt: * js/script-tests/Promise-types.js: * js/typedarray-constructors-expected.txt: - Updated error message string. Canonical link: https://commits.webkit.org/172692@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196986 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-23 19:41:56 +00:00
PASS WeakSet() threw exception TypeError: calling WeakSet constructor without new is invalid.
Optimize constructors of ES6 collections https://bugs.webkit.org/show_bug.cgi?id=223953 Reviewed by Yusuke Suzuki. JSTests: * microbenchmarks/map-constructor.js: * microbenchmarks/set-constructor.js: Added. * microbenchmarks/weak-map-constructor.js: Added. * microbenchmarks/weak-set-constructor.js: Added. * stress/map-constructor-adder.js: * stress/set-constructor-adder.js: * stress/weak-map-constructor-adder-error-cross-realm.js: Added. * stress/weak-map-constructor-adder.js: * stress/weak-set-constructor-adder-error-cross-realm.js: Added. * stress/weak-set-constructor-adder.js: * stress/weak-set-constructor.js: Source/JavaScriptCore: This patch speeds up the constructors by avoiding call() for non-observable "set" / "add" methods and using getIndex() for Map / WeakMap collections. For Map / Set, this change leverages existing cloning helpers, which rely on watchpoints, to avoid even a method lookup. However, slower path is used for subclasses. Results in 1.9x speed-up for common case. For WeakMap / WeakSet, adder function is checked by C++ pointer, which enables fast path even for cross-realm subclasses. Results in 2.3x progression. Both approaches require special handling of a cross-realm NewTarget to ensure that raised exceptions (OOM / TypeError) belong to realm of the adder function, and not to constructor's or NewTarget's. Also, adds descriptve error messages for non-callable "set" / "add" properties. * runtime/JSMap.cpp: (JSC::JSMap::isSetFastAndNonObservable): (JSC::JSMap::canCloneFastAndNonObservable): Deleted. * runtime/JSMap.h: * runtime/JSSet.cpp: (JSC::JSSet::isAddFastAndNonObservable): (JSC::JSSet::canCloneFastAndNonObservable): Deleted. * runtime/JSSet.h: * runtime/MapConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/SetConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/WeakMapConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/WeakMapPrototype.cpp: (JSC::WeakMapPrototype::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/WeakMapPrototype.h: * runtime/WeakSetConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/WeakSetPrototype.cpp: (JSC::WeakSetPrototype::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/WeakSetPrototype.h: LayoutTests: * js/dom/basic-weakset-expected.txt: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275271 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235956@main
2021-03-31 07:21:37 +00:00
PASS set.add(0) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(0.5) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add('foo') threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(true) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(false) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(null) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(undefined) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
PASS set.add(Symbol.iterator) threw exception TypeError: Attempted to add a non-object value to a WeakSet.
[ES6] Implement WeakSet https://bugs.webkit.org/show_bug.cgi?id=142408 Reviewed by Darin Adler. Source/JavaScriptCore: This patch implements ES6 WeakSet. Current implementation simply leverages WeakMapData with undefined value. This WeakMapData should be optimized in the same manner as MapData/SetData in the subsequent patch[1]. And in this patch, we also fix WeakMap/WeakSet behavior to conform the ES6 spec. Except for adders (WeakMap.prototype.set/WeakSet.prototype.add), methods return false (or undefined for WeakMap.prototype.get) when a key is not Object instead of throwing a type error. [1]: https://bugs.webkit.org/show_bug.cgi?id=143919 * CMakeLists.txt: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/CommonIdentifiers.h: * runtime/JSGlobalObject.cpp: * runtime/JSGlobalObject.h: * runtime/JSWeakSet.cpp: Added. (JSC::JSWeakSet::finishCreation): (JSC::JSWeakSet::visitChildren): * runtime/JSWeakSet.h: Added. (JSC::JSWeakSet::createStructure): (JSC::JSWeakSet::create): (JSC::JSWeakSet::weakMapData): (JSC::JSWeakSet::JSWeakSet): * runtime/WeakMapPrototype.cpp: (JSC::getWeakMapData): (JSC::protoFuncWeakMapDelete): (JSC::protoFuncWeakMapGet): (JSC::protoFuncWeakMapHas): * runtime/WeakSetConstructor.cpp: Added. (JSC::WeakSetConstructor::finishCreation): (JSC::callWeakSet): (JSC::constructWeakSet): (JSC::WeakSetConstructor::getConstructData): (JSC::WeakSetConstructor::getCallData): * runtime/WeakSetConstructor.h: Added. (JSC::WeakSetConstructor::create): (JSC::WeakSetConstructor::createStructure): (JSC::WeakSetConstructor::WeakSetConstructor): * runtime/WeakSetPrototype.cpp: Added. (JSC::WeakSetPrototype::finishCreation): (JSC::getWeakMapData): (JSC::protoFuncWeakSetDelete): (JSC::protoFuncWeakSetHas): (JSC::protoFuncWeakSetAdd): * runtime/WeakSetPrototype.h: Added. (JSC::WeakSetPrototype::create): (JSC::WeakSetPrototype::createStructure): (JSC::WeakSetPrototype::WeakSetPrototype): * tests/stress/weak-set-constructor-adder.js: Added. (WeakSet.prototype.add): * tests/stress/weak-set-constructor.js: Added. LayoutTests: Add basic-weakset test and fix WeakMap behavior to conform the latest spec. * js/dom/basic-weakmap-expected.txt: * js/dom/basic-weakset-expected.txt: Added. * js/dom/basic-weakset.html: Added. * js/dom/script-tests/basic-weakmap.js: * js/dom/script-tests/basic-weakset.js: Added. Canonical link: https://commits.webkit.org/161919@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182994 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-19 18:08:14 +00:00
PASS set.has(0) is false
PASS set.has(0.5) is false
PASS set.has('foo') is false
PASS set.has(true) is false
PASS set.has(false) is false
PASS set.has(null) is false
PASS set.has(undefined) is false
PASS set.has(Symbol.iterator) is false
PASS set.delete(0) is false
PASS set.delete(0.5) is false
PASS set.delete('foo') is false
PASS set.delete(true) is false
PASS set.delete(false) is false
PASS set.delete(null) is false
PASS set.delete(undefined) is false
PASS set.delete(Symbol.iterator) is false
PASS set.add(new String('foo')) is set
PASS set.add(new String('foo')) is set
PASS set.has(new String('foo')) is false
PASS set.add(object) is set
PASS set.has(object) is true
PASS set.delete(new String('foo')) is false
PASS set.delete(object) is true
PASS set.has(object) is false
PASS set.delete(object) is false
PASS successfullyParsed is true
TEST COMPLETE