/
dfg-put-private-name-check-barrier-insertion.js
69 lines (58 loc) · 1.56 KB
/
dfg-put-private-name-check-barrier-insertion.js
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
//@ requireOptions("--allowUnsupportedTiers=true", "--usePrivateClassFields=true", "--maxPolymorphicAccessInliningListSize=2")
let assert = {
sameValue: function(a, e) {
if (a !== e)
throw new Error("Expected: " + e + " but got: " + a);
},
throws: function(exception, functor) {
let threwException;
try {
functor();
threwException = false;
} catch(e) {
threwException = true;
if (!e instanceof exception)
throw new Error("Expected to throw: " + exception.name + " but it throws: " + e.name);
}
if (!threwException)
throw new Error("Expected to throw: " + exception.name + " but executed without exception");
}
}
let i = 0;
class C {
#field = this.init();
init() {
let arr = ["p1", "p2", "p3"];
let key = arr[i % 3];
this[key] = i;
if (key === "p2")
this["p1"] = i;
if (key === "p3") {
this["p1"] = i;
this["p2"] = i;
}
}
setField(v) {
this.#field = v;
}
getField() {
return this.#field;
}
}
noInline(C.prototype.setField);
noInline(C.prototype.getField);
noDFG(C.prototype.getField);
noFTL(C.prototype.getField);
let oldObject = new C;
for (; i < 10000; i++) {
if (i < 5000) {
let c = new C;
c.setField(i);
} else {
if (i == 5000)
gc();
oldObject.setField({prop: i});
edenGC();
assert.sameValue(oldObject.getField().prop, i);
}
}