| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 var sentinelUndefined = {}; | 383 var sentinelUndefined = {}; |
| 384 var sentinelInProgress = {}; | 384 var sentinelInProgress = {}; |
| 385 prototype[fieldName] = sentinelUndefined; | 385 prototype[fieldName] = sentinelUndefined; |
| 386 prototype[getterName] = function() { | 386 prototype[getterName] = function() { |
| 387 var result = $isolate[fieldName]; | 387 var result = $isolate[fieldName]; |
| 388 try { | 388 try { |
| 389 if (result === sentinelUndefined) { | 389 if (result === sentinelUndefined) { |
| 390 $isolate[fieldName] = sentinelInProgress; | 390 $isolate[fieldName] = sentinelInProgress; |
| 391 try { | 391 try { |
| 392 result = $isolate[fieldName] = lazyValue(); | 392 result = $isolate[fieldName] = lazyValue(); |
| 393 } catch (e) { | 393 } finally { |
| 394 if ($isolate[fieldName] === sentinelInProgress) { | 394 """ // Use try-finally, not try-catch/throw as it destroys the stack trace. |
| 395 $isolate[fieldName] = null; | 395 """ |
| 396 if (result === sentinelUndefined) { |
| 397 if ($isolate[fieldName] === sentinelInProgress) { |
| 398 $isolate[fieldName] = null; |
| 399 } |
| 396 } | 400 } |
| 397 throw e; | |
| 398 } | 401 } |
| 399 } else if (result === sentinelInProgress) { | 402 } else if (result === sentinelInProgress) { |
| 400 $cyclicThrow(staticName); | 403 $cyclicThrow(staticName); |
| 401 } | 404 } |
| 402 return result; | 405 return result; |
| 403 } finally { | 406 } finally { |
| 404 $isolate[getterName] = getter; | 407 $isolate[getterName] = getter; |
| 405 } | 408 } |
| 406 };"""; | 409 };"""; |
| 407 } | 410 } |
| (...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2167 """; | 2170 """; |
| 2168 const String HOOKS_API_USAGE = """ | 2171 const String HOOKS_API_USAGE = """ |
| 2169 // The code supports the following hooks: | 2172 // The code supports the following hooks: |
| 2170 // dartPrint(message) - if this function is defined it is called | 2173 // dartPrint(message) - if this function is defined it is called |
| 2171 // instead of the Dart [print] method. | 2174 // instead of the Dart [print] method. |
| 2172 // dartMainRunner(main) - if this function is defined, the Dart [main] | 2175 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 2173 // method will not be invoked directly. | 2176 // method will not be invoked directly. |
| 2174 // Instead, a closure that will invoke [main] is | 2177 // Instead, a closure that will invoke [main] is |
| 2175 // passed to [dartMainRunner]. | 2178 // passed to [dartMainRunner]. |
| 2176 """; | 2179 """; |
| OLD | NEW |