Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: test/mjsunit/for-in-opt.js

Issue 1516843002: [proxy] fixing harmony/proxy.js tests and improving error messages + some drive-by fixes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-proxies --allow-natives-syntax --expose-debug-as debug
6
7 "use strict";
8
9 // Test non-JSObject receiver.
10 function f(o) {
11 var result = [];
12 for (var i in o) {
13 result.push(i);
14 }
15 return result;
16 }
17
18 assertEquals(["0"], f("a"));
Jakob Kummerow 2015/12/10 15:35:03 What's wrong with this? (I mean the entire file.)
neis 2015/12/10 16:08:13 I tried to figure out what it was testing (in orde
Camillo Bruni 2015/12/10 20:22:13 enabled it again (for in + proxies + prototype wal
19 assertEquals(["0"], f("a"));
20 %OptimizeFunctionOnNextCall(f);
21 assertEquals(["0","1","2"], f("bla"));
22
23 // Test the lazy deopt points.
24 var keys = ["a", "b", "c", "d"];
25 var has_keys = [];
26 var deopt_has = false;
27 var deopt_enum = false;
28
29 var handler = {
30 enumerate: function(target) {
31 if (deopt_enum) {
32 %DeoptimizeFunction(f2);
33 deopt_enum = false;
34 }
35 return keys;
36 },
37
38 getPropertyDescriptor: function(k) {
39 if (deopt_has) {
40 %DeoptimizeFunction(f2);
41 deopt_has = false;
42 }
43 has_keys.push(k);
44 return {value: 10, configurable: true, writable: false, enumerable: true};
45 }
46 };
47
48
49 var proxy = new Proxy({}, handler);
50 var o = {__proto__: proxy};
51
52 function f2(o) {
53 var result = [];
54 for (var i in o) {
55 result.push(i);
56 }
57 return result;
58 }
59
60 function check_f2() {
61 assertEquals(keys, f2(o));
62 assertEquals(keys, has_keys);
63 has_keys.length = 0;
64 }
65
66 check_f2();
67 check_f2();
68 // Test lazy deopt after GetPropertyNamesFast
69 %OptimizeFunctionOnNextCall(f2);
70 deopt_enum = true;
71 check_f2();
72 // Test lazy deopt after FILTER_KEY
73 %OptimizeFunctionOnNextCall(f2);
74 deopt_has = true;
75 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);
87
88 // Reliable repro for an issue previously flushed out by GC stress.
89 var handler2 = {
90 getPropertyDescriptor: function(k) {
91 has_keys.push(k);
92 return {value: 10, configurable: true, writable: false, enumerable: true};
93 }
94 }
95 var proxy2 = new Proxy({}, handler2);
96 var o2 = {__proto__: proxy2};
97 var p = {x: "x"}
98
99 function f4(o, p) {
100 var result = [];
101 for (var i in o) {
102 var j = p.x + "str";
103 result.push(i);
104 }
105 return result;
106 }
107 function check_f4() {
108 assertEquals(keys, f4(o, p));
109 assertEquals(keys, has_keys);
110 has_keys.length = 0;
111 }
112 check_f4();
113 check_f4();
114 %OptimizeFunctionOnNextCall(f4);
115 p.y = "y"; // Change map, cause eager deopt.
116 check_f4();
117
118 // Repro for Turbofan equivalent.
119 var x;
120 var count = 0;
121
122 var Debug = debug.Debug;
123
124 function listener(event, exec_state, event_data, data) {
125 if (event == Debug.DebugEvent.Break) {
126 %DeoptimizeFunction(f5);
127 }
128 }
129
130 var handler3 = {
131 enumerate: function(target) {
132 return ["a", "b"];
133 },
134
135 getPropertyDescriptor: function(k) {
136 if (k == "a") count++;
137 if (x) %ScheduleBreak();
138 return {value: 10, configurable: true, writable: false, enumerable: true};
139 }
140 };
141
142 var proxy3 = new Proxy({}, handler3);
143 var o3 = {__proto__: proxy3};
144
145 function f5() {
146 for (var p in o3) {
147 print(p);
148 }
149 }
150
151 x = false;
152
153 f5(); f5(); f5();
154 %OptimizeFunctionOnNextCall(f5);
155 x = true;
156 count = 0;
157 Debug.setListener(listener);
158 f5();
159 Debug.setListener(null);
160 assertEquals(1, count);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698