| 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 12 matching lines...) Expand all Loading... |
| 23 #include "vm/snapshot.h" | 23 #include "vm/snapshot.h" |
| 24 #include "vm/stub_code.h" | 24 #include "vm/stub_code.h" |
| 25 #include "vm/symbols.h" | 25 #include "vm/symbols.h" |
| 26 #include "vm/thread_interrupter.h" | 26 #include "vm/thread_interrupter.h" |
| 27 #include "vm/thread_pool.h" | 27 #include "vm/thread_pool.h" |
| 28 #include "vm/virtual_memory.h" | 28 #include "vm/virtual_memory.h" |
| 29 #include "vm/zone.h" | 29 #include "vm/zone.h" |
| 30 | 30 |
| 31 namespace dart { | 31 namespace dart { |
| 32 | 32 |
| 33 DEFINE_FLAG(int, new_gen_heap_size, 32, "new gen heap size in MB," |
| 34 "e.g: --new_gen_heap_size=64 allocates a 64MB new gen heap"); |
| 35 DEFINE_FLAG(int, old_gen_heap_size, Heap::kHeapSizeInMB, |
| 36 "old gen heap size in MB," |
| 37 "e.g: --old_gen_heap_size=1024 allocates a 1024MB old gen heap"); |
| 38 |
| 33 DECLARE_FLAG(bool, print_class_table); | 39 DECLARE_FLAG(bool, print_class_table); |
| 34 DECLARE_FLAG(bool, trace_isolates); | 40 DECLARE_FLAG(bool, trace_isolates); |
| 35 | 41 |
| 36 Isolate* Dart::vm_isolate_ = NULL; | 42 Isolate* Dart::vm_isolate_ = NULL; |
| 37 ThreadPool* Dart::thread_pool_ = NULL; | 43 ThreadPool* Dart::thread_pool_ = NULL; |
| 38 DebugInfo* Dart::pprof_symbol_generator_ = NULL; | 44 DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
| 39 ReadOnlyHandles* Dart::predefined_handles_ = NULL; | 45 ReadOnlyHandles* Dart::predefined_handles_ = NULL; |
| 40 | 46 |
| 41 // An object visitor which will mark all visited objects. This is used to | 47 // An object visitor which will mark all visited objects. This is used to |
| 42 // premark all objects in the vm_isolate_ heap. | 48 // premark all objects in the vm_isolate_ heap. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 predefined_handles_ = new ReadOnlyHandles(); | 116 predefined_handles_ = new ReadOnlyHandles(); |
| 111 // Create the VM isolate and finish the VM initialization. | 117 // Create the VM isolate and finish the VM initialization. |
| 112 ASSERT(thread_pool_ == NULL); | 118 ASSERT(thread_pool_ == NULL); |
| 113 thread_pool_ = new ThreadPool(); | 119 thread_pool_ = new ThreadPool(); |
| 114 { | 120 { |
| 115 ASSERT(vm_isolate_ == NULL); | 121 ASSERT(vm_isolate_ == NULL); |
| 116 ASSERT(Flags::Initialized()); | 122 ASSERT(Flags::Initialized()); |
| 117 vm_isolate_ = Isolate::Init("vm-isolate"); | 123 vm_isolate_ = Isolate::Init("vm-isolate"); |
| 118 StackZone zone(vm_isolate_); | 124 StackZone zone(vm_isolate_); |
| 119 HandleScope handle_scope(vm_isolate_); | 125 HandleScope handle_scope(vm_isolate_); |
| 120 Heap::Init(vm_isolate_); | 126 Heap::Init(vm_isolate_, |
| 127 0, // New gen size 0; VM isolate should only allocate in old. |
| 128 FLAG_old_gen_heap_size * MBInWords); |
| 121 ObjectStore::Init(vm_isolate_); | 129 ObjectStore::Init(vm_isolate_); |
| 122 TargetCPUFeatures::InitOnce(); | 130 TargetCPUFeatures::InitOnce(); |
| 123 Object::InitOnce(); | 131 Object::InitOnce(); |
| 124 ArgumentsDescriptor::InitOnce(); | 132 ArgumentsDescriptor::InitOnce(); |
| 125 StubCode::InitOnce(); | 133 StubCode::InitOnce(); |
| 126 Symbols::InitOnce(vm_isolate_); | 134 Symbols::InitOnce(vm_isolate_); |
| 127 Scanner::InitOnce(); | 135 Scanner::InitOnce(); |
| 128 Object::CreateInternalMetaData(); | 136 Object::CreateInternalMetaData(); |
| 129 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 137 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 130 // Dart VM requires at least SSE2. | 138 // Dart VM requires at least SSE2. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 204 } |
| 197 | 205 |
| 198 | 206 |
| 199 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { | 207 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { |
| 200 // Initialize the new isolate. | 208 // Initialize the new isolate. |
| 201 Isolate* isolate = Isolate::Current(); | 209 Isolate* isolate = Isolate::Current(); |
| 202 TIMERSCOPE(isolate, time_isolate_initialization); | 210 TIMERSCOPE(isolate, time_isolate_initialization); |
| 203 ASSERT(isolate != NULL); | 211 ASSERT(isolate != NULL); |
| 204 StackZone zone(isolate); | 212 StackZone zone(isolate); |
| 205 HandleScope handle_scope(isolate); | 213 HandleScope handle_scope(isolate); |
| 206 Heap::Init(isolate); | 214 Heap::Init(isolate, |
| 215 FLAG_new_gen_heap_size * MBInWords, |
| 216 FLAG_old_gen_heap_size * MBInWords); |
| 207 ObjectIdRing::Init(isolate); | 217 ObjectIdRing::Init(isolate); |
| 208 ObjectStore::Init(isolate); | 218 ObjectStore::Init(isolate); |
| 209 | 219 |
| 210 if (snapshot_buffer == NULL) { | 220 if (snapshot_buffer == NULL) { |
| 211 const Error& error = Error::Handle(Object::Init(isolate)); | 221 const Error& error = Error::Handle(Object::Init(isolate)); |
| 212 if (!error.IsNull()) { | 222 if (!error.IsNull()) { |
| 213 return error.raw(); | 223 return error.raw(); |
| 214 } | 224 } |
| 215 } else { | 225 } else { |
| 216 // Initialize from snapshot (this should replicate the functionality | 226 // Initialize from snapshot (this should replicate the functionality |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return predefined_handles_->handles_.AllocateScopedHandle(); | 297 return predefined_handles_->handles_.AllocateScopedHandle(); |
| 288 } | 298 } |
| 289 | 299 |
| 290 | 300 |
| 291 bool Dart::IsReadOnlyHandle(uword address) { | 301 bool Dart::IsReadOnlyHandle(uword address) { |
| 292 ASSERT(predefined_handles_ != NULL); | 302 ASSERT(predefined_handles_ != NULL); |
| 293 return predefined_handles_->handles_.IsValidScopedHandle(address); | 303 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 294 } | 304 } |
| 295 | 305 |
| 296 } // namespace dart | 306 } // namespace dart |
| OLD | NEW |