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

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: fix return statement 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
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 var theWindow = JS('var', 'window');
Lasse Reichstein Nielsen 2012/11/22 11:26:48 This read will throw if 'window' is not there. Con
ahe 2012/11/22 12:54:46 You don't have to call the variable theWindow. We
540 if (theWindow != null) {
541 var performance = JS('var', 'window.performance');
542 if (performance != null &&
543 JS('bool', 'typeof #.webkitNow == "function"', performance)) {
544 return JS('num', '#.webkitNow()', performance);
545 }
546 }
547 return 1000 * dateNow();
548 }
549
538 static String stringFromCharCodes(charCodes) { 550 static String stringFromCharCodes(charCodes) {
539 for (var i in charCodes) { 551 for (var i in charCodes) {
540 if (i is !int) throw new ArgumentError(i); 552 if (i is !int) throw new ArgumentError(i);
541 } 553 }
542 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes); 554 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes);
543 } 555 }
544 556
545 static String getTimeZoneName(receiver) { 557 static String getTimeZoneName(receiver) {
546 // When calling toString on a Date it will emit the timezone in parenthesis. 558 // When calling toString on a Date it will emit the timezone in parenthesis.
547 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)". 559 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 return typeName == other.typeName; 1548 return typeName == other.typeName;
1537 } 1549 }
1538 } 1550 }
1539 1551
1540 String getRuntimeTypeString(var object) { 1552 String getRuntimeTypeString(var object) {
1541 var typeInfo = JS('var', r'#.builtin$typeInfo', object); 1553 var typeInfo = JS('var', r'#.builtin$typeInfo', object);
1542 return JS('String', r'#.runtimeType', typeInfo); 1554 return JS('String', r'#.runtimeType', typeInfo);
1543 } 1555 }
1544 1556
1545 createRuntimeType(String name) => new TypeImpl(name); 1557 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698