OLD | NEW |
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return reinterpret_cast<uint8_t*>(new_ptr); | 155 return reinterpret_cast<uint8_t*>(new_ptr); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 static void SendIsolateServiceMessage(Dart_NativeArguments args) { | 159 static void SendIsolateServiceMessage(Dart_NativeArguments args) { |
160 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 160 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
161 Isolate* isolate = arguments->isolate(); | 161 Isolate* isolate = arguments->isolate(); |
162 StackZone zone(isolate); | 162 StackZone zone(isolate); |
163 HANDLESCOPE(isolate); | 163 HANDLESCOPE(isolate); |
164 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); | 164 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, sp, arguments->NativeArgAt(0)); |
165 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(1)); | 165 GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(1)); |
| 166 |
| 167 // Set the type of the OOB message. |
| 168 message.SetAt(0, Smi::Handle(isolate, Smi::New(Message::kServiceOOBMsg))); |
166 | 169 |
167 // Serialize message. | 170 // Serialize message. |
168 uint8_t* data = NULL; | 171 uint8_t* data = NULL; |
169 MessageWriter writer(&data, &allocator); | 172 MessageWriter writer(&data, &allocator); |
170 writer.WriteMessage(message); | 173 writer.WriteMessage(message); |
171 | 174 |
172 // TODO(turnidge): Throw an exception when the return value is false? | 175 // TODO(turnidge): Throw an exception when the return value is false? |
173 PortMap::PostMessage(new Message(sp.Id(), data, writer.BytesWritten(), | 176 PortMap::PostMessage(new Message(sp.Id(), data, writer.BytesWritten(), |
174 Message::kOOBPriority)); | 177 Message::kOOBPriority)); |
175 } | 178 } |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 jsobj.AddProperty("id", ""); | 615 jsobj.AddProperty("id", ""); |
613 jsobj.AddProperty("kind", kind); | 616 jsobj.AddProperty("kind", kind); |
614 jsobj.AddProperty("message", buffer); | 617 jsobj.AddProperty("message", buffer); |
615 PrintArgumentsAndOptions(jsobj, js); | 618 PrintArgumentsAndOptions(jsobj, js); |
616 } | 619 } |
617 | 620 |
618 | 621 |
619 void Service::HandleIsolateMessage(Isolate* isolate, const Instance& msg) { | 622 void Service::HandleIsolateMessage(Isolate* isolate, const Instance& msg) { |
620 ASSERT(isolate != NULL); | 623 ASSERT(isolate != NULL); |
621 ASSERT(!msg.IsNull()); | 624 ASSERT(!msg.IsNull()); |
622 ASSERT(msg.IsGrowableObjectArray()); | 625 ASSERT(msg.IsArray()); |
623 | 626 |
624 { | 627 { |
625 StackZone zone(isolate); | 628 StackZone zone(isolate); |
626 HANDLESCOPE(isolate); | 629 HANDLESCOPE(isolate); |
627 | 630 |
628 const GrowableObjectArray& message = GrowableObjectArray::Cast(msg); | 631 const Array& message = Array::Cast(msg); |
629 // Message is a list with four entries. | 632 // Message is a list with five entries. |
630 ASSERT(message.Length() == 4); | 633 ASSERT(message.Length() == 5); |
631 | 634 |
632 Instance& reply_port = Instance::Handle(isolate); | 635 Instance& reply_port = Instance::Handle(isolate); |
633 GrowableObjectArray& path = GrowableObjectArray::Handle(isolate); | 636 GrowableObjectArray& path = GrowableObjectArray::Handle(isolate); |
634 GrowableObjectArray& option_keys = GrowableObjectArray::Handle(isolate); | 637 Array& option_keys = Array::Handle(isolate); |
635 GrowableObjectArray& option_values = GrowableObjectArray::Handle(isolate); | 638 Array& option_values = Array::Handle(isolate); |
636 reply_port ^= message.At(0); | 639 reply_port ^= message.At(1); |
637 path ^= message.At(1); | 640 path ^= message.At(2); |
638 option_keys ^= message.At(2); | 641 option_keys ^= message.At(3); |
639 option_values ^= message.At(3); | 642 option_values ^= message.At(4); |
640 | 643 |
641 ASSERT(!path.IsNull()); | 644 ASSERT(!path.IsNull()); |
642 ASSERT(!option_keys.IsNull()); | 645 ASSERT(!option_keys.IsNull()); |
643 ASSERT(!option_values.IsNull()); | 646 ASSERT(!option_values.IsNull()); |
644 // Same number of option keys as values. | 647 // Same number of option keys as values. |
645 ASSERT(option_keys.Length() == option_values.Length()); | 648 ASSERT(option_keys.Length() == option_values.Length()); |
646 | 649 |
647 if (!reply_port.IsSendPort()) { | 650 if (!reply_port.IsSendPort()) { |
648 FATAL("SendPort expected."); | 651 FATAL("SendPort expected."); |
649 } | 652 } |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 if (FLAG_trace_service) { | 1829 if (FLAG_trace_service) { |
1827 OS::Print("Service has no isolate message handler for <%s>\n", command); | 1830 OS::Print("Service has no isolate message handler for <%s>\n", command); |
1828 } | 1831 } |
1829 return NULL; | 1832 return NULL; |
1830 } | 1833 } |
1831 | 1834 |
1832 | 1835 |
1833 void Service::HandleRootMessage(const Instance& msg) { | 1836 void Service::HandleRootMessage(const Instance& msg) { |
1834 Isolate* isolate = Isolate::Current(); | 1837 Isolate* isolate = Isolate::Current(); |
1835 ASSERT(!msg.IsNull()); | 1838 ASSERT(!msg.IsNull()); |
1836 ASSERT(msg.IsGrowableObjectArray()); | 1839 ASSERT(msg.IsArray()); |
1837 | 1840 |
1838 { | 1841 { |
1839 StackZone zone(isolate); | 1842 StackZone zone(isolate); |
1840 HANDLESCOPE(isolate); | 1843 HANDLESCOPE(isolate); |
1841 | 1844 |
1842 const GrowableObjectArray& message = GrowableObjectArray::Cast(msg); | 1845 const Array& message = Array::Cast(msg); |
1843 // Message is a list with four entries. | 1846 // Message is a list with five entries. |
1844 ASSERT(message.Length() == 4); | 1847 ASSERT(message.Length() == 5); |
1845 | 1848 |
1846 Instance& reply_port = Instance::Handle(isolate); | 1849 Instance& reply_port = Instance::Handle(isolate); |
1847 GrowableObjectArray& path = GrowableObjectArray::Handle(isolate); | 1850 GrowableObjectArray& path = GrowableObjectArray::Handle(isolate); |
1848 GrowableObjectArray& option_keys = GrowableObjectArray::Handle(isolate); | 1851 Array& option_keys = Array::Handle(isolate); |
1849 GrowableObjectArray& option_values = GrowableObjectArray::Handle(isolate); | 1852 Array& option_values = Array::Handle(isolate); |
1850 | 1853 |
1851 reply_port ^= message.At(0); | 1854 reply_port ^= message.At(1); |
1852 path ^= message.At(1); | 1855 path ^= message.At(2); |
1853 option_keys ^= message.At(2); | 1856 option_keys ^= message.At(3); |
1854 option_values ^= message.At(3); | 1857 option_values ^= message.At(4); |
1855 | 1858 |
1856 ASSERT(!path.IsNull()); | 1859 ASSERT(!path.IsNull()); |
1857 ASSERT(!option_keys.IsNull()); | 1860 ASSERT(!option_keys.IsNull()); |
1858 ASSERT(!option_values.IsNull()); | 1861 ASSERT(!option_values.IsNull()); |
1859 // Path always has at least one entry in it. | 1862 // Path always has at least one entry in it. |
1860 ASSERT(path.Length() > 0); | 1863 ASSERT(path.Length() > 0); |
1861 // Same number of option keys as values. | 1864 // Same number of option keys as values. |
1862 ASSERT(option_keys.Length() == option_values.Length()); | 1865 ASSERT(option_keys.Length() == option_values.Length()); |
1863 | 1866 |
1864 if (!reply_port.IsSendPort()) { | 1867 if (!reply_port.IsSendPort()) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 while (current != NULL) { | 2106 while (current != NULL) { |
2104 if (strcmp(name, current->name()) == 0) { | 2107 if (strcmp(name, current->name()) == 0) { |
2105 return current; | 2108 return current; |
2106 } | 2109 } |
2107 current = current->next(); | 2110 current = current->next(); |
2108 } | 2111 } |
2109 return NULL; | 2112 return NULL; |
2110 } | 2113 } |
2111 | 2114 |
2112 } // namespace dart | 2115 } // namespace dart |
OLD | NEW |