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 --gc-global |
| 6 |
| 7 (function TestGCDuringToObjectForWith() { |
| 8 function f(o) { |
| 9 if (o == 'warmup') { return g() } |
| 10 with (o) { return x } |
| 11 } |
| 12 function g() { |
| 13 // Only a marker function serving as weak embedded object. |
| 14 } |
| 15 |
| 16 // Warm up 'f' so that weak embedded object 'g' will be used. |
| 17 f('warmup'); |
| 18 f('warmup'); |
| 19 g = null; |
| 20 |
| 21 // Test that 'f' behaves correctly unoptimized. |
| 22 assertEquals(23, f({ x:23 })); |
| 23 assertEquals(42, f({ x:42 })); |
| 24 |
| 25 // Test that 'f' behaves correctly optimized. |
| 26 %OptimizeFunctionOnNextCall(f); |
| 27 assertEquals(65, f({ x:65 })); |
| 28 |
| 29 // Test that 'f' behaves correctly on numbers. |
| 30 Number.prototype.x = 99; |
| 31 assertEquals(99, f(0)); |
| 32 |
| 33 // Make sure the next [[ToObject]] allocation triggers GC. This in turn will |
| 34 // deoptimize 'f' because it has the weak embedded object 'g' in the code. |
| 35 %SetAllocationTimeout(1000, 1, false); |
| 36 assertEquals(99, f(0)); |
| 37 })(); |
OLD | NEW |