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

Side by Side Diff: runtime/bin/vmservice_impl.cc

Issue 93873015: - Remove the reply_port from the VM internal message object. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/lib/isolate.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "bin/vmservice_impl.h" 5 #include "bin/vmservice_impl.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return reinterpret_cast<uint8_t*>(new_ptr); 484 return reinterpret_cast<uint8_t*>(new_ptr);
485 } 485 }
486 486
487 487
488 static void SendServiceMessage(Dart_NativeArguments args) { 488 static void SendServiceMessage(Dart_NativeArguments args) {
489 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 489 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
490 Isolate* isolate = arguments->isolate(); 490 Isolate* isolate = arguments->isolate();
491 StackZone zone(isolate); 491 StackZone zone(isolate);
492 HANDLESCOPE(isolate); 492 HANDLESCOPE(isolate);
493 GET_NON_NULL_NATIVE_ARGUMENT(Instance, sp, arguments->NativeArgAt(0)); 493 GET_NON_NULL_NATIVE_ARGUMENT(Instance, sp, arguments->NativeArgAt(0));
494 GET_NON_NULL_NATIVE_ARGUMENT(Instance, rp, arguments->NativeArgAt(1)); 494 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(1));
495 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(2));
496 495
497 // Extract SendPort port id. 496 // Extract SendPort port id.
498 const Object& sp_id_obj = Object::Handle(DartLibraryCalls::PortGetId(sp)); 497 const Object& sp_id_obj = Object::Handle(DartLibraryCalls::PortGetId(sp));
499 if (sp_id_obj.IsError()) { 498 if (sp_id_obj.IsError()) {
500 Exceptions::PropagateError(Error::Cast(sp_id_obj)); 499 Exceptions::PropagateError(Error::Cast(sp_id_obj));
501 } 500 }
502 Integer& id = Integer::Handle(); 501 Integer& id = Integer::Handle();
503 id ^= sp_id_obj.raw(); 502 id ^= sp_id_obj.raw();
504 Dart_Port sp_id = static_cast<Dart_Port>(id.AsInt64Value()); 503 Dart_Port sp_id = static_cast<Dart_Port>(id.AsInt64Value());
505
506 // Extract ReceivePort port id.
507 const Object& rp_id_obj = Object::Handle(DartLibraryCalls::PortGetId(rp));
508 if (rp_id_obj.IsError()) {
509 Exceptions::PropagateError(Error::Cast(rp_id_obj));
510 }
511 ASSERT(rp_id_obj.IsSmi() || rp_id_obj.IsMint());
512 id ^= rp_id_obj.raw();
513 Dart_Port rp_id = static_cast<Dart_Port>(id.AsInt64Value());
514
515 // Both are valid ports.
516 ASSERT(sp_id != ILLEGAL_PORT); 504 ASSERT(sp_id != ILLEGAL_PORT);
517 ASSERT(rp_id != ILLEGAL_PORT);
518 505
519 // Serialize message. 506 // Serialize message.
520 uint8_t* data = NULL; 507 uint8_t* data = NULL;
521 MessageWriter writer(&data, &allocator); 508 MessageWriter writer(&data, &allocator);
522 writer.WriteMessage(message); 509 writer.WriteMessage(message);
523 510
524 // TODO(turnidge): Throw an exception when the return value is false? 511 // TODO(turnidge): Throw an exception when the return value is false?
525 PortMap::PostMessage(new Message(sp_id, rp_id, data, writer.BytesWritten(), 512 PortMap::PostMessage(new Message(sp_id, data, writer.BytesWritten(),
526 Message::kOOBPriority)); 513 Message::kOOBPriority));
527 } 514 }
528 515
529 516
530 struct VmServiceNativeEntry { 517 struct VmServiceNativeEntry {
531 const char* name; 518 const char* name;
532 int num_arguments; 519 int num_arguments;
533 Dart_NativeFunction function; 520 Dart_NativeFunction function;
534 }; 521 };
535 522
536 523
537 static VmServiceNativeEntry _VmServiceNativeEntries[] = { 524 static VmServiceNativeEntry _VmServiceNativeEntries[] = {
538 {"VMService_SendServiceMessage", 3, SendServiceMessage} 525 {"VMService_SendServiceMessage", 2, SendServiceMessage}
539 }; 526 };
540 527
541 528
542 static Dart_NativeFunction VmServiceNativeResolver(Dart_Handle name, 529 static Dart_NativeFunction VmServiceNativeResolver(Dart_Handle name,
543 int num_arguments) { 530 int num_arguments) {
544 const Object& obj = Object::Handle(Api::UnwrapHandle(name)); 531 const Object& obj = Object::Handle(Api::UnwrapHandle(name));
545 if (!obj.IsString()) { 532 if (!obj.IsString()) {
546 return NULL; 533 return NULL;
547 } 534 }
548 const char* function_name = obj.ToCString(); 535 const char* function_name = obj.ToCString();
549 ASSERT(function_name != NULL); 536 ASSERT(function_name != NULL);
550 intptr_t n = 537 intptr_t n =
551 sizeof(_VmServiceNativeEntries) / sizeof(_VmServiceNativeEntries[0]); 538 sizeof(_VmServiceNativeEntries) / sizeof(_VmServiceNativeEntries[0]);
552 for (intptr_t i = 0; i < n; i++) { 539 for (intptr_t i = 0; i < n; i++) {
553 VmServiceNativeEntry entry = _VmServiceNativeEntries[i]; 540 VmServiceNativeEntry entry = _VmServiceNativeEntries[i];
554 if (!strcmp(function_name, entry.name) && 541 if (!strcmp(function_name, entry.name) &&
555 (num_arguments == entry.num_arguments)) { 542 (num_arguments == entry.num_arguments)) {
556 return entry.function; 543 return entry.function;
557 } 544 }
558 } 545 }
559 return NULL; 546 return NULL;
560 } 547 }
561 548
562 } // namespace bin 549 } // namespace bin
563 } // namespace dart 550 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/vmservice.dart ('k') | runtime/lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698