| 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 --max-opt-count=100 | 28 // Flags: --allow-natives-syntax --inline-accessors |
| 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, obj, expected) { | 35 function TestInlinedGetter(context, expected) { |
| 36 forceDeopt = { deopt: 0 }; | 36 forceDeopt = 0; |
| 37 accessorCallCount = 0; | 37 accessorCallCount = 0; |
| 38 | 38 |
| 39 assertEquals(expected, context(obj)); | 39 assertEquals(expected, context()); |
| 40 assertEquals(1, accessorCallCount); | 40 assertEquals(1, accessorCallCount); |
| 41 | 41 |
| 42 assertEquals(expected, context(obj)); | 42 assertEquals(expected, context()); |
| 43 assertEquals(2, accessorCallCount); | 43 assertEquals(2, accessorCallCount); |
| 44 | 44 |
| 45 %OptimizeFunctionOnNextCall(context); | 45 %OptimizeFunctionOnNextCall(context); |
| 46 assertEquals(expected, context(obj)); | 46 assertEquals(expected, context()); |
| 47 assertEquals(3, accessorCallCount); | 47 assertEquals(3, accessorCallCount); |
| 48 | 48 |
| 49 forceDeopt = { /* empty*/ }; | 49 %DeoptimizeFunction(context); |
| 50 assertEquals(expected, context(obj)); | 50 %ClearFunctionTypeFeedback(context); |
| 51 assertEquals(4, accessorCallCount); | |
| 52 } | 51 } |
| 53 | 52 |
| 54 | 53 |
| 55 function value_context_for_getter(obj) { | 54 function TestGetterInAllContexts(obj, expected) { |
| 56 return obj.getterProperty; | 55 function value_context() { |
| 57 } | 56 return obj.getterProperty; |
| 57 } |
| 58 TestInlinedGetter(value_context, expected); |
| 58 | 59 |
| 59 function test_context_for_getter(obj) { | 60 function test_context() { |
| 60 if (obj.getterProperty) { | 61 if (obj.getterProperty) { |
| 61 return 111; | 62 return 111; |
| 62 } else { | 63 } else { |
| 63 return 222; | 64 return 222; |
| 65 } |
| 64 } | 66 } |
| 65 } | 67 TestInlinedGetter(test_context, expected ? 111 : 222); |
| 66 | 68 |
| 67 function effect_context_for_getter(obj) { | 69 function effect_context() { |
| 68 obj.getterProperty; | 70 obj.getterProperty; |
| 69 return 5678; | 71 return 5678; |
| 70 } | |
| 71 | |
| 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); | |
| 79 } | 72 } |
| 80 %DeoptimizeFunction(context); | 73 TestInlinedGetter(effect_context, 5678); |
| 81 %ClearFunctionTypeFeedback(context); | |
| 82 %ClearFunctionTypeFeedback(getter); | |
| 83 } | |
| 84 | |
| 85 function TestGetterInAllContexts(getter, obj, expected, expectException) { | |
| 86 TryGetter(value_context_for_getter, getter, obj, expected, expectException); | |
| 87 TryGetter(test_context_for_getter, getter, obj, expected ? 111 : 222, | |
| 88 expectException); | |
| 89 TryGetter(effect_context_for_getter, getter, obj, 5678, expectException); | |
| 90 } | 74 } |
| 91 | 75 |
| 92 // ----------------------------------------------------------------------------- | 76 // ----------------------------------------------------------------------------- |
| 93 // Test getter returning something 'true'ish in all contexts. | 77 // Test getter returning something 'true'ish in all contexts. |
| 94 | 78 |
| 95 function getter1() { | 79 function getter1() { |
| 96 assertSame(obj, this); | 80 assertSame(obj, this); |
| 97 accessorCallCount++; | 81 accessorCallCount++; |
| 98 forceDeopt.deopt; | 82 forceDeopt + 1; |
| 99 return 1234; | 83 return 1234; |
| 100 } | 84 } |
| 101 | 85 |
| 102 function ConstrG1() { } | 86 function ConstrG1() { } |
| 103 obj = Object.defineProperty(new ConstrG1(), "getterProperty", { get: getter1 }); | 87 obj = Object.defineProperty(new ConstrG1(), "getterProperty", { get: getter1 }); |
| 104 TestGetterInAllContexts(getter1, obj, 1234, false); | 88 TestGetterInAllContexts(obj, 1234); |
| 105 obj = Object.create(obj); | 89 obj = Object.create(obj); |
| 106 TestGetterInAllContexts(getter1, obj, 1234, false); | 90 TestGetterInAllContexts(obj, 1234); |
| 107 | 91 |
| 108 // ----------------------------------------------------------------------------- | 92 // ----------------------------------------------------------------------------- |
| 109 // Test getter returning false in all contexts. | 93 // Test getter returning false in all contexts. |
| 110 | 94 |
| 111 function getter2() { | 95 function getter2() { |
| 112 assertSame(obj, this); | 96 assertSame(obj, this); |
| 113 accessorCallCount++; | 97 accessorCallCount++; |
| 114 forceDeopt.deopt; | 98 forceDeopt + 1; |
| 115 return false; | 99 return false; |
| 116 } | 100 } |
| 117 | 101 |
| 118 function ConstrG2() { } | 102 function ConstrG2() { } |
| 119 obj = Object.defineProperty(new ConstrG2(), "getterProperty", { get: getter2 }); | 103 obj = Object.defineProperty(new ConstrG2(), "getterProperty", { get: getter2 }); |
| 120 TestGetterInAllContexts(getter2, obj, false, false); | 104 TestGetterInAllContexts(obj, false); |
| 121 obj = Object.create(obj); | 105 obj = Object.create(obj); |
| 122 TestGetterInAllContexts(getter2, obj, false, false); | 106 TestGetterInAllContexts(obj, false); |
| 123 | 107 |
| 124 // ----------------------------------------------------------------------------- | 108 // ----------------------------------------------------------------------------- |
| 125 // Test getter without a return in all contexts. | 109 // Test getter without a return in all contexts. |
| 126 | 110 |
| 127 function getter3() { | 111 function getter3() { |
| 128 assertSame(obj, this); | 112 assertSame(obj, this); |
| 129 accessorCallCount++; | 113 accessorCallCount++; |
| 130 forceDeopt.deopt; | 114 forceDeopt + 1; |
| 131 } | 115 } |
| 132 | 116 |
| 133 function ConstrG3() { } | 117 function ConstrG3() { } |
| 134 obj = Object.defineProperty(new ConstrG3(), "getterProperty", { get: getter3 }); | 118 obj = Object.defineProperty(new ConstrG3(), "getterProperty", { get: getter3 }); |
| 135 TestGetterInAllContexts(getter3, obj, undefined, false); | 119 TestGetterInAllContexts(obj, undefined); |
| 136 obj = Object.create(obj); | 120 obj = Object.create(obj); |
| 137 TestGetterInAllContexts(getter3, obj, undefined, false); | 121 TestGetterInAllContexts(obj, undefined); |
| 138 | 122 |
| 139 // ----------------------------------------------------------------------------- | 123 // ----------------------------------------------------------------------------- |
| 140 // Test getter with too many arguments without a return in all contexts. | 124 // Test getter with too many arguments without a return in all contexts. |
| 141 | 125 |
| 142 function getter4(a) { | 126 function getter4(a) { |
| 143 assertSame(obj, this); | 127 assertSame(obj, this); |
| 144 assertEquals(undefined, a); | 128 assertEquals(undefined, a); |
| 145 accessorCallCount++; | 129 accessorCallCount++; |
| 146 forceDeopt.deopt; | 130 forceDeopt + 1; |
| 147 } | 131 } |
| 148 | 132 |
| 149 function ConstrG4() { } | 133 function ConstrG4() { } |
| 150 obj = Object.defineProperty(new ConstrG4(), "getterProperty", { get: getter4 }); | 134 obj = Object.defineProperty(new ConstrG4(), "getterProperty", { get: getter4 }); |
| 151 TestGetterInAllContexts(getter4, obj, undefined, false); | 135 TestGetterInAllContexts(obj, undefined); |
| 152 obj = Object.create(obj); | 136 obj = Object.create(obj); |
| 153 TestGetterInAllContexts(getter4, obj, undefined, false); | 137 TestGetterInAllContexts(obj, undefined); |
| 154 | 138 |
| 155 // ----------------------------------------------------------------------------- | 139 // ----------------------------------------------------------------------------- |
| 156 // Test getter with too many arguments with a return in all contexts. | 140 // Test getter with too many arguments with a return in all contexts. |
| 157 | 141 |
| 158 function getter5(a) { | 142 function getter5(a) { |
| 159 assertSame(obj, this); | 143 assertSame(obj, this); |
| 160 assertEquals(undefined, a); | 144 assertEquals(undefined, a); |
| 161 accessorCallCount++; | 145 accessorCallCount++; |
| 162 forceDeopt.deopt; | 146 forceDeopt + 1; |
| 163 return 9876; | 147 return 9876; |
| 164 } | 148 } |
| 165 | 149 |
| 166 function ConstrG5() { } | 150 function ConstrG5() { } |
| 167 obj = Object.defineProperty(new ConstrG5(), "getterProperty", { get: getter5 }); | 151 obj = Object.defineProperty(new ConstrG5(), "getterProperty", { get: getter5 }); |
| 168 TestGetterInAllContexts(getter5, obj, 9876, false); | 152 TestGetterInAllContexts(obj, 9876); |
| 169 obj = Object.create(obj); | 153 obj = Object.create(obj); |
| 170 TestGetterInAllContexts(getter5, obj, 9876, false); | 154 TestGetterInAllContexts(obj, 9876); |
| 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); | |
| 188 | 155 |
| 189 // ----------------------------------------------------------------------------- | 156 // ----------------------------------------------------------------------------- |
| 190 // Helpers for testing inlining of setters. | 157 // Helpers for testing inlining of setters. |
| 191 | 158 |
| 192 function TestInlinedSetter(context, obj, value, expected) { | 159 function TestInlinedSetter(context, value, expected) { |
| 193 forceDeopt = { deopt: 0 }; | 160 forceDeopt = 0; |
| 194 accessorCallCount = 0; | 161 accessorCallCount = 0; |
| 195 setterArgument = value; | 162 setterArgument = value; |
| 196 | 163 |
| 197 assertEquals(expected, context(obj, value)); | 164 assertEquals(expected, context(value)); |
| 198 assertEquals(value, setterValue); | 165 assertEquals(value, setterValue); |
| 199 assertEquals(1, accessorCallCount); | 166 assertEquals(1, accessorCallCount); |
| 200 | 167 |
| 201 assertEquals(expected, context(obj, value)); | 168 assertEquals(expected, context(value)); |
| 202 assertEquals(value, setterValue); | 169 assertEquals(value, setterValue); |
| 203 assertEquals(2, accessorCallCount); | 170 assertEquals(2, accessorCallCount); |
| 204 | 171 |
| 205 %OptimizeFunctionOnNextCall(context); | 172 %OptimizeFunctionOnNextCall(context); |
| 206 assertEquals(expected, context(obj, value)); | 173 assertEquals(expected, context(value)); |
| 207 assertEquals(value, setterValue); | 174 assertEquals(value, setterValue); |
| 208 assertEquals(3, accessorCallCount); | 175 assertEquals(3, accessorCallCount); |
| 209 | 176 |
| 210 forceDeopt = { /* empty*/ }; | 177 %DeoptimizeFunction(context); |
| 211 assertEquals(expected, context(obj, value)); | 178 %ClearFunctionTypeFeedback(context); |
| 212 assertEquals(value, setterValue); | |
| 213 assertEquals(4, accessorCallCount); | |
| 214 } | 179 } |
| 215 | 180 |
| 216 function value_context_for_setter(obj, value) { | 181 function TestSetterInAllContexts(obj) { |
| 217 return obj.setterProperty = value; | 182 function value_context(value) { |
| 218 } | 183 return obj.setterProperty = value; |
| 184 } |
| 185 TestInlinedSetter(value_context, 111, 111); |
| 219 | 186 |
| 220 function test_context_for_setter(obj, value) { | 187 function test_context(value) { |
| 221 if (obj.setterProperty = value) { | 188 if (obj.setterProperty = value) { |
| 222 return 333; | 189 return 333; |
| 223 } else { | 190 } else { |
| 224 return 444; | 191 return 444; |
| 192 } |
| 225 } | 193 } |
| 226 } | 194 TestInlinedSetter(test_context, true, 333); |
| 195 TestInlinedSetter(test_context, false, 444); |
| 227 | 196 |
| 228 function effect_context_for_setter(obj, value) { | 197 function effect_context(value) { |
| 229 obj.setterProperty = value; | 198 obj.setterProperty = value; |
| 230 return 666; | 199 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 } | 200 } |
| 241 %DeoptimizeFunction(context); | 201 TestInlinedSetter(effect_context, 555, 666); |
| 242 %ClearFunctionTypeFeedback(context); | |
| 243 %ClearFunctionTypeFeedback(setter); | |
| 244 } | |
| 245 | |
| 246 function TestSetterInAllContexts(setter, obj, expectException) { | |
| 247 TrySetter(value_context_for_setter, setter, obj, expectException, 111, 111); | |
| 248 TrySetter(test_context_for_setter, setter, obj, expectException, true, 333); | |
| 249 TrySetter(test_context_for_setter, setter, obj, expectException, false, 444); | |
| 250 TrySetter(effect_context_for_setter, setter, obj, expectException, 555, 666); | |
| 251 } | 202 } |
| 252 | 203 |
| 253 // ----------------------------------------------------------------------------- | 204 // ----------------------------------------------------------------------------- |
| 254 // Test setter without a return in all contexts. | 205 // Test setter without a return in all contexts. |
| 255 | 206 |
| 256 function setter1(value) { | 207 function setter1(value) { |
| 257 assertSame(obj, this); | 208 assertSame(obj, this); |
| 258 accessorCallCount++; | 209 accessorCallCount++; |
| 259 forceDeopt.deopt; | 210 forceDeopt + 1; |
| 260 setterValue = value; | 211 setterValue = value; |
| 261 } | 212 } |
| 262 | 213 |
| 263 function ConstrS1() { } | 214 function ConstrS1() { } |
| 264 obj = Object.defineProperty(new ConstrS1(), "setterProperty", { set: setter1 }); | 215 obj = Object.defineProperty(new ConstrS1(), "setterProperty", { set: setter1 }); |
| 265 TestSetterInAllContexts(setter1, obj, false); | 216 TestSetterInAllContexts(obj); |
| 266 obj = Object.create(obj); | 217 obj = Object.create(obj); |
| 267 TestSetterInAllContexts(setter1, obj, false); | 218 TestSetterInAllContexts(obj); |
| 268 | 219 |
| 269 // ----------------------------------------------------------------------------- | 220 // ----------------------------------------------------------------------------- |
| 270 // Test setter returning something different than the RHS in all contexts. | 221 // Test setter returning something different than the RHS in all contexts. |
| 271 | 222 |
| 272 function setter2(value) { | 223 function setter2(value) { |
| 273 assertSame(obj, this); | 224 assertSame(obj, this); |
| 274 accessorCallCount++; | 225 accessorCallCount++; |
| 275 forceDeopt.deopt; | 226 forceDeopt + 1; |
| 276 setterValue = value; | 227 setterValue = value; |
| 277 return 1000000; | 228 return 1000000; |
| 278 } | 229 } |
| 279 | 230 |
| 280 function ConstrS2() { } | 231 function ConstrS2() { } |
| 281 obj = Object.defineProperty(new ConstrS2(), "setterProperty", { set: setter2 }); | 232 obj = Object.defineProperty(new ConstrS2(), "setterProperty", { set: setter2 }); |
| 282 TestSetterInAllContexts(setter2, obj, false); | 233 TestSetterInAllContexts(obj); |
| 283 obj = Object.create(obj); | 234 obj = Object.create(obj); |
| 284 TestSetterInAllContexts(setter2, obj, false); | 235 TestSetterInAllContexts(obj); |
| 285 | 236 |
| 286 // ----------------------------------------------------------------------------- | 237 // ----------------------------------------------------------------------------- |
| 287 // Test setter with too few arguments without a return in all contexts. | 238 // Test setter with too few arguments without a return in all contexts. |
| 288 | 239 |
| 289 function setter3() { | 240 function setter3() { |
| 290 assertSame(obj, this); | 241 assertSame(obj, this); |
| 291 accessorCallCount++; | 242 accessorCallCount++; |
| 292 forceDeopt.deopt; | 243 forceDeopt + 1; |
| 293 setterValue = setterArgument; | 244 setterValue = setterArgument; |
| 294 } | 245 } |
| 295 | 246 |
| 296 function ConstrS3() { } | 247 function ConstrS3() { } |
| 297 obj = Object.defineProperty(new ConstrS3(), "setterProperty", { set: setter3 }); | 248 obj = Object.defineProperty(new ConstrS3(), "setterProperty", { set: setter3 }); |
| 298 TestSetterInAllContexts(setter3, obj, false); | 249 TestSetterInAllContexts(obj); |
| 299 obj = Object.create(obj); | 250 obj = Object.create(obj); |
| 300 TestSetterInAllContexts(setter3, obj, false); | 251 TestSetterInAllContexts(obj); |
| 301 | 252 |
| 302 // ----------------------------------------------------------------------------- | 253 // ----------------------------------------------------------------------------- |
| 303 // Test setter with too few arguments with a return in all contexts. | 254 // Test setter with too few arguments with a return in all contexts. |
| 304 | 255 |
| 305 function setter4() { | 256 function setter4() { |
| 306 assertSame(obj, this); | 257 assertSame(obj, this); |
| 307 accessorCallCount++; | 258 accessorCallCount++; |
| 308 forceDeopt.deopt; | 259 forceDeopt + 1; |
| 309 setterValue = setterArgument; | 260 setterValue = setterArgument; |
| 310 return 2000000; | 261 return 2000000; |
| 311 } | 262 } |
| 312 | 263 |
| 313 function ConstrS4() { } | 264 function ConstrS4() { } |
| 314 obj = Object.defineProperty(new ConstrS4(), "setterProperty", { set: setter4 }); | 265 obj = Object.defineProperty(new ConstrS4(), "setterProperty", { set: setter4 }); |
| 315 TestSetterInAllContexts(setter4, obj, false); | 266 TestSetterInAllContexts(obj); |
| 316 obj = Object.create(obj); | 267 obj = Object.create(obj); |
| 317 TestSetterInAllContexts(setter4, obj, false); | 268 TestSetterInAllContexts(obj); |
| 318 | 269 |
| 319 // ----------------------------------------------------------------------------- | 270 // ----------------------------------------------------------------------------- |
| 320 // Test setter with too many arguments without a return in all contexts. | 271 // Test setter with too many arguments without a return in all contexts. |
| 321 | 272 |
| 322 function setter5(value, foo) { | 273 function setter5(value, foo) { |
| 323 assertSame(obj, this); | 274 assertSame(obj, this); |
| 324 assertEquals(undefined, foo); | 275 assertEquals(undefined, foo); |
| 325 accessorCallCount++; | 276 accessorCallCount++; |
| 326 forceDeopt.deopt; | 277 forceDeopt + 1; |
| 327 setterValue = value; | 278 setterValue = value; |
| 328 } | 279 } |
| 329 | 280 |
| 330 function ConstrS5() { } | 281 function ConstrS5() { } |
| 331 obj = Object.defineProperty(new ConstrS5(), "setterProperty", { set: setter5 }); | 282 obj = Object.defineProperty(new ConstrS5(), "setterProperty", { set: setter5 }); |
| 332 TestSetterInAllContexts(setter5, obj, false); | 283 TestSetterInAllContexts(obj); |
| 333 obj = Object.create(obj); | 284 obj = Object.create(obj); |
| 334 TestSetterInAllContexts(setter5, obj, false); | 285 TestSetterInAllContexts(obj); |
| 335 | 286 |
| 336 // ----------------------------------------------------------------------------- | 287 // ----------------------------------------------------------------------------- |
| 337 // Test setter with too many arguments with a return in all contexts. | 288 // Test setter with too many arguments with a return in all contexts. |
| 338 | 289 |
| 339 function setter6(value, foo) { | 290 function setter6(value, foo) { |
| 340 assertSame(obj, this); | 291 assertSame(obj, this); |
| 341 assertEquals(undefined, foo); | 292 assertEquals(undefined, foo); |
| 342 accessorCallCount++; | 293 accessorCallCount++; |
| 343 forceDeopt.deopt; | 294 forceDeopt + 1; |
| 344 setterValue = value; | 295 setterValue = value; |
| 345 return 3000000; | 296 return 3000000; |
| 346 } | 297 } |
| 347 | 298 |
| 348 function ConstrS6() { } | 299 function ConstrS6() { } |
| 349 obj = Object.defineProperty(new ConstrS6(), "setterProperty", { set: setter6 }); | 300 obj = Object.defineProperty(new ConstrS6(), "setterProperty", { set: setter6 }); |
| 350 TestSetterInAllContexts(setter6, obj, false); | 301 TestSetterInAllContexts(obj); |
| 351 obj = Object.create(obj); | 302 obj = Object.create(obj); |
| 352 TestSetterInAllContexts(setter6, obj, false); | 303 TestSetterInAllContexts(obj); |
| 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 |