| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-proxies --allow-natives-syntax | 5 // This is adapted from mjsunit/for-in-opt.js. |
| 6 |
| 7 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax |
| 8 |
| 6 | 9 |
| 7 "use strict"; | 10 "use strict"; |
| 8 | 11 |
| 9 // Test non-JSObject receiver. | |
| 10 function f(o) { | 12 function f(o) { |
| 11 var result = []; | 13 var result = []; |
| 12 for (var i in o) { | 14 for (var i of Reflect.enumerate(Object(o))) { |
| 13 result.push(i); | 15 result.push(i); |
| 14 } | 16 } |
| 15 return result; | 17 return result; |
| 16 } | 18 } |
| 17 | 19 |
| 18 assertEquals(["0"], f("a")); | 20 assertEquals(["0"], f("a")); |
| 19 assertEquals(["0"], f("a")); | 21 assertEquals(["0"], f("a")); |
| 20 %OptimizeFunctionOnNextCall(f); | 22 %OptimizeFunctionOnNextCall(f); |
| 21 assertEquals(["0","1","2"], f("bla")); | 23 assertEquals(["0","1","2"], f("bla")); |
| 22 | 24 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 return {value: 10, configurable: true, writable: false, enumerable: true}; | 46 return {value: 10, configurable: true, writable: false, enumerable: true}; |
| 45 } | 47 } |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 | 50 |
| 49 var proxy = Proxy.create(handler); | 51 var proxy = Proxy.create(handler); |
| 50 var o = {__proto__: proxy}; | 52 var o = {__proto__: proxy}; |
| 51 | 53 |
| 52 function f2(o) { | 54 function f2(o) { |
| 53 var result = []; | 55 var result = []; |
| 54 for (var i in o) { | 56 for (var i of Reflect.enumerate(o)) { |
| 55 result.push(i); | 57 result.push(i); |
| 56 } | 58 } |
| 57 return result; | 59 return result; |
| 58 } | 60 } |
| 59 | 61 |
| 60 function check_f2() { | 62 function check_f2() { |
| 61 assertEquals(keys, f2(o)); | 63 assertEquals(keys, f2(o)); |
| 62 assertEquals(keys, has_keys); | 64 assertEquals(keys, has_keys); |
| 63 has_keys.length = 0; | 65 has_keys.length = 0; |
| 64 } | 66 } |
| 65 | 67 |
| 66 check_f2(); | 68 check_f2(); |
| 67 check_f2(); | 69 check_f2(); |
| 68 // Test lazy deopt after GetPropertyNamesFast | 70 // Test lazy deopt after GetPropertyNamesFast |
| 69 %OptimizeFunctionOnNextCall(f2); | 71 %OptimizeFunctionOnNextCall(f2); |
| 70 deopt_enum = true; | 72 deopt_enum = true; |
| 71 check_f2(); | 73 check_f2(); |
| 72 // Test lazy deopt after FILTER_KEY | 74 // Test lazy deopt after FILTER_KEY |
| 73 %OptimizeFunctionOnNextCall(f2); | 75 %OptimizeFunctionOnNextCall(f2); |
| 74 deopt_has = true; | 76 deopt_has = true; |
| 75 check_f2(); | 77 check_f2(); |
| 76 | |
| 77 function f3(o) { | |
| 78 for (var i in o) { | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 f3({__proto__:{x:1}}); | |
| 83 f3({__proto__:{x:1}}); | |
| 84 %OptimizeFunctionOnNextCall(f3); | |
| 85 f3(undefined); | |
| 86 f3(null); | |
| OLD | NEW |