| 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" |
| 11 #include "bin/thread.h" | 11 #include "bin/thread.h" |
| 12 #include "bin/utils.h" | 12 #include "bin/utils.h" |
| 13 #include "bin/vmservice_impl.h" | 13 #include "bin/vmservice_impl.h" |
| 14 #include "zlib/zlib.h" | 14 #include "zlib/zlib.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 namespace bin { | 17 namespace bin { |
| 18 | 18 |
| 19 #define CHECK_RESULT(result) \ | 19 #define CHECK_RESULT(result) \ |
| 20 if (Dart_IsError(result)) { \ | 20 if (Dart_IsError(result)) { \ |
| 21 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ | 21 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ |
| 22 Dart_ExitScope(); \ | 22 Dart_ExitScope(); \ |
| 23 Dart_ShutdownIsolate(); \ | 23 Dart_ShutdownIsolate(); \ |
| 24 return 0; \ | 24 return 0; \ |
| 25 } \ | 25 } |
| 26 | |
| 27 | 26 |
| 28 | 27 |
| 29 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 28 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; |
| 30 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; | 29 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; |
| 31 | 30 |
| 32 void VmServiceServer::Bootstrap() { | 31 void VmServiceServer::Bootstrap() { |
| 33 if (!Platform::Initialize()) { | 32 if (!Platform::Initialize()) { |
| 34 fprintf(stderr, "Platform::Initialize() failed\n"); | 33 fprintf(stderr, "Platform::Initialize() failed\n"); |
| 35 } | 34 } |
| 36 DartUtils::SetOriginalWorkingDirectory(); | 35 DartUtils::SetOriginalWorkingDirectory(); |
| 37 Thread::InitOnce(); | 36 Thread::InitOnce(); |
| 38 TimerUtils::InitOnce(); | 37 TimerUtils::InitOnce(); |
| 39 EventHandler::Start(); | 38 EventHandler::Start(); |
| 40 } | 39 } |
| 41 | 40 |
| 42 | 41 |
| 43 Dart_Isolate VmServiceServer::CreateIsolate(const uint8_t* snapshot_buffer) { | 42 Dart_Isolate VmServiceServer::CreateIsolate(const uint8_t* snapshot_buffer) { |
| 44 ASSERT(snapshot_buffer != NULL); | 43 ASSERT(snapshot_buffer != NULL); |
| 45 // Create the isolate. | 44 // Create the isolate. |
| 46 IsolateData* isolate_data = new IsolateData(DART_VM_SERVICE_ISOLATE_NAME, | 45 IsolateData* isolate_data = |
| 47 NULL, | 46 new IsolateData(DART_VM_SERVICE_ISOLATE_NAME, NULL, NULL); |
| 48 NULL); | |
| 49 char* error = 0; | 47 char* error = 0; |
| 50 Dart_Isolate isolate = Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, | 48 Dart_Isolate isolate = |
| 51 "main", | 49 Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, "main", snapshot_buffer, |
| 52 snapshot_buffer, | 50 NULL, isolate_data, &error); |
| 53 NULL, | |
| 54 isolate_data, | |
| 55 &error); | |
| 56 if (!isolate) { | 51 if (!isolate) { |
| 57 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); | 52 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); |
| 58 return 0; | 53 return 0; |
| 59 } | 54 } |
| 60 | 55 |
| 61 Dart_EnterScope(); | 56 Dart_EnterScope(); |
| 62 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 57 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 63 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 58 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| 64 | 59 |
| 65 ASSERT(Dart_IsServiceIsolate(isolate)); | 60 ASSERT(Dart_IsServiceIsolate(isolate)); |
| 66 if (!VmService::Setup(DEFAULT_VM_SERVICE_SERVER_IP, | 61 if (!VmService::Setup( |
| 67 DEFAULT_VM_SERVICE_SERVER_PORT, | 62 DEFAULT_VM_SERVICE_SERVER_IP, DEFAULT_VM_SERVICE_SERVER_PORT, |
| 68 false /* running_precompiled */, | 63 false /* running_precompiled */, false /* disable origin checks */)) { |
| 69 false /* disable origin checks */)) { | 64 fprintf(stderr, "Vmservice::Setup failed: %s\n", |
| 70 fprintf(stderr, | 65 VmService::GetErrorMessage()); |
| 71 "Vmservice::Setup failed: %s\n", VmService::GetErrorMessage()); | |
| 72 isolate = NULL; | 66 isolate = NULL; |
| 73 } | 67 } |
| 74 Dart_ExitScope(); | 68 Dart_ExitScope(); |
| 75 Dart_ExitIsolate(); | 69 Dart_ExitIsolate(); |
| 76 return isolate; | 70 return isolate; |
| 77 } | 71 } |
| 78 | 72 |
| 79 | 73 |
| 80 const char* VmServiceServer::GetServerAddress() { | 74 const char* VmServiceServer::GetServerAddress() { |
| 81 return VmService::GetServerAddress(); | 75 return VmService::GetServerAddress(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 input_cursor += size_in; | 133 input_cursor += size_in; |
| 140 | 134 |
| 141 // We're finished decompressing when zlib tells us. | 135 // We're finished decompressing when zlib tells us. |
| 142 } while (ret != Z_STREAM_END); | 136 } while (ret != Z_STREAM_END); |
| 143 | 137 |
| 144 inflateEnd(&strm); | 138 inflateEnd(&strm); |
| 145 } | 139 } |
| 146 | 140 |
| 147 | 141 |
| 148 /* DISALLOW_ALLOCATION */ | 142 /* DISALLOW_ALLOCATION */ |
| 149 void VmServiceServer::operator delete(void* pointer) { | 143 void VmServiceServer::operator delete(void* pointer) { |
| 150 fprintf(stderr, "unreachable code\n"); | 144 fprintf(stderr, "unreachable code\n"); |
| 151 abort(); | 145 abort(); |
| 152 } | 146 } |
| 153 | 147 |
| 154 } // namespace bin | 148 } // namespace bin |
| 155 } // namespace dart | 149 } // namespace dart |
| OLD | NEW |