| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 string_iterator ^= param_values.At(i); | 72 string_iterator ^= param_values.At(i); |
| 73 param_values_native[i] = | 73 param_values_native[i] = |
| 74 zone->MakeCopyOfString(string_iterator.ToCString()); | 74 zone->MakeCopyOfString(string_iterator.ToCString()); |
| 75 } | 75 } |
| 76 SetParams(param_keys_native, param_values_native, param_keys.Length()); | 76 SetParams(param_keys_native, param_values_native, param_keys.Length()); |
| 77 } | 77 } |
| 78 if (FLAG_trace_service) { | 78 if (FLAG_trace_service) { |
| 79 Isolate* isolate = Isolate::Current(); | 79 Isolate* isolate = Isolate::Current(); |
| 80 ASSERT(isolate != NULL); | 80 ASSERT(isolate != NULL); |
| 81 const char* isolate_name = isolate->name(); | 81 const char* isolate_name = isolate->name(); |
| 82 OS::Print("Isolate %s processing service request %s\n", | |
| 83 isolate_name, method_); | |
| 84 setup_time_micros_ = OS::GetCurrentTimeMicros(); | 82 setup_time_micros_ = OS::GetCurrentTimeMicros(); |
| 83 int64_t timestamp = setup_time_micros_ - Dart::vm_isolate()->start_time(); |
| 84 OS::Print("[@%" Pd64 "] Isolate %s processing service request %s\n", |
| 85 timestamp, isolate_name, method_); |
| 85 } | 86 } |
| 86 buffer_.Printf("{\"jsonrpc\":\"2.0\", \"result\":"); | 87 buffer_.Printf("{\"jsonrpc\":\"2.0\", \"result\":"); |
| 87 } | 88 } |
| 88 | 89 |
| 89 | 90 |
| 90 void JSONStream::SetupError() { | 91 void JSONStream::SetupError() { |
| 91 buffer_.Clear(); | 92 buffer_.Clear(); |
| 92 buffer_.Printf("{\"jsonrpc\":\"2.0\", \"error\":"); | 93 buffer_.Printf("{\"jsonrpc\":\"2.0\", \"error\":"); |
| 93 } | 94 } |
| 94 | 95 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void JSONStream::PostNullReply(Dart_Port port) { | 166 void JSONStream::PostNullReply(Dart_Port port) { |
| 166 PortMap::PostMessage(new Message( | 167 PortMap::PostMessage(new Message( |
| 167 port, Object::null(), Message::kNormalPriority)); | 168 port, Object::null(), Message::kNormalPriority)); |
| 168 } | 169 } |
| 169 | 170 |
| 170 | 171 |
| 171 void JSONStream::PostReply() { | 172 void JSONStream::PostReply() { |
| 172 Dart_Port port = reply_port(); | 173 Dart_Port port = reply_port(); |
| 173 ASSERT(port != ILLEGAL_PORT); | 174 ASSERT(port != ILLEGAL_PORT); |
| 174 set_reply_port(ILLEGAL_PORT); // Prevent double replies. | 175 set_reply_port(ILLEGAL_PORT); // Prevent double replies. |
| 175 int64_t process_delta_micros = 0; | |
| 176 if (FLAG_trace_service) { | |
| 177 process_delta_micros = OS::GetCurrentTimeMicros() - setup_time_micros_; | |
| 178 } | |
| 179 ASSERT(seq_ != NULL); | 176 ASSERT(seq_ != NULL); |
| 180 if (seq_->IsString()) { | 177 if (seq_->IsString()) { |
| 181 const String& str = String::Cast(*seq_); | 178 const String& str = String::Cast(*seq_); |
| 182 PrintProperty("id", str.ToCString()); | 179 PrintProperty("id", str.ToCString()); |
| 183 } else if (seq_->IsInteger()) { | 180 } else if (seq_->IsInteger()) { |
| 184 const Integer& integer = Integer::Cast(*seq_); | 181 const Integer& integer = Integer::Cast(*seq_); |
| 185 PrintProperty64("id", integer.AsInt64Value()); | 182 PrintProperty64("id", integer.AsInt64Value()); |
| 186 } else if (seq_->IsDouble()) { | 183 } else if (seq_->IsDouble()) { |
| 187 const Double& dbl = Double::Cast(*seq_); | 184 const Double& dbl = Double::Cast(*seq_); |
| 188 PrintProperty("id", dbl.value()); | 185 PrintProperty("id", dbl.value()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 199 uint8_t* data = NULL; | 196 uint8_t* data = NULL; |
| 200 MessageWriter writer(&data, &allocator, false); | 197 MessageWriter writer(&data, &allocator, false); |
| 201 writer.WriteMessage(reply); | 198 writer.WriteMessage(reply); |
| 202 bool result = PortMap::PostMessage(new Message(port, data, | 199 bool result = PortMap::PostMessage(new Message(port, data, |
| 203 writer.BytesWritten(), | 200 writer.BytesWritten(), |
| 204 Message::kNormalPriority)); | 201 Message::kNormalPriority)); |
| 205 if (FLAG_trace_service) { | 202 if (FLAG_trace_service) { |
| 206 Isolate* isolate = Isolate::Current(); | 203 Isolate* isolate = Isolate::Current(); |
| 207 ASSERT(isolate != NULL); | 204 ASSERT(isolate != NULL); |
| 208 const char* isolate_name = isolate->name(); | 205 const char* isolate_name = isolate->name(); |
| 206 int64_t current_time = OS::GetCurrentTimeMicros(); |
| 207 int64_t process_delta_micros = current_time - setup_time_micros_; |
| 208 int64_t timestamp = current_time - Dart::vm_isolate()->start_time(); |
| 209 if (result) { | 209 if (result) { |
| 210 OS::Print("Isolate %s processed service request %s in %" Pd64" us.\n", | 210 OS::Print("[@%" Pd64 "] Isolate %s processed service request %s " |
| 211 isolate_name, method_, process_delta_micros); | 211 "(%" Pd64 "us)\n", |
| 212 timestamp, isolate_name, method_, process_delta_micros); |
| 212 } else { | 213 } else { |
| 213 OS::Print("Isolate %s FAILED to post response for service request %s.\n", | 214 OS::Print("[@%" Pd64 "] Isolate %s processed service request %s " |
| 214 isolate_name, method_); | 215 "(%" Pd64 "us) FAILED\n", |
| 216 timestamp, isolate_name, method_, process_delta_micros); |
| 215 } | 217 } |
| 216 } | 218 } |
| 217 } | 219 } |
| 218 | 220 |
| 219 | 221 |
| 220 const char* JSONStream::LookupParam(const char* key) const { | 222 const char* JSONStream::LookupParam(const char* key) const { |
| 221 for (int i = 0; i < num_params(); i++) { | 223 for (int i = 0; i < num_params(); i++) { |
| 222 if (!strcmp(key, param_keys_[i])) { | 224 if (!strcmp(key, param_keys_[i])) { |
| 223 return param_values_[i]; | 225 return param_values_[i]; |
| 224 } | 226 } |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 ASSERT(len == len2); | 857 ASSERT(len == len2); |
| 856 stream_->buffer_.AddChar('"'); | 858 stream_->buffer_.AddChar('"'); |
| 857 stream_->AddEscapedUTF8String(p); | 859 stream_->AddEscapedUTF8String(p); |
| 858 stream_->buffer_.AddChar('"'); | 860 stream_->buffer_.AddChar('"'); |
| 859 free(p); | 861 free(p); |
| 860 } | 862 } |
| 861 | 863 |
| 862 #endif // !PRODUCT | 864 #endif // !PRODUCT |
| 863 | 865 |
| 864 } // namespace dart | 866 } // namespace dart |
| OLD | NEW |