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

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

Issue 2525623002: VM: [Kernel] Split kernel API into 3 steps: ([read binary], parse-binary, bootstrap, load program) (Closed)
Patch Set: addressed comments Created 4 years 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/vm/bootstrap.cc ('k') | runtime/vm/dart.h » ('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/bootstrap.h" 5 #include "vm/bootstrap.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #if !defined(DART_PRECOMPILED_RUNTIME) 9 #if !defined(DART_PRECOMPILED_RUNTIME)
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // through the hoops of trying to compile their scope class. 48 // through the hoops of trying to compile their scope class.
49 ObjectStore* object_store = thread->isolate()->object_store(); 49 ObjectStore* object_store = thread->isolate()->object_store();
50 Class& cls = Class::Handle(thread->zone(), object_store->closure_class()); 50 Class& cls = Class::Handle(thread->zone(), object_store->closure_class());
51 Compiler::CompileClass(cls); 51 Compiler::CompileClass(cls);
52 // Eagerly compile Bool class, bool constants are used from within compiler. 52 // Eagerly compile Bool class, bool constants are used from within compiler.
53 cls = object_store->bool_class(); 53 cls = object_store->bool_class();
54 Compiler::CompileClass(cls); 54 Compiler::CompileClass(cls);
55 } 55 }
56 56
57 57
58 RawError* BootstrapFromKernel(Thread* thread, 58 RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) {
59 const uint8_t* buffer,
60 intptr_t buffer_length) {
61 Zone* zone = thread->zone(); 59 Zone* zone = thread->zone();
62 kernel::KernelReader reader(buffer, buffer_length); 60 kernel::KernelReader reader(program);
63 kernel::Program* program = reader.ReadPrecompiledProgram();
64 if (program == NULL) {
65 const String& message =
66 String::Handle(zone, String::New("Failed to read Kernel file"));
67 return ApiError::New(message);
68 }
69
70 Isolate* isolate = thread->isolate(); 61 Isolate* isolate = thread->isolate();
71 // Mark the already-pending classes. This mark bit will be used to avoid 62 // Mark the already-pending classes. This mark bit will be used to avoid
72 // adding classes to the list more than once. 63 // adding classes to the list more than once.
73 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle( 64 GrowableObjectArray& pending_classes = GrowableObjectArray::Handle(
74 zone, isolate->object_store()->pending_classes()); 65 zone, isolate->object_store()->pending_classes());
75 dart::Class& pending = dart::Class::Handle(zone); 66 dart::Class& pending = dart::Class::Handle(zone);
76 for (intptr_t i = 0; i < pending_classes.Length(); ++i) { 67 for (intptr_t i = 0; i < pending_classes.Length(); ++i) {
77 pending ^= pending_classes.At(i); 68 pending ^= pending_classes.At(i);
78 pending.set_is_marked_for_parsing(); 69 pending.set_is_marked_for_parsing();
79 } 70 }
(...skipping 15 matching lines...) Expand all
95 break; 86 break;
96 } 87 }
97 } 88 }
98 } 89 }
99 90
100 Finish(thread, /*from_kernel=*/true); 91 Finish(thread, /*from_kernel=*/true);
101 return Error::null(); 92 return Error::null();
102 } 93 }
103 94
104 95
105 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, 96 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) {
106 intptr_t kernel_buffer_length) {
107 Thread* thread = Thread::Current(); 97 Thread* thread = Thread::Current();
108 Isolate* isolate = thread->isolate(); 98 Isolate* isolate = thread->isolate();
109 Zone* zone = thread->zone(); 99 Zone* zone = thread->zone();
110 String& uri = String::Handle(zone); 100 String& uri = String::Handle(zone);
111 Library& lib = Library::Handle(zone); 101 Library& lib = Library::Handle(zone);
112 102
113 HANDLESCOPE(thread); 103 HANDLESCOPE(thread);
114 104
115 // Ensure there are library objects for all the bootstrap libraries. 105 // Ensure there are library objects for all the bootstrap libraries.
116 for (intptr_t i = 0; i < bootstrap_library_count; ++i) { 106 for (intptr_t i = 0; i < bootstrap_library_count; ++i) {
117 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index; 107 ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
118 uri = Symbols::New(thread, bootstrap_libraries[i].uri); 108 uri = Symbols::New(thread, bootstrap_libraries[i].uri);
119 lib = isolate->object_store()->bootstrap_library(id); 109 lib = isolate->object_store()->bootstrap_library(id);
120 ASSERT(lib.raw() == Library::LookupLibrary(thread, uri)); 110 ASSERT(lib.raw() == Library::LookupLibrary(thread, uri));
121 if (lib.IsNull()) { 111 if (lib.IsNull()) {
122 lib = Library::NewLibraryHelper(uri, false); 112 lib = Library::NewLibraryHelper(uri, false);
123 lib.SetLoadRequested(); 113 lib.SetLoadRequested();
124 lib.Register(thread); 114 lib.Register(thread);
125 isolate->object_store()->set_bootstrap_library(id, lib); 115 isolate->object_store()->set_bootstrap_library(id, lib);
126 } 116 }
127 } 117 }
128 118
129 ASSERT(kernel_buffer != NULL); 119 return BootstrapFromKernel(thread, program);
130 return BootstrapFromKernel(thread, kernel_buffer, kernel_buffer_length);
131 } 120 }
132 #else 121 #else
133 RawError* Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer, 122 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) {
134 intptr_t kernel_buffer_length) {
135 UNREACHABLE(); 123 UNREACHABLE();
136 return Error::null(); 124 return Error::null();
137 } 125 }
138 #endif // !defined(DART_PRECOMPILED_RUNTIME) 126 #endif // !defined(DART_PRECOMPILED_RUNTIME)
139 127
140 } // namespace dart 128 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap.cc ('k') | runtime/vm/dart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698