| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_dartium.h" | 5 #include "bin/vmservice_dartium.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
| 10 #include "bin/platform.h" | 10 #include "bin/platform.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void VmServiceServer::Bootstrap() { | 38 void VmServiceServer::Bootstrap() { |
| 39 if (!Platform::Initialize()) { | 39 if (!Platform::Initialize()) { |
| 40 fprintf(stderr, "Platform::Initialize() failed\n"); | 40 fprintf(stderr, "Platform::Initialize() failed\n"); |
| 41 } | 41 } |
| 42 DartUtils::SetOriginalWorkingDirectory(); | 42 DartUtils::SetOriginalWorkingDirectory(); |
| 43 Thread::InitOnce(); | 43 Thread::InitOnce(); |
| 44 TimerUtils::InitOnce(); | 44 TimerUtils::InitOnce(); |
| 45 EventHandler::Start(); | 45 EventHandler::Start(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | |
| 49 Dart_Isolate VmServiceServer::CreateIsolate(const uint8_t* snapshot_buffer) { | 48 Dart_Isolate VmServiceServer::CreateIsolate(const uint8_t* snapshot_buffer) { |
| 50 ASSERT(snapshot_buffer != NULL); | 49 ASSERT(snapshot_buffer != NULL); |
| 51 // Create the isolate. | 50 // Create the isolate. |
| 52 IsolateData* isolate_data = | 51 IsolateData* isolate_data = |
| 53 new IsolateData(DART_VM_SERVICE_ISOLATE_NAME, NULL, NULL, NULL); | 52 new IsolateData(DART_VM_SERVICE_ISOLATE_NAME, NULL, NULL, NULL); |
| 54 char* error = 0; | 53 char* error = 0; |
| 55 Dart_Isolate isolate = | 54 Dart_Isolate isolate = |
| 56 Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, "main", snapshot_buffer, | 55 Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, "main", snapshot_buffer, |
| 57 NULL, NULL, isolate_data, &error); | 56 NULL, NULL, isolate_data, &error); |
| 58 if (!isolate) { | 57 if (!isolate) { |
| 59 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); | 58 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); |
| 60 return 0; | 59 return 0; |
| 61 } | 60 } |
| 62 | 61 |
| 63 Dart_EnterScope(); | 62 Dart_EnterScope(); |
| 64 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 63 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 65 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 64 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 66 | 65 |
| 67 ASSERT(Dart_IsServiceIsolate(isolate)); | 66 ASSERT(Dart_IsServiceIsolate(isolate)); |
| 68 if (!VmService::Setup( | 67 if (!VmService::Setup( |
| 69 IsIpv6Only() ? DEFAULT_VM_SERVICE_SERVER_IP_V6 : | 68 IsIpv6Only() ? DEFAULT_VM_SERVICE_SERVER_IP_V6 |
| 70 DEFAULT_VM_SERVICE_SERVER_IP_V4, | 69 : DEFAULT_VM_SERVICE_SERVER_IP_V4, |
| 71 DEFAULT_VM_SERVICE_SERVER_PORT, | 70 DEFAULT_VM_SERVICE_SERVER_PORT, false /* running_precompiled */, |
| 72 false /* running_precompiled */, false /* disable origin checks */, | 71 false /* disable origin checks */, false /* trace_loading */)) { |
| 73 false /* trace_loading */)) { | |
| 74 fprintf(stderr, "Vmservice::Setup failed: %s\n", | 72 fprintf(stderr, "Vmservice::Setup failed: %s\n", |
| 75 VmService::GetErrorMessage()); | 73 VmService::GetErrorMessage()); |
| 76 isolate = NULL; | 74 isolate = NULL; |
| 77 } | 75 } |
| 78 Dart_ExitScope(); | 76 Dart_ExitScope(); |
| 79 Dart_ExitIsolate(); | 77 Dart_ExitIsolate(); |
| 80 return isolate; | 78 return isolate; |
| 81 } | 79 } |
| 82 | 80 |
| 83 | |
| 84 const char* VmServiceServer::GetServerAddress() { | 81 const char* VmServiceServer::GetServerAddress() { |
| 85 return VmService::GetServerAddress(); | 82 return VmService::GetServerAddress(); |
| 86 } | 83 } |
| 87 | 84 |
| 88 | |
| 89 void VmServiceServer::DecompressAssets(const uint8_t* input, | 85 void VmServiceServer::DecompressAssets(const uint8_t* input, |
| 90 unsigned int input_len, | 86 unsigned int input_len, |
| 91 uint8_t** output, | 87 uint8_t** output, |
| 92 unsigned int* output_length) { | 88 unsigned int* output_length) { |
| 93 ASSERT(input != NULL); | 89 ASSERT(input != NULL); |
| 94 ASSERT(input_len > 0); | 90 ASSERT(input_len > 0); |
| 95 ASSERT(output != NULL); | 91 ASSERT(output != NULL); |
| 96 ASSERT(output_length != NULL); | 92 ASSERT(output_length != NULL); |
| 97 | 93 |
| 98 // Initialize output. | 94 // Initialize output. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 137 |
| 142 // We've processed size_in bytes. | 138 // We've processed size_in bytes. |
| 143 input_cursor += size_in; | 139 input_cursor += size_in; |
| 144 | 140 |
| 145 // We're finished decompressing when zlib tells us. | 141 // We're finished decompressing when zlib tells us. |
| 146 } while (ret != Z_STREAM_END); | 142 } while (ret != Z_STREAM_END); |
| 147 | 143 |
| 148 inflateEnd(&strm); | 144 inflateEnd(&strm); |
| 149 } | 145 } |
| 150 | 146 |
| 151 | |
| 152 /* DISALLOW_ALLOCATION */ | 147 /* DISALLOW_ALLOCATION */ |
| 153 void VmServiceServer::operator delete(void* pointer) { | 148 void VmServiceServer::operator delete(void* pointer) { |
| 154 fprintf(stderr, "unreachable code\n"); | 149 fprintf(stderr, "unreachable code\n"); |
| 155 abort(); | 150 abort(); |
| 156 } | 151 } |
| 157 | 152 |
| 158 } // namespace bin | 153 } // namespace bin |
| 159 } // namespace dart | 154 } // namespace dart |
| OLD | NEW |