OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax --expose-gc |
| 6 |
| 7 function P() { |
| 8 this.a0 = {}; |
| 9 this.a1 = {}; |
| 10 this.a2 = {}; |
| 11 this.a3 = {}; |
| 12 this.a4 = {}; |
| 13 } |
| 14 |
| 15 function A() { |
| 16 } |
| 17 |
| 18 var proto = new P(); |
| 19 A.prototype = proto; |
| 20 |
| 21 function foo(o) { |
| 22 return o.a0; |
| 23 } |
| 24 |
| 25 // Ensure |proto| is in old space. |
| 26 gc(); |
| 27 gc(); |
| 28 gc(); |
| 29 |
| 30 // Ensure |proto| is marked as "should be fast". |
| 31 var o = new A(); |
| 32 foo(o); |
| 33 foo(o); |
| 34 foo(o); |
| 35 assertTrue(%HasFastProperties(proto)); |
| 36 |
| 37 // Contruct a double value that looks like a tagged pointer. |
| 38 var buffer = new ArrayBuffer(8); |
| 39 var int32view = new Int32Array(buffer); |
| 40 var float64view = new Float64Array(buffer); |
| 41 int32view[0] = int32view[1] = 0x40000001; |
| 42 var boom = float64view[0]; |
| 43 |
| 44 |
| 45 // Write new space object. |
| 46 proto.a4 = {a: 0}; |
| 47 // Immediately delete the field. |
| 48 delete proto.a4; |
| 49 |
| 50 // |proto| must sill be fast. |
| 51 assertTrue(%HasFastProperties(proto)); |
| 52 |
| 53 // Add a double field instead of deleted a4 that looks like a tagged pointer. |
| 54 proto.boom = boom; |
| 55 |
| 56 // Boom! |
| 57 gc(); |
OLD | NEW |