Chromium Code Reviews| 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 #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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 strings_.WriteToStatic<StringImpl>(writer); | 821 strings_.WriteToStatic<StringImpl>(writer); |
| 822 | 822 |
| 823 // Build up the "String* -> index" table. | 823 // Build up the "String* -> index" table. |
| 824 WriterHelper* helper = writer->helper(); | 824 WriterHelper* helper = writer->helper(); |
| 825 for (int i = 0; i < strings_.length(); i++) { | 825 for (int i = 0; i < strings_.length(); i++) { |
| 826 helper->strings().Push(strings_[i]); | 826 helper->strings().Push(strings_[i]); |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 | 829 |
| 830 | 830 |
| 831 void LineStartingTable::ReadFrom(Reader* reader) { | 831 void LineStartingTableAndSource::ReadFrom(Reader* reader) { |
| 832 size_ = reader->helper()->program()->source_uri_table().strings().length(); | 832 size_ = reader->helper()->program()->source_uri_table().strings().length(); |
| 833 values_ = new intptr_t*[size_]; | 833 source_code_ = new String*[size_]; |
| 834 line_starts_ = new intptr_t*[size_]; | |
| 834 for (intptr_t i = 0; i < size_; ++i) { | 835 for (intptr_t i = 0; i < size_; ++i) { |
| 836 source_code_[i] = StringImpl::ReadFrom(reader); | |
| 835 intptr_t line_count = reader->ReadUInt(); | 837 intptr_t line_count = reader->ReadUInt(); |
| 836 intptr_t* line_starts = new intptr_t[line_count + 1]; | 838 intptr_t* line_starts = new intptr_t[line_count + 1]; |
|
Kevin Millikin (Google)
2016/12/20 12:03:33
I think we should define a simple class that conta
jensj
2016/12/20 13:30:23
I've done another change instead. Hopefully that'l
| |
| 837 line_starts[0] = line_count; | 839 line_starts[0] = line_count; |
| 838 intptr_t previous_line_start = 0; | 840 intptr_t previous_line_start = 0; |
| 839 for (intptr_t j = 0; j < line_count; ++j) { | 841 for (intptr_t j = 0; j < line_count; ++j) { |
| 840 intptr_t line_start = reader->ReadUInt() + previous_line_start; | 842 intptr_t line_start = reader->ReadUInt() + previous_line_start; |
| 841 line_starts[j + 1] = line_start; | 843 line_starts[j + 1] = line_start; |
| 842 previous_line_start = line_start; | 844 previous_line_start = line_start; |
| 843 } | 845 } |
| 844 values_[i] = line_starts; | 846 line_starts_[i] = line_starts; |
| 845 } | 847 } |
| 846 } | 848 } |
| 847 | 849 |
| 848 | 850 |
| 849 void LineStartingTable::WriteTo(Writer* writer) { | 851 void LineStartingTableAndSource::WriteTo(Writer* writer) { |
| 850 for (intptr_t i = 0; i < size_; ++i) { | 852 for (intptr_t i = 0; i < size_; ++i) { |
| 851 intptr_t* line_starts = values_[i]; | 853 StringImpl::WriteTo(writer, source_code_[i]); |
| 854 intptr_t* line_starts = line_starts_[i]; | |
| 852 intptr_t line_count = line_starts[0]; | 855 intptr_t line_count = line_starts[0]; |
| 853 writer->WriteUInt(line_count); | 856 writer->WriteUInt(line_count); |
| 854 | 857 |
| 855 intptr_t previous_line_start = 0; | 858 intptr_t previous_line_start = 0; |
| 856 for (intptr_t j = 0; j < line_count; ++j) { | 859 for (intptr_t j = 0; j < line_count; ++j) { |
| 857 intptr_t line_start = line_starts[j + 1]; | 860 intptr_t line_start = line_starts[j + 1]; |
| 858 writer->WriteUInt(line_start - previous_line_start); | 861 writer->WriteUInt(line_start - previous_line_start); |
| 859 previous_line_start = line_start; | 862 previous_line_start = line_start; |
| 860 } | 863 } |
| 861 } | 864 } |
| (...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2821 Program* Program::ReadFrom(Reader* reader) { | 2824 Program* Program::ReadFrom(Reader* reader) { |
| 2822 TRACE_READ_OFFSET(); | 2825 TRACE_READ_OFFSET(); |
| 2823 uint32_t magic = reader->ReadUInt32(); | 2826 uint32_t magic = reader->ReadUInt32(); |
| 2824 if (magic != kMagicProgramFile) FATAL("Invalid magic identifier"); | 2827 if (magic != kMagicProgramFile) FATAL("Invalid magic identifier"); |
| 2825 | 2828 |
| 2826 Program* program = new Program(); | 2829 Program* program = new Program(); |
| 2827 reader->helper()->set_program(program); | 2830 reader->helper()->set_program(program); |
| 2828 | 2831 |
| 2829 program->string_table_.ReadFrom(reader); | 2832 program->string_table_.ReadFrom(reader); |
| 2830 program->source_uri_table_.ReadFrom(reader); | 2833 program->source_uri_table_.ReadFrom(reader); |
| 2831 program->line_starting_table_.ReadFrom(reader); | 2834 program->line_starting_table_and_source_.ReadFrom(reader); |
| 2832 | 2835 |
| 2833 int libraries = reader->ReadUInt(); | 2836 int libraries = reader->ReadUInt(); |
| 2834 program->libraries().EnsureInitialized(libraries); | 2837 program->libraries().EnsureInitialized(libraries); |
| 2835 for (int i = 0; i < libraries; i++) { | 2838 for (int i = 0; i < libraries; i++) { |
| 2836 program->libraries().GetOrCreate<Library>(i)->ReadFrom(reader); | 2839 program->libraries().GetOrCreate<Library>(i)->ReadFrom(reader); |
| 2837 } | 2840 } |
| 2838 | 2841 |
| 2839 program->main_method_ = Procedure::Cast(Reference::ReadMemberFrom(reader)); | 2842 program->main_method_ = Procedure::Cast(Reference::ReadMemberFrom(reader)); |
| 2840 | 2843 |
| 2841 return program; | 2844 return program; |
| 2842 } | 2845 } |
| 2843 | 2846 |
| 2844 | 2847 |
| 2845 void Program::WriteTo(Writer* writer) { | 2848 void Program::WriteTo(Writer* writer) { |
| 2846 TRACE_WRITE_OFFSET(); | 2849 TRACE_WRITE_OFFSET(); |
| 2847 | 2850 |
| 2848 writer->helper()->SetProgram(this); | 2851 writer->helper()->SetProgram(this); |
| 2849 | 2852 |
| 2850 writer->WriteUInt32(kMagicProgramFile); | 2853 writer->WriteUInt32(kMagicProgramFile); |
| 2851 | 2854 |
| 2852 // NOTE: Currently we don't GC strings and we require that all referenced | 2855 // NOTE: Currently we don't GC strings and we require that all referenced |
| 2853 // strings in nodes are present in [string_table_]. | 2856 // strings in nodes are present in [string_table_]. |
| 2854 string_table_.WriteTo(writer); | 2857 string_table_.WriteTo(writer); |
| 2855 source_uri_table_.WriteTo(writer); | 2858 source_uri_table_.WriteTo(writer); |
| 2856 line_starting_table_.WriteTo(writer); | 2859 line_starting_table_and_source_.WriteTo(writer); |
| 2857 | 2860 |
| 2858 libraries_.WriteTo(writer); | 2861 libraries_.WriteTo(writer); |
| 2859 Reference::WriteMemberTo(writer, main_method_); | 2862 Reference::WriteMemberTo(writer, main_method_); |
| 2860 } | 2863 } |
| 2861 | 2864 |
| 2862 | 2865 |
| 2863 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { | 2866 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { |
| 2864 TRACE_READ_OFFSET(); | 2867 TRACE_READ_OFFSET(); |
| 2865 TypeParameterScope<ReaderHelper> scope(reader->helper()); | 2868 TypeParameterScope<ReaderHelper> scope(reader->helper()); |
| 2866 | 2869 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2930 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) { | 2933 void WritePrecompiledKernel(ByteWriter* byte_writer, kernel::Program* program) { |
| 2931 ASSERT(byte_writer != NULL); | 2934 ASSERT(byte_writer != NULL); |
| 2932 | 2935 |
| 2933 kernel::Writer writer(byte_writer); | 2936 kernel::Writer writer(byte_writer); |
| 2934 program->WriteTo(&writer); | 2937 program->WriteTo(&writer); |
| 2935 } | 2938 } |
| 2936 | 2939 |
| 2937 | 2940 |
| 2938 } // namespace dart | 2941 } // namespace dart |
| 2939 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 2942 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |