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() { |
| 8 function foo() { |
| 9 var a = new Array(); |
| 10 a[0] = 10; |
| 11 return a; |
| 12 } |
| 13 |
| 14 assertEquals(1, foo().length); |
| 15 |
| 16 gc(); |
| 17 gc(); |
| 18 gc(); |
| 19 gc(); |
| 20 |
| 21 // Change prototype elements from fast smi to slow elements dictionary. |
| 22 // The validity cell is invalidated by the change of Array.prototype's |
| 23 // map. |
| 24 Array.prototype.__defineSetter__("0", function() {}); |
| 25 |
| 26 assertEquals(0, foo().length); |
| 27 })(); |
| 28 |
| 29 |
| 30 (function() { |
| 31 function foo() { |
| 32 var a = new Array(); |
| 33 a[0] = 10; |
| 34 return a; |
| 35 } |
| 36 |
| 37 // Change prototype elements from fast smi to dictionary. |
| 38 Array.prototype[123456789] = 42; |
| 39 Array.prototype.length = 0; |
| 40 |
| 41 assertEquals(1, foo().length); |
| 42 |
| 43 gc(); |
| 44 gc(); |
| 45 gc(); |
| 46 gc(); |
| 47 |
| 48 // Change prototype elements from dictionary to slow elements dictionary. |
| 49 // The validity cell is invalidated by making the elements dictionary slow. |
| 50 Array.prototype.__defineSetter__("0", function() {}); |
| 51 |
| 52 assertEquals(0, foo().length); |
| 53 })(); |
OLD | NEW |