OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/dart.h" | 5 #include "vm/dart.h" |
6 | 6 |
7 #include "vm/code_observers.h" | 7 #include "vm/code_observers.h" |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "vm/symbols.h" | 27 #include "vm/symbols.h" |
28 #include "vm/thread_interrupter.h" | 28 #include "vm/thread_interrupter.h" |
29 #include "vm/thread_pool.h" | 29 #include "vm/thread_pool.h" |
30 #include "vm/virtual_memory.h" | 30 #include "vm/virtual_memory.h" |
31 #include "vm/zone.h" | 31 #include "vm/zone.h" |
32 | 32 |
33 namespace dart { | 33 namespace dart { |
34 | 34 |
35 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32, | 35 DEFINE_FLAG(int, new_gen_semi_max_size, (kWordSize <= 4) ? 16 : 32, |
36 "Max size of new gen semi space in MB"); | 36 "Max size of new gen semi space in MB"); |
37 DEFINE_FLAG(int, old_gen_heap_size, Heap::kHeapSizeInMB, | 37 DEFINE_FLAG(int, old_gen_heap_size, 0, |
38 "Max size of old gen heap size in MB," | 38 "Max size of old gen heap size in MB, or 0 for unlimited," |
39 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap"); | 39 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap"); |
| 40 DEFINE_FLAG(int, external_max_size, (kWordSize <= 4) ? 512 : 1024, |
| 41 "Max total size of external allocations in MB, or 0 for unlimited," |
| 42 "e.g: --external_max_size=1024 allows up to 1024MB of externals"); |
| 43 |
40 | 44 |
41 DECLARE_FLAG(bool, print_class_table); | 45 DECLARE_FLAG(bool, print_class_table); |
42 DECLARE_FLAG(bool, trace_isolates); | 46 DECLARE_FLAG(bool, trace_isolates); |
43 | 47 |
44 Isolate* Dart::vm_isolate_ = NULL; | 48 Isolate* Dart::vm_isolate_ = NULL; |
45 ThreadPool* Dart::thread_pool_ = NULL; | 49 ThreadPool* Dart::thread_pool_ = NULL; |
46 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 50 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
47 ReadOnlyHandles* Dart::predefined_handles_ = NULL; | 51 ReadOnlyHandles* Dart::predefined_handles_ = NULL; |
48 | 52 |
49 // Structure for managing read-only global handles allocation used for | 53 // Structure for managing read-only global handles allocation used for |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ASSERT(thread_pool_ == NULL); | 111 ASSERT(thread_pool_ == NULL); |
108 thread_pool_ = new ThreadPool(); | 112 thread_pool_ = new ThreadPool(); |
109 { | 113 { |
110 ASSERT(vm_isolate_ == NULL); | 114 ASSERT(vm_isolate_ == NULL); |
111 ASSERT(Flags::Initialized()); | 115 ASSERT(Flags::Initialized()); |
112 vm_isolate_ = Isolate::Init("vm-isolate"); | 116 vm_isolate_ = Isolate::Init("vm-isolate"); |
113 StackZone zone(vm_isolate_); | 117 StackZone zone(vm_isolate_); |
114 HandleScope handle_scope(vm_isolate_); | 118 HandleScope handle_scope(vm_isolate_); |
115 Heap::Init(vm_isolate_, | 119 Heap::Init(vm_isolate_, |
116 0, // New gen size 0; VM isolate should only allocate in old. | 120 0, // New gen size 0; VM isolate should only allocate in old. |
117 FLAG_old_gen_heap_size * MBInWords); | 121 FLAG_old_gen_heap_size * MBInWords, |
| 122 FLAG_external_max_size * MBInWords); |
118 ObjectStore::Init(vm_isolate_); | 123 ObjectStore::Init(vm_isolate_); |
119 TargetCPUFeatures::InitOnce(); | 124 TargetCPUFeatures::InitOnce(); |
120 Object::InitOnce(vm_isolate_); | 125 Object::InitOnce(vm_isolate_); |
121 ArgumentsDescriptor::InitOnce(); | 126 ArgumentsDescriptor::InitOnce(); |
122 StubCode::InitOnce(); | 127 StubCode::InitOnce(); |
123 Symbols::InitOnce(vm_isolate_); | 128 Symbols::InitOnce(vm_isolate_); |
124 Scanner::InitOnce(); | 129 Scanner::InitOnce(); |
125 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 130 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
126 // Dart VM requires at least SSE2. | 131 // Dart VM requires at least SSE2. |
127 if (!TargetCPUFeatures::sse2_supported()) { | 132 if (!TargetCPUFeatures::sse2_supported()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 195 |
191 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 196 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
192 // Initialize the new isolate. | 197 // Initialize the new isolate. |
193 Isolate* isolate = Isolate::Current(); | 198 Isolate* isolate = Isolate::Current(); |
194 TIMERSCOPE(isolate, time_isolate_initialization); | 199 TIMERSCOPE(isolate, time_isolate_initialization); |
195 ASSERT(isolate != NULL); | 200 ASSERT(isolate != NULL); |
196 StackZone zone(isolate); | 201 StackZone zone(isolate); |
197 HandleScope handle_scope(isolate); | 202 HandleScope handle_scope(isolate); |
198 Heap::Init(isolate, | 203 Heap::Init(isolate, |
199 FLAG_new_gen_semi_max_size * MBInWords, | 204 FLAG_new_gen_semi_max_size * MBInWords, |
200 FLAG_old_gen_heap_size * MBInWords); | 205 FLAG_old_gen_heap_size * MBInWords, |
| 206 FLAG_external_max_size * MBInWords); |
201 ObjectIdRing::Init(isolate); | 207 ObjectIdRing::Init(isolate); |
202 ObjectStore::Init(isolate); | 208 ObjectStore::Init(isolate); |
203 | 209 |
204 // Setup for profiling. | 210 // Setup for profiling. |
205 Profiler::InitProfilingForIsolate(isolate); | 211 Profiler::InitProfilingForIsolate(isolate); |
206 | 212 |
207 if (snapshot_buffer == NULL) { | 213 if (snapshot_buffer == NULL) { |
208 const Error& error = Error::Handle(Object::Init(isolate)); | 214 const Error& error = Error::Handle(Object::Init(isolate)); |
209 if (!error.IsNull()) { | 215 if (!error.IsNull()) { |
210 return error.raw(); | 216 return error.raw(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return predefined_handles_->handles_.AllocateScopedHandle(); | 297 return predefined_handles_->handles_.AllocateScopedHandle(); |
292 } | 298 } |
293 | 299 |
294 | 300 |
295 bool Dart::IsReadOnlyHandle(uword address) { | 301 bool Dart::IsReadOnlyHandle(uword address) { |
296 ASSERT(predefined_handles_ != NULL); | 302 ASSERT(predefined_handles_ != NULL); |
297 return predefined_handles_->handles_.IsValidScopedHandle(address); | 303 return predefined_handles_->handles_.IsValidScopedHandle(address); |
298 } | 304 } |
299 | 305 |
300 } // namespace dart | 306 } // namespace dart |
OLD | NEW |