| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/message.h" | 10 #include "vm/message.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 string_iterator ^= option_values.At(i); | 66 string_iterator ^= option_values.At(i); |
| 67 option_values_native[i] = | 67 option_values_native[i] = |
| 68 zone->MakeCopyOfString(string_iterator.ToCString()); | 68 zone->MakeCopyOfString(string_iterator.ToCString()); |
| 69 } | 69 } |
| 70 SetOptions(option_keys_native, option_values_native, option_keys.Length()); | 70 SetOptions(option_keys_native, option_values_native, option_keys.Length()); |
| 71 } | 71 } |
| 72 if (FLAG_trace_service) { | 72 if (FLAG_trace_service) { |
| 73 Isolate* isolate = Isolate::Current(); | 73 Isolate* isolate = Isolate::Current(); |
| 74 ASSERT(isolate != NULL); | 74 ASSERT(isolate != NULL); |
| 75 const char* isolate_name = isolate->name(); | 75 const char* isolate_name = isolate->name(); |
| 76 OS::Print("Isolate %s processing service request /%s", | 76 OS::Print("Isolate %s processing service request %s", |
| 77 isolate_name, command_); | 77 isolate_name, command_); |
| 78 for (intptr_t i = 1; i < num_arguments(); i++) { | 78 for (intptr_t i = 1; i < num_arguments(); i++) { |
| 79 OS::Print("/%s", GetArgument(i)); | 79 OS::Print("/%s", GetArgument(i)); |
| 80 } |
| 81 OS::Print("\n"); |
| 82 setup_time_micros_ = OS::GetCurrentTimeMicros(); |
| 83 } |
| 84 } |
| 85 |
| 86 |
| 87 void JSONStream::SetupNew(Zone* zone, |
| 88 Dart_Port reply_port, |
| 89 const String& method, |
| 90 const Array& option_keys, |
| 91 const Array& option_values) { |
| 92 set_reply_port(reply_port); |
| 93 command_ = method.ToCString(); |
| 94 |
| 95 String& string_iterator = String::Handle(); |
| 96 if (option_keys.Length() > 0) { |
| 97 const char** option_keys_native = |
| 98 zone->Alloc<const char*>(option_keys.Length()); |
| 99 const char** option_values_native = |
| 100 zone->Alloc<const char*>(option_keys.Length()); |
| 101 for (intptr_t i = 0; i < option_keys.Length(); i++) { |
| 102 string_iterator ^= option_keys.At(i); |
| 103 option_keys_native[i] = |
| 104 zone->MakeCopyOfString(string_iterator.ToCString()); |
| 105 string_iterator ^= option_values.At(i); |
| 106 option_values_native[i] = |
| 107 zone->MakeCopyOfString(string_iterator.ToCString()); |
| 108 } |
| 109 SetOptions(option_keys_native, option_values_native, option_keys.Length()); |
| 110 } |
| 111 if (FLAG_trace_service) { |
| 112 Isolate* isolate = Isolate::Current(); |
| 113 ASSERT(isolate != NULL); |
| 114 const char* isolate_name = isolate->name(); |
| 115 OS::Print("Isolate %s processing service request %s", |
| 116 isolate_name, command_); |
| 117 for (intptr_t i = 1; i < num_arguments(); i++) { |
| 118 OS::Print("/%s", GetArgument(i)); |
| 80 } | 119 } |
| 81 OS::Print("\n"); | 120 OS::Print("\n"); |
| 82 setup_time_micros_ = OS::GetCurrentTimeMicros(); | 121 setup_time_micros_ = OS::GetCurrentTimeMicros(); |
| 83 } | 122 } |
| 84 } | 123 } |
| 85 | 124 |
| 86 | 125 |
| 87 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 126 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 88 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 127 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 89 return reinterpret_cast<uint8_t*>(new_ptr); | 128 return reinterpret_cast<uint8_t*>(new_ptr); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 104 uint8_t* data = NULL; | 143 uint8_t* data = NULL; |
| 105 MessageWriter writer(&data, &allocator, false); | 144 MessageWriter writer(&data, &allocator, false); |
| 106 writer.WriteMessage(reply); | 145 writer.WriteMessage(reply); |
| 107 PortMap::PostMessage(new Message(port, data, | 146 PortMap::PostMessage(new Message(port, data, |
| 108 writer.BytesWritten(), | 147 writer.BytesWritten(), |
| 109 Message::kNormalPriority)); | 148 Message::kNormalPriority)); |
| 110 if (FLAG_trace_service) { | 149 if (FLAG_trace_service) { |
| 111 Isolate* isolate = Isolate::Current(); | 150 Isolate* isolate = Isolate::Current(); |
| 112 ASSERT(isolate != NULL); | 151 ASSERT(isolate != NULL); |
| 113 const char* isolate_name = isolate->name(); | 152 const char* isolate_name = isolate->name(); |
| 114 OS::Print("Isolate %s processed service request /%s", | 153 OS::Print("Isolate %s processed service request %s", |
| 115 isolate_name, command_); | 154 isolate_name, command_); |
| 116 for (intptr_t i = 1; i < num_arguments(); i++) { | 155 for (intptr_t i = 1; i < num_arguments(); i++) { |
| 117 OS::Print("/%s", GetArgument(i)); | 156 OS::Print("/%s", GetArgument(i)); |
| 118 } | 157 } |
| 119 OS::Print(" in %" Pd64" us.\n", process_delta_micros); | 158 OS::Print(" in %" Pd64" us.\n", process_delta_micros); |
| 120 } | 159 } |
| 121 } | 160 } |
| 122 | 161 |
| 123 | 162 |
| 124 const char* JSONStream::LookupOption(const char* key) const { | 163 const char* JSONStream::LookupOption(const char* key) const { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 546 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
| 508 va_end(args); | 547 va_end(args); |
| 509 ASSERT(len == len2); | 548 ASSERT(len == len2); |
| 510 stream_->buffer_.AddChar('"'); | 549 stream_->buffer_.AddChar('"'); |
| 511 stream_->AddEscapedUTF8String(p); | 550 stream_->AddEscapedUTF8String(p); |
| 512 stream_->buffer_.AddChar('"'); | 551 stream_->buffer_.AddChar('"'); |
| 513 free(p); | 552 free(p); |
| 514 } | 553 } |
| 515 | 554 |
| 516 } // namespace dart | 555 } // namespace dart |
| OLD | NEW |