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 RUNTIME_VM_DART_H_ | 5 #ifndef RUNTIME_VM_DART_H_ |
6 #define RUNTIME_VM_DART_H_ | 6 #define RUNTIME_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 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 // Forward declarations. | 14 // Forward declarations. |
15 class DebugInfo; | 15 class DebugInfo; |
16 class Isolate; | 16 class Isolate; |
17 class LocalHandle; | 17 class LocalHandle; |
18 class RawError; | 18 class RawError; |
19 class ReadOnlyHandles; | 19 class ReadOnlyHandles; |
20 class ThreadPool; | 20 class ThreadPool; |
21 namespace kernel { | 21 namespace kernel { |
22 class Program; | 22 class Program; |
23 } | 23 } |
24 | 24 |
25 class Dart : public AllStatic { | 25 class Dart : public AllStatic { |
26 public: | 26 public: |
27 static char* InitOnce(const uint8_t* vm_isolate_snapshot, | 27 static char* InitOnce(const uint8_t* vm_snapshot_data, |
28 const uint8_t* instructions_snapshot, | 28 const uint8_t* vm_snapshot_instructions, |
29 const uint8_t* data_snapshot, | |
30 Dart_IsolateCreateCallback create, | 29 Dart_IsolateCreateCallback create, |
31 Dart_IsolateShutdownCallback shutdown, | 30 Dart_IsolateShutdownCallback shutdown, |
32 Dart_ThreadExitCallback thread_exit, | 31 Dart_ThreadExitCallback thread_exit, |
33 Dart_FileOpenCallback file_open, | 32 Dart_FileOpenCallback file_open, |
34 Dart_FileReadCallback file_read, | 33 Dart_FileReadCallback file_read, |
35 Dart_FileWriteCallback file_write, | 34 Dart_FileWriteCallback file_write, |
36 Dart_FileCloseCallback file_close, | 35 Dart_FileCloseCallback file_close, |
37 Dart_EntropySource entropy_source, | 36 Dart_EntropySource entropy_source, |
38 Dart_GetVMServiceAssetsArchive get_service_assets); | 37 Dart_GetVMServiceAssetsArchive get_service_assets); |
39 static const char* Cleanup(); | 38 static const char* Cleanup(); |
40 | 39 |
41 static Isolate* CreateIsolate(const char* name_prefix, | 40 static Isolate* CreateIsolate(const char* name_prefix, |
42 const Dart_IsolateFlags& api_flags); | 41 const Dart_IsolateFlags& api_flags); |
43 | 42 |
44 // Initialize an isolate, either from a snapshot, from a Kernel binary, or | 43 // Initialize an isolate, either from a snapshot, from a Kernel binary, or |
45 // from SDK library sources. If the snapshot_buffer is non-NULL, | 44 // from SDK library sources. If the snapshot_buffer is non-NULL, |
46 // initialize from a snapshot or a Kernel binary depending on the value of | 45 // initialize from a snapshot or a Kernel binary depending on the value of |
47 // from_kernel. Otherwise, initialize from sources. | 46 // from_kernel. Otherwise, initialize from sources. |
48 static RawError* InitializeIsolate(const uint8_t* snapshot_buffer, | 47 static RawError* InitializeIsolate(const uint8_t* snapshot_data, |
| 48 const uint8_t* snapshot_instructions, |
49 intptr_t snapshot_length, | 49 intptr_t snapshot_length, |
50 kernel::Program* kernel_program, | 50 kernel::Program* kernel_program, |
51 void* data); | 51 void* data); |
52 static void RunShutdownCallback(); | 52 static void RunShutdownCallback(); |
53 static void ShutdownIsolate(Isolate* isolate); | 53 static void ShutdownIsolate(Isolate* isolate); |
54 static void ShutdownIsolate(); | 54 static void ShutdownIsolate(); |
55 | 55 |
56 static Isolate* vm_isolate() { return vm_isolate_; } | 56 static Isolate* vm_isolate() { return vm_isolate_; } |
57 static ThreadPool* thread_pool() { return thread_pool_; } | 57 static ThreadPool* thread_pool() { return thread_pool_; } |
58 | 58 |
59 static int64_t UptimeMicros(); | 59 static int64_t UptimeMicros(); |
60 static int64_t UptimeMillis() { | 60 static int64_t UptimeMillis() { |
61 return UptimeMicros() / kMicrosecondsPerMillisecond; | 61 return UptimeMicros() / kMicrosecondsPerMillisecond; |
62 } | 62 } |
63 | 63 |
64 static void set_pprof_symbol_generator(DebugInfo* value) { | 64 static void set_pprof_symbol_generator(DebugInfo* value) { |
65 pprof_symbol_generator_ = value; | 65 pprof_symbol_generator_ = value; |
66 } | 66 } |
67 static DebugInfo* pprof_symbol_generator() { return pprof_symbol_generator_; } | 67 static DebugInfo* pprof_symbol_generator() { return pprof_symbol_generator_; } |
68 | 68 |
69 static LocalHandle* AllocateReadOnlyApiHandle(); | 69 static LocalHandle* AllocateReadOnlyApiHandle(); |
70 static bool IsReadOnlyApiHandle(Dart_Handle handle); | 70 static bool IsReadOnlyApiHandle(Dart_Handle handle); |
71 | 71 |
72 static uword AllocateReadOnlyHandle(); | 72 static uword AllocateReadOnlyHandle(); |
73 static bool IsReadOnlyHandle(uword address); | 73 static bool IsReadOnlyHandle(uword address); |
74 | 74 |
75 static const char* FeaturesString(Snapshot::Kind kind); | 75 static const char* FeaturesString(Snapshot::Kind kind); |
76 | 76 static Snapshot::Kind vm_snapshot_kind() { return vm_snapshot_kind_; } |
77 static Snapshot::Kind snapshot_kind() { return snapshot_kind_; } | |
78 static const uint8_t* instructions_snapshot_buffer() { | |
79 return instructions_snapshot_buffer_; | |
80 } | |
81 static void set_instructions_snapshot_buffer(const uint8_t* buffer) { | |
82 instructions_snapshot_buffer_ = buffer; | |
83 } | |
84 static const uint8_t* data_snapshot_buffer() { return data_snapshot_buffer_; } | |
85 static void set_data_snapshot_buffer(const uint8_t* buffer) { | |
86 data_snapshot_buffer_ = buffer; | |
87 } | |
88 | 77 |
89 static Dart_ThreadExitCallback thread_exit_callback() { | 78 static Dart_ThreadExitCallback thread_exit_callback() { |
90 return thread_exit_callback_; | 79 return thread_exit_callback_; |
91 } | 80 } |
92 static void set_thread_exit_callback(Dart_ThreadExitCallback cback) { | 81 static void set_thread_exit_callback(Dart_ThreadExitCallback cback) { |
93 thread_exit_callback_ = cback; | 82 thread_exit_callback_ = cback; |
94 } | 83 } |
95 static void SetFileCallbacks(Dart_FileOpenCallback file_open, | 84 static void SetFileCallbacks(Dart_FileOpenCallback file_open, |
96 Dart_FileReadCallback file_read, | 85 Dart_FileReadCallback file_read, |
97 Dart_FileWriteCallback file_write, | 86 Dart_FileWriteCallback file_write, |
(...skipping 26 matching lines...) Expand all Loading... |
124 | 113 |
125 private: | 114 private: |
126 static void WaitForIsolateShutdown(); | 115 static void WaitForIsolateShutdown(); |
127 static void WaitForApplicationIsolateShutdown(); | 116 static void WaitForApplicationIsolateShutdown(); |
128 | 117 |
129 static Isolate* vm_isolate_; | 118 static Isolate* vm_isolate_; |
130 static int64_t start_time_micros_; | 119 static int64_t start_time_micros_; |
131 static ThreadPool* thread_pool_; | 120 static ThreadPool* thread_pool_; |
132 static DebugInfo* pprof_symbol_generator_; | 121 static DebugInfo* pprof_symbol_generator_; |
133 static ReadOnlyHandles* predefined_handles_; | 122 static ReadOnlyHandles* predefined_handles_; |
134 static Snapshot::Kind snapshot_kind_; | 123 static Snapshot::Kind vm_snapshot_kind_; |
135 static const uint8_t* instructions_snapshot_buffer_; | |
136 static const uint8_t* data_snapshot_buffer_; | |
137 static Dart_ThreadExitCallback thread_exit_callback_; | 124 static Dart_ThreadExitCallback thread_exit_callback_; |
138 static Dart_FileOpenCallback file_open_callback_; | 125 static Dart_FileOpenCallback file_open_callback_; |
139 static Dart_FileReadCallback file_read_callback_; | 126 static Dart_FileReadCallback file_read_callback_; |
140 static Dart_FileWriteCallback file_write_callback_; | 127 static Dart_FileWriteCallback file_write_callback_; |
141 static Dart_FileCloseCallback file_close_callback_; | 128 static Dart_FileCloseCallback file_close_callback_; |
142 static Dart_EntropySource entropy_source_callback_; | 129 static Dart_EntropySource entropy_source_callback_; |
143 }; | 130 }; |
144 | 131 |
145 } // namespace dart | 132 } // namespace dart |
146 | 133 |
147 #endif // RUNTIME_VM_DART_H_ | 134 #endif // RUNTIME_VM_DART_H_ |
OLD | NEW |