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/kernel_binary.h" | 10 #include "vm/kernel_binary.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 TypedData& offsets = TypedData::Handle( | 148 TypedData& offsets = TypedData::Handle( |
149 Z, TypedData::New(kTypedDataUint32ArrayCid, count, Heap::kOld)); | 149 Z, TypedData::New(kTypedDataUint32ArrayCid, count, Heap::kOld)); |
150 offsets.SetUint32(0, 0); | 150 offsets.SetUint32(0, 0); |
151 intptr_t end_offset = 0; | 151 intptr_t end_offset = 0; |
152 for (intptr_t i = 1; i < count; ++i) { | 152 for (intptr_t i = 1; i < count; ++i) { |
153 end_offset = reader.ReadUInt(); | 153 end_offset = reader.ReadUInt(); |
154 offsets.SetUint32(i << 2, end_offset); | 154 offsets.SetUint32(i << 2, end_offset); |
155 } | 155 } |
156 | 156 |
157 // Copy the string data out of the binary and into the VM's heap. | 157 // Copy the string data out of the binary and into the VM's heap. |
158 TypedData& data = TypedData::Handle( | 158 TypedData& data = |
159 Z, TypedData::New(kTypedDataUint8ArrayCid, end_offset, Heap::kOld)); | 159 reader.CopyDataToVMHeap(Z, reader.offset(), reader.offset() + end_offset); |
160 { | |
161 NoSafepointScope no_safepoint; | |
162 memmove(data.DataAddr(0), reader.buffer() + reader.offset(), end_offset); | |
163 } | |
164 | 160 |
165 // Copy the canonical names into the VM's heap. Encode them as unsigned, so | 161 // Copy the canonical names into the VM's heap. Encode them as unsigned, so |
166 // the parent indexes are adjusted when extracted. | 162 // the parent indexes are adjusted when extracted. |
167 reader.set_offset(program->name_table_offset()); | 163 reader.set_offset(program->name_table_offset()); |
168 count = reader.ReadUInt() * 2; | 164 count = reader.ReadUInt() * 2; |
169 TypedData& names = TypedData::Handle( | 165 TypedData& names = TypedData::Handle( |
170 Z, TypedData::New(kTypedDataUint32ArrayCid, count, Heap::kOld)); | 166 Z, TypedData::New(kTypedDataUint32ArrayCid, count, Heap::kOld)); |
171 for (intptr_t i = 0; i < count; ++i) { | 167 for (intptr_t i = 0; i < count; ++i) { |
172 names.SetUint32(i << 2, reader.ReadUInt()); | 168 names.SetUint32(i << 2, reader.ReadUInt()); |
173 } | 169 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_); | 271 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_); |
276 dart::Field& field = dart::Field::Handle( | 272 dart::Field& field = dart::Field::Handle( |
277 Z, dart::Field::NewTopLevel(name, field_helper.IsFinal(), | 273 Z, dart::Field::NewTopLevel(name, field_helper.IsFinal(), |
278 field_helper.IsConst(), script_class, | 274 field_helper.IsConst(), script_class, |
279 field_helper.position_)); | 275 field_helper.position_)); |
280 field.set_kernel_offset(field_offset); | 276 field.set_kernel_offset(field_offset); |
281 const AbstractType& type = T.BuildType(); // read type. | 277 const AbstractType& type = T.BuildType(); // read type. |
282 field.SetFieldType(type); | 278 field.SetFieldType(type); |
283 field_helper.SetJustRead(FieldHelper::kType); | 279 field_helper.SetJustRead(FieldHelper::kType); |
284 field_helper.ReadUntilExcluding(FieldHelper::kInitializer); | 280 field_helper.ReadUntilExcluding(FieldHelper::kInitializer); |
| 281 intptr_t field_initializer_offset = builder_.ReaderOffset(); |
285 field.set_has_initializer(builder_.PeekTag() == kSomething); | 282 field.set_has_initializer(builder_.PeekTag() == kSomething); |
286 GenerateFieldAccessors(toplevel_class, field, &field_helper, field_offset); | |
287 field_helper.ReadUntilExcluding(FieldHelper::kEnd); | 283 field_helper.ReadUntilExcluding(FieldHelper::kEnd); |
| 284 TypedData& kernel_data = builder_.reader_->CopyDataToVMHeap( |
| 285 Z, field_offset, builder_.ReaderOffset()); |
| 286 field.set_kernel_data(kernel_data); |
| 287 { |
| 288 // GenerateFieldAccessors reads (some of) the initializer. |
| 289 AlternativeReadingScope alt(builder_.reader_, field_initializer_offset); |
| 290 GenerateFieldAccessors(toplevel_class, field, &field_helper, |
| 291 field_offset); |
| 292 } |
288 if (FLAG_enable_mirrors && field_helper.annotation_count_ > 0) { | 293 if (FLAG_enable_mirrors && field_helper.annotation_count_ > 0) { |
289 library.AddFieldMetadata(field, TokenPosition::kNoSource, field_offset); | 294 library.AddFieldMetadata(field, TokenPosition::kNoSource, field_offset, |
| 295 &kernel_data); |
290 } | 296 } |
291 fields_.Add(&field); | 297 fields_.Add(&field); |
292 library.AddObject(field, name); | 298 library.AddObject(field, name); |
293 } | 299 } |
294 toplevel_class.AddFields(fields_); | 300 toplevel_class.AddFields(fields_); |
295 | 301 |
296 // Load toplevel procedures. | 302 // Load toplevel procedures. |
297 intptr_t procedure_count = builder_.ReadListLength(); // read list length. | 303 intptr_t procedure_count = builder_.ReadListLength(); // read list length. |
298 for (intptr_t i = 0; i < procedure_count; ++i) { | 304 for (intptr_t i = 0; i < procedure_count; ++i) { |
299 ReadProcedure(library, toplevel_class, false); | 305 ReadProcedure(library, toplevel_class, false); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // a script to detect test functions that should not be optimized. | 362 // a script to detect test functions that should not be optimized. |
357 if (klass.script() == Script::null()) { | 363 if (klass.script() == Script::null()) { |
358 class_helper.ReadUntilIncluding(ClassHelper::kSourceUriIndex); | 364 class_helper.ReadUntilIncluding(ClassHelper::kSourceUriIndex); |
359 klass.set_script(ScriptAt(class_helper.source_uri_index_)); | 365 klass.set_script(ScriptAt(class_helper.source_uri_index_)); |
360 } | 366 } |
361 if (klass.token_pos() == TokenPosition::kNoSource) { | 367 if (klass.token_pos() == TokenPosition::kNoSource) { |
362 class_helper.ReadUntilIncluding(ClassHelper::kPosition); | 368 class_helper.ReadUntilIncluding(ClassHelper::kPosition); |
363 klass.set_token_pos(class_helper.position_); | 369 klass.set_token_pos(class_helper.position_); |
364 } | 370 } |
365 | 371 |
| 372 class_helper.ReadUntilIncluding(ClassHelper::kAnnotations); |
| 373 intptr_t class_offset_after_annotations = builder_.ReaderOffset(); |
366 class_helper.ReadUntilExcluding(ClassHelper::kTypeParameters); | 374 class_helper.ReadUntilExcluding(ClassHelper::kTypeParameters); |
367 intptr_t type_parameter_counts = | 375 intptr_t type_parameter_counts = |
368 builder_.ReadListLength(); // read type_parameters list length. | 376 builder_.ReadListLength(); // read type_parameters list length. |
369 | 377 |
370 ActiveClassScope active_class_scope(&active_class_, &klass); | 378 ActiveClassScope active_class_scope(&active_class_, &klass); |
371 if (!klass.is_cycle_free()) { | 379 if (!klass.is_cycle_free()) { |
372 ReadPreliminaryClass(&klass, &class_helper, type_parameter_counts); | 380 ReadPreliminaryClass(&klass, &class_helper, type_parameter_counts); |
373 } else { | 381 } else { |
374 for (intptr_t i = 0; i < type_parameter_counts; ++i) { | 382 for (intptr_t i = 0; i < type_parameter_counts; ++i) { |
375 builder_.SkipStringReference(); // read ith name index. | 383 builder_.SkipStringReference(); // read ith name index. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 Z, | 420 Z, |
413 dart::Field::New(name, field_helper.IsStatic(), | 421 dart::Field::New(name, field_helper.IsStatic(), |
414 // In the VM all const fields are implicitly final | 422 // In the VM all const fields are implicitly final |
415 // whereas in Kernel they are not final because they | 423 // whereas in Kernel they are not final because they |
416 // are not explicitly declared that way. | 424 // are not explicitly declared that way. |
417 field_helper.IsFinal() || field_helper.IsConst(), | 425 field_helper.IsFinal() || field_helper.IsConst(), |
418 field_helper.IsConst(), is_reflectable, script_class, | 426 field_helper.IsConst(), is_reflectable, script_class, |
419 type, field_helper.position_)); | 427 type, field_helper.position_)); |
420 field.set_kernel_offset(field_offset); | 428 field.set_kernel_offset(field_offset); |
421 field_helper.ReadUntilExcluding(FieldHelper::kInitializer); | 429 field_helper.ReadUntilExcluding(FieldHelper::kInitializer); |
| 430 intptr_t field_initializer_offset = builder_.ReaderOffset(); |
422 field.set_has_initializer(builder_.PeekTag() == kSomething); | 431 field.set_has_initializer(builder_.PeekTag() == kSomething); |
423 GenerateFieldAccessors(klass, field, &field_helper, field_offset); | |
424 field_helper.ReadUntilExcluding(FieldHelper::kEnd); | 432 field_helper.ReadUntilExcluding(FieldHelper::kEnd); |
| 433 TypedData& kernel_data = builder_.reader_->CopyDataToVMHeap( |
| 434 Z, field_offset, builder_.ReaderOffset()); |
| 435 field.set_kernel_data(kernel_data); |
| 436 { |
| 437 // GenerateFieldAccessors reads (some of) the initializer. |
| 438 AlternativeReadingScope alt(builder_.reader_, field_initializer_offset); |
| 439 GenerateFieldAccessors(klass, field, &field_helper, field_offset); |
| 440 } |
425 if (FLAG_enable_mirrors && field_helper.annotation_count_ > 0) { | 441 if (FLAG_enable_mirrors && field_helper.annotation_count_ > 0) { |
426 library.AddFieldMetadata(field, TokenPosition::kNoSource, field_offset); | 442 library.AddFieldMetadata(field, TokenPosition::kNoSource, field_offset, |
| 443 &kernel_data); |
427 } | 444 } |
428 fields_.Add(&field); | 445 fields_.Add(&field); |
429 } | 446 } |
430 klass.AddFields(fields_); | 447 klass.AddFields(fields_); |
431 class_helper.SetJustRead(ClassHelper::kFields); | 448 class_helper.SetJustRead(ClassHelper::kFields); |
432 } | 449 } |
433 | 450 |
434 class_helper.ReadUntilExcluding(ClassHelper::kConstructors); | 451 class_helper.ReadUntilExcluding(ClassHelper::kConstructors); |
435 int constructor_count = builder_.ReadListLength(); // read list length. | 452 int constructor_count = builder_.ReadListLength(); // read list length. |
436 for (intptr_t i = 0; i < constructor_count; ++i) { | 453 for (intptr_t i = 0; i < constructor_count; ++i) { |
(...skipping 20 matching lines...) Expand all Loading... |
457 FunctionNodeHelper function_node_helper(&builder_); | 474 FunctionNodeHelper function_node_helper(&builder_); |
458 function_node_helper.ReadUntilExcluding( | 475 function_node_helper.ReadUntilExcluding( |
459 FunctionNodeHelper::kRequiredParameterCount); | 476 FunctionNodeHelper::kRequiredParameterCount); |
460 builder_.SetupFunctionParameters(klass, function, | 477 builder_.SetupFunctionParameters(klass, function, |
461 true, // is_method | 478 true, // is_method |
462 false, // is_closure | 479 false, // is_closure |
463 &function_node_helper); | 480 &function_node_helper); |
464 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); | 481 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); |
465 constructor_helper.SetJustRead(ConstructorHelper::kFunction); | 482 constructor_helper.SetJustRead(ConstructorHelper::kFunction); |
466 constructor_helper.ReadUntilExcluding(ConstructorHelper::kEnd); | 483 constructor_helper.ReadUntilExcluding(ConstructorHelper::kEnd); |
| 484 TypedData& kernel_data = builder_.reader_->CopyDataToVMHeap( |
| 485 Z, constructor_offset, builder_.ReaderOffset()); |
| 486 function.set_kernel_data(kernel_data); |
467 | 487 |
468 if (FLAG_enable_mirrors && constructor_helper.annotation_count_ > 0) { | 488 if (FLAG_enable_mirrors && constructor_helper.annotation_count_ > 0) { |
469 library.AddFunctionMetadata(function, TokenPosition::kNoSource, | 489 library.AddFunctionMetadata(function, TokenPosition::kNoSource, |
470 constructor_offset); | 490 constructor_offset, &kernel_data); |
471 } | 491 } |
472 } | 492 } |
473 class_helper.SetJustRead(ClassHelper::kConstructors); | 493 class_helper.SetJustRead(ClassHelper::kConstructors); |
474 | 494 |
475 class_helper.ReadUntilExcluding(ClassHelper::kProcedures); | 495 class_helper.ReadUntilExcluding(ClassHelper::kProcedures); |
476 int procedure_count = builder_.ReadListLength(); // read list length. | 496 int procedure_count = builder_.ReadListLength(); // read list length. |
477 for (intptr_t i = 0; i < procedure_count; ++i) { | 497 for (intptr_t i = 0; i < procedure_count; ++i) { |
478 ReadProcedure(library, klass, true); | 498 ReadProcedure(library, klass, true); |
479 } | 499 } |
480 class_helper.SetJustRead(ClassHelper::kProcedures); | 500 class_helper.SetJustRead(ClassHelper::kProcedures); |
481 | 501 |
482 klass.SetFunctions(Array::Handle(MakeFunctionsArray())); | 502 klass.SetFunctions(Array::Handle(MakeFunctionsArray())); |
483 | 503 |
484 if (!klass.is_marked_for_parsing()) { | 504 if (!klass.is_marked_for_parsing()) { |
485 klass.set_is_marked_for_parsing(); | 505 klass.set_is_marked_for_parsing(); |
486 } | 506 } |
487 | 507 |
488 if (FLAG_enable_mirrors && class_helper.annotation_count_ > 0) { | 508 if (FLAG_enable_mirrors && class_helper.annotation_count_ > 0) { |
| 509 TypedData& header_data = builder_.reader_->CopyDataToVMHeap( |
| 510 Z, class_offset, class_offset_after_annotations); |
489 library.AddClassMetadata(klass, toplevel_class, TokenPosition::kNoSource, | 511 library.AddClassMetadata(klass, toplevel_class, TokenPosition::kNoSource, |
490 class_offset); | 512 class_offset, &header_data); |
491 } | 513 } |
492 | 514 |
493 class_helper.ReadUntilExcluding(ClassHelper::kEnd); | 515 class_helper.ReadUntilExcluding(ClassHelper::kEnd); |
494 | 516 |
495 return klass; | 517 return klass; |
496 } | 518 } |
497 | 519 |
498 void KernelReader::ReadProcedure(const dart::Library& library, | 520 void KernelReader::ReadProcedure(const dart::Library& library, |
499 const dart::Class& owner, | 521 const dart::Class& owner, |
500 bool in_class) { | 522 bool in_class) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); | 651 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); |
630 procedure_helper.SetJustRead(ProcedureHelper::kFunction); | 652 procedure_helper.SetJustRead(ProcedureHelper::kFunction); |
631 | 653 |
632 if (!in_class) { | 654 if (!in_class) { |
633 library.AddObject(function, name); | 655 library.AddObject(function, name); |
634 ASSERT(!Object::Handle( | 656 ASSERT(!Object::Handle( |
635 Z, library.LookupObjectAllowPrivate( | 657 Z, library.LookupObjectAllowPrivate( |
636 H.DartProcedureName(procedure_helper.canonical_name_))) | 658 H.DartProcedureName(procedure_helper.canonical_name_))) |
637 .IsNull()); | 659 .IsNull()); |
638 } | 660 } |
| 661 |
| 662 procedure_helper.ReadUntilExcluding(ProcedureHelper::kEnd); |
| 663 TypedData& kernel_data = builder_.reader_->CopyDataToVMHeap( |
| 664 Z, procedure_offset, builder_.ReaderOffset()); |
| 665 function.set_kernel_data(kernel_data); |
| 666 |
639 if (FLAG_enable_mirrors && annotation_count > 0) { | 667 if (FLAG_enable_mirrors && annotation_count > 0) { |
640 library.AddFunctionMetadata(function, TokenPosition::kNoSource, | 668 library.AddFunctionMetadata(function, TokenPosition::kNoSource, |
641 procedure_offset); | 669 procedure_offset, &kernel_data); |
642 } | 670 } |
643 | |
644 procedure_helper.ReadUntilExcluding(ProcedureHelper::kEnd); | |
645 } | 671 } |
646 | 672 |
647 void KernelReader::ReadAndSetupTypeParameters( | 673 void KernelReader::ReadAndSetupTypeParameters( |
648 const Object& set_on, | 674 const Object& set_on, |
649 intptr_t type_parameter_count, | 675 intptr_t type_parameter_count, |
650 const Class& parameterized_class, | 676 const Class& parameterized_class, |
651 const Function& parameterized_function) { | 677 const Function& parameterized_function) { |
652 ASSERT(type_parameter_count >= 0); | 678 ASSERT(type_parameter_count >= 0); |
653 if (type_parameter_count == 0) { | 679 if (type_parameter_count == 0) { |
654 return; | 680 return; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 747 |
722 Script& KernelReader::ScriptAt(intptr_t index, StringIndex import_uri) { | 748 Script& KernelReader::ScriptAt(intptr_t index, StringIndex import_uri) { |
723 Script& script = Script::ZoneHandle(Z); | 749 Script& script = Script::ZoneHandle(Z); |
724 script ^= scripts_.At(index); | 750 script ^= scripts_.At(index); |
725 if (script.IsNull()) { | 751 if (script.IsNull()) { |
726 // Create script with correct uri(s). | 752 // Create script with correct uri(s). |
727 dart::String& uri_string = builder_.SourceTableUriFor(index); | 753 dart::String& uri_string = builder_.SourceTableUriFor(index); |
728 dart::String& import_uri_string = | 754 dart::String& import_uri_string = |
729 import_uri == -1 ? uri_string : H.DartString(import_uri, Heap::kOld); | 755 import_uri == -1 ? uri_string : H.DartString(import_uri, Heap::kOld); |
730 script = Script::New(import_uri_string, uri_string, | 756 script = Script::New(import_uri_string, uri_string, |
731 String::Handle(String::null()), RawScript::kKernelTag); | 757 builder_.GetSourceFor(index), RawScript::kKernelTag); |
732 script.set_kernel_data(program_->kernel_data()); | |
733 script.set_kernel_data_size(program_->kernel_data_size()); | |
734 script.set_kernel_script_index(index); | 758 script.set_kernel_script_index(index); |
735 script.set_kernel_string_offsets(H.string_offsets()); | 759 script.set_kernel_string_offsets(H.string_offsets()); |
736 script.set_kernel_string_data(H.string_data()); | 760 script.set_kernel_string_data(H.string_data()); |
737 script.set_kernel_canonical_names(H.canonical_names()); | 761 script.set_kernel_canonical_names(H.canonical_names()); |
738 scripts_.SetAt(index, script); | 762 scripts_.SetAt(index, script); |
739 | 763 |
740 script.set_line_starts(Array::Handle(Array::null())); | 764 script.set_line_starts(builder_.GetLineStartsFor(index)); |
741 script.set_debug_positions(Array::Handle(Array::null())); | 765 script.set_debug_positions(Array::Handle(Array::null())); |
742 script.set_yield_positions(Array::Handle(Array::null())); | 766 script.set_yield_positions(Array::Handle(Array::null())); |
743 } | 767 } |
744 return script; | 768 return script; |
745 } | 769 } |
746 | 770 |
747 void KernelReader::GenerateFieldAccessors(const dart::Class& klass, | 771 void KernelReader::GenerateFieldAccessors(const dart::Class& klass, |
748 const dart::Field& field, | 772 const dart::Field& field, |
749 FieldHelper* field_helper, | 773 FieldHelper* field_helper, |
750 intptr_t field_offset) { | 774 intptr_t field_offset) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 // that are const (not just final) and they have is_const for | 820 // that are const (not just final) and they have is_const for |
797 // non-static | 821 // non-static |
798 // fields that are final. | 822 // fields that are final. |
799 field_helper->IsStatic() ? field_helper->IsConst() | 823 field_helper->IsStatic() ? field_helper->IsConst() |
800 : field_helper->IsFinal(), | 824 : field_helper->IsFinal(), |
801 false, // is_abstract | 825 false, // is_abstract |
802 false, // is_external | 826 false, // is_external |
803 false, // is_native | 827 false, // is_native |
804 script_class, field_helper->position_)); | 828 script_class, field_helper->position_)); |
805 functions_.Add(&getter); | 829 functions_.Add(&getter); |
| 830 getter.set_kernel_data(TypedData::Handle(Z, field.kernel_data())); |
806 getter.set_end_token_pos(field_helper->end_position_); | 831 getter.set_end_token_pos(field_helper->end_position_); |
807 getter.set_kernel_offset(field_offset); | 832 getter.set_kernel_offset(field_offset); |
808 getter.set_result_type(AbstractType::Handle(Z, field.type())); | 833 getter.set_result_type(AbstractType::Handle(Z, field.type())); |
809 getter.set_is_debuggable(false); | 834 getter.set_is_debuggable(false); |
810 SetupFieldAccessorFunction(klass, getter); | 835 SetupFieldAccessorFunction(klass, getter); |
811 | 836 |
812 if (!field_helper->IsStatic() && !field_helper->IsFinal()) { | 837 if (!field_helper->IsStatic() && !field_helper->IsFinal()) { |
813 // Only static fields can be const. | 838 // Only static fields can be const. |
814 ASSERT(!field_helper->IsConst()); | 839 ASSERT(!field_helper->IsConst()); |
815 const dart::String& setter_name = | 840 const dart::String& setter_name = |
816 H.DartSetterName(field_helper->canonical_name_); | 841 H.DartSetterName(field_helper->canonical_name_); |
817 Function& setter = Function::ZoneHandle( | 842 Function& setter = Function::ZoneHandle( |
818 Z, Function::New(setter_name, RawFunction::kImplicitSetter, | 843 Z, Function::New(setter_name, RawFunction::kImplicitSetter, |
819 false, // is_static | 844 false, // is_static |
820 false, // is_const | 845 false, // is_const |
821 false, // is_abstract | 846 false, // is_abstract |
822 false, // is_external | 847 false, // is_external |
823 false, // is_native | 848 false, // is_native |
824 script_class, field_helper->position_)); | 849 script_class, field_helper->position_)); |
825 functions_.Add(&setter); | 850 functions_.Add(&setter); |
| 851 setter.set_kernel_data(TypedData::Handle(Z, field.kernel_data())); |
826 setter.set_end_token_pos(field_helper->end_position_); | 852 setter.set_end_token_pos(field_helper->end_position_); |
827 setter.set_kernel_offset(field_offset); | 853 setter.set_kernel_offset(field_offset); |
828 setter.set_result_type(Object::void_type()); | 854 setter.set_result_type(Object::void_type()); |
829 setter.set_is_debuggable(false); | 855 setter.set_is_debuggable(false); |
830 SetupFieldAccessorFunction(klass, setter); | 856 SetupFieldAccessorFunction(klass, setter); |
831 } | 857 } |
832 } | 858 } |
833 | 859 |
834 void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass, | 860 void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass, |
835 const dart::Function& function) { | 861 const dart::Function& function) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 bool KernelReader::FieldHasFunctionLiteralInitializer(const dart::Field& field, | 939 bool KernelReader::FieldHasFunctionLiteralInitializer(const dart::Field& field, |
914 TokenPosition* start, | 940 TokenPosition* start, |
915 TokenPosition* end) { | 941 TokenPosition* end) { |
916 dart::Zone* zone = Thread::Current()->zone(); | 942 dart::Zone* zone = Thread::Current()->zone(); |
917 const Script& script = Script::Handle(zone, field.Script()); | 943 const Script& script = Script::Handle(zone, field.Script()); |
918 | 944 |
919 TranslationHelper translation_helper( | 945 TranslationHelper translation_helper( |
920 Thread::Current(), script.kernel_string_offsets(), | 946 Thread::Current(), script.kernel_string_offsets(), |
921 script.kernel_string_data(), script.kernel_canonical_names()); | 947 script.kernel_string_data(), script.kernel_canonical_names()); |
922 | 948 |
923 kernel::StreamingFlowGraphBuilder* builder = | 949 StreamingFlowGraphBuilder builder( |
924 new kernel::StreamingFlowGraphBuilder(&translation_helper, zone, | 950 &translation_helper, zone, field.kernel_offset(), |
925 script.kernel_data(), | 951 TypedData::Handle(zone, field.kernel_data())); |
926 script.kernel_data_size()); | 952 kernel::FieldHelper field_helper(&builder); |
927 | |
928 kernel::FieldHelper field_helper(builder, field.kernel_offset()); | |
929 field_helper.ReadUntilExcluding(kernel::FieldHelper::kEnd, true); | 953 field_helper.ReadUntilExcluding(kernel::FieldHelper::kEnd, true); |
930 bool result = field_helper.FieldHasFunctionLiteralInitializer(start, end); | 954 return field_helper.FieldHasFunctionLiteralInitializer(start, end); |
931 | |
932 delete builder; | |
933 return result; | |
934 } | 955 } |
935 | 956 |
936 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, | 957 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, |
937 const dart::Field& field) { | 958 const dart::Field& field) { |
938 Thread* thread = Thread::Current(); | 959 Thread* thread = Thread::Current(); |
939 | 960 |
940 dart::String& init_name = dart::String::Handle(zone, field.name()); | 961 dart::String& init_name = dart::String::Handle(zone, field.name()); |
941 init_name = Symbols::FromConcat(thread, Symbols::InitPrefix(), init_name); | 962 init_name = Symbols::FromConcat(thread, Symbols::InitPrefix(), init_name); |
942 | 963 |
943 // Create a static initializer. | 964 // Create a static initializer. |
944 const Object& owner = Object::Handle(field.RawOwner()); | 965 const Object& owner = Object::Handle(field.RawOwner()); |
945 const Function& initializer_fun = Function::ZoneHandle( | 966 const Function& initializer_fun = Function::ZoneHandle( |
946 zone, | 967 zone, |
947 dart::Function::New(init_name, RawFunction::kImplicitStaticFinalGetter, | 968 dart::Function::New(init_name, RawFunction::kImplicitStaticFinalGetter, |
948 true, // is_static | 969 true, // is_static |
949 false, // is_const | 970 false, // is_const |
950 false, // is_abstract | 971 false, // is_abstract |
951 false, // is_external | 972 false, // is_external |
952 false, // is_native | 973 false, // is_native |
953 owner, TokenPosition::kNoSource)); | 974 owner, TokenPosition::kNoSource)); |
| 975 initializer_fun.set_kernel_data(TypedData::Handle(zone, field.kernel_data())); |
954 initializer_fun.set_kernel_offset(field.kernel_offset()); | 976 initializer_fun.set_kernel_offset(field.kernel_offset()); |
955 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); | 977 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); |
956 initializer_fun.set_is_debuggable(false); | 978 initializer_fun.set_is_debuggable(false); |
957 initializer_fun.set_is_reflectable(false); | 979 initializer_fun.set_is_reflectable(false); |
958 initializer_fun.set_is_inlinable(false); | 980 initializer_fun.set_is_inlinable(false); |
959 return new (zone) ParsedFunction(thread, initializer_fun); | 981 return new (zone) ParsedFunction(thread, initializer_fun); |
960 } | 982 } |
961 | 983 |
962 } // namespace kernel | 984 } // namespace kernel |
963 } // namespace dart | 985 } // namespace dart |
964 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 986 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |