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

Side by Side Diff: runtime/vm/kernel_reader.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/kernel_reader.h ('k') | runtime/vm/object.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) 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_reader.h" 5 #include "vm/kernel_reader.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary( 86 RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary(
87 Library* library) { 87 Library* library) {
88 return reader_->LookupLibrary(library).raw(); 88 return reader_->LookupLibrary(library).raw();
89 } 89 }
90 90
91 91
92 RawClass* BuildingTranslationHelper::LookupClassByKernelClass(Class* klass) { 92 RawClass* BuildingTranslationHelper::LookupClassByKernelClass(Class* klass) {
93 return reader_->LookupClass(klass).raw(); 93 return reader_->LookupClass(klass).raw();
94 } 94 }
95 95
96 Program* KernelReader::ReadPrecompiledProgram() { 96 KernelReader::KernelReader(Program* program)
97 Program* program = ReadPrecompiledKernelFromBuffer(buffer_, buffer_length_); 97 : program_(program),
98 if (program == NULL) return NULL; 98 thread_(dart::Thread::Current()),
99 intptr_t source_file_count = program->line_starting_table().size(); 99 zone_(thread_->zone()),
100 isolate_(thread_->isolate()),
101 scripts_(Array::ZoneHandle(zone_)),
102 translation_helper_(this, thread_, zone_, isolate_),
103 type_translator_(&translation_helper_,
104 &active_class_,
105 /*finalize=*/false) {
106 intptr_t source_file_count = program_->line_starting_table().size();
100 scripts_ = Array::New(source_file_count); 107 scripts_ = Array::New(source_file_count);
101 program_ = program;
102 return program;
103 } 108 }
104 109
105 Object& KernelReader::ReadProgram() { 110 Object& KernelReader::ReadProgram() {
106 Program* program = ReadPrecompiledProgram();
107 if (program == NULL) {
108 const dart::String& error = H.DartString("Failed to read .kernell file");
109 return Object::Handle(Z, ApiError::New(error));
110 }
111
112 LongJumpScope jump; 111 LongJumpScope jump;
113 if (setjmp(*jump.Set()) == 0) { 112 if (setjmp(*jump.Set()) == 0) {
114 Procedure* main = program->main_method(); 113 Procedure* main = program_->main_method();
115 Library* kernel_main_library = Library::Cast(main->parent()); 114 Library* kernel_main_library = Library::Cast(main->parent());
116 115
117 intptr_t length = program->libraries().length(); 116 intptr_t length = program_->libraries().length();
118 for (intptr_t i = 0; i < length; i++) { 117 for (intptr_t i = 0; i < length; i++) {
119 Library* kernel_library = program->libraries()[i]; 118 Library* kernel_library = program_->libraries()[i];
120 ReadLibrary(kernel_library); 119 ReadLibrary(kernel_library);
121 } 120 }
122 121
123 for (intptr_t i = 0; i < length; i++) { 122 for (intptr_t i = 0; i < length; i++) {
124 dart::Library& library = LookupLibrary(program->libraries()[i]); 123 dart::Library& library = LookupLibrary(program_->libraries()[i]);
125 if (!library.Loaded()) library.SetLoaded(); 124 if (!library.Loaded()) library.SetLoaded();
126 } 125 }
127 126
128 if (!ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) { 127 if (!ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) {
129 FATAL("Error in class finalization during bootstrapping."); 128 FATAL("Error in class finalization during bootstrapping.");
130 } 129 }
131 130
132 dart::Library& library = LookupLibrary(kernel_main_library); 131 dart::Library& library = LookupLibrary(kernel_main_library);
133 132
134 // Sanity check that we can find the main entrypoint. 133 // Sanity check that we can find the main entrypoint.
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 initializer_fun.set_is_debuggable(false); 720 initializer_fun.set_is_debuggable(false);
722 initializer_fun.set_is_reflectable(false); 721 initializer_fun.set_is_reflectable(false);
723 initializer_fun.set_is_inlinable(false); 722 initializer_fun.set_is_inlinable(false);
724 return new (zone) ParsedFunction(thread, initializer_fun); 723 return new (zone) ParsedFunction(thread, initializer_fun);
725 } 724 }
726 725
727 726
728 } // namespace kernel 727 } // namespace kernel
729 } // namespace dart 728 } // namespace dart
730 #endif // !defined(DART_PRECOMPILED_RUNTIME) 729 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_reader.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698