mark.lam@apple.com | 7682413 | 2017-11-24 10:58:16 +0000 | [diff] [blame] | 1 | var createDOMJITGetterBaseJSObject = $vm.createDOMJITGetterBaseJSObject; |
| 2 | |
sbarati@apple.com | 8ebc61d | 2017-10-04 01:53:18 +0000 | [diff] [blame] | 3 | function assert(b, m) { |
| 4 | if (!b) |
| 5 | throw new Error("Bad:" + m); |
| 6 | } |
| 7 | |
| 8 | function makePolyProtoObject() { |
| 9 | function foo() { |
| 10 | class C { |
| 11 | constructor() { |
| 12 | this._field = 25; |
| 13 | } |
| 14 | }; |
| 15 | return new C; |
| 16 | } |
| 17 | for (let i = 0; i < 15; ++i) |
| 18 | foo(); |
| 19 | return foo(); |
| 20 | } |
| 21 | |
| 22 | let proto = createDOMJITGetterBaseJSObject(); |
| 23 | let obj = makePolyProtoObject(); |
| 24 | obj.__proto__ = proto; |
| 25 | |
| 26 | function validate(x, v) { |
| 27 | assert(x.customGetter === v, x.customGetter); |
| 28 | } |
| 29 | noInline(validate); |
| 30 | |
| 31 | for (let i = 0; i < 1000; ++i) |
| 32 | validate(obj, proto); |
| 33 | |
| 34 | proto.foo = 25; |
| 35 | for (let i = 0; i < 1000; ++i) |
| 36 | validate(obj, proto); |
| 37 | |
| 38 | Reflect.setPrototypeOf(obj, {}); |
| 39 | for (let i = 0; i < 1000; ++i) { |
| 40 | validate(obj, undefined); |
| 41 | } |