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

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

Issue 2664143002: Revert "Debugging in kernel shaping up." (Closed)
Patch Set: Revert "Debugging in kernel shaping up." Created 3 years, 10 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
« no previous file with comments | « runtime/vm/kernel.cc ('k') | runtime/vm/kernel_reader.cc » ('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 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/kernel.h" 9 #include "vm/kernel.h"
10 #include "vm/kernel_to_il.h" 10 #include "vm/kernel_to_il.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // 11... 362 // 11...
363 ASSERT(offset_ + 4 <= size_); 363 ASSERT(offset_ + 4 <= size_);
364 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) | 364 uint32_t value = ((byte0 & ~0xc0) << 24) | (buffer_[offset_ + 1] << 16) |
365 (buffer_[offset_ + 2] << 8) | 365 (buffer_[offset_ + 2] << 8) |
366 (buffer_[offset_ + 3] << 0); 366 (buffer_[offset_ + 3] << 0);
367 offset_ += 4; 367 offset_ += 4;
368 return value; 368 return value;
369 } 369 }
370 } 370 }
371 371
372 void add_token_position(
373 MallocGrowableArray<MallocGrowableArray<intptr_t>*>* list,
374 TokenPosition position) {
375 intptr_t size = list->length();
376 while (size <= current_script_id_) {
377 MallocGrowableArray<intptr_t>* tmp = new MallocGrowableArray<intptr_t>();
378 list->Add(tmp);
379 size = list->length();
380 }
381 list->At(current_script_id_)->Add(position.value());
382 }
383
384 void record_token_position(TokenPosition position) {
385 if (position.IsReal()) {
386 add_token_position(&helper()->program()->valid_token_positions, position);
387 }
388 }
389
390 void record_yield_token_position(TokenPosition position) {
391 add_token_position(&helper()->program()->yield_token_positions, position);
392 }
393
394 /** 372 /**
395 * Read and return a TokenPosition from this reader. 373 * Read and return a TokenPosition from this reader.
396 * @param record specifies whether or not the read position is saved as a
397 * valid token position in the current script.
398 * If not be sure to record it later by calling record_token_position (after
399 * setting the correct current_script_id).
400 */ 374 */
401 TokenPosition ReadPosition(bool record = true) { 375 TokenPosition ReadPosition() {
402 // Position is saved as unsigned, 376 // Position is saved as unsigned,
403 // but actually ranges from -1 and up (thus the -1) 377 // but actually ranges from -1 and up (thus the -1)
404 intptr_t value = ReadUInt() - 1; 378 intptr_t value = ReadUInt() - 1;
405 TokenPosition result = TokenPosition(value); 379 TokenPosition result = TokenPosition(value);
406 max_position_ = Utils::Maximum(max_position_, result); 380 max_position_ = Utils::Maximum(max_position_, result);
407 if (min_position_.IsNoSource()) { 381 if (min_position_.IsNoSource()) {
408 min_position_ = result; 382 min_position_ = result;
409 } else if (result.IsReal()) { 383 } else if (result.IsReal()) {
410 min_position_ = Utils::Minimum(min_position_, result); 384 min_position_ = Utils::Minimum(min_position_, result);
411 } 385 }
412 386
413 if (record) {
414 record_token_position(result);
415 }
416 return result; 387 return result;
417 } 388 }
418 389
419 intptr_t ReadListLength() { return ReadUInt(); } 390 intptr_t ReadListLength() { return ReadUInt(); }
420 391
421 uint8_t ReadByte() { return buffer_[offset_++]; } 392 uint8_t ReadByte() { return buffer_[offset_++]; }
422 393
423 bool ReadBool() { return (ReadByte() & 1) == 1; } 394 bool ReadBool() { return (ReadByte() & 1) == 1; }
424 395
425 word ReadFlags() { return ReadByte(); } 396 word ReadFlags() { return ReadByte(); }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 665
695 fields().ReadFrom<Field>(reader, this); 666 fields().ReadFrom<Field>(reader, this);
696 procedures().ReadFrom<Procedure>(reader, this); 667 procedures().ReadFrom<Procedure>(reader, this);
697 return this; 668 return this;
698 } 669 }
699 670
700 671
701 Class* Class::ReadFrom(Reader* reader) { 672 Class* Class::ReadFrom(Reader* reader) {
702 TRACE_READ_OFFSET(); 673 TRACE_READ_OFFSET();
703 674
704 position_ = reader->ReadPosition(false); 675 position_ = reader->ReadPosition();
705 is_abstract_ = reader->ReadBool(); 676 is_abstract_ = reader->ReadBool();
706 name_ = Reference::ReadStringFrom(reader); 677 name_ = Reference::ReadStringFrom(reader);
707 source_uri_index_ = reader->ReadUInt(); 678 source_uri_index_ = reader->ReadUInt();
708 reader->set_current_script_id(source_uri_index_); 679 reader->set_current_script_id(source_uri_index_);
709 reader->record_token_position(position_);
710 annotations_.ReadFromStatic<Expression>(reader); 680 annotations_.ReadFromStatic<Expression>(reader);
711 681
712 return this; 682 return this;
713 } 683 }
714 684
715 685
716 NormalClass* NormalClass::ReadFrom(Reader* reader) { 686 NormalClass* NormalClass::ReadFrom(Reader* reader) {
717 TRACE_READ_OFFSET(); 687 TRACE_READ_OFFSET();
718 Class::ReadFrom(reader); 688 Class::ReadFrom(reader);
719 TypeParameterScope<ReaderHelper> scope(reader->helper()); 689 TypeParameterScope<ReaderHelper> scope(reader->helper());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 int index = reader->ReadUInt(); 800 int index = reader->ReadUInt();
831 return reader->helper()->program()->string_table().strings()[index]; 801 return reader->helper()->program()->string_table().strings()[index];
832 } 802 }
833 803
834 804
835 Field* Field::ReadFrom(Reader* reader) { 805 Field* Field::ReadFrom(Reader* reader) {
836 TRACE_READ_OFFSET(); 806 TRACE_READ_OFFSET();
837 Tag tag = reader->ReadTag(); 807 Tag tag = reader->ReadTag();
838 ASSERT(tag == kField); 808 ASSERT(tag == kField);
839 809
840 position_ = reader->ReadPosition(false); 810 position_ = reader->ReadPosition();
841 end_position_ = reader->ReadPosition(false); 811 end_position_ = reader->ReadPosition();
842 flags_ = reader->ReadFlags(); 812 flags_ = reader->ReadFlags();
843 name_ = Name::ReadFrom(reader); 813 name_ = Name::ReadFrom(reader);
844 source_uri_index_ = reader->ReadUInt(); 814 source_uri_index_ = reader->ReadUInt();
845 reader->set_current_script_id(source_uri_index_); 815 reader->set_current_script_id(source_uri_index_);
846 reader->record_token_position(position_);
847 reader->record_token_position(end_position_);
848 annotations_.ReadFromStatic<Expression>(reader); 816 annotations_.ReadFromStatic<Expression>(reader);
849 type_ = DartType::ReadFrom(reader); 817 type_ = DartType::ReadFrom(reader);
850 inferred_value_ = reader->ReadOptional<InferredValue>(); 818 inferred_value_ = reader->ReadOptional<InferredValue>();
851 initializer_ = reader->ReadOptional<Expression>(); 819 initializer_ = reader->ReadOptional<Expression>();
852 return this; 820 return this;
853 } 821 }
854 822
855 823
856 Constructor* Constructor::ReadFrom(Reader* reader) { 824 Constructor* Constructor::ReadFrom(Reader* reader) {
857 TRACE_READ_OFFSET(); 825 TRACE_READ_OFFSET();
(...skipping 11 matching lines...) Expand all
869 return this; 837 return this;
870 } 838 }
871 839
872 840
873 Procedure* Procedure::ReadFrom(Reader* reader) { 841 Procedure* Procedure::ReadFrom(Reader* reader) {
874 TRACE_READ_OFFSET(); 842 TRACE_READ_OFFSET();
875 Tag tag = reader->ReadTag(); 843 Tag tag = reader->ReadTag();
876 ASSERT(tag == kProcedure); 844 ASSERT(tag == kProcedure);
877 845
878 VariableScope<ReaderHelper> parameters(reader->helper()); 846 VariableScope<ReaderHelper> parameters(reader->helper());
879 position_ = reader->ReadPosition(false); 847 position_ = reader->ReadPosition();
880 end_position_ = reader->ReadPosition(false); 848 end_position_ = reader->ReadPosition();
881 kind_ = static_cast<ProcedureKind>(reader->ReadByte()); 849 kind_ = static_cast<ProcedureKind>(reader->ReadByte());
882 flags_ = reader->ReadFlags(); 850 flags_ = reader->ReadFlags();
883 name_ = Name::ReadFrom(reader); 851 name_ = Name::ReadFrom(reader);
884 source_uri_index_ = reader->ReadUInt(); 852 source_uri_index_ = reader->ReadUInt();
885 reader->set_current_script_id(source_uri_index_); 853 reader->set_current_script_id(source_uri_index_);
886 reader->record_token_position(position_);
887 reader->record_token_position(end_position_);
888 annotations_.ReadFromStatic<Expression>(reader); 854 annotations_.ReadFromStatic<Expression>(reader);
889 function_ = reader->ReadOptional<FunctionNode>(); 855 function_ = reader->ReadOptional<FunctionNode>();
890 return this; 856 return this;
891 } 857 }
892 858
893 859
894 Initializer* Initializer::ReadFrom(Reader* reader) { 860 Initializer* Initializer::ReadFrom(Reader* reader) {
895 TRACE_READ_OFFSET(); 861 TRACE_READ_OFFSET();
896 Tag tag = reader->ReadTag(); 862 Tag tag = reader->ReadTag();
897 switch (tag) { 863 switch (tag) {
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 tf->body_ = Statement::ReadFrom(reader); 1653 tf->body_ = Statement::ReadFrom(reader);
1688 tf->finalizer_ = Statement::ReadFrom(reader); 1654 tf->finalizer_ = Statement::ReadFrom(reader);
1689 return tf; 1655 return tf;
1690 } 1656 }
1691 1657
1692 1658
1693 YieldStatement* YieldStatement::ReadFrom(Reader* reader) { 1659 YieldStatement* YieldStatement::ReadFrom(Reader* reader) {
1694 TRACE_READ_OFFSET(); 1660 TRACE_READ_OFFSET();
1695 YieldStatement* stmt = new YieldStatement(); 1661 YieldStatement* stmt = new YieldStatement();
1696 stmt->position_ = reader->ReadPosition(); 1662 stmt->position_ = reader->ReadPosition();
1697 reader->record_yield_token_position(stmt->position_);
1698 stmt->flags_ = reader->ReadByte(); 1663 stmt->flags_ = reader->ReadByte();
1699 stmt->expression_ = Expression::ReadFrom(reader); 1664 stmt->expression_ = Expression::ReadFrom(reader);
1700 return stmt; 1665 return stmt;
1701 } 1666 }
1702 1667
1703 1668
1704 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 1669 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
1705 TRACE_READ_OFFSET(); 1670 TRACE_READ_OFFSET();
1706 Tag tag = reader->ReadTag(); 1671 Tag tag = reader->ReadTag();
1707 ASSERT(tag == kVariableDeclaration); 1672 ASSERT(tag == kVariableDeclaration);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 1892
1928 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1893 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1929 intptr_t buffer_length) { 1894 intptr_t buffer_length) {
1930 kernel::Reader reader(buffer, buffer_length); 1895 kernel::Reader reader(buffer, buffer_length);
1931 return kernel::Program::ReadFrom(&reader); 1896 return kernel::Program::ReadFrom(&reader);
1932 } 1897 }
1933 1898
1934 1899
1935 } // namespace dart 1900 } // namespace dart
1936 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1901 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698