Repository navigation
Commit 5d5248a
committed
[JSC] Install the private class brand before evaluating class elements
https://bugs.webkit.org/show_bug.cgi?id=327984
Reviewed by Yusuke Suzuki.
The brand of static private methods and accessors was stored in the class scope
after the class elements were evaluated, so a closure created in a computed
property name could read the empty value and pass it to op_stricteq. DFG and FTL
speculated that the brand is an object and crashed by reading the type of a null
cell.
let f;
function probe(g) { f = g; g({}); }
for (let i = 0; i < testLoopCount; i++) {
class C { static #m() { } static [probe(o => #m in o)]() { } }
f(C);
}
This patch stores it right after the constructor is created. Accessing a static
private method at that point now throws a TypeError instead of a ReferenceError.
op_check_tdz in emitCheckPrivateBrand is no longer needed. No user code runs
between the creation of the class scope and this store, so the brand is never
empty when it is read.
Test: JSTests/stress/static-private-brand-check-in-computed-property-name.js
* JSTests/stress/static-private-brand-check-in-computed-property-name.js: Added.
(shouldBe):
(shouldThrowTypeError):
(checkWithoutBrand):
(checkWithBrand):
(abortIf):
(define.return.method):
(define.return.get getter):
(define.return.set setter):
(define.return):
(define):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitCheckPrivateBrand):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::ClassExprNode::emitBytecode):
Canonical link: https://commits.webkit.org/324222@main1 parent f2af25b commit 5d5248a
3 files changed
Lines changed: 77 additions & 4 deletions
File tree
- JSTests/stress
- Source/JavaScriptCore/bytecompiler
| 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 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3160 | 3160 | | |
3161 | 3161 | | |
3162 | 3162 | | |
3163 | | - | |
3164 | 3163 | | |
3165 | 3164 | | |
3166 | 3165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5813 | 5813 | | |
5814 | 5814 | | |
5815 | 5815 | | |
| 5816 | + | |
| 5817 | + | |
| 5818 | + | |
5816 | 5819 | | |
5817 | 5820 | | |
5818 | 5821 | | |
| |||
5869 | 5872 | | |
5870 | 5873 | | |
5871 | 5874 | | |
5872 | | - | |
5873 | | - | |
5874 | | - | |
5875 | 5875 | | |
5876 | 5876 | | |
5877 | 5877 | | |
| |||
0 commit comments