OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --inline-accessors | 28 // Flags: --allow-natives-syntax --inline-accessors --max-opt-count=100 |
29 | 29 |
30 var accessorCallCount, setterArgument, setterValue, obj, forceDeopt; | 30 var accessorCallCount, setterArgument, setterValue, obj, forceDeopt; |
31 | 31 |
32 // ----------------------------------------------------------------------------- | 32 // ----------------------------------------------------------------------------- |
33 // Helpers for testing inlining of getters. | 33 // Helpers for testing inlining of getters. |
34 | 34 |
35 function TestInlinedGetter(context, expected) { | 35 function TestInlinedGetter(context, obj, expected) { |
36 forceDeopt = 0; | 36 forceDeopt = { deopt: 0 }; |
37 accessorCallCount = 0; | 37 accessorCallCount = 0; |
38 | 38 |
39 assertEquals(expected, context()); | 39 assertEquals(expected, context(obj)); |
40 assertEquals(1, accessorCallCount); | 40 assertEquals(1, accessorCallCount); |
41 | 41 |
42 assertEquals(expected, context()); | 42 assertEquals(expected, context(obj)); |
43 assertEquals(2, accessorCallCount); | 43 assertEquals(2, accessorCallCount); |
44 | 44 |
45 %OptimizeFunctionOnNextCall(context); | 45 %OptimizeFunctionOnNextCall(context); |
46 assertEquals(expected, context()); | 46 assertEquals(expected, context(obj)); |
47 assertEquals(3, accessorCallCount); | 47 assertEquals(3, accessorCallCount); |
48 | 48 |
49 %DeoptimizeFunction(context); | 49 forceDeopt = { /* empty*/ }; |
50 %ClearFunctionTypeFeedback(context); | 50 assertEquals(expected, context(obj)); |
| 51 assertEquals(4, accessorCallCount); |
51 } | 52 } |
52 | 53 |
53 | 54 |
54 function TestGetterInAllContexts(obj, expected) { | 55 function value_context_for_getter(obj) { |
55 function value_context() { | 56 return obj.getterProperty; |
56 return obj.getterProperty; | 57 } |
| 58 |
| 59 function test_context_for_getter(obj) { |
| 60 if (obj.getterProperty) { |
| 61 return 111; |
| 62 } else { |
| 63 return 222; |
57 } | 64 } |
58 TestInlinedGetter(value_context, expected); | 65 } |
59 | 66 |
60 function test_context() { | 67 function effect_context_for_getter(obj) { |
61 if (obj.getterProperty) { | 68 obj.getterProperty; |
62 return 111; | 69 return 5678; |
63 } else { | 70 } |
64 return 222; | 71 |
65 } | 72 function TryGetter(context, getter, obj, expected, expectException) { |
| 73 try { |
| 74 TestInlinedGetter(context, obj, expected); |
| 75 assertFalse(expectException); |
| 76 } catch (exception) { |
| 77 assertTrue(expectException); |
| 78 assertEquals(7, exception.stack.split('\n').length); |
66 } | 79 } |
67 TestInlinedGetter(test_context, expected ? 111 : 222); | 80 %DeoptimizeFunction(context); |
| 81 %ClearFunctionTypeFeedback(context); |
| 82 %ClearFunctionTypeFeedback(getter); |
| 83 } |
68 | 84 |
69 function effect_context() { | 85 function TestGetterInAllContexts(getter, obj, expected, expectException) { |
70 obj.getterProperty; | 86 TryGetter(value_context_for_getter, getter, obj, expected, expectException); |
71 return 5678; | 87 TryGetter(test_context_for_getter, getter, obj, expected ? 111 : 222, |
72 } | 88 expectException); |
73 TestInlinedGetter(effect_context, 5678); | 89 TryGetter(effect_context_for_getter, getter, obj, 5678, expectException); |
74 } | 90 } |
75 | 91 |
76 // ----------------------------------------------------------------------------- | 92 // ----------------------------------------------------------------------------- |
77 // Test getter returning something 'true'ish in all contexts. | 93 // Test getter returning something 'true'ish in all contexts. |
78 | 94 |
79 function getter1() { | 95 function getter1() { |
80 assertSame(obj, this); | 96 assertSame(obj, this); |
81 accessorCallCount++; | 97 accessorCallCount++; |
82 forceDeopt + 1; | 98 forceDeopt.deopt; |
83 return 1234; | 99 return 1234; |
84 } | 100 } |
85 | 101 |
86 function ConstrG1() { } | 102 function ConstrG1() { } |
87 obj = Object.defineProperty(new ConstrG1(), "getterProperty", { get: getter1 }); | 103 obj = Object.defineProperty(new ConstrG1(), "getterProperty", { get: getter1 }); |
88 TestGetterInAllContexts(obj, 1234); | 104 TestGetterInAllContexts(getter1, obj, 1234, false); |
89 obj = Object.create(obj); | 105 obj = Object.create(obj); |
90 TestGetterInAllContexts(obj, 1234); | 106 TestGetterInAllContexts(getter1, obj, 1234, false); |
91 | 107 |
92 // ----------------------------------------------------------------------------- | 108 // ----------------------------------------------------------------------------- |
93 // Test getter returning false in all contexts. | 109 // Test getter returning false in all contexts. |
94 | 110 |
95 function getter2() { | 111 function getter2() { |
96 assertSame(obj, this); | 112 assertSame(obj, this); |
97 accessorCallCount++; | 113 accessorCallCount++; |
98 forceDeopt + 1; | 114 forceDeopt.deopt; |
99 return false; | 115 return false; |
100 } | 116 } |
101 | 117 |
102 function ConstrG2() { } | 118 function ConstrG2() { } |
103 obj = Object.defineProperty(new ConstrG2(), "getterProperty", { get: getter2 }); | 119 obj = Object.defineProperty(new ConstrG2(), "getterProperty", { get: getter2 }); |
104 TestGetterInAllContexts(obj, false); | 120 TestGetterInAllContexts(getter2, obj, false, false); |
105 obj = Object.create(obj); | 121 obj = Object.create(obj); |
106 TestGetterInAllContexts(obj, false); | 122 TestGetterInAllContexts(getter2, obj, false, false); |
107 | 123 |
108 // ----------------------------------------------------------------------------- | 124 // ----------------------------------------------------------------------------- |
109 // Test getter without a return in all contexts. | 125 // Test getter without a return in all contexts. |
110 | 126 |
111 function getter3() { | 127 function getter3() { |
112 assertSame(obj, this); | 128 assertSame(obj, this); |
113 accessorCallCount++; | 129 accessorCallCount++; |
114 forceDeopt + 1; | 130 forceDeopt.deopt; |
115 } | 131 } |
116 | 132 |
117 function ConstrG3() { } | 133 function ConstrG3() { } |
118 obj = Object.defineProperty(new ConstrG3(), "getterProperty", { get: getter3 }); | 134 obj = Object.defineProperty(new ConstrG3(), "getterProperty", { get: getter3 }); |
119 TestGetterInAllContexts(obj, undefined); | 135 TestGetterInAllContexts(getter3, obj, undefined, false); |
120 obj = Object.create(obj); | 136 obj = Object.create(obj); |
121 TestGetterInAllContexts(obj, undefined); | 137 TestGetterInAllContexts(getter3, obj, undefined, false); |
122 | 138 |
123 // ----------------------------------------------------------------------------- | 139 // ----------------------------------------------------------------------------- |
124 // Test getter with too many arguments without a return in all contexts. | 140 // Test getter with too many arguments without a return in all contexts. |
125 | 141 |
126 function getter4(a) { | 142 function getter4(a) { |
127 assertSame(obj, this); | 143 assertSame(obj, this); |
128 assertEquals(undefined, a); | 144 assertEquals(undefined, a); |
129 accessorCallCount++; | 145 accessorCallCount++; |
130 forceDeopt + 1; | 146 forceDeopt.deopt; |
131 } | 147 } |
132 | 148 |
133 function ConstrG4() { } | 149 function ConstrG4() { } |
134 obj = Object.defineProperty(new ConstrG4(), "getterProperty", { get: getter4 }); | 150 obj = Object.defineProperty(new ConstrG4(), "getterProperty", { get: getter4 }); |
135 TestGetterInAllContexts(obj, undefined); | 151 TestGetterInAllContexts(getter4, obj, undefined, false); |
136 obj = Object.create(obj); | 152 obj = Object.create(obj); |
137 TestGetterInAllContexts(obj, undefined); | 153 TestGetterInAllContexts(getter4, obj, undefined, false); |
138 | 154 |
139 // ----------------------------------------------------------------------------- | 155 // ----------------------------------------------------------------------------- |
140 // Test getter with too many arguments with a return in all contexts. | 156 // Test getter with too many arguments with a return in all contexts. |
141 | 157 |
142 function getter5(a) { | 158 function getter5(a) { |
143 assertSame(obj, this); | 159 assertSame(obj, this); |
144 assertEquals(undefined, a); | 160 assertEquals(undefined, a); |
145 accessorCallCount++; | 161 accessorCallCount++; |
146 forceDeopt + 1; | 162 forceDeopt.deopt; |
147 return 9876; | 163 return 9876; |
148 } | 164 } |
149 | 165 |
150 function ConstrG5() { } | 166 function ConstrG5() { } |
151 obj = Object.defineProperty(new ConstrG5(), "getterProperty", { get: getter5 }); | 167 obj = Object.defineProperty(new ConstrG5(), "getterProperty", { get: getter5 }); |
152 TestGetterInAllContexts(obj, 9876); | 168 TestGetterInAllContexts(getter5, obj, 9876, false); |
153 obj = Object.create(obj); | 169 obj = Object.create(obj); |
154 TestGetterInAllContexts(obj, 9876); | 170 TestGetterInAllContexts(getter5, obj, 9876, false); |
| 171 |
| 172 // ----------------------------------------------------------------------------- |
| 173 // Test getter which throws from optimized code. |
| 174 |
| 175 function getter6() { |
| 176 assertSame(obj, this); |
| 177 accessorCallCount++; |
| 178 forceDeopt.deopt; |
| 179 if (accessorCallCount == 4) { 123 in null; } |
| 180 return 13579; |
| 181 } |
| 182 |
| 183 function ConstrG6() { } |
| 184 obj = Object.defineProperty(new ConstrG6(), "getterProperty", { get: getter6 }); |
| 185 TestGetterInAllContexts(getter6, obj, 13579, true); |
| 186 obj = Object.create(obj); |
| 187 TestGetterInAllContexts(getter6, obj, 13579, true); |
155 | 188 |
156 // ----------------------------------------------------------------------------- | 189 // ----------------------------------------------------------------------------- |
157 // Helpers for testing inlining of setters. | 190 // Helpers for testing inlining of setters. |
158 | 191 |
159 function TestInlinedSetter(context, value, expected) { | 192 function TestInlinedSetter(context, obj, value, expected) { |
160 forceDeopt = 0; | 193 forceDeopt = { deopt: 0 }; |
161 accessorCallCount = 0; | 194 accessorCallCount = 0; |
162 setterArgument = value; | 195 setterArgument = value; |
163 | 196 |
164 assertEquals(expected, context(value)); | 197 assertEquals(expected, context(obj, value)); |
165 assertEquals(value, setterValue); | 198 assertEquals(value, setterValue); |
166 assertEquals(1, accessorCallCount); | 199 assertEquals(1, accessorCallCount); |
167 | 200 |
168 assertEquals(expected, context(value)); | 201 assertEquals(expected, context(obj, value)); |
169 assertEquals(value, setterValue); | 202 assertEquals(value, setterValue); |
170 assertEquals(2, accessorCallCount); | 203 assertEquals(2, accessorCallCount); |
171 | 204 |
172 %OptimizeFunctionOnNextCall(context); | 205 %OptimizeFunctionOnNextCall(context); |
173 assertEquals(expected, context(value)); | 206 assertEquals(expected, context(obj, value)); |
174 assertEquals(value, setterValue); | 207 assertEquals(value, setterValue); |
175 assertEquals(3, accessorCallCount); | 208 assertEquals(3, accessorCallCount); |
176 | 209 |
| 210 forceDeopt = { /* empty*/ }; |
| 211 assertEquals(expected, context(obj, value)); |
| 212 assertEquals(value, setterValue); |
| 213 assertEquals(4, accessorCallCount); |
| 214 } |
| 215 |
| 216 function value_context_for_setter(obj, value) { |
| 217 return obj.setterProperty = value; |
| 218 } |
| 219 |
| 220 function test_context_for_setter(obj, value) { |
| 221 if (obj.setterProperty = value) { |
| 222 return 333; |
| 223 } else { |
| 224 return 444; |
| 225 } |
| 226 } |
| 227 |
| 228 function effect_context_for_setter(obj, value) { |
| 229 obj.setterProperty = value; |
| 230 return 666; |
| 231 } |
| 232 |
| 233 function TrySetter(context, setter, obj, expectException, value, expected) { |
| 234 try { |
| 235 TestInlinedSetter(context, obj, value, expected); |
| 236 assertFalse(expectException); |
| 237 } catch (exception) { |
| 238 assertTrue(expectException); |
| 239 assertEquals(7, exception.stack.split('\n').length); |
| 240 } |
177 %DeoptimizeFunction(context); | 241 %DeoptimizeFunction(context); |
178 %ClearFunctionTypeFeedback(context); | 242 %ClearFunctionTypeFeedback(context); |
| 243 %ClearFunctionTypeFeedback(setter); |
179 } | 244 } |
180 | 245 |
181 function TestSetterInAllContexts(obj) { | 246 function TestSetterInAllContexts(setter, obj, expectException) { |
182 function value_context(value) { | 247 TrySetter(value_context_for_setter, setter, obj, expectException, 111, 111); |
183 return obj.setterProperty = value; | 248 TrySetter(test_context_for_setter, setter, obj, expectException, true, 333); |
184 } | 249 TrySetter(test_context_for_setter, setter, obj, expectException, false, 444); |
185 TestInlinedSetter(value_context, 111, 111); | 250 TrySetter(effect_context_for_setter, setter, obj, expectException, 555, 666); |
186 | |
187 function test_context(value) { | |
188 if (obj.setterProperty = value) { | |
189 return 333; | |
190 } else { | |
191 return 444; | |
192 } | |
193 } | |
194 TestInlinedSetter(test_context, true, 333); | |
195 TestInlinedSetter(test_context, false, 444); | |
196 | |
197 function effect_context(value) { | |
198 obj.setterProperty = value; | |
199 return 666; | |
200 } | |
201 TestInlinedSetter(effect_context, 555, 666); | |
202 } | 251 } |
203 | 252 |
204 // ----------------------------------------------------------------------------- | 253 // ----------------------------------------------------------------------------- |
205 // Test setter without a return in all contexts. | 254 // Test setter without a return in all contexts. |
206 | 255 |
207 function setter1(value) { | 256 function setter1(value) { |
208 assertSame(obj, this); | 257 assertSame(obj, this); |
209 accessorCallCount++; | 258 accessorCallCount++; |
210 forceDeopt + 1; | 259 forceDeopt.deopt; |
211 setterValue = value; | 260 setterValue = value; |
212 } | 261 } |
213 | 262 |
214 function ConstrS1() { } | 263 function ConstrS1() { } |
215 obj = Object.defineProperty(new ConstrS1(), "setterProperty", { set: setter1 }); | 264 obj = Object.defineProperty(new ConstrS1(), "setterProperty", { set: setter1 }); |
216 TestSetterInAllContexts(obj); | 265 TestSetterInAllContexts(setter1, obj, false); |
217 obj = Object.create(obj); | 266 obj = Object.create(obj); |
218 TestSetterInAllContexts(obj); | 267 TestSetterInAllContexts(setter1, obj, false); |
219 | 268 |
220 // ----------------------------------------------------------------------------- | 269 // ----------------------------------------------------------------------------- |
221 // Test setter returning something different than the RHS in all contexts. | 270 // Test setter returning something different than the RHS in all contexts. |
222 | 271 |
223 function setter2(value) { | 272 function setter2(value) { |
224 assertSame(obj, this); | 273 assertSame(obj, this); |
225 accessorCallCount++; | 274 accessorCallCount++; |
226 forceDeopt + 1; | 275 forceDeopt.deopt; |
227 setterValue = value; | 276 setterValue = value; |
228 return 1000000; | 277 return 1000000; |
229 } | 278 } |
230 | 279 |
231 function ConstrS2() { } | 280 function ConstrS2() { } |
232 obj = Object.defineProperty(new ConstrS2(), "setterProperty", { set: setter2 }); | 281 obj = Object.defineProperty(new ConstrS2(), "setterProperty", { set: setter2 }); |
233 TestSetterInAllContexts(obj); | 282 TestSetterInAllContexts(setter2, obj, false); |
234 obj = Object.create(obj); | 283 obj = Object.create(obj); |
235 TestSetterInAllContexts(obj); | 284 TestSetterInAllContexts(setter2, obj, false); |
236 | 285 |
237 // ----------------------------------------------------------------------------- | 286 // ----------------------------------------------------------------------------- |
238 // Test setter with too few arguments without a return in all contexts. | 287 // Test setter with too few arguments without a return in all contexts. |
239 | 288 |
240 function setter3() { | 289 function setter3() { |
241 assertSame(obj, this); | 290 assertSame(obj, this); |
242 accessorCallCount++; | 291 accessorCallCount++; |
243 forceDeopt + 1; | 292 forceDeopt.deopt; |
244 setterValue = setterArgument; | 293 setterValue = setterArgument; |
245 } | 294 } |
246 | 295 |
247 function ConstrS3() { } | 296 function ConstrS3() { } |
248 obj = Object.defineProperty(new ConstrS3(), "setterProperty", { set: setter3 }); | 297 obj = Object.defineProperty(new ConstrS3(), "setterProperty", { set: setter3 }); |
249 TestSetterInAllContexts(obj); | 298 TestSetterInAllContexts(setter3, obj, false); |
250 obj = Object.create(obj); | 299 obj = Object.create(obj); |
251 TestSetterInAllContexts(obj); | 300 TestSetterInAllContexts(setter3, obj, false); |
252 | 301 |
253 // ----------------------------------------------------------------------------- | 302 // ----------------------------------------------------------------------------- |
254 // Test setter with too few arguments with a return in all contexts. | 303 // Test setter with too few arguments with a return in all contexts. |
255 | 304 |
256 function setter4() { | 305 function setter4() { |
257 assertSame(obj, this); | 306 assertSame(obj, this); |
258 accessorCallCount++; | 307 accessorCallCount++; |
259 forceDeopt + 1; | 308 forceDeopt.deopt; |
260 setterValue = setterArgument; | 309 setterValue = setterArgument; |
261 return 2000000; | 310 return 2000000; |
262 } | 311 } |
263 | 312 |
264 function ConstrS4() { } | 313 function ConstrS4() { } |
265 obj = Object.defineProperty(new ConstrS4(), "setterProperty", { set: setter4 }); | 314 obj = Object.defineProperty(new ConstrS4(), "setterProperty", { set: setter4 }); |
266 TestSetterInAllContexts(obj); | 315 TestSetterInAllContexts(setter4, obj, false); |
267 obj = Object.create(obj); | 316 obj = Object.create(obj); |
268 TestSetterInAllContexts(obj); | 317 TestSetterInAllContexts(setter4, obj, false); |
269 | 318 |
270 // ----------------------------------------------------------------------------- | 319 // ----------------------------------------------------------------------------- |
271 // Test setter with too many arguments without a return in all contexts. | 320 // Test setter with too many arguments without a return in all contexts. |
272 | 321 |
273 function setter5(value, foo) { | 322 function setter5(value, foo) { |
274 assertSame(obj, this); | 323 assertSame(obj, this); |
275 assertEquals(undefined, foo); | 324 assertEquals(undefined, foo); |
276 accessorCallCount++; | 325 accessorCallCount++; |
277 forceDeopt + 1; | 326 forceDeopt.deopt; |
278 setterValue = value; | 327 setterValue = value; |
279 } | 328 } |
280 | 329 |
281 function ConstrS5() { } | 330 function ConstrS5() { } |
282 obj = Object.defineProperty(new ConstrS5(), "setterProperty", { set: setter5 }); | 331 obj = Object.defineProperty(new ConstrS5(), "setterProperty", { set: setter5 }); |
283 TestSetterInAllContexts(obj); | 332 TestSetterInAllContexts(setter5, obj, false); |
284 obj = Object.create(obj); | 333 obj = Object.create(obj); |
285 TestSetterInAllContexts(obj); | 334 TestSetterInAllContexts(setter5, obj, false); |
286 | 335 |
287 // ----------------------------------------------------------------------------- | 336 // ----------------------------------------------------------------------------- |
288 // Test setter with too many arguments with a return in all contexts. | 337 // Test setter with too many arguments with a return in all contexts. |
289 | 338 |
290 function setter6(value, foo) { | 339 function setter6(value, foo) { |
291 assertSame(obj, this); | 340 assertSame(obj, this); |
292 assertEquals(undefined, foo); | 341 assertEquals(undefined, foo); |
293 accessorCallCount++; | 342 accessorCallCount++; |
294 forceDeopt + 1; | 343 forceDeopt.deopt; |
295 setterValue = value; | 344 setterValue = value; |
296 return 3000000; | 345 return 3000000; |
297 } | 346 } |
298 | 347 |
299 function ConstrS6() { } | 348 function ConstrS6() { } |
300 obj = Object.defineProperty(new ConstrS6(), "setterProperty", { set: setter6 }); | 349 obj = Object.defineProperty(new ConstrS6(), "setterProperty", { set: setter6 }); |
301 TestSetterInAllContexts(obj); | 350 TestSetterInAllContexts(setter6, obj, false); |
302 obj = Object.create(obj); | 351 obj = Object.create(obj); |
303 TestSetterInAllContexts(obj); | 352 TestSetterInAllContexts(setter6, obj, false); |
| 353 |
| 354 // ----------------------------------------------------------------------------- |
| 355 // Test setter which throws from optimized code. |
| 356 |
| 357 function setter7(value) { |
| 358 accessorCallCount++; |
| 359 forceDeopt.deopt; |
| 360 if (accessorCallCount == 4) { 123 in null; } |
| 361 setterValue = value; |
| 362 } |
| 363 |
| 364 function ConstrS7() { } |
| 365 obj = Object.defineProperty(new ConstrS7(), "setterProperty", { set: setter7 }); |
| 366 TestSetterInAllContexts(setter7, obj, true); |
| 367 obj = Object.create(obj); |
| 368 TestSetterInAllContexts(setter7, obj, true); |
OLD | NEW |