Repository navigation
Commit 7febf0a
committed
[JSC] DFG Array.push with 0-argument should throw an error when length is not writable
https://bugs.webkit.org/show_bug.cgi?id=328086
rdar://190437846
Reviewed by Keith Miller.
Array.prototype.push with no arguments still performs Set(O, "length", len, true), which throws a
TypeError when length is not writable. DFG fixup turned array.push() into GetArrayLength for any
array mode that supports self length, including ArrayStorage, which is the only kind of array whose
length can be non-writable, so the TypeError was lost in DFG and FTL code.
This patch applies this optimization only for Int32, Double, and Contiguous arrays as their length
is not frozen.
Test: JSTests/stress/array-push-no-arguments-throws-on-read-only-length.js
* JSTests/stress/array-push-no-arguments-throws-on-read-only-length.js: Added.
(push):
(make):
(i.catch):
* Source/JavaScriptCore/dfg/DFGArrayMode.h:
(JSC::DFG::arrayModeImpliesWritableLength):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
Canonical link: https://commits.webkit.org/324204@main1 parent 0083ac4 commit 7febf0a
4 files changed
Lines changed: 43 additions & 1 deletion
File tree
- JSTests/stress
- Source/JavaScriptCore/dfg
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3179 | 3179 | | |
3180 | 3180 | | |
3181 | 3181 | | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
3182 | 3187 | | |
3183 | 3188 | | |
3184 | 3189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1733 | 1733 | | |
1734 | 1734 | | |
1735 | 1735 | | |
1736 | | - | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1737 | 1739 | | |
| 1740 | + | |
| 1741 | + | |
1738 | 1742 | | |
1739 | 1743 | | |
1740 | 1744 | | |
| |||
0 commit comments