| 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 // This is adapted from mjsunit/for-in-opt.js. | 5 // This is adapted from mjsunit/for-in-opt.js. |
| 6 | 6 |
| 7 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax | 7 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax |
| 8 | 8 |
| 9 | 9 |
| 10 "use strict"; | 10 "use strict"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 getPropertyDescriptor: function(k) { | 40 getPropertyDescriptor: function(k) { |
| 41 if (deopt_has) { | 41 if (deopt_has) { |
| 42 %DeoptimizeFunction(f2); | 42 %DeoptimizeFunction(f2); |
| 43 deopt_has = false; | 43 deopt_has = false; |
| 44 } | 44 } |
| 45 has_keys.push(k); | 45 has_keys.push(k); |
| 46 return {value: 10, configurable: true, writable: false, enumerable: true}; | 46 return {value: 10, configurable: true, writable: false, enumerable: true}; |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 | 50 // TODO(neis,cbruni): Enable once the enumerate proxy trap is properly |
| 51 var proxy = Proxy.create(handler); | 51 // implemented. |
| 52 var o = {__proto__: proxy}; | 52 // var proxy = new Proxy({}, handler); |
| 53 | 53 // var o = {__proto__: proxy}; |
| 54 function f2(o) { | 54 // |
| 55 var result = []; | 55 // function f2(o) { |
| 56 for (var i of Reflect.enumerate(o)) { | 56 // var result = []; |
| 57 result.push(i); | 57 // for (var i of Reflect.enumerate(o)) { |
| 58 } | 58 // result.push(i); |
| 59 return result; | 59 // } |
| 60 } | 60 // return result; |
| 61 | 61 // } |
| 62 function check_f2() { | 62 // |
| 63 assertEquals(keys, f2(o)); | 63 // function check_f2() { |
| 64 assertEquals(keys, has_keys); | 64 // assertEquals(keys, f2(o)); |
| 65 has_keys.length = 0; | 65 // assertEquals(keys, has_keys); |
| 66 } | 66 // has_keys.length = 0; |
| 67 | 67 // } |
| 68 check_f2(); | 68 // |
| 69 check_f2(); | 69 // check_f2(); |
| 70 // check_f2(); |
| 70 // Test lazy deopt after GetPropertyNamesFast | 71 // Test lazy deopt after GetPropertyNamesFast |
| 71 %OptimizeFunctionOnNextCall(f2); | 72 // %OptimizeFunctionOnNextCall(f2); |
| 72 deopt_enum = true; | 73 // deopt_enum = true; |
| 73 check_f2(); | 74 // check_f2(); |
| 74 // Test lazy deopt after FILTER_KEY | 75 // Test lazy deopt after FILTER_KEY |
| 75 %OptimizeFunctionOnNextCall(f2); | 76 // %OptimizeFunctionOnNextCall(f2); |
| 76 deopt_has = true; | 77 // deopt_has = true; |
| 77 check_f2(); | 78 // check_f2(); |
| OLD | NEW |