Changeset 182994 in webkit
- Timestamp:
- Apr 19, 2015 11:08:14 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r182986 r182994 1 2015-04-19 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [ES6] Implement WeakSet 4 https://bugs.webkit.org/show_bug.cgi?id=142408 5 6 Reviewed by Darin Adler. 7 8 Add basic-weakset test and fix WeakMap behavior to conform the latest spec. 9 10 * js/dom/basic-weakmap-expected.txt: 11 * js/dom/basic-weakset-expected.txt: Added. 12 * js/dom/basic-weakset.html: Added. 13 * js/dom/script-tests/basic-weakmap.js: 14 * js/dom/script-tests/basic-weakset.js: Added. 15 1 16 2015-04-18 Michał Pakuła vel Rutka <m.pakula@samsung.com> 2 17 -
trunk/LayoutTests/js/dom/basic-weakmap-expected.txt
r181333 r182994 15 15 PASS map.set(null, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap. 16 16 PASS map.set(undefined, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap. 17 PASS map.get(0) threw exception TypeError: A WeakMap cannot have a non-object key.18 PASS map.get(0.5) threw exception TypeError: A WeakMap cannot have a non-object key.19 PASS map.get('foo') threw exception TypeError: A WeakMap cannot have a non-object key.20 PASS map.get(true) threw exception TypeError: A WeakMap cannot have a non-object key.21 PASS map.get(false) threw exception TypeError: A WeakMap cannot have a non-object key.22 PASS map.get(null) threw exception TypeError: A WeakMap cannot have a non-object key.23 PASS map.get(undefined) threw exception TypeError: A WeakMap cannot have a non-object key.24 PASS map.has(0) threw exception TypeError: A WeakMap cannot have a non-object key.25 PASS map.has(0.5) threw exception TypeError: A WeakMap cannot have a non-object key.26 PASS map.has('foo') threw exception TypeError: A WeakMap cannot have a non-object key.27 PASS map.has(true) threw exception TypeError: A WeakMap cannot have a non-object key.28 PASS map.has(false) threw exception TypeError: A WeakMap cannot have a non-object key.29 PASS map.has(null) threw exception TypeError: A WeakMap cannot have a non-object key.30 PASS map.has(undefined) threw exception TypeError: A WeakMap cannot have a non-object key.31 PASS map.delete(0) threw exception TypeError: A WeakMap cannot have a non-object key.32 PASS map.delete(0.5) threw exception TypeError: A WeakMap cannot have a non-object key.33 PASS map.delete('foo') threw exception TypeError: A WeakMap cannot have a non-object key.34 PASS map.delete(true) threw exception TypeError: A WeakMap cannot have a non-object key.35 PASS map.delete(false) threw exception TypeError: A WeakMap cannot have a non-object key.36 PASS map.delete(null) threw exception TypeError: A WeakMap cannot have a non-object key.37 PASS map.delete(undefined) threw exception TypeError: A WeakMap cannot have a non-object key.17 PASS map.get(0) is undefined. 18 PASS map.get(0.5) is undefined. 19 PASS map.get('foo') is undefined. 20 PASS map.get(true) is undefined. 21 PASS map.get(false) is undefined. 22 PASS map.get(null) is undefined. 23 PASS map.get(undefined) is undefined. 24 PASS map.has(0) is false 25 PASS map.has(0.5) is false 26 PASS map.has('foo') is false 27 PASS map.has(true) is false 28 PASS map.has(false) is false 29 PASS map.has(null) is false 30 PASS map.has(undefined) is false 31 PASS map.delete(0) is false 32 PASS map.delete(0.5) is false 33 PASS map.delete('foo') is false 34 PASS map.delete(true) is false 35 PASS map.delete(false) is false 36 PASS map.delete(null) is false 37 PASS map.delete(undefined) is false 38 38 PASS map.set(new String('foo'), 'foo') is map 39 PASS map.get(new String('foo')) is undefined 39 PASS map.get(new String('foo')) is undefined. 40 40 PASS map.has(new String('foo')) is false 41 PASS map.set(object, 'foo') is map 42 PASS map.has(object) is true 43 PASS map.get(object) is 'foo' 44 PASS map.delete(object) is true 45 PASS map.has(object) is false 46 PASS map.delete(object) is false 47 PASS map.get(object) is undefined. 41 48 PASS successfullyParsed is true 42 49 -
trunk/LayoutTests/js/dom/script-tests/basic-weakmap.js
r167954 r182994 17 17 shouldThrow("map.set(null, 1)") 18 18 shouldThrow("map.set(undefined, 1)") 19 should Throw("map.get(0)")20 should Throw("map.get(0.5)")21 should Throw("map.get('foo')")22 should Throw("map.get(true)")23 should Throw("map.get(false)")24 should Throw("map.get(null)")25 should Throw("map.get(undefined)")26 should Throw("map.has(0)")27 should Throw("map.has(0.5)")28 should Throw("map.has('foo')")29 should Throw("map.has(true)")30 should Throw("map.has(false)")31 should Throw("map.has(null)")32 should Throw("map.has(undefined)")33 should Throw("map.delete(0)")34 should Throw("map.delete(0.5)")35 should Throw("map.delete('foo')")36 should Throw("map.delete(true)")37 should Throw("map.delete(false)")38 should Throw("map.delete(null)")39 should Throw("map.delete(undefined)")19 shouldBeUndefined("map.get(0)") 20 shouldBeUndefined("map.get(0.5)") 21 shouldBeUndefined("map.get('foo')") 22 shouldBeUndefined("map.get(true)") 23 shouldBeUndefined("map.get(false)") 24 shouldBeUndefined("map.get(null)") 25 shouldBeUndefined("map.get(undefined)") 26 shouldBeFalse("map.has(0)") 27 shouldBeFalse("map.has(0.5)") 28 shouldBeFalse("map.has('foo')") 29 shouldBeFalse("map.has(true)") 30 shouldBeFalse("map.has(false)") 31 shouldBeFalse("map.has(null)") 32 shouldBeFalse("map.has(undefined)") 33 shouldBeFalse("map.delete(0)") 34 shouldBeFalse("map.delete(0.5)") 35 shouldBeFalse("map.delete('foo')") 36 shouldBeFalse("map.delete(true)") 37 shouldBeFalse("map.delete(false)") 38 shouldBeFalse("map.delete(null)") 39 shouldBeFalse("map.delete(undefined)") 40 40 41 var object = new String('hello'); 41 42 shouldBe("map.set(new String('foo'), 'foo')", "map"); 42 shouldBe ("map.get(new String('foo'))", "undefined");43 shouldBeUndefined("map.get(new String('foo'))"); 43 44 shouldBeFalse("map.has(new String('foo'))"); 45 shouldBe("map.set(object, 'foo')", "map"); 46 shouldBeTrue("map.has(object)"); 47 shouldBe("map.get(object)", "'foo'"); 48 shouldBeTrue("map.delete(object)"); 49 shouldBeFalse("map.has(object)"); 50 shouldBeFalse("map.delete(object)"); 51 shouldBeUndefined("map.get(object)"); -
trunk/Source/JavaScriptCore/CMakeLists.txt
r182927 r182994 509 509 runtime/JSTypedArrays.cpp 510 510 runtime/JSWeakMap.cpp 511 runtime/JSWeakSet.cpp 511 512 runtime/JSWithScope.cpp 512 513 runtime/JSWrapperObject.cpp … … 586 587 runtime/WeakMapData.cpp 587 588 runtime/WeakMapPrototype.cpp 589 runtime/WeakSetConstructor.cpp 590 runtime/WeakSetPrototype.cpp 588 591 ) 589 592 -
trunk/Source/JavaScriptCore/ChangeLog
r182971 r182994 1 2015-04-19 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [ES6] Implement WeakSet 4 https://bugs.webkit.org/show_bug.cgi?id=142408 5 6 Reviewed by Darin Adler. 7 8 This patch implements ES6 WeakSet. 9 Current implementation simply leverages WeakMapData with undefined value. 10 This WeakMapData should be optimized in the same manner as MapData/SetData in the subsequent patch[1]. 11 12 And in this patch, we also fix WeakMap/WeakSet behavior to conform the ES6 spec. 13 Except for adders (WeakMap.prototype.set/WeakSet.prototype.add), 14 methods return false (or undefined for WeakMap.prototype.get) 15 when a key is not Object instead of throwing a type error. 16 17 [1]: https://bugs.webkit.org/show_bug.cgi?id=143919 18 19 * CMakeLists.txt: 20 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 21 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 22 * JavaScriptCore.xcodeproj/project.pbxproj: 23 * runtime/CommonIdentifiers.h: 24 * runtime/JSGlobalObject.cpp: 25 * runtime/JSGlobalObject.h: 26 * runtime/JSWeakSet.cpp: Added. 27 (JSC::JSWeakSet::finishCreation): 28 (JSC::JSWeakSet::visitChildren): 29 * runtime/JSWeakSet.h: Added. 30 (JSC::JSWeakSet::createStructure): 31 (JSC::JSWeakSet::create): 32 (JSC::JSWeakSet::weakMapData): 33 (JSC::JSWeakSet::JSWeakSet): 34 * runtime/WeakMapPrototype.cpp: 35 (JSC::getWeakMapData): 36 (JSC::protoFuncWeakMapDelete): 37 (JSC::protoFuncWeakMapGet): 38 (JSC::protoFuncWeakMapHas): 39 * runtime/WeakSetConstructor.cpp: Added. 40 (JSC::WeakSetConstructor::finishCreation): 41 (JSC::callWeakSet): 42 (JSC::constructWeakSet): 43 (JSC::WeakSetConstructor::getConstructData): 44 (JSC::WeakSetConstructor::getCallData): 45 * runtime/WeakSetConstructor.h: Added. 46 (JSC::WeakSetConstructor::create): 47 (JSC::WeakSetConstructor::createStructure): 48 (JSC::WeakSetConstructor::WeakSetConstructor): 49 * runtime/WeakSetPrototype.cpp: Added. 50 (JSC::WeakSetPrototype::finishCreation): 51 (JSC::getWeakMapData): 52 (JSC::protoFuncWeakSetDelete): 53 (JSC::protoFuncWeakSetHas): 54 (JSC::protoFuncWeakSetAdd): 55 * runtime/WeakSetPrototype.h: Added. 56 (JSC::WeakSetPrototype::create): 57 (JSC::WeakSetPrototype::createStructure): 58 (JSC::WeakSetPrototype::WeakSetPrototype): 59 * tests/stress/weak-set-constructor-adder.js: Added. 60 (WeakSet.prototype.add): 61 * tests/stress/weak-set-constructor.js: Added. 62 1 63 2015-04-17 Alexey Proskuryakov <ap@apple.com> 2 64 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r182927 r182994 773 773 <ClCompile Include="..\runtime\JSEnvironmentRecord.cpp" /> 774 774 <ClCompile Include="..\runtime\JSWeakMap.cpp" /> 775 <ClCompile Include="..\runtime\JSWeakSet.cpp" /> 775 776 <ClCompile Include="..\runtime\JSWithScope.cpp" /> 776 777 <ClCompile Include="..\runtime\JSWrapperObject.cpp" /> … … 850 851 <ClCompile Include="..\runtime\WeakMapData.cpp" /> 851 852 <ClCompile Include="..\runtime\WeakMapPrototype.cpp" /> 853 <ClCompile Include="..\runtime\WeakSetConstructor.cpp" /> 854 <ClCompile Include="..\runtime\WeakSetPrototype.cpp" /> 852 855 <ClCompile Include="..\tools\CodeProfile.cpp" /> 853 856 <ClCompile Include="..\tools\CodeProfiling.cpp" /> … … 1590 1593 <ClInclude Include="..\runtime\JSEnvironmentRecord.h" /> 1591 1594 <ClInclude Include="..\runtime\JSWeakMap.h" /> 1595 <ClInclude Include="..\runtime\JSWeakSet.h" /> 1592 1596 <ClInclude Include="..\runtime\JSWithScope.h" /> 1593 1597 <ClInclude Include="..\runtime\JSWrapperObject.h" /> … … 1695 1699 <ClInclude Include="..\runtime\WeakMapData.h" /> 1696 1700 <ClInclude Include="..\runtime\WeakMapPrototype.h" /> 1701 <ClInclude Include="..\runtime\WeakSetConstructor.h" /> 1702 <ClInclude Include="..\runtime\WeakSetPrototype.h" /> 1697 1703 <ClInclude Include="..\runtime\WeakRandom.h" /> 1698 1704 <ClInclude Include="..\runtime\WriteBarrier.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r182927 r182994 718 718 <Filter>runtime</Filter> 719 719 </ClCompile> 720 <ClCompile Include="..\runtime\JSWeakSet.cpp"> 721 <Filter>runtime</Filter> 722 </ClCompile> 720 723 <ClCompile Include="..\runtime\JSWrapperObject.cpp"> 721 724 <Filter>runtime</Filter> … … 1025 1028 </ClCompile> 1026 1029 <ClCompile Include="..\runtime\WeakMapPrototype.cpp"> 1030 <Filter>runtime</Filter> 1031 </ClCompile> 1032 <ClCompile Include="..\runtime\WeakSetConstructor.cpp"> 1033 <Filter>runtime</Filter> 1034 </ClCompile> 1035 <ClCompile Include="..\runtime\WeakSetPrototype.cpp"> 1027 1036 <Filter>runtime</Filter> 1028 1037 </ClCompile> … … 3754 3763 <Filter>runtime</Filter> 3755 3764 </ClInclude> 3765 <ClInclude Include="..\runtime\WeakSetConstructor.h"> 3766 <Filter>runtime</Filter> 3767 </ClInclude> 3768 <ClInclude Include="..\runtime\WeakSetPrototype.h"> 3769 <Filter>runtime</Filter> 3770 </ClInclude> 3756 3771 <ClInclude Include="..\runtime\JSWeakMap.h"> 3772 <Filter>runtime</Filter> 3773 </ClInclude> 3774 <ClInclude Include="..\runtime\JSWeakSet.h"> 3757 3775 <Filter>runtime</Filter> 3758 3776 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r182927 r182994 986 986 705B41B11A6E501E00716757 /* SymbolPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 705B41A91A6E501E00716757 /* SymbolPrototype.cpp */; }; 987 987 705B41B21A6E501E00716757 /* SymbolPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 705B41AA1A6E501E00716757 /* SymbolPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; }; 988 709FB8671AE335C60039D069 /* JSWeakSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 709FB8611AE335C60039D069 /* JSWeakSet.cpp */; }; 989 709FB8681AE335C60039D069 /* JSWeakSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 709FB8621AE335C60039D069 /* JSWeakSet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 990 709FB8691AE335C60039D069 /* WeakSetConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 709FB8631AE335C60039D069 /* WeakSetConstructor.cpp */; }; 991 709FB86A1AE335C60039D069 /* WeakSetConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 709FB8641AE335C60039D069 /* WeakSetConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 992 709FB86B1AE335C60039D069 /* WeakSetPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 709FB8651AE335C60039D069 /* WeakSetPrototype.cpp */; }; 993 709FB86C1AE335C60039D069 /* WeakSetPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 709FB8661AE335C60039D069 /* WeakSetPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; }; 988 994 70B0A9D11A9B66460001306A /* RuntimeFlags.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B0A9D01A9B66200001306A /* RuntimeFlags.h */; settings = {ATTRIBUTES = (Private, ); }; }; 989 995 70EC0EC21AA0D7DA00B6AAFA /* JSStringIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 70EC0EBC1AA0D7DA00B6AAFA /* JSStringIterator.cpp */; }; … … 2706 2712 705B41A91A6E501E00716757 /* SymbolPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolPrototype.cpp; sourceTree = "<group>"; }; 2707 2713 705B41AA1A6E501E00716757 /* SymbolPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolPrototype.h; sourceTree = "<group>"; }; 2714 709FB8611AE335C60039D069 /* JSWeakSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWeakSet.cpp; sourceTree = "<group>"; }; 2715 709FB8621AE335C60039D069 /* JSWeakSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWeakSet.h; sourceTree = "<group>"; }; 2716 709FB8631AE335C60039D069 /* WeakSetConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakSetConstructor.cpp; sourceTree = "<group>"; }; 2717 709FB8641AE335C60039D069 /* WeakSetConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakSetConstructor.h; sourceTree = "<group>"; }; 2718 709FB8651AE335C60039D069 /* WeakSetPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakSetPrototype.cpp; sourceTree = "<group>"; }; 2719 709FB8661AE335C60039D069 /* WeakSetPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakSetPrototype.h; sourceTree = "<group>"; }; 2708 2720 70B0A9D01A9B66200001306A /* RuntimeFlags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeFlags.h; sourceTree = "<group>"; }; 2709 2721 70EC0EBC1AA0D7DA00B6AAFA /* JSStringIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringIterator.cpp; sourceTree = "<group>"; }; … … 4551 4563 A7CA3AE117DA41AE006538AF /* JSWeakMap.cpp */, 4552 4564 A7CA3AE217DA41AE006538AF /* JSWeakMap.h */, 4565 709FB8611AE335C60039D069 /* JSWeakSet.cpp */, 4566 709FB8621AE335C60039D069 /* JSWeakSet.h */, 4553 4567 1442565F15EDE98D0066A49B /* JSWithScope.cpp */, 4554 4568 1442566015EDE98D0066A49B /* JSWithScope.h */, … … 4740 4754 A7CA3AE017DA41AE006538AF /* WeakMapPrototype.h */, 4741 4755 1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */, 4756 709FB8631AE335C60039D069 /* WeakSetConstructor.cpp */, 4757 709FB8641AE335C60039D069 /* WeakSetConstructor.h */, 4758 709FB8651AE335C60039D069 /* WeakSetPrototype.cpp */, 4759 709FB8661AE335C60039D069 /* WeakSetPrototype.h */, 4742 4760 A7DCB77912E3D90500911940 /* WriteBarrier.h */, 4743 4761 C2B6D75218A33793004A9301 /* WriteBarrierInlines.h */, … … 5661 5679 0F0B83A714BCF50700885B4F /* CodeType.h in Headers */, 5662 5680 BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */, 5681 709FB86C1AE335C60039D069 /* WeakSetPrototype.h in Headers */, 5663 5682 0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */, 5664 5683 6553A33217A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h in Headers */, … … 5781 5800 A7D89CFC17A0B8CC00773AD8 /* DFGLivenessAnalysisPhase.h in Headers */, 5782 5801 0FF0F19B16B729FA005DF95B /* DFGLongLivedState.h in Headers */, 5802 709FB8681AE335C60039D069 /* JSWeakSet.h in Headers */, 5783 5803 A767B5B617A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h in Headers */, 5784 5804 0F2B9CED19D0BA7D00B1D1B5 /* DFGPromotedHeapLocation.h in Headers */, … … 6113 6133 14874AE415EBDE4A002E3587 /* JSNameScope.h in Headers */, 6114 6134 BC18C4240E16F5CD00B34460 /* JSObject.h in Headers */, 6135 709FB86A1AE335C60039D069 /* WeakSetConstructor.h in Headers */, 6115 6136 BC18C4250E16F5CD00B34460 /* JSObjectRef.h in Headers */, 6116 6137 A7280A2811557E3000D56957 /* JSObjectRefPrivate.h in Headers */, … … 7109 7130 0FC097A1146B28CA00CF2442 /* DFGThunks.cpp in Sources */, 7110 7131 0F93B4A918B92C4D00178A3F /* PutByIdVariant.cpp in Sources */, 7132 709FB8671AE335C60039D069 /* JSWeakSet.cpp in Sources */, 7111 7133 0FD8A32717D51F5700CA2C40 /* DFGTierUpCheckInjectionPhase.cpp in Sources */, 7112 7134 0FD8A32917D51F5700CA2C40 /* DFGToFTLDeferredCompilationCallback.cpp in Sources */, … … 7229 7251 A57D23E51890CEBF0031C7FA /* InspectorDebuggerAgent.cpp in Sources */, 7230 7252 A532438718568335002ED692 /* InspectorBackendDispatchers.cpp in Sources */, 7253 709FB8691AE335C60039D069 /* WeakSetConstructor.cpp in Sources */, 7231 7254 A532438918568335002ED692 /* InspectorFrontendDispatchers.cpp in Sources */, 7232 7255 A532438B18568335002ED692 /* InspectorProtocolObjects.cpp in Sources */, … … 7321 7344 7C008CD2186F8A9300955C24 /* JSPromiseFunctions.cpp in Sources */, 7322 7345 7C184E1E17BEE22E007CB63A /* JSPromisePrototype.cpp in Sources */, 7346 709FB86B1AE335C60039D069 /* WeakSetPrototype.cpp in Sources */, 7323 7347 7C008CDE1871258D00955C24 /* JSPromiseReaction.cpp in Sources */, 7324 7348 862553D116136DA9009F17D0 /* JSProxy.cpp in Sources */, -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r182938 r182994 58 58 macro(UTC) \ 59 59 macro(WeakMap)\ 60 macro(WeakSet)\ 60 61 macro(__defineGetter__) \ 61 62 macro(__defineSetter__) \ -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r182938 r182994 88 88 #include "JSTypedArrays.h" 89 89 #include "JSWeakMap.h" 90 #include "JSWeakSet.h" 90 91 #include "JSWithScope.h" 91 92 #include "LegacyProfiler.h" … … 128 129 #include "WeakMapConstructor.h" 129 130 #include "WeakMapPrototype.h" 131 #include "WeakSetConstructor.h" 132 #include "WeakSetPrototype.h" 130 133 131 134 #if ENABLE(PROMISES) -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r182938 r182994 103 103 macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \ 104 104 DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \ 105 DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \ 105 106 106 107 #define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \ -
trunk/Source/JavaScriptCore/runtime/WeakMapPrototype.cpp
r173410 r182994 59 59 if (!value.isObject()) { 60 60 throwTypeError(callFrame, WTF::ASCIILiteral("Called WeakMap function on non-object")); 61 return 0;61 return nullptr; 62 62 } 63 63 … … 66 66 67 67 throwTypeError(callFrame, WTF::ASCIILiteral("Called WeakMap function on a non-WeakMap object")); 68 return 0;68 return nullptr; 69 69 } 70 70 … … 84 84 return JSValue::encode(jsUndefined()); 85 85 JSValue key = callFrame->argument(0); 86 if (!key.isObject()) 87 return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("A WeakMap cannot have a non-object key"))); 88 return JSValue::encode(jsBoolean(map->remove(asObject(key)))); 86 return JSValue::encode(jsBoolean(key.isObject() && map->remove(asObject(key)))); 89 87 } 90 88 … … 96 94 JSValue key = callFrame->argument(0); 97 95 if (!key.isObject()) 98 return JSValue::encode( throwTypeError(callFrame, WTF::ASCIILiteral("A WeakMap cannot have a non-object key")));96 return JSValue::encode(jsUndefined()); 99 97 return JSValue::encode(map->get(asObject(key))); 100 98 } … … 106 104 return JSValue::encode(jsUndefined()); 107 105 JSValue key = callFrame->argument(0); 108 if (!key.isObject()) 109 return JSValue::encode(throwTypeError(callFrame, WTF::ASCIILiteral("A WeakMap cannot have a non-object key"))); 110 return JSValue::encode(jsBoolean(map->contains(asObject(key)))); 106 return JSValue::encode(jsBoolean(key.isObject() && map->contains(asObject(key)))); 111 107 } 112 108
Note: See TracChangeset
for help on using the changeset viewer.