OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.utilities.general; | 8 library engine.utilities.general; |
9 | 9 |
10 import 'dart:developer'; | 10 import 'dart:profiler'; |
11 | 11 |
12 /** | 12 /** |
13 * Jenkins hash function, optimized for small integers. | 13 * Jenkins hash function, optimized for small integers. |
14 * Borrowed from sdk/lib/math/jenkins_smi_hash.dart. | 14 * Borrowed from sdk/lib/math/jenkins_smi_hash.dart. |
15 */ | 15 */ |
16 class JenkinsSmiHash { | 16 class JenkinsSmiHash { |
17 static int combine(int hash, int value) { | 17 static int combine(int hash, int value) { |
18 hash = 0x1fffffff & (hash + value); | 18 hash = 0x1fffffff & (hash + value); |
19 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); | 19 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); |
20 return hash ^ (hash >> 6); | 20 return hash ^ (hash >> 6); |
21 } | 21 } |
22 | 22 |
23 static int finish(int hash) { | 23 static int finish(int hash) { |
24 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 24 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
25 hash = hash ^ (hash >> 11); | 25 hash = hash ^ (hash >> 11); |
26 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 26 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
27 } | 27 } |
28 | 28 |
29 static int hash2(a, b) => finish(combine(combine(0, a), b)); | 29 static int hash2(a, b) => finish(combine(combine(0, a), b)); |
30 | 30 |
31 static int hash4(a, b, c, d) => | 31 static int hash4(a, b, c, d) => |
32 finish(combine(combine(combine(combine(0, a), b), c), d)); | 32 finish(combine(combine(combine(combine(0, a), b), c), d)); |
33 } | 33 } |
34 | 34 |
35 /** | 35 /** |
36 * Helper class for gathering performance statistics. This class is modeled on | 36 * Helper class for gathering performance statistics. This class is modeled on |
37 * the UserTag class in dart:developer so that it can interoperate easily with | 37 * the UserTag class in dart:profiler so that it can interoperate easily with |
38 * it. | 38 * it. |
39 */ | 39 */ |
40 abstract class PerformanceTag { | 40 abstract class PerformanceTag { |
41 /** | 41 /** |
42 * Return a list of all [PerformanceTag]s which have been created. | 42 * Return a list of all [PerformanceTag]s which have been created. |
43 */ | 43 */ |
44 static List<PerformanceTag> get all => _PerformanceTagImpl.all.toList(); | 44 static List<PerformanceTag> get all => _PerformanceTagImpl.all.toList(); |
45 | 45 |
46 /** | 46 /** |
47 * Return the current [PerformanceTag] for the isolate. | 47 * Return the current [PerformanceTag] for the isolate. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 makeCurrentWhile(f()) { | 147 makeCurrentWhile(f()) { |
148 PerformanceTag prevTag = makeCurrent(); | 148 PerformanceTag prevTag = makeCurrent(); |
149 try { | 149 try { |
150 return f(); | 150 return f(); |
151 } finally { | 151 } finally { |
152 prevTag.makeCurrent(); | 152 prevTag.makeCurrent(); |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
OLD | NEW |