Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1000)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11417110: Let stopwatch use window.performance.now when available. Fix for: http://code.google.com/p/dart/iss… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address lasse and peter's comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 part 'constant_map.dart'; 9 part 'constant_map.dart';
10 part 'native_helper.dart'; 10 part 'native_helper.dart';
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if ((length is !int) || (length < 0)) { 528 if ((length is !int) || (length < 0)) {
529 throw new ArgumentError(length); 529 throw new ArgumentError(length);
530 } 530 }
531 var result = JS('=List', r'new Array(#)', length); 531 var result = JS('=List', r'new Array(#)', length);
532 JS('void', r'#.fixed$length = #', result, true); 532 JS('void', r'#.fixed$length = #', result, true);
533 return result; 533 return result;
534 } 534 }
535 535
536 static num dateNow() => JS('num', r'Date.now()'); 536 static num dateNow() => JS('num', r'Date.now()');
537 537
538 static num numMicroseconds() {
539 if (JS('bool', 'typeof window != "undefined" && window !== null')) {
540 var performance = JS('var', 'window.performance');
541 if (performance != null &&
542 JS('bool', 'typeof #.webkitNow == "function"', performance)) {
543 return JS('num', '#.webkitNow()', performance);
544 }
545 }
546 return 1000 * dateNow();
547 }
548
538 // This is to avoid stack overflows due to very large argument arrays in 549 // This is to avoid stack overflows due to very large argument arrays in
539 // apply(). It fixes http://dartbug.com/6919 550 // apply(). It fixes http://dartbug.com/6919
540 static String _fromCharCodeApply(List<int> array) { 551 static String _fromCharCodeApply(List<int> array) {
541 String result = ""; 552 String result = "";
542 const kMaxApply = 500; 553 const kMaxApply = 500;
543 int end = array.length; 554 int end = array.length;
544 for (var i = 0; i < end; i += kMaxApply) { 555 for (var i = 0; i < end; i += kMaxApply) {
545 var subarray; 556 var subarray;
546 if (end <= kMaxApply) { 557 if (end <= kMaxApply) {
547 subarray = array; 558 subarray = array;
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 var argument = typeInfo[i]; 1603 var argument = typeInfo[i];
1593 if (argument == null) { 1604 if (argument == null) {
1594 argument = 'dynamic'; 1605 argument = 'dynamic';
1595 } 1606 }
1596 arguments.add(argument); 1607 arguments.add(argument);
1597 } 1608 }
1598 return '$className<$arguments>'; 1609 return '$className<$arguments>';
1599 } 1610 }
1600 1611
1601 createRuntimeType(String name) => new TypeImpl(name); 1612 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698