OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 : program_(program), | 97 : program_(program), |
98 thread_(dart::Thread::Current()), | 98 thread_(dart::Thread::Current()), |
99 zone_(thread_->zone()), | 99 zone_(thread_->zone()), |
100 isolate_(thread_->isolate()), | 100 isolate_(thread_->isolate()), |
101 scripts_(Array::ZoneHandle(zone_)), | 101 scripts_(Array::ZoneHandle(zone_)), |
102 translation_helper_(this, thread_, zone_, isolate_), | 102 translation_helper_(this, thread_, zone_, isolate_), |
103 type_translator_(&translation_helper_, | 103 type_translator_(&translation_helper_, |
104 &active_class_, | 104 &active_class_, |
105 /*finalize=*/false) { | 105 /*finalize=*/false) { |
106 intptr_t source_file_count = program_->line_starting_table().size(); | 106 intptr_t source_file_count = program_->line_starting_table().size(); |
107 scripts_ = Array::New(source_file_count); | 107 scripts_ = Array::New(source_file_count, Heap::kOld); |
108 } | 108 } |
109 | 109 |
110 Object& KernelReader::ReadProgram() { | 110 Object& KernelReader::ReadProgram() { |
111 LongJumpScope jump; | 111 LongJumpScope jump; |
112 if (setjmp(*jump.Set()) == 0) { | 112 if (setjmp(*jump.Set()) == 0) { |
113 Procedure* main = program_->main_method(); | 113 Procedure* main = program_->main_method(); |
114 Library* kernel_main_library = Library::Cast(main->parent()); | 114 Library* kernel_main_library = Library::Cast(main->parent()); |
115 | 115 |
116 intptr_t length = program_->libraries().length(); | 116 intptr_t length = program_->libraries().length(); |
117 for (intptr_t i = 0; i < length; i++) { | 117 for (intptr_t i = 0; i < length; i++) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (kernel_normal_class->super_class() != NULL) { | 258 if (kernel_normal_class->super_class() != NULL) { |
259 AbstractType& super_type = | 259 AbstractType& super_type = |
260 T.TranslateTypeWithoutFinalization(kernel_normal_class->super_class()); | 260 T.TranslateTypeWithoutFinalization(kernel_normal_class->super_class()); |
261 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); | 261 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); |
262 klass->set_super_type(super_type); | 262 klass->set_super_type(super_type); |
263 } | 263 } |
264 | 264 |
265 // Build implemented interface types | 265 // Build implemented interface types |
266 intptr_t interface_count = kernel_klass->implemented_classes().length(); | 266 intptr_t interface_count = kernel_klass->implemented_classes().length(); |
267 const dart::Array& interfaces = | 267 const dart::Array& interfaces = |
268 dart::Array::Handle(Z, dart::Array::New(interface_count)); | 268 dart::Array::Handle(Z, dart::Array::New(interface_count, Heap::kOld)); |
269 for (intptr_t i = 0; i < interface_count; i++) { | 269 for (intptr_t i = 0; i < interface_count; i++) { |
270 InterfaceType* kernel_interface_type = | 270 InterfaceType* kernel_interface_type = |
271 kernel_klass->implemented_classes()[i]; | 271 kernel_klass->implemented_classes()[i]; |
272 const AbstractType& type = | 272 const AbstractType& type = |
273 T.TranslateTypeWithoutFinalization(kernel_interface_type); | 273 T.TranslateTypeWithoutFinalization(kernel_interface_type); |
274 if (type.IsMalformed()) H.ReportError("Malformed interface type."); | 274 if (type.IsMalformed()) H.ReportError("Malformed interface type."); |
275 interfaces.SetAt(i, type); | 275 interfaces.SetAt(i, type); |
276 } | 276 } |
277 klass->set_interfaces(interfaces); | 277 klass->set_interfaces(interfaces); |
278 if (kernel_klass->is_abstract()) klass->set_is_abstract(); | 278 if (kernel_klass->is_abstract()) klass->set_is_abstract(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script)); | 428 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script)); |
429 } | 429 } |
430 return klass; | 430 return klass; |
431 } | 431 } |
432 | 432 |
433 Script& KernelReader::ScriptAt(intptr_t source_uri_index) { | 433 Script& KernelReader::ScriptAt(intptr_t source_uri_index) { |
434 Script& script = Script::ZoneHandle(Z); | 434 Script& script = Script::ZoneHandle(Z); |
435 script ^= scripts_.At(source_uri_index); | 435 script ^= scripts_.At(source_uri_index); |
436 if (script.IsNull()) { | 436 if (script.IsNull()) { |
437 String* uri = program_->source_uri_table().strings()[source_uri_index]; | 437 String* uri = program_->source_uri_table().strings()[source_uri_index]; |
438 script = Script::New(H.DartString(uri), dart::String::ZoneHandle(Z), | 438 script = Script::New(H.DartString(uri, Heap::kOld), |
439 RawScript::kKernelTag); | 439 dart::String::ZoneHandle(Z), RawScript::kKernelTag); |
440 scripts_.SetAt(source_uri_index, script); | 440 scripts_.SetAt(source_uri_index, script); |
441 intptr_t* line_starts = | 441 intptr_t* line_starts = |
442 program_->line_starting_table().valuesFor(source_uri_index); | 442 program_->line_starting_table().valuesFor(source_uri_index); |
443 intptr_t line_count = line_starts[0]; | 443 intptr_t line_count = line_starts[0]; |
444 Array& array_object = Array::Handle(Z, Array::New(line_count)); | 444 Array& array_object = Array::Handle(Z, Array::New(line_count, Heap::kOld)); |
445 Smi& value = Smi::Handle(Z); | 445 Smi& value = Smi::Handle(Z); |
446 for (intptr_t i = 0; i < line_count; ++i) { | 446 for (intptr_t i = 0; i < line_count; ++i) { |
447 value = Smi::New(line_starts[i + 1]); | 447 value = Smi::New(line_starts[i + 1]); |
448 array_object.SetAt(i, value); | 448 array_object.SetAt(i, value); |
449 } | 449 } |
450 script.set_line_starts(array_object); | 450 script.set_line_starts(array_object); |
451 } | 451 } |
452 return script; | 452 return script; |
453 } | 453 } |
454 | 454 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 initializer_fun.set_is_debuggable(false); | 708 initializer_fun.set_is_debuggable(false); |
709 initializer_fun.set_is_reflectable(false); | 709 initializer_fun.set_is_reflectable(false); |
710 initializer_fun.set_is_inlinable(false); | 710 initializer_fun.set_is_inlinable(false); |
711 return new (zone) ParsedFunction(thread, initializer_fun); | 711 return new (zone) ParsedFunction(thread, initializer_fun); |
712 } | 712 } |
713 | 713 |
714 | 714 |
715 } // namespace kernel | 715 } // namespace kernel |
716 } // namespace dart | 716 } // namespace dart |
717 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 717 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |