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

Side by Side Diff: runtime/lib/object_patch.dart

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « runtime/lib/null_patch.dart ('k') | runtime/lib/print_patch.dart » ('j') | 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 @patch 5 @patch class Object {
6 class Object { 6
7 // The VM has its own implementation of equals. 7 // The VM has its own implementation of equals.
8 @patch 8 @patch bool operator ==(other) native "Object_equals";
9 bool operator ==(other) native "Object_equals";
10 9
11 // Helpers used to implement hashCode. If a hashCode is used, we remember it 10 // Helpers used to implement hashCode. If a hashCode is used, we remember it
12 // in a weak table in the VM. A new hashCode value is calculated using a 11 // in a weak table in the VM. A new hashCode value is calculated using a
13 // number generator. 12 // number generator.
14 static final _hashCodeRnd = new Random(); 13 static final _hashCodeRnd = new Random();
15 14
16 static _getHash(obj) native "Object_getHash"; 15 static _getHash(obj) native "Object_getHash";
17 static _setHash(obj, hash) native "Object_setHash"; 16 static _setHash(obj, hash) native "Object_setHash";
18 17
19 // Shared static implentation for hashCode and _identityHashCode. 18 // Shared static implentation for hashCode and _identityHashCode.
20 static int _objectHashCode(obj) { 19 static int _objectHashCode(obj) {
21 var result = _getHash(obj); 20 var result = _getHash(obj);
22 if (result == 0) { 21 if (result == 0) {
23 // We want the hash to be a Smi value greater than 0. 22 // We want the hash to be a Smi value greater than 0.
24 result = _hashCodeRnd.nextInt(0x40000000); 23 result = _hashCodeRnd.nextInt(0x40000000);
25 while (result == 0) { 24 while (result == 0) {
26 result = _hashCodeRnd.nextInt(0x40000000); 25 result = _hashCodeRnd.nextInt(0x40000000);
27 } 26 }
28 _setHash(obj, result); 27 _setHash(obj, result);
29 } 28 }
30 return result; 29 return result;
31 } 30 }
32 31
33 @patch 32 @patch int get hashCode => _objectHashCode(this);
34 int get hashCode => _objectHashCode(this);
35 int get _identityHashCode => _objectHashCode(this); 33 int get _identityHashCode => _objectHashCode(this);
36 34
37 @patch 35 @patch String toString() native "Object_toString";
38 String toString() native "Object_toString";
39 // A statically dispatched version of Object.toString. 36 // A statically dispatched version of Object.toString.
40 static String _toString(obj) native "Object_toString"; 37 static String _toString(obj) native "Object_toString";
41 38
42 _noSuchMethod(bool isMethod, String memberName, int type, List arguments, 39 _noSuchMethod(bool isMethod,
43 Map<String, dynamic> namedArguments) native "Object_noSuchMethod"; 40 String memberName,
41 int type,
42 List arguments,
43 Map<String, dynamic> namedArguments)
44 native "Object_noSuchMethod";
44 45
45 @patch 46 @patch dynamic noSuchMethod(Invocation invocation) {
46 dynamic noSuchMethod(Invocation invocation) { 47 return _noSuchMethod(invocation.isMethod,
47 return _noSuchMethod( 48 internal.Symbol.getName(invocation.memberName),
48 invocation.isMethod, 49 invocation._type,
49 internal.Symbol.getName(invocation.memberName), 50 invocation.positionalArguments,
50 invocation._type, 51 _symbolMapToStringMap(invocation.namedArguments));
51 invocation.positionalArguments,
52 _symbolMapToStringMap(invocation.namedArguments));
53 } 52 }
54 53
55 @patch 54 @patch Type get runtimeType native "Object_runtimeType";
56 Type get runtimeType native "Object_runtimeType";
57 55
58 static bool _haveSameRuntimeType(a, b) native "Object_haveSameRuntimeType"; 56 static bool _haveSameRuntimeType(a, b) native "Object_haveSameRuntimeType";
59 57
60 // Call this function instead of inlining instanceof, thus collecting 58 // Call this function instead of inlining instanceof, thus collecting
61 // type feedback and reducing code size of unoptimized code. 59 // type feedback and reducing code size of unoptimized code.
62 bool _instanceOf(instantiator_type_arguments, type) 60 bool _instanceOf(instantiator_type_arguments, type)
63 native "Object_instanceOf"; 61 native "Object_instanceOf";
64 62
65 // Group of functions for implementing fast simple instance of. 63 // Group of functions for implementing fast simple instance of.
66 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf"; 64 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf";
67 bool _simpleInstanceOfTrue(type) => true; 65 bool _simpleInstanceOfTrue(type) => true;
68 bool _simpleInstanceOfFalse(type) => false; 66 bool _simpleInstanceOfFalse(type) => false;
69 67
70 // Call this function instead of inlining 'as', thus collecting type 68 // Call this function instead of inlining 'as', thus collecting type
71 // feedback. Returns receiver. 69 // feedback. Returns receiver.
72 _as(instantiator_type_arguments, type) native "Object_as"; 70 _as(instantiator_type_arguments, type) native "Object_as";
73 71
74 static _symbolMapToStringMap(Map<Symbol, dynamic> map) { 72 static _symbolMapToStringMap(Map<Symbol, dynamic> map) {
75 var result = new Map<String, dynamic>(); 73 var result = new Map<String, dynamic>();
76 map.forEach((Symbol key, value) { 74 map.forEach((Symbol key, value) {
77 result[internal.Symbol.getName(key)] = value; 75 result[internal.Symbol.getName(key)] = value;
78 }); 76 });
79 return result; 77 return result;
80 } 78 }
81 } 79 }
OLDNEW
« no previous file with comments | « runtime/lib/null_patch.dart ('k') | runtime/lib/print_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698