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

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

Issue 2632183002: Debugging in kernel shaping up. (Closed)
Patch Set: Created 3 years, 11 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
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 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include <map> 6 #include <map>
7 #include <vector> 7 #include <vector>
8 8
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // 11... 357 // 11...
358 ASSERT(offset_ + 4 <= size_); 358 ASSERT(offset_ + 4 <= size_);
359 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) | 359 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) |
360 (buffer_[offset_ + 2] << 8) | 360 (buffer_[offset_ + 2] << 8) |
361 (buffer_[offset_ + 3] << 0); 361 (buffer_[offset_ + 3] << 0);
362 offset_ += 4; 362 offset_ += 4;
363 return value; 363 return value;
364 } 364 }
365 } 365 }
366 366
367 void add_token_position(
368 MallocGrowableArray<MallocGrowableArray<intptr_t>*>* list,
369 TokenPosition position) {
370 intptr_t size = list->length();
371 while (size <= current_script_id_) {
372 MallocGrowableArray<intptr_t>* tmp = new MallocGrowableArray<intptr_t>();
373 list->Add(tmp);
374 size = list->length();
375 }
376 list->At(current_script_id_)->Add(position.value());
377 }
378
379 void record_token_position(TokenPosition position) {
380 add_token_position(&helper()->program()->valid_token_positions, position);
381 }
382
383 void record_yield_token_position(TokenPosition position) {
384 add_token_position(&helper()->program()->yield_token_positions, position);
385 }
386
367 /** 387 /**
368 * Read and return a TokenPosition from this reader. 388 * Read and return a TokenPosition from this reader.
389 * @param record specifies whether or not the read position is saved as a
390 * valid token position in the current script.
391 * If not be sure to record it later by calling record_token_position (after
392 * setting the correct current_script_id).
369 */ 393 */
370 TokenPosition ReadPosition() { 394 TokenPosition ReadPosition(bool record = true) {
371 // Position is saved as unsigned, 395 // Position is saved as unsigned,
372 // but actually ranges from -1 and up (thus the -1) 396 // but actually ranges from -1 and up (thus the -1)
373 intptr_t value = ReadUInt() - 1; 397 intptr_t value = ReadUInt() - 1;
374 TokenPosition result = TokenPosition(value); 398 TokenPosition result = TokenPosition(value);
375 max_position_ = Utils::Maximum(max_position_, result); 399 max_position_ = Utils::Maximum(max_position_, result);
376 if (min_position_.IsNoSource()) { 400 if (min_position_.IsNoSource()) {
377 min_position_ = result; 401 min_position_ = result;
378 } else if (result.IsReal()) { 402 } else if (result.IsReal()) {
379 min_position_ = Utils::Minimum(min_position_, result); 403 min_position_ = Utils::Minimum(min_position_, result);
380 } 404 }
381 405
406 if (record) {
407 record_token_position(result);
408 }
382 return result; 409 return result;
383 } 410 }
384 411
385 intptr_t ReadListLength() { return ReadUInt(); } 412 intptr_t ReadListLength() { return ReadUInt(); }
386 413
387 uint8_t ReadByte() { return buffer_[offset_++]; } 414 uint8_t ReadByte() { return buffer_[offset_++]; }
388 415
389 bool ReadBool() { return (ReadByte() & 1) == 1; } 416 bool ReadBool() { return (ReadByte() & 1) == 1; }
390 417
391 word ReadFlags() { return ReadByte(); } 418 word ReadFlags() { return ReadByte(); }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 687
661 fields().ReadFrom<Field>(reader, this); 688 fields().ReadFrom<Field>(reader, this);
662 procedures().ReadFrom<Procedure>(reader, this); 689 procedures().ReadFrom<Procedure>(reader, this);
663 return this; 690 return this;
664 } 691 }
665 692
666 693
667 Class* Class::ReadFrom(Reader* reader) { 694 Class* Class::ReadFrom(Reader* reader) {
668 TRACE_READ_OFFSET(); 695 TRACE_READ_OFFSET();
669 696
670 position_ = reader->ReadPosition(); 697 position_ = reader->ReadPosition(false);
671 is_abstract_ = reader->ReadBool(); 698 is_abstract_ = reader->ReadBool();
672 name_ = Reference::ReadStringFrom(reader); 699 name_ = Reference::ReadStringFrom(reader);
673 source_uri_index_ = reader->ReadUInt(); 700 source_uri_index_ = reader->ReadUInt();
674 reader->set_current_script_id(source_uri_index_); 701 reader->set_current_script_id(source_uri_index_);
702 reader->record_token_position(position_);
675 annotations_.ReadFromStatic<Expression>(reader); 703 annotations_.ReadFromStatic<Expression>(reader);
676 704
677 return this; 705 return this;
678 } 706 }
679 707
680 708
681 NormalClass* NormalClass::ReadFrom(Reader* reader) { 709 NormalClass* NormalClass::ReadFrom(Reader* reader) {
682 TRACE_READ_OFFSET(); 710 TRACE_READ_OFFSET();
683 Class::ReadFrom(reader); 711 Class::ReadFrom(reader);
684 TypeParameterScope<ReaderHelper> scope(reader->helper()); 712 TypeParameterScope<ReaderHelper> scope(reader->helper());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 int index = reader->ReadUInt(); 823 int index = reader->ReadUInt();
796 return reader->helper()->program()->string_table().strings()[index]; 824 return reader->helper()->program()->string_table().strings()[index];
797 } 825 }
798 826
799 827
800 Field* Field::ReadFrom(Reader* reader) { 828 Field* Field::ReadFrom(Reader* reader) {
801 TRACE_READ_OFFSET(); 829 TRACE_READ_OFFSET();
802 Tag tag = reader->ReadTag(); 830 Tag tag = reader->ReadTag();
803 ASSERT(tag == kField); 831 ASSERT(tag == kField);
804 832
805 position_ = reader->ReadPosition(); 833 position_ = reader->ReadPosition(false);
806 end_position_ = reader->ReadPosition(); 834 end_position_ = reader->ReadPosition(false);
807 flags_ = reader->ReadFlags(); 835 flags_ = reader->ReadFlags();
808 name_ = Name::ReadFrom(reader); 836 name_ = Name::ReadFrom(reader);
809 source_uri_index_ = reader->ReadUInt(); 837 source_uri_index_ = reader->ReadUInt();
810 reader->set_current_script_id(source_uri_index_); 838 reader->set_current_script_id(source_uri_index_);
839 reader->record_token_position(position_);
840 reader->record_token_position(end_position_);
811 annotations_.ReadFromStatic<Expression>(reader); 841 annotations_.ReadFromStatic<Expression>(reader);
812 type_ = DartType::ReadFrom(reader); 842 type_ = DartType::ReadFrom(reader);
813 inferred_value_ = reader->ReadOptional<InferredValue>(); 843 inferred_value_ = reader->ReadOptional<InferredValue>();
814 initializer_ = reader->ReadOptional<Expression>(); 844 initializer_ = reader->ReadOptional<Expression>();
815 return this; 845 return this;
816 } 846 }
817 847
818 848
819 Constructor* Constructor::ReadFrom(Reader* reader) { 849 Constructor* Constructor::ReadFrom(Reader* reader) {
820 TRACE_READ_OFFSET(); 850 TRACE_READ_OFFSET();
(...skipping 11 matching lines...) Expand all
832 return this; 862 return this;
833 } 863 }
834 864
835 865
836 Procedure* Procedure::ReadFrom(Reader* reader) { 866 Procedure* Procedure::ReadFrom(Reader* reader) {
837 TRACE_READ_OFFSET(); 867 TRACE_READ_OFFSET();
838 Tag tag = reader->ReadTag(); 868 Tag tag = reader->ReadTag();
839 ASSERT(tag == kProcedure); 869 ASSERT(tag == kProcedure);
840 870
841 VariableScope<ReaderHelper> parameters(reader->helper()); 871 VariableScope<ReaderHelper> parameters(reader->helper());
842 position_ = reader->ReadPosition(); 872 position_ = reader->ReadPosition(false);
843 end_position_ = reader->ReadPosition(); 873 end_position_ = reader->ReadPosition(false);
844 kind_ = static_cast<ProcedureKind>(reader->ReadByte()); 874 kind_ = static_cast<ProcedureKind>(reader->ReadByte());
845 flags_ = reader->ReadFlags(); 875 flags_ = reader->ReadFlags();
846 name_ = Name::ReadFrom(reader); 876 name_ = Name::ReadFrom(reader);
847 source_uri_index_ = reader->ReadUInt(); 877 source_uri_index_ = reader->ReadUInt();
848 reader->set_current_script_id(source_uri_index_); 878 reader->set_current_script_id(source_uri_index_);
879 reader->record_token_position(position_);
880 reader->record_token_position(end_position_);
849 annotations_.ReadFromStatic<Expression>(reader); 881 annotations_.ReadFromStatic<Expression>(reader);
850 function_ = reader->ReadOptional<FunctionNode>(); 882 function_ = reader->ReadOptional<FunctionNode>();
851 return this; 883 return this;
852 } 884 }
853 885
854 886
855 Initializer* Initializer::ReadFrom(Reader* reader) { 887 Initializer* Initializer::ReadFrom(Reader* reader) {
856 TRACE_READ_OFFSET(); 888 TRACE_READ_OFFSET();
857 Tag tag = reader->ReadTag(); 889 Tag tag = reader->ReadTag();
858 switch (tag) { 890 switch (tag) {
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 tf->body_ = Statement::ReadFrom(reader); 1680 tf->body_ = Statement::ReadFrom(reader);
1649 tf->finalizer_ = Statement::ReadFrom(reader); 1681 tf->finalizer_ = Statement::ReadFrom(reader);
1650 return tf; 1682 return tf;
1651 } 1683 }
1652 1684
1653 1685
1654 YieldStatement* YieldStatement::ReadFrom(Reader* reader) { 1686 YieldStatement* YieldStatement::ReadFrom(Reader* reader) {
1655 TRACE_READ_OFFSET(); 1687 TRACE_READ_OFFSET();
1656 YieldStatement* stmt = new YieldStatement(); 1688 YieldStatement* stmt = new YieldStatement();
1657 stmt->position_ = reader->ReadPosition(); 1689 stmt->position_ = reader->ReadPosition();
1690 reader->record_yield_token_position(stmt->position_);
1658 stmt->flags_ = reader->ReadByte(); 1691 stmt->flags_ = reader->ReadByte();
1659 stmt->expression_ = Expression::ReadFrom(reader); 1692 stmt->expression_ = Expression::ReadFrom(reader);
1660 return stmt; 1693 return stmt;
1661 } 1694 }
1662 1695
1663 1696
1664 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 1697 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
1665 TRACE_READ_OFFSET(); 1698 TRACE_READ_OFFSET();
1666 Tag tag = reader->ReadTag(); 1699 Tag tag = reader->ReadTag();
1667 ASSERT(tag == kVariableDeclaration); 1700 ASSERT(tag == kVariableDeclaration);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 1920
1888 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1921 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1889 intptr_t buffer_length) { 1922 intptr_t buffer_length) {
1890 kernel::Reader reader(buffer, buffer_length); 1923 kernel::Reader reader(buffer, buffer_length);
1891 return kernel::Program::ReadFrom(&reader); 1924 return kernel::Program::ReadFrom(&reader);
1892 } 1925 }
1893 1926
1894 1927
1895 } // namespace dart 1928 } // namespace dart
1896 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1929 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698