Debian Codegraph @

js/src/jit-test/tests/watchtower/freeze-proto-2.js

raw
1 // |jit-test| --fast-warmup; --no-threads
2
3 // Freezing a prototype object must invalidate the megamorphic set-property cache.
4
5 function addProps(obj) {
6 for (var i = 0; i < 10; i++) {
7 obj["random$name" + i] = i;
8 }
9 }
10
11 function f() {
12 var proto = Object.create(null);
13 proto.random$name0 = 0;
14 proto.random$name5 = 0;
15 proto.random$name9 = 0;
16
17 var obj1 = Object.create(proto);
18 var obj2 = Object.create(proto);
19
20 addProps(obj1);
21 Object.freeze(proto);
22 addProps(obj2);
23
24 assertEq(Object.keys(obj1).length, 10);
25 assertEq(Object.keys(obj2).length, 7);
26 }
27 for (var i = 0; i < 10; i++) {
28 f();
29 }