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

Side by Side Diff: runtime/lib/isolate.cc

Issue 778983002: - Implement hashCode and == for Capability. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « no previous file | runtime/lib/isolate_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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 30
31 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) { 31 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) {
32 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); 32 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull());
33 uint64_t id = isolate->random()->NextUInt64(); 33 uint64_t id = isolate->random()->NextUInt64();
34 return Capability::New(id); 34 return Capability::New(id);
35 } 35 }
36 36
37 37
38 DEFINE_NATIVE_ENTRY(CapabilityImpl_equals, 2) {
39 GET_NON_NULL_NATIVE_ARGUMENT(Capability, recv, arguments->NativeArgAt(0));
40 GET_NON_NULL_NATIVE_ARGUMENT(Capability, other, arguments->NativeArgAt(1));
41 return (recv.Id() == other.Id()) ? Bool::True().raw() : Bool::False().raw();
42 }
43
44
45 DEFINE_NATIVE_ENTRY(CapabilityImpl_get_hashcode, 1) {
46 GET_NON_NULL_NATIVE_ARGUMENT(Capability, cap, arguments->NativeArgAt(0));
47 int64_t id = cap.Id();
48 int32_t hi = static_cast<int32_t>(id >> 32);
49 int32_t lo = static_cast<int32_t>(id);
50 int32_t hash = (hi ^ lo) & kSmiMax;
51 return Smi::New(hash);
52 }
53
54
38 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) { 55 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_factory, 1) {
39 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); 56 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull());
40 Dart_Port port_id = 57 Dart_Port port_id =
41 PortMap::CreatePort(arguments->isolate()->message_handler()); 58 PortMap::CreatePort(arguments->isolate()->message_handler());
42 return ReceivePort::New(port_id, false /* not control port */); 59 return ReceivePort::New(port_id, false /* not control port */);
43 } 60 }
44 61
45 62
46 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) { 63 DEFINE_NATIVE_ENTRY(RawReceivePortImpl_get_id, 1) {
47 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0)); 64 GET_NON_NULL_NATIVE_ARGUMENT(ReceivePort, port, arguments->NativeArgAt(0));
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 MessageWriter writer(&data, &allocator); 278 MessageWriter writer(&data, &allocator);
262 writer.WriteMessage(msg); 279 writer.WriteMessage(msg);
263 280
264 PortMap::PostMessage(new Message(port.Id(), 281 PortMap::PostMessage(new Message(port.Id(),
265 data, writer.BytesWritten(), 282 data, writer.BytesWritten(),
266 Message::kOOBPriority)); 283 Message::kOOBPriority));
267 return Object::null(); 284 return Object::null();
268 } 285 }
269 286
270 } // namespace dart 287 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698