Changeset 244806 in webkit
- Timestamp:
- Apr 30, 2019 3:25:09 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244760 r244806 1 2019-04-30 Tadeu Zagallo <tzagallo@apple.com> 2 3 TypeArrays should not store properties that are canonical numeric indices 4 https://bugs.webkit.org/show_bug.cgi?id=197228 5 <rdar://problem/49557381> 6 7 Reviewed by Darin Adler. 8 9 * stress/typed-array-canonical-numeric-index-string.js: Added. 10 (makeTest.assert): 11 (makeTest): 12 (const.testInvalidIndices.makeTest.set assert): 13 (const.testInvalidIndices.makeTest): 14 (const.testValidIndices.makeTest.set assert): 15 (const.testValidIndices.makeTest): 16 1 17 2019-04-29 Yusuke Suzuki <ysuzuki@apple.com> 2 18 -
trunk/LayoutTests/ChangeLog
r244800 r244806 1 2019-04-30 Tadeu Zagallo <tzagallo@apple.com> 2 3 TypeArrays should not store properties that are canonical numeric indices 4 https://bugs.webkit.org/show_bug.cgi?id=197228 5 <rdar://problem/49557381> 6 7 Reviewed by Darin Adler. 8 9 * fast/canvas/canvas-ImageData-behaviour-expected.txt: 10 * fast/canvas/canvas-ImageData-behaviour.js: 11 1 12 2019-04-30 Commit Queue <commit-queue@webkit.org> 2 13 -
trunk/LayoutTests/fast/canvas/canvas-ImageData-behaviour-expected.txt
r126023 r244806 44 44 PASS imageData.data[0] = undefined, imageData.data[0] is 0 45 45 PASS imageData.data['foo']='garbage',imageData.data['foo'] is 'garbage' 46 PASS imageData.data[-1]='garbage',imageData.data[-1] is 'garbage'46 PASS imageData.data[-1]='garbage',imageData.data[-1] is undefined 47 47 PASS imageData.data[17]='garbage',imageData.data[17] is undefined 48 48 PASS successfullyParsed is true -
trunk/LayoutTests/fast/canvas/canvas-ImageData-behaviour.js
r126023 r244806 22 22 23 23 shouldBe("imageData.data['foo']='garbage',imageData.data['foo']", "'garbage'"); 24 shouldBe("imageData.data[-1]='garbage',imageData.data[-1]", " 'garbage'");24 shouldBe("imageData.data[-1]='garbage',imageData.data[-1]", "undefined"); 25 25 shouldBe("imageData.data[17]='garbage',imageData.data[17]", "undefined"); -
trunk/Source/JavaScriptCore/CMakeLists.txt
r244741 r244806 858 858 runtime/JSGlobalLexicalEnvironment.h 859 859 runtime/JSGlobalObject.h 860 runtime/JSGlobalObjectFunctions.h 860 861 runtime/JSGlobalObjectInlines.h 861 862 runtime/JSImmutableButterfly.h -
trunk/Source/JavaScriptCore/ChangeLog
r244791 r244806 1 2019-04-30 Tadeu Zagallo <tzagallo@apple.com> 2 3 TypeArrays should not store properties that are canonical numeric indices 4 https://bugs.webkit.org/show_bug.cgi?id=197228 5 <rdar://problem/49557381> 6 7 Reviewed by Darin Adler. 8 9 According to the spec[1], TypedArrays should not perform an ordinary GetOwnProperty/SetOwnProperty 10 if the index is a CanonicalNumericIndexString, but invalid according toIntegerIndexedElementGet 11 and similar functions. I.e., there are a few properties that should not be set in a TypedArray, 12 like NaN, Infinity and -0. 13 14 [1]: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-integer-indexed-exotic-objects-defineownproperty-p-desc 15 16 * CMakeLists.txt: 17 * JavaScriptCore.xcodeproj/project.pbxproj: 18 * runtime/JSGenericTypedArrayViewInlines.h: 19 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot): 20 (JSC::JSGenericTypedArrayView<Adaptor>::put): 21 (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): 22 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 23 (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): 24 * runtime/JSTypedArrays.cpp: 25 * runtime/PropertyName.h: 26 (JSC::canonicalNumericIndexString): 27 1 28 2019-04-30 Brian Burg <bburg@apple.com> 2 29 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r244652 r244806 1670 1670 BC3046070E1F497F003232CF /* Error.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3046060E1F497F003232CF /* Error.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1671 1671 BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1672 BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; };1672 BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1673 1673 BC87CDB910712AD4000614CF /* JSONObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = BC87CDB810712ACA000614CF /* JSONObject.lut.h */; }; 1674 1674 BC9041480EB9250900FE26FA /* StructureTransitionTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9041470EB9250900FE26FA /* StructureTransitionTable.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r241244 r244806 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 360 360 return false; 361 361 } 362 362 363 if (canonicalNumericIndexString(propertyName)) 364 return false; 365 363 366 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 364 367 } … … 376 379 if (Optional<uint32_t> index = parseIndex(propertyName)) 377 380 return putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode()); 378 381 382 if (canonicalNumericIndexString(propertyName)) 383 return false; 384 379 385 return Base::put(thisObject, exec, propertyName, value, slot); 380 386 } … … 411 417 return true; 412 418 } 413 419 420 if (canonicalNumericIndexString(propertyName)) 421 return false; 422 414 423 RELEASE_AND_RETURN(scope, Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow)); 415 424 } … … 434 443 template<typename Adaptor> 435 444 bool JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex( 436 JSObject* object, ExecState* exec, unsigned propertyName, PropertySlot& slot)445 JSObject* object, ExecState*, unsigned propertyName, PropertySlot& slot) 437 446 { 438 447 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object); … … 443 452 } 444 453 445 if (propertyName > MAX_ARRAY_INDEX) { 446 return thisObject->methodTable(exec->vm())->getOwnPropertySlot( 447 thisObject, exec, Identifier::from(exec, propertyName), slot); 448 } 454 if (propertyName > MAX_ARRAY_INDEX) 455 return false; 449 456 450 457 if (!thisObject->canGetIndexQuickly(propertyName)) … … 457 464 template<typename Adaptor> 458 465 bool JSGenericTypedArrayView<Adaptor>::putByIndex( 459 JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool shouldThrow)466 JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) 460 467 { 461 468 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell); 462 469 463 if (propertyName > MAX_ARRAY_INDEX) { 464 PutPropertySlot slot(JSValue(thisObject), shouldThrow); 465 return thisObject->methodTable(exec->vm())->put(thisObject, exec, Identifier::from(exec, propertyName), value, slot); 466 } 470 if (propertyName > MAX_ARRAY_INDEX) 471 return false; 467 472 468 473 return thisObject->setIndex(exec, propertyName, value); -
trunk/Source/JavaScriptCore/runtime/JSTypedArrays.cpp
r221954 r244806 56 56 } 57 57 58 59 58 } // namespace JSC 60 59 -
trunk/Source/JavaScriptCore/runtime/PropertyName.h
r239427 r244806 27 27 28 28 #include "Identifier.h" 29 #include "JSGlobalObjectFunctions.h" 29 30 #include "PrivateName.h" 30 31 #include <wtf/Optional.h> 32 #include <wtf/dtoa.h> 31 33 32 34 namespace JSC { … … 131 133 } 132 134 135 // https://www.ecma-international.org/ecma-262/9.0/index.html#sec-canonicalnumericindexstring 136 ALWAYS_INLINE Optional<double> canonicalNumericIndexString(const PropertyName& propertyName) 137 { 138 StringImpl* property = propertyName.uid(); 139 if (equal(property, "-0")) 140 return { -0.0 }; 141 double index = jsToNumber(property); 142 NumberToStringBuffer buffer; 143 const char* indexString = WTF::numberToString(index, buffer); 144 if (!equal(property, indexString)) 145 return WTF::nullopt; 146 return { index }; 147 } 148 133 149 } // namespace JSC
Note: See TracChangeset
for help on using the changeset viewer.