OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 const uint8_t* buffer, | 58 const uint8_t* buffer, |
59 intptr_t buffer_length) | 59 intptr_t buffer_length) |
60 : flow_graph_builder_(flow_graph_builder), | 60 : flow_graph_builder_(flow_graph_builder), |
61 translation_helper_(flow_graph_builder->translation_helper_), | 61 translation_helper_(flow_graph_builder->translation_helper_), |
62 zone_(flow_graph_builder->zone_), | 62 zone_(flow_graph_builder->zone_), |
63 reader_(new kernel::Reader(buffer, buffer_length)), | 63 reader_(new kernel::Reader(buffer, buffer_length)), |
64 constant_evaluator_(this, | 64 constant_evaluator_(this, |
65 flow_graph_builder->zone_, | 65 flow_graph_builder->zone_, |
66 &flow_graph_builder->translation_helper_, | 66 &flow_graph_builder->translation_helper_, |
67 &flow_graph_builder->type_translator_), | 67 &flow_graph_builder->type_translator_), |
68 string_offset_count_(0), | |
69 string_offsets_(NULL), | |
70 canonical_names_(NULL), | 68 canonical_names_(NULL), |
71 canonical_names_size_(-1), | 69 canonical_names_size_(-1), |
72 canonical_names_entries_read_(0), | 70 canonical_names_entries_read_(0), |
73 canonical_names_next_offset_(-1) {} | 71 canonical_names_next_offset_(-1) {} |
74 | 72 |
75 virtual ~StreamingFlowGraphBuilder() { | 73 virtual ~StreamingFlowGraphBuilder() { |
76 delete reader_; | 74 delete reader_; |
77 delete[] string_offsets_; | |
78 // The canonical names themselves are not (yet) deallocated. | 75 // The canonical names themselves are not (yet) deallocated. |
79 delete[] canonical_names_; | 76 delete[] canonical_names_; |
80 } | 77 } |
81 | 78 |
82 Fragment BuildAt(intptr_t kernel_offset); | 79 Fragment BuildAt(intptr_t kernel_offset); |
83 | 80 |
84 private: | 81 private: |
85 intptr_t GetStringOffset(intptr_t index); | |
86 CanonicalName* GetCanonicalName(intptr_t index); | 82 CanonicalName* GetCanonicalName(intptr_t index); |
87 | 83 |
88 intptr_t ReaderOffset(); | 84 intptr_t ReaderOffset(); |
89 void SetOffset(intptr_t offset); | 85 void SetOffset(intptr_t offset); |
90 void SkipBytes(intptr_t skip); | 86 void SkipBytes(intptr_t skip); |
91 uint32_t ReadUInt(); | 87 uint32_t ReadUInt(); |
92 intptr_t ReadListLength(); | 88 intptr_t ReadListLength(); |
93 TokenPosition ReadPosition(bool record = true); | 89 TokenPosition ReadPosition(bool record = true); |
94 Tag ReadTag(uint8_t* payload = NULL); | 90 Tag ReadTag(uint8_t* payload = NULL); |
95 | 91 |
96 CatchBlock* catch_block(); | 92 CatchBlock* catch_block(); |
97 ScopeBuildingResult* scopes(); | 93 ScopeBuildingResult* scopes(); |
98 ParsedFunction* parsed_function(); | 94 ParsedFunction* parsed_function(); |
99 | 95 |
100 dart::String& DartSymbol(intptr_t str_index); | |
101 dart::String& DartString(intptr_t str_index); | |
102 String* KernelString(intptr_t str_index); | |
103 | |
104 Fragment DebugStepCheck(TokenPosition position); | 96 Fragment DebugStepCheck(TokenPosition position); |
105 Fragment LoadLocal(LocalVariable* variable); | 97 Fragment LoadLocal(LocalVariable* variable); |
106 Fragment PushArgument(); | 98 Fragment PushArgument(); |
107 Fragment RethrowException(TokenPosition position, int catch_try_index); | 99 Fragment RethrowException(TokenPosition position, int catch_try_index); |
108 Fragment ThrowNoSuchMethodError(); | 100 Fragment ThrowNoSuchMethodError(); |
109 Fragment Constant(const Object& value); | 101 Fragment Constant(const Object& value); |
110 Fragment IntConstant(int64_t value); | 102 Fragment IntConstant(int64_t value); |
111 Fragment LoadStaticField(); | 103 Fragment LoadStaticField(); |
112 Fragment StaticCall(TokenPosition position, | 104 Fragment StaticCall(TokenPosition position, |
113 const Function& target, | 105 const Function& target, |
(...skipping 11 matching lines...) Expand all Loading... |
125 Fragment BuildDoubleLiteral(); | 117 Fragment BuildDoubleLiteral(); |
126 Fragment BuildBoolLiteral(bool value); | 118 Fragment BuildBoolLiteral(bool value); |
127 Fragment BuildNullLiteral(); | 119 Fragment BuildNullLiteral(); |
128 | 120 |
129 FlowGraphBuilder* flow_graph_builder_; | 121 FlowGraphBuilder* flow_graph_builder_; |
130 TranslationHelper& translation_helper_; | 122 TranslationHelper& translation_helper_; |
131 Zone* zone_; | 123 Zone* zone_; |
132 kernel::Reader* reader_; | 124 kernel::Reader* reader_; |
133 StreamingConstantEvaluator constant_evaluator_; | 125 StreamingConstantEvaluator constant_evaluator_; |
134 | 126 |
135 // We build a table that gives us the start and end offsets of all the strings | |
136 // in the binary. | |
137 // | |
138 // The number of string offsets. Note that this is one more than the number | |
139 // of strings in the binary. | |
140 intptr_t string_offset_count_; | |
141 | |
142 // An array of offsets of size string_table_size_ + 1, in order to include the | |
143 // end offset of the last string. The string with index N consists of the | |
144 // UTF-8 encoded bytes stretching from string_table_offsets_[N] (enclusive) to | |
145 // string_table_offsets_[N+1] (exclusive). | |
146 intptr_t* string_offsets_; | |
147 | |
148 CanonicalName** canonical_names_; | 127 CanonicalName** canonical_names_; |
149 intptr_t canonical_names_size_; | 128 intptr_t canonical_names_size_; |
150 intptr_t canonical_names_entries_read_; | 129 intptr_t canonical_names_entries_read_; |
151 intptr_t canonical_names_next_offset_; | 130 intptr_t canonical_names_next_offset_; |
152 | 131 |
153 friend class StreamingConstantEvaluator; | 132 friend class StreamingConstantEvaluator; |
154 }; | 133 }; |
155 | 134 |
156 | 135 |
157 } // namespace kernel | 136 } // namespace kernel |
158 } // namespace dart | 137 } // namespace dart |
159 | 138 |
160 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 139 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
161 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ | 140 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ |
OLD | NEW |