OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_DART_H_ | 5 #ifndef VM_DART_H_ |
6 #define VM_DART_H_ | 6 #define VM_DART_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class DebugInfo; | 14 class DebugInfo; |
15 class Isolate; | 15 class Isolate; |
16 class LocalHandle; | 16 class LocalHandle; |
17 class RawError; | 17 class RawError; |
18 class ReadOnlyHandles; | 18 class ReadOnlyHandles; |
19 class ThreadPool; | 19 class ThreadPool; |
20 | 20 |
21 class Dart : public AllStatic { | 21 class Dart : public AllStatic { |
22 public: | 22 public: |
23 static const char* InitOnce( | 23 static const char* InitOnce( |
24 const uint8_t* vm_isolate_snapshot, | 24 const uint8_t* vm_isolate_snapshot, |
25 const uint8_t* instructions_snapshot, | 25 const uint8_t* instructions_snapshot, |
26 const uint8_t* data_snapshot, | 26 const uint8_t* data_snapshot, |
27 Dart_IsolateCreateCallback create, | 27 Dart_IsolateCreateCallback create, |
28 Dart_IsolateShutdownCallback shutdown, | 28 Dart_IsolateShutdownCallback shutdown, |
| 29 Dart_ThreadExitCallback thread_exit, |
29 Dart_FileOpenCallback file_open, | 30 Dart_FileOpenCallback file_open, |
30 Dart_FileReadCallback file_read, | 31 Dart_FileReadCallback file_read, |
31 Dart_FileWriteCallback file_write, | 32 Dart_FileWriteCallback file_write, |
32 Dart_FileCloseCallback file_close, | 33 Dart_FileCloseCallback file_close, |
33 Dart_EntropySource entropy_source, | 34 Dart_EntropySource entropy_source, |
34 Dart_GetVMServiceAssetsArchive get_service_assets); | 35 Dart_GetVMServiceAssetsArchive get_service_assets); |
35 static const char* Cleanup(); | 36 static const char* Cleanup(); |
36 | 37 |
37 static Isolate* CreateIsolate(const char* name_prefix, | 38 static Isolate* CreateIsolate(const char* name_prefix, |
38 const Dart_IsolateFlags& api_flags); | 39 const Dart_IsolateFlags& api_flags); |
(...skipping 30 matching lines...) Expand all Loading... |
69 return instructions_snapshot_buffer_ != NULL; | 70 return instructions_snapshot_buffer_ != NULL; |
70 } | 71 } |
71 | 72 |
72 static const uint8_t* data_snapshot_buffer() { | 73 static const uint8_t* data_snapshot_buffer() { |
73 return data_snapshot_buffer_; | 74 return data_snapshot_buffer_; |
74 } | 75 } |
75 static void set_data_snapshot_buffer(const uint8_t* buffer) { | 76 static void set_data_snapshot_buffer(const uint8_t* buffer) { |
76 data_snapshot_buffer_ = buffer; | 77 data_snapshot_buffer_ = buffer; |
77 } | 78 } |
78 | 79 |
| 80 static Dart_ThreadExitCallback thread_exit_callback() { |
| 81 return thread_exit_callback_; |
| 82 } |
| 83 static void set_thread_exit_callback(Dart_ThreadExitCallback cback) { |
| 84 thread_exit_callback_ = cback; |
| 85 } |
| 86 static void SetFileCallbacks(Dart_FileOpenCallback file_open, |
| 87 Dart_FileReadCallback file_read, |
| 88 Dart_FileWriteCallback file_write, |
| 89 Dart_FileCloseCallback file_close) { |
| 90 file_open_callback_ = file_open; |
| 91 file_read_callback_ = file_read; |
| 92 file_write_callback_ = file_write; |
| 93 file_close_callback_ = file_close; |
| 94 } |
| 95 |
| 96 static Dart_FileOpenCallback file_open_callback() { |
| 97 return file_open_callback_; |
| 98 } |
| 99 static Dart_FileReadCallback file_read_callback() { |
| 100 return file_read_callback_; |
| 101 } |
| 102 static Dart_FileWriteCallback file_write_callback() { |
| 103 return file_write_callback_; |
| 104 } |
| 105 static Dart_FileCloseCallback file_close_callback() { |
| 106 return file_close_callback_; |
| 107 } |
| 108 |
| 109 static void set_entropy_source_callback(Dart_EntropySource entropy_source) { |
| 110 entropy_source_callback_ = entropy_source; |
| 111 } |
| 112 static Dart_EntropySource entropy_source_callback() { |
| 113 return entropy_source_callback_; |
| 114 } |
| 115 |
79 private: | 116 private: |
80 static void WaitForIsolateShutdown(); | 117 static void WaitForIsolateShutdown(); |
81 | 118 |
82 static Isolate* vm_isolate_; | 119 static Isolate* vm_isolate_; |
83 static int64_t start_time_; | 120 static int64_t start_time_; |
84 static ThreadPool* thread_pool_; | 121 static ThreadPool* thread_pool_; |
85 static DebugInfo* pprof_symbol_generator_; | 122 static DebugInfo* pprof_symbol_generator_; |
86 static ReadOnlyHandles* predefined_handles_; | 123 static ReadOnlyHandles* predefined_handles_; |
87 static const uint8_t* instructions_snapshot_buffer_; | 124 static const uint8_t* instructions_snapshot_buffer_; |
88 static const uint8_t* data_snapshot_buffer_; | 125 static const uint8_t* data_snapshot_buffer_; |
| 126 static Dart_ThreadExitCallback thread_exit_callback_; |
| 127 static Dart_FileOpenCallback file_open_callback_; |
| 128 static Dart_FileReadCallback file_read_callback_; |
| 129 static Dart_FileWriteCallback file_write_callback_; |
| 130 static Dart_FileCloseCallback file_close_callback_; |
| 131 static Dart_EntropySource entropy_source_callback_; |
89 }; | 132 }; |
90 | 133 |
91 } // namespace dart | 134 } // namespace dart |
92 | 135 |
93 #endif // VM_DART_H_ | 136 #endif // VM_DART_H_ |
OLD | NEW |