| 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/vmservice_impl.h" | 12 #include "bin/vmservice_impl.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 namespace bin { | 15 namespace bin { |
| 16 | 16 |
| 17 #define CHECK_RESULT(result) \ | 17 #define CHECK_RESULT(result) \ |
| 18 if (Dart_IsError(result)) { \ | 18 if (Dart_IsError(result)) { \ |
| 19 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ | 19 fprintf(stderr, "CHECK_RESULT failed: %s", Dart_GetError(result)); \ |
| 20 Dart_ExitScope(); \ | 20 Dart_ExitScope(); \ |
| 21 Dart_ShutdownIsolate(); \ | 21 Dart_ShutdownIsolate(); \ |
| 22 return 0; \ | 22 return 0; \ |
| 23 } \ | 23 } \ |
| 24 | 24 |
| 25 | 25 |
| 26 | 26 |
| 27 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise | 27 // isolate_snapshot_buffer points to a snapshot if we link in a snapshot |
| 28 // it is initialized to NULL. | 28 // otherwise it is initialized to NULL. |
| 29 extern const uint8_t* snapshot_buffer; | 29 extern const uint8_t* isolate_snapshot_buffer; |
| 30 | 30 |
| 31 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; | 31 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; |
| 32 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; | 32 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 0; |
| 33 | 33 |
| 34 void VmServiceServer::Bootstrap() { | 34 void VmServiceServer::Bootstrap() { |
| 35 if (!Platform::Initialize()) { | 35 if (!Platform::Initialize()) { |
| 36 fprintf(stderr, "Platform::Initialize() failed\n"); | 36 fprintf(stderr, "Platform::Initialize() failed\n"); |
| 37 } | 37 } |
| 38 DartUtils::SetOriginalWorkingDirectory(); | 38 DartUtils::SetOriginalWorkingDirectory(); |
| 39 Thread::InitOnce(); | 39 Thread::InitOnce(); |
| 40 EventHandler::Start(); | 40 EventHandler::Start(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 Dart_Isolate VmServiceServer::CreateIsolate() { | 44 Dart_Isolate VmServiceServer::CreateIsolate() { |
| 45 ASSERT(snapshot_buffer != NULL); | 45 ASSERT(isolate_snapshot_buffer != NULL); |
| 46 // Create the isolate. | 46 // Create the isolate. |
| 47 char* error = 0; | 47 char* error = 0; |
| 48 Dart_Isolate isolate = Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, | 48 Dart_Isolate isolate = Dart_CreateIsolate(DART_VM_SERVICE_ISOLATE_NAME, |
| 49 "main", | 49 "main", |
| 50 dart::bin::snapshot_buffer, | 50 dart::bin::isolate_snapshot_buffer, |
| 51 NULL, | 51 NULL, |
| 52 &error); | 52 &error); |
| 53 if (!isolate) { | 53 if (!isolate) { |
| 54 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); | 54 fprintf(stderr, "Dart_CreateIsolate failed: %s\n", error); |
| 55 return 0; | 55 return 0; |
| 56 } | 56 } |
| 57 | 57 |
| 58 Dart_EnterScope(); | 58 Dart_EnterScope(); |
| 59 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 59 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 60 Builtin::SetNativeResolver(Builtin::kIOLibrary); | 60 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 | 95 |
| 96 /* DISALLOW_ALLOCATION */ | 96 /* DISALLOW_ALLOCATION */ |
| 97 void VmServiceServer::operator delete(void* pointer) { | 97 void VmServiceServer::operator delete(void* pointer) { |
| 98 fprintf(stderr, "unreachable code\n"); | 98 fprintf(stderr, "unreachable code\n"); |
| 99 abort(); | 99 abort(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace bin | 102 } // namespace bin |
| 103 } // namespace dart | 103 } // namespace dart |
| OLD | NEW |