OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 function base_getter_test(create_func) { | 80 function base_getter_test(create_func) { |
81 var calls = 0; | 81 var calls = 0; |
82 | 82 |
83 // Testcase: setter in prototype chain | 83 // Testcase: setter in prototype chain |
84 foo = function(a) { var x = a[0]; return x + 3; } | 84 foo = function(a) { var x = a[0]; return x + 3; } |
85 var a = create_func(); | 85 var a = create_func(); |
86 var ap = []; | 86 var ap = []; |
87 ap.__defineGetter__(0, function() { calls++; return 0; }); | 87 ap.__defineGetter__(0, function() { calls++; return 0; }); |
88 | 88 |
89 foo(a); | 89 foo(a); |
| 90 assertUnoptimized(foo); |
90 foo(a); | 91 foo(a); |
91 foo(a); | 92 foo(a); |
92 delete a[0]; | 93 delete a[0]; |
93 | 94 |
94 assertEquals(0, calls); | 95 assertEquals(0, calls); |
95 a.__proto__ = ap; | 96 a.__proto__ = ap; |
96 foo(a); | 97 foo(a); |
97 assertEquals(1, calls); | 98 assertEquals(1, calls); |
98 optimize(foo); | 99 optimize(foo); |
99 foo(a); | 100 foo(a); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bar(a); | 159 bar(a); |
159 optimize(bar); | 160 optimize(bar); |
160 bar(a); | 161 bar(a); |
161 assertOptimized(bar); | 162 assertOptimized(bar); |
162 assertEquals(0, calls); | 163 assertEquals(0, calls); |
163 delete a[3]; | 164 delete a[3]; |
164 ap2.__defineGetter__(3, function() { calls++; return 0; }); | 165 ap2.__defineGetter__(3, function() { calls++; return 0; }); |
165 bar(a); | 166 bar(a); |
166 assertOptimized(bar); | 167 assertOptimized(bar); |
167 assertEquals(1, calls); | 168 assertEquals(1, calls); |
| 169 |
| 170 // Reset the state of foo and bar. |
| 171 clearFunctionTypeFeedback(foo); |
| 172 deoptimizeFunction(foo); |
| 173 clearFunctionTypeFeedback(foo); |
| 174 |
| 175 clearFunctionTypeFeedback(bar); |
| 176 deoptimizeFunction(bar); |
| 177 clearFunctionTypeFeedback(bar); |
168 } | 178 } |
169 | 179 |
170 // Verify that map transitions don't confuse us. | 180 // Verify that map transitions don't confuse us. |
171 create_func_smi = function() { return [,,,,,,5]; } | 181 create_func_smi = function() { return [,,,,,,5]; } |
172 create_func_double = function() { return [,,,,,,5.5]; } | 182 create_func_double = function() { return [,,,,,,5.5]; } |
173 create_func_fast = function() { return [,,,,,,true]; } | 183 create_func_fast = function() { return [,,,,,,true]; } |
174 | 184 |
175 var cf = [create_func_smi, | 185 var cf = [create_func_smi, |
176 create_func_double, | 186 create_func_double, |
177 create_func_fast]; | 187 create_func_fast]; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 optimize(fun); | 222 optimize(fun); |
213 fun(a); | 223 fun(a); |
214 assertOptimized(fun); | 224 assertOptimized(fun); |
215 | 225 |
216 var calls = 0; | 226 var calls = 0; |
217 delete a[0]; | 227 delete a[0]; |
218 ap.__defineGetter__(0, function() { calls++; return 0; }); | 228 ap.__defineGetter__(0, function() { calls++; return 0; }); |
219 fun(a); | 229 fun(a); |
220 assertEquals(1, calls); | 230 assertEquals(1, calls); |
221 assertUnoptimized(fun); | 231 assertUnoptimized(fun); |
OLD | NEW |