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

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

Issue 10823028: - Improve the formatting of generated source text. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/object.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"
11 #include "vm/heap.h" 11 #include "vm/heap.h"
12 #include "vm/isolate.h" 12 #include "vm/isolate.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/port.h" 15 #include "vm/port.h"
16 #include "vm/snapshot.h" 16 #include "vm/snapshot.h"
17 #include "vm/stub_code.h" 17 #include "vm/stub_code.h"
18 #include "vm/symbols.h" 18 #include "vm/symbols.h"
19 #include "vm/thread_pool.h" 19 #include "vm/thread_pool.h"
20 #include "vm/virtual_memory.h" 20 #include "vm/virtual_memory.h"
21 #include "vm/zone.h" 21 #include "vm/zone.h"
22 22
23 namespace dart { 23 namespace dart {
24 24
25 DECLARE_FLAG(bool, print_bootstrap);
25 DECLARE_FLAG(bool, print_class_table); 26 DECLARE_FLAG(bool, print_class_table);
26 DECLARE_FLAG(bool, trace_isolates); 27 DECLARE_FLAG(bool, trace_isolates);
27 28
28 Isolate* Dart::vm_isolate_ = NULL; 29 Isolate* Dart::vm_isolate_ = NULL;
29 ThreadPool* Dart::thread_pool_ = NULL; 30 ThreadPool* Dart::thread_pool_ = NULL;
30 DebugInfo* Dart::pprof_symbol_generator_ = NULL; 31 DebugInfo* Dart::pprof_symbol_generator_ = NULL;
31 FileWriterFunction Dart::flow_graph_writer_ = NULL; 32 FileWriterFunction Dart::flow_graph_writer_ = NULL;
32 33
33 // An object visitor which will mark all visited objects. This is used to 34 // An object visitor which will mark all visited objects. This is used to
34 // premark all objects in the vm_isolate_ heap. 35 // premark all objects in the vm_isolate_ heap.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 88
88 Isolate* Dart::CreateIsolate(const char* name_prefix) { 89 Isolate* Dart::CreateIsolate(const char* name_prefix) {
89 // Create a new isolate. 90 // Create a new isolate.
90 Isolate* isolate = Isolate::Init(name_prefix); 91 Isolate* isolate = Isolate::Init(name_prefix);
91 ASSERT(isolate != NULL); 92 ASSERT(isolate != NULL);
92 return isolate; 93 return isolate;
93 } 94 }
94 95
95 96
97 static void PrintLibrarySources(Isolate* isolate) {
98 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
99 isolate->object_store()->libraries());
100 intptr_t lib_count = libs.Length();
101 Library& lib = Library::Handle();
102 Array& scripts = Array::Handle();
103 Script& script = Script::Handle();
104 String& url = String::Handle();
105 String& source = String::Handle();
106 for (int i = 0; i < lib_count; i++) {
107 lib ^= libs.At(i);
108 url = lib.url();
109 OS::Print("Library %s:\n", url.ToCString());
110 scripts = lib.LoadedScripts();
111 intptr_t script_count = scripts.Length();
112 for (intptr_t i = 0; i < script_count; i++) {
113 script ^= scripts.At(i);
114 url = script.url();
115 source = script.Source();
116 OS::Print("Source for %s:\n", url.ToCString());
117 OS::Print("%s\n", source.ToCString());
118 }
siva 2012/07/26 00:51:05 In the non snapshot case the print-bootstrap flat
119 }
120 }
121
122
96 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) { 123 RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
97 // Initialize the new isolate. 124 // Initialize the new isolate.
98 TIMERSCOPE(time_isolate_initialization); 125 TIMERSCOPE(time_isolate_initialization);
99 Isolate* isolate = Isolate::Current(); 126 Isolate* isolate = Isolate::Current();
100 ASSERT(isolate != NULL); 127 ASSERT(isolate != NULL);
101 Zone zone(isolate); 128 Zone zone(isolate);
102 HandleScope handle_scope(isolate); 129 HandleScope handle_scope(isolate);
103 Heap::Init(isolate); 130 Heap::Init(isolate);
104 ObjectStore::Init(isolate); 131 ObjectStore::Init(isolate);
105 132
106 if (snapshot_buffer == NULL) { 133 if (snapshot_buffer == NULL) {
107 const Error& error = Error::Handle(Object::Init(isolate)); 134 const Error& error = Error::Handle(Object::Init(isolate));
108 if (!error.IsNull()) { 135 if (!error.IsNull()) {
109 return error.raw(); 136 return error.raw();
110 } 137 }
111 } else { 138 } else {
112 // Initialize from snapshot (this should replicate the functionality 139 // Initialize from snapshot (this should replicate the functionality
113 // of Object::Init(..) in a regular isolate creation path. 140 // of Object::Init(..) in a regular isolate creation path.
114 Object::InitFromSnapshot(isolate); 141 Object::InitFromSnapshot(isolate);
115 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); 142 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
116 if (FLAG_trace_isolates) { 143 if (FLAG_trace_isolates) {
117 OS::Print("Size of isolate snapshot = %ld\n", snapshot->length()); 144 OS::Print("Size of isolate snapshot = %ld\n", snapshot->length());
118 } 145 }
119 SnapshotReader reader(snapshot, isolate); 146 SnapshotReader reader(snapshot, isolate);
120 reader.ReadFullSnapshot(); 147 reader.ReadFullSnapshot();
121 if (FLAG_trace_isolates) { 148 if (FLAG_trace_isolates) {
122 isolate->heap()->PrintSizes(); 149 isolate->heap()->PrintSizes();
123 } 150 }
151 if (FLAG_print_bootstrap) {
152 PrintLibrarySources(isolate);
153 }
124 } 154 }
125 155
126 StubCode::Init(isolate); 156 StubCode::Init(isolate);
127 isolate->heap()->EnableGrowthControl(); 157 isolate->heap()->EnableGrowthControl();
128 isolate->set_init_callback_data(data); 158 isolate->set_init_callback_data(data);
129 if (FLAG_print_class_table) { 159 if (FLAG_print_class_table) {
130 isolate->class_table()->Print(); 160 isolate->class_table()->Print();
131 } 161 }
132 return Error::null(); 162 return Error::null();
133 } 163 }
134 164
135 165
136 void Dart::ShutdownIsolate() { 166 void Dart::ShutdownIsolate() {
137 Isolate* isolate = Isolate::Current(); 167 Isolate* isolate = Isolate::Current();
138 void* callback_data = isolate->init_callback_data(); 168 void* callback_data = isolate->init_callback_data();
139 isolate->Shutdown(); 169 isolate->Shutdown();
140 delete isolate; 170 delete isolate;
141 171
142 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); 172 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback();
143 if (callback != NULL) { 173 if (callback != NULL) {
144 (callback)(callback_data); 174 (callback)(callback_data);
145 } 175 }
146 } 176 }
147 177
148 } // namespace dart 178 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698