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

Side by Side Diff: runtime/vm/service.cc

Issue 834233003: Fix for issue 21398 (only send "literal like" objects across isolates spawned using spawnURI (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.h » ('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 "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 StackZone zone(isolate); 221 StackZone zone(isolate);
222 HANDLESCOPE(isolate); 222 HANDLESCOPE(isolate);
223 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); 223 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0));
224 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(1)); 224 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(1));
225 225
226 // Set the type of the OOB message. 226 // Set the type of the OOB message.
227 message.SetAt(0, Smi::Handle(isolate, Smi::New(Message::kServiceOOBMsg))); 227 message.SetAt(0, Smi::Handle(isolate, Smi::New(Message::kServiceOOBMsg)));
228 228
229 // Serialize message. 229 // Serialize message.
230 uint8_t* data = NULL; 230 uint8_t* data = NULL;
231 MessageWriter writer(&data, &allocator); 231 MessageWriter writer(&data, &allocator, false);
232 writer.WriteMessage(message); 232 writer.WriteMessage(message);
233 233
234 // TODO(turnidge): Throw an exception when the return value is false? 234 // TODO(turnidge): Throw an exception when the return value is false?
235 PortMap::PostMessage(new Message(sp.Id(), data, writer.BytesWritten(), 235 PortMap::PostMessage(new Message(sp.Id(), data, writer.BytesWritten(),
236 Message::kOOBPriority)); 236 Message::kOOBPriority));
237 } 237 }
238 238
239 239
240 static void SendRootServiceMessage(Dart_NativeArguments args) { 240 static void SendRootServiceMessage(Dart_NativeArguments args) {
241 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 241 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 ASSERT(isolate != NULL); 490 ASSERT(isolate != NULL);
491 HANDLESCOPE(isolate); 491 HANDLESCOPE(isolate);
492 const String& name = String::Handle(String::New(isolate->name())); 492 const String& name = String::Handle(String::New(isolate->name()));
493 ASSERT(!name.IsNull()); 493 ASSERT(!name.IsNull());
494 const Array& list = Array::Handle( 494 const Array& list = Array::Handle(
495 MakeServiceControlMessage(Dart_GetMainPortId(), 495 MakeServiceControlMessage(Dart_GetMainPortId(),
496 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID, 496 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID,
497 name)); 497 name));
498 ASSERT(!list.IsNull()); 498 ASSERT(!list.IsNull());
499 uint8_t* data = NULL; 499 uint8_t* data = NULL;
500 MessageWriter writer(&data, &allocator); 500 MessageWriter writer(&data, &allocator, false);
501 writer.WriteMessage(list); 501 writer.WriteMessage(list);
502 intptr_t len = writer.BytesWritten(); 502 intptr_t len = writer.BytesWritten();
503 if (FLAG_trace_service) { 503 if (FLAG_trace_service) {
504 OS::Print("Isolate %s %" Pd64 " registered with service \n", 504 OS::Print("Isolate %s %" Pd64 " registered with service \n",
505 name.ToCString(), 505 name.ToCString(),
506 Dart_GetMainPortId()); 506 Dart_GetMainPortId());
507 } 507 }
508 return PortMap::PostMessage( 508 return PortMap::PostMessage(
509 new Message(port_, data, len, Message::kNormalPriority)); 509 new Message(port_, data, len, Message::kNormalPriority));
510 } 510 }
511 511
512 512
513 bool Service::SendIsolateShutdownMessage() { 513 bool Service::SendIsolateShutdownMessage() {
514 if (!IsRunning()) { 514 if (!IsRunning()) {
515 return false; 515 return false;
516 } 516 }
517 Isolate* isolate = Isolate::Current(); 517 Isolate* isolate = Isolate::Current();
518 ASSERT(isolate != NULL); 518 ASSERT(isolate != NULL);
519 HANDLESCOPE(isolate); 519 HANDLESCOPE(isolate);
520 const String& name = String::Handle(String::New(isolate->name())); 520 const String& name = String::Handle(String::New(isolate->name()));
521 ASSERT(!name.IsNull()); 521 ASSERT(!name.IsNull());
522 const Array& list = Array::Handle( 522 const Array& list = Array::Handle(
523 MakeServiceControlMessage(Dart_GetMainPortId(), 523 MakeServiceControlMessage(Dart_GetMainPortId(),
524 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID, 524 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID,
525 name)); 525 name));
526 ASSERT(!list.IsNull()); 526 ASSERT(!list.IsNull());
527 uint8_t* data = NULL; 527 uint8_t* data = NULL;
528 MessageWriter writer(&data, &allocator); 528 MessageWriter writer(&data, &allocator, false);
529 writer.WriteMessage(list); 529 writer.WriteMessage(list);
530 intptr_t len = writer.BytesWritten(); 530 intptr_t len = writer.BytesWritten();
531 if (FLAG_trace_service) { 531 if (FLAG_trace_service) {
532 OS::Print("Isolate %s %" Pd64 " deregistered with service \n", 532 OS::Print("Isolate %s %" Pd64 " deregistered with service \n",
533 name.ToCString(), 533 name.ToCString(),
534 Dart_GetMainPortId()); 534 Dart_GetMainPortId());
535 } 535 }
536 return PortMap::PostMessage( 536 return PortMap::PostMessage(
537 new Message(port_, data, len, Message::kNormalPriority)); 537 new Message(port_, data, len, Message::kNormalPriority));
538 } 538 }
(...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 HANDLESCOPE(isolate); 2626 HANDLESCOPE(isolate);
2627 2627
2628 // Construct a list of the form [eventId, eventMessage]. 2628 // Construct a list of the form [eventId, eventMessage].
2629 const Array& list = Array::Handle(Array::New(2)); 2629 const Array& list = Array::Handle(Array::New(2));
2630 ASSERT(!list.IsNull()); 2630 ASSERT(!list.IsNull());
2631 list.SetAt(0, Integer::Handle(Integer::New(eventId))); 2631 list.SetAt(0, Integer::Handle(Integer::New(eventId)));
2632 list.SetAt(1, eventMessage); 2632 list.SetAt(1, eventMessage);
2633 2633
2634 // Push the event to port_. 2634 // Push the event to port_.
2635 uint8_t* data = NULL; 2635 uint8_t* data = NULL;
2636 MessageWriter writer(&data, &allocator); 2636 MessageWriter writer(&data, &allocator, false);
2637 writer.WriteMessage(list); 2637 writer.WriteMessage(list);
2638 intptr_t len = writer.BytesWritten(); 2638 intptr_t len = writer.BytesWritten();
2639 if (FLAG_trace_service) { 2639 if (FLAG_trace_service) {
2640 OS::Print("Pushing event of type %" Pd ", len %" Pd "\n", eventId, len); 2640 OS::Print("Pushing event of type %" Pd ", len %" Pd "\n", eventId, len);
2641 } 2641 }
2642 // TODO(turnidge): For now we ignore failure to send an event. Revisit? 2642 // TODO(turnidge): For now we ignore failure to send an event. Revisit?
2643 PortMap::PostMessage( 2643 PortMap::PostMessage(
2644 new Message(port_, data, len, Message::kNormalPriority)); 2644 new Message(port_, data, len, Message::kNormalPriority));
2645 } 2645 }
2646 2646
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 while (current != NULL) { 2780 while (current != NULL) {
2781 if (strcmp(name, current->name()) == 0) { 2781 if (strcmp(name, current->name()) == 0) {
2782 return current; 2782 return current;
2783 } 2783 }
2784 current = current->next(); 2784 current = current->next();
2785 } 2785 }
2786 return NULL; 2786 return NULL;
2787 } 2787 }
2788 2788
2789 } // namespace dart 2789 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698