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

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

Issue 2665753002: Reapply "Create an app snapshot of the Dart front end." (Closed)
Patch Set: merge Created 3 years, 10 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
« no previous file with comments | « runtime/tools/kernel-service.dart ('k') | tools/testing/dart/compiler_configuration.dart » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/kernel_isolate.h" 5 #include "vm/kernel_isolate.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 KernelIsolate::FinishedInitializing(); 67 KernelIsolate::FinishedInitializing();
68 return; 68 return;
69 } 69 }
70 70
71 Dart_IsolateFlags api_flags; 71 Dart_IsolateFlags api_flags;
72 Isolate::FlagsInitialize(&api_flags); 72 Isolate::FlagsInitialize(&api_flags);
73 73
74 isolate = reinterpret_cast<Isolate*>(create_callback( 74 isolate = reinterpret_cast<Isolate*>(create_callback(
75 KernelIsolate::kName, NULL, NULL, NULL, &api_flags, NULL, &error)); 75 KernelIsolate::kName, NULL, NULL, NULL, &api_flags, NULL, &error));
76 if (isolate == NULL) { 76 if (isolate == NULL) {
77 if (FLAG_trace_kernel) { 77 OS::PrintErr(DART_KERNEL_ISOLATE_NAME ": Isolate creation error: %s\n",
78 OS::PrintErr(DART_KERNEL_ISOLATE_NAME ": Isolate creation error: %s\n", 78 error);
79 error);
80 }
81 KernelIsolate::SetKernelIsolate(NULL); 79 KernelIsolate::SetKernelIsolate(NULL);
82 KernelIsolate::FinishedInitializing(); 80 KernelIsolate::FinishedInitializing();
83 return; 81 return;
84 } 82 }
85 83
86 bool init_success = false; 84 bool init_success = false;
87 { 85 {
88 ASSERT(Isolate::Current() == NULL); 86 ASSERT(Isolate::Current() == NULL);
89 StartIsolateScope start_scope(isolate); 87 StartIsolateScope start_scope(isolate);
90 init_success = RunMain(isolate); 88 init_success = RunMain(isolate);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 142
145 bool RunMain(Isolate* I) { 143 bool RunMain(Isolate* I) {
146 Thread* T = Thread::Current(); 144 Thread* T = Thread::Current();
147 ASSERT(I == T->isolate()); 145 ASSERT(I == T->isolate());
148 StackZone zone(T); 146 StackZone zone(T);
149 HANDLESCOPE(T); 147 HANDLESCOPE(T);
150 // Invoke main which will return the port to which load requests are sent. 148 // Invoke main which will return the port to which load requests are sent.
151 const Library& root_library = 149 const Library& root_library =
152 Library::Handle(Z, I->object_store()->root_library()); 150 Library::Handle(Z, I->object_store()->root_library());
153 if (root_library.IsNull()) { 151 if (root_library.IsNull()) {
154 if (FLAG_trace_kernel) { 152 OS::Print(DART_KERNEL_ISOLATE_NAME
155 OS::Print(DART_KERNEL_ISOLATE_NAME 153 ": Embedder did not install a script.");
156 ": Embedder did not install a script.");
157 }
158 // Kernel isolate is not supported by embedder. 154 // Kernel isolate is not supported by embedder.
159 return false; 155 return false;
160 } 156 }
161 ASSERT(!root_library.IsNull()); 157 ASSERT(!root_library.IsNull());
162 const String& entry_name = String::Handle(Z, String::New("main")); 158 const String& entry_name = String::Handle(Z, String::New("main"));
163 ASSERT(!entry_name.IsNull()); 159 ASSERT(!entry_name.IsNull());
164 const Function& entry = Function::Handle( 160 const Function& entry = Function::Handle(
165 Z, root_library.LookupFunctionAllowPrivate(entry_name)); 161 Z, root_library.LookupFunctionAllowPrivate(entry_name));
166 if (entry.IsNull()) { 162 if (entry.IsNull()) {
167 // Kernel isolate is not supported by embedder. 163 // Kernel isolate is not supported by embedder.
168 if (FLAG_trace_kernel) { 164 OS::Print(DART_KERNEL_ISOLATE_NAME
169 OS::Print(DART_KERNEL_ISOLATE_NAME 165 ": Embedder did not provide a main function.");
170 ": Embedder did not provide a main function.");
171 }
172 return false; 166 return false;
173 } 167 }
174 ASSERT(!entry.IsNull()); 168 ASSERT(!entry.IsNull());
175 const Object& result = Object::Handle( 169 const Object& result = Object::Handle(
176 Z, DartEntry::InvokeFunction(entry, Object::empty_array())); 170 Z, DartEntry::InvokeFunction(entry, Object::empty_array()));
177 ASSERT(!result.IsNull()); 171 ASSERT(!result.IsNull());
178 if (result.IsError()) { 172 if (result.IsError()) {
179 // Kernel isolate did not initialize properly. 173 // Kernel isolate did not initialize properly.
180 if (FLAG_trace_kernel) { 174 const Error& error = Error::Cast(result);
181 const Error& error = Error::Cast(result); 175 OS::Print(DART_KERNEL_ISOLATE_NAME
182 OS::Print(DART_KERNEL_ISOLATE_NAME 176 ": Calling main resulted in an error: %s",
183 ": Calling main resulted in an error: %s", 177 error.ToErrorCString());
184 error.ToErrorCString());
185 }
186 return false; 178 return false;
187 } 179 }
188 ASSERT(result.IsReceivePort()); 180 ASSERT(result.IsReceivePort());
189 const ReceivePort& rp = ReceivePort::Cast(result); 181 const ReceivePort& rp = ReceivePort::Cast(result);
190 KernelIsolate::SetLoadPort(rp.Id()); 182 KernelIsolate::SetLoadPort(rp.Id());
191 return true; 183 return true;
192 } 184 }
193 }; 185 };
194 186
195 187
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 433 }
442 434
443 KernelCompilationRequest request; 435 KernelCompilationRequest request;
444 return request.SendAndWaitForResponse(kernel_port, script_uri); 436 return request.SendAndWaitForResponse(kernel_port, script_uri);
445 } 437 }
446 438
447 439
448 #endif // DART_PRECOMPILED_RUNTIME 440 #endif // DART_PRECOMPILED_RUNTIME
449 441
450 } // namespace dart 442 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tools/kernel-service.dart ('k') | tools/testing/dart/compiler_configuration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698