Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: runtime/vm/dart.cc

Issue 10675010: - Premark vm_isolate objects to avoid having to test for them (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/gc_marker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/dart_api_state.h" 7 #include "vm/dart_api_state.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/freelist.h" 9 #include "vm/freelist.h"
10 #include "vm/handles.h" 10 #include "vm/handles.h"
(...skipping 11 matching lines...) Expand all
22 namespace dart { 22 namespace dart {
23 23
24 DECLARE_FLAG(bool, print_class_table); 24 DECLARE_FLAG(bool, print_class_table);
25 DECLARE_FLAG(bool, trace_isolates); 25 DECLARE_FLAG(bool, trace_isolates);
26 26
27 Isolate* Dart::vm_isolate_ = NULL; 27 Isolate* Dart::vm_isolate_ = NULL;
28 ThreadPool* Dart::thread_pool_ = NULL; 28 ThreadPool* Dart::thread_pool_ = NULL;
29 DebugInfo* Dart::pprof_symbol_generator_ = NULL; 29 DebugInfo* Dart::pprof_symbol_generator_ = NULL;
30 FileWriterFunction Dart::flow_graph_writer_ = NULL; 30 FileWriterFunction Dart::flow_graph_writer_ = NULL;
31 31
32 // An object visitor which will mark all visited objects. This is used to
33 // premark all objects in the vm_isolate_ heap.
34 class PremarkingVisitor : public ObjectVisitor {
35 public:
36 void VisitObject(RawObject* obj) {
37 // RawInstruction objects are premarked on allocation.
38 if (!obj->IsMarked()) {
39 obj->SetMarkBit();
40 }
41 }
42 };
43
44
32 // TODO(turnidge): We should add a corresponding Dart::Cleanup. 45 // TODO(turnidge): We should add a corresponding Dart::Cleanup.
33 bool Dart::InitOnce(Dart_IsolateCreateCallback create, 46 bool Dart::InitOnce(Dart_IsolateCreateCallback create,
34 Dart_IsolateInterruptCallback interrupt) { 47 Dart_IsolateInterruptCallback interrupt) {
35 // TODO(iposva): Fix race condition here. 48 // TODO(iposva): Fix race condition here.
36 if (vm_isolate_ != NULL || !Flags::Initialized()) { 49 if (vm_isolate_ != NULL || !Flags::Initialized()) {
37 return false; 50 return false;
38 } 51 }
39 OS::InitOnce(); 52 OS::InitOnce();
40 VirtualMemory::InitOnce(); 53 VirtualMemory::InitOnce();
41 Isolate::InitOnce(); 54 Isolate::InitOnce();
42 PortMap::InitOnce(); 55 PortMap::InitOnce();
43 FreeListElement::InitOnce(); 56 FreeListElement::InitOnce();
44 Api::InitOnce(); 57 Api::InitOnce();
45 // Create the VM isolate and finish the VM initialization. 58 // Create the VM isolate and finish the VM initialization.
46 ASSERT(thread_pool_ == NULL); 59 ASSERT(thread_pool_ == NULL);
47 thread_pool_ = new ThreadPool(); 60 thread_pool_ = new ThreadPool();
48 { 61 {
49 ASSERT(vm_isolate_ == NULL); 62 ASSERT(vm_isolate_ == NULL);
50 ASSERT(Flags::Initialized()); 63 ASSERT(Flags::Initialized());
51 vm_isolate_ = Isolate::Init("vm-isolate"); 64 vm_isolate_ = Isolate::Init("vm-isolate");
52 Zone zone(vm_isolate_); 65 Zone zone(vm_isolate_);
53 HandleScope handle_scope(vm_isolate_); 66 HandleScope handle_scope(vm_isolate_);
54 Heap::Init(vm_isolate_); 67 Heap::Init(vm_isolate_);
55 ObjectStore::Init(vm_isolate_); 68 ObjectStore::Init(vm_isolate_);
56 Object::InitOnce(); 69 Object::InitOnce();
57 StubCode::InitOnce(); 70 StubCode::InitOnce();
58 Scanner::InitOnce(); 71 Scanner::InitOnce();
72 PremarkingVisitor premarker;
73 vm_isolate_->heap()->IterateOldObjects(&premarker);
59 } 74 }
60 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. 75 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread.
61 Isolate::SetCreateCallback(create); 76 Isolate::SetCreateCallback(create);
62 Isolate::SetInterruptCallback(interrupt); 77 Isolate::SetInterruptCallback(interrupt);
63 return true; 78 return true;
64 } 79 }
65 80
66 81
67 Isolate* Dart::CreateIsolate(const char* name_prefix) { 82 Isolate* Dart::CreateIsolate(const char* name_prefix) {
68 // Create a new isolate. 83 // Create a new isolate.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 127 }
113 128
114 129
115 void Dart::ShutdownIsolate() { 130 void Dart::ShutdownIsolate() {
116 Isolate* isolate = Isolate::Current(); 131 Isolate* isolate = Isolate::Current();
117 isolate->Shutdown(); 132 isolate->Shutdown();
118 delete isolate; 133 delete isolate;
119 } 134 }
120 135
121 } // namespace dart 136 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/gc_marker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698