| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * The js.dart library provides simple JavaScript invocation from Dart that | 6 * The js.dart library provides simple JavaScript invocation from Dart that |
| 7 * works on both Dartium and on other modern browsers via Dart2JS. | 7 * works on both Dartium and on other modern browsers via Dart2JS. |
| 8 * | 8 * |
| 9 * It provides a model based on scoped [Proxy] objects. Proxies give Dart | 9 * It provides a model based on scoped [Proxy] objects. Proxies give Dart |
| 10 * code access to JavaScript objects, fields, and functions as well as the | 10 * code access to JavaScript objects, fields, and functions as well as the |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 726 } |
| 727 | 727 |
| 728 // Depth of current scope. Return 0 if no scope. | 728 // Depth of current scope. Return 0 if no scope. |
| 729 get _depth => _proxiedObjectTable._scopeIndices.length; | 729 get _depth => _proxiedObjectTable._scopeIndices.length; |
| 730 | 730 |
| 731 // If we are not already in a scope, enter one and register a | 731 // If we are not already in a scope, enter one and register a |
| 732 // corresponding exit once we return to the event loop. | 732 // corresponding exit once we return to the event loop. |
| 733 void _enterScopeIfNeeded() { | 733 void _enterScopeIfNeeded() { |
| 734 if (_depth == 0) { | 734 if (_depth == 0) { |
| 735 var depth = _enterScope(); | 735 var depth = _enterScope(); |
| 736 runAsync(() => _exitScope(depth)); | 736 scheduleMicrotask(() => _exitScope(depth)); |
| 737 } | 737 } |
| 738 } | 738 } |
| 739 | 739 |
| 740 /** | 740 /** |
| 741 * Executes the closure [f] within a scope. Any proxies created within this | 741 * Executes the closure [f] within a scope. Any proxies created within this |
| 742 * scope are invalidated afterward unless they are converted to a global proxy. | 742 * scope are invalidated afterward unless they are converted to a global proxy. |
| 743 */ | 743 */ |
| 744 scoped(f) { | 744 scoped(f) { |
| 745 var depth = _enterScope(); | 745 var depth = _enterScope(); |
| 746 try { | 746 try { |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 // debugging / profiling purposes. | 1389 // debugging / profiling purposes. |
| 1390 void _proxyDebug([String message = '']) { | 1390 void _proxyDebug([String message = '']) { |
| 1391 print('Proxy status $message:'); | 1391 print('Proxy status $message:'); |
| 1392 var dartLive = proxyCount(dartOnly: true); | 1392 var dartLive = proxyCount(dartOnly: true); |
| 1393 var dartTotal = proxyCount(dartOnly: true, all: true); | 1393 var dartTotal = proxyCount(dartOnly: true, all: true); |
| 1394 var jsLive = proxyCount(jsOnly: true); | 1394 var jsLive = proxyCount(jsOnly: true); |
| 1395 var jsTotal = proxyCount(jsOnly: true, all: true); | 1395 var jsTotal = proxyCount(jsOnly: true, all: true); |
| 1396 print(' Dart objects Live : $dartLive (out of $dartTotal ever allocated).'); | 1396 print(' Dart objects Live : $dartLive (out of $dartTotal ever allocated).'); |
| 1397 print(' JS objects Live : $jsLive (out of $jsTotal ever allocated).'); | 1397 print(' JS objects Live : $jsLive (out of $jsTotal ever allocated).'); |
| 1398 } | 1398 } |
| OLD | NEW |