OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 x: { get:getter, set:setter }, | 193 x: { get:getter, set:setter }, |
194 y: { get:getter, set:setter } | 194 y: { get:getter, set:setter } |
195 }); | 195 }); |
196 check(23, 42); check(23, 42); | 196 check(23, 42); check(23, 42); |
197 %OptimizeFunctionOnNextCall(check); | 197 %OptimizeFunctionOnNextCall(check); |
198 check(23, 42); check(23, 42); | 198 check(23, 42); check(23, 42); |
199 constructor.prototype = monkey; | 199 constructor.prototype = monkey; |
200 check(27, 27); check(27, 27); | 200 check(27, 27); check(27, 27); |
201 assertEquals(130, sum); | 201 assertEquals(130, sum); |
202 })(); | 202 })(); |
| 203 |
| 204 |
| 205 // Test OSR into a loop with captured objects. |
| 206 (function testOSR() { |
| 207 function constructor() { |
| 208 this.a = 23; |
| 209 } |
| 210 function osr1(length) { |
| 211 assertEquals(23, (new constructor()).a); |
| 212 var result = 0; |
| 213 for (var i = 0; i < length; i++) { |
| 214 result = (result + i) % 99; |
| 215 } |
| 216 return result; |
| 217 } |
| 218 function osr2(length) { |
| 219 var result = 0; |
| 220 for (var i = 0; i < length; i++) { |
| 221 result = (result + i) % 99; |
| 222 } |
| 223 assertEquals(23, (new constructor()).a); |
| 224 return result; |
| 225 } |
| 226 function osr3(length) { |
| 227 var result = 0; |
| 228 var o = new constructor(); |
| 229 for (var i = 0; i < length; i++) { |
| 230 result = (result + i) % 99; |
| 231 } |
| 232 assertEquals(23, o.a); |
| 233 return result; |
| 234 } |
| 235 function test(closure) { |
| 236 assertEquals(45, closure(10)); |
| 237 assertEquals(45, closure(10)); |
| 238 assertEquals(10, closure(50000)); |
| 239 } |
| 240 test(osr1); |
| 241 test(osr2); |
| 242 test(osr3); |
| 243 })(); |
OLD | NEW |