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