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 #ifndef RUNTIME_VM_KERNEL_H_ | 5 #ifndef RUNTIME_VM_KERNEL_H_ |
6 #define RUNTIME_VM_KERNEL_H_ | 6 #define RUNTIME_VM_KERNEL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Returns element at [index]. | 223 // Returns element at [index]. |
224 T*& operator[](int index) { | 224 T*& operator[](int index) { |
225 ASSERT(index < length_); | 225 ASSERT(index < length_); |
226 return array_[index]; | 226 return array_[index]; |
227 } | 227 } |
228 | 228 |
229 int length() { return length_; } | 229 int length() { return length_; } |
230 | 230 |
231 T** raw_array() { return array_; } | 231 T** raw_array() { return array_; } |
232 | 232 |
| 233 bool CanStream() { |
| 234 for (intptr_t i = 0; i < length_; ++i) { |
| 235 if (!array_[i]->can_stream()) return false; |
| 236 } |
| 237 return true; |
| 238 } |
| 239 |
233 private: | 240 private: |
234 T** array_; | 241 T** array_; |
235 int length_; | 242 int length_; |
236 | 243 |
237 DISALLOW_COPY_AND_ASSIGN(List); | 244 DISALLOW_COPY_AND_ASSIGN(List); |
238 }; | 245 }; |
239 | 246 |
240 | 247 |
241 class TypeParameterList : public List<TypeParameter> { | 248 class TypeParameterList : public List<TypeParameter> { |
242 public: | 249 public: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 387 |
381 class TreeNode : public Node { | 388 class TreeNode : public Node { |
382 public: | 389 public: |
383 virtual ~TreeNode(); | 390 virtual ~TreeNode(); |
384 | 391 |
385 DEFINE_CASTING_OPERATIONS(TreeNode); | 392 DEFINE_CASTING_OPERATIONS(TreeNode); |
386 | 393 |
387 virtual void AcceptVisitor(Visitor* visitor); | 394 virtual void AcceptVisitor(Visitor* visitor); |
388 virtual void AcceptTreeVisitor(TreeVisitor* visitor) = 0; | 395 virtual void AcceptTreeVisitor(TreeVisitor* visitor) = 0; |
389 intptr_t kernel_offset() const { return kernel_offset_; } | 396 intptr_t kernel_offset() const { return kernel_offset_; } |
| 397 bool can_stream() { return can_stream_; } |
390 | 398 |
391 protected: | 399 protected: |
392 TreeNode() : kernel_offset_(-1) {} | 400 TreeNode() : kernel_offset_(-1), can_stream_(true) {} |
393 | 401 |
394 // Offset for this node in the kernel-binary. If this node has a tag the | 402 // Offset for this node in the kernel-binary. If this node has a tag the |
395 // offset includes the tag. Can be -1 to indicate "unknown" or invalid offset. | 403 // offset includes the tag. Can be -1 to indicate "unknown" or invalid offset. |
396 intptr_t kernel_offset_; | 404 intptr_t kernel_offset_; |
397 | 405 |
| 406 bool can_stream_; |
| 407 |
398 private: | 408 private: |
399 DISALLOW_COPY_AND_ASSIGN(TreeNode); | 409 DISALLOW_COPY_AND_ASSIGN(TreeNode); |
400 }; | 410 }; |
401 | 411 |
402 | 412 |
403 class LinkedNode : public TreeNode { | 413 class LinkedNode : public TreeNode { |
404 public: | 414 public: |
405 virtual ~LinkedNode(); | 415 virtual ~LinkedNode(); |
406 | 416 |
407 NameIndex canonical_name() { return canonical_name_; } | 417 NameIndex canonical_name() { return canonical_name_; } |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1021 |
1012 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); | 1022 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); |
1013 virtual void VisitChildren(Visitor* visitor); | 1023 virtual void VisitChildren(Visitor* visitor); |
1014 | 1024 |
1015 VariableDeclaration* variable() { return variable_; } | 1025 VariableDeclaration* variable() { return variable_; } |
1016 | 1026 |
1017 private: | 1027 private: |
1018 VariableGet() {} | 1028 VariableGet() {} |
1019 | 1029 |
1020 Ref<VariableDeclaration> variable_; | 1030 Ref<VariableDeclaration> variable_; |
| 1031 intptr_t variable_kernel_offset_; |
1021 | 1032 |
1022 DISALLOW_COPY_AND_ASSIGN(VariableGet); | 1033 DISALLOW_COPY_AND_ASSIGN(VariableGet); |
1023 }; | 1034 }; |
1024 | 1035 |
1025 | 1036 |
1026 class VariableSet : public Expression { | 1037 class VariableSet : public Expression { |
1027 public: | 1038 public: |
1028 static VariableSet* ReadFrom(Reader* reader); | 1039 static VariableSet* ReadFrom(Reader* reader); |
1029 static VariableSet* ReadFrom(Reader* reader, uint8_t payload); | 1040 static VariableSet* ReadFrom(Reader* reader, uint8_t payload); |
1030 | 1041 |
1031 virtual ~VariableSet(); | 1042 virtual ~VariableSet(); |
1032 | 1043 |
1033 DEFINE_CASTING_OPERATIONS(VariableSet); | 1044 DEFINE_CASTING_OPERATIONS(VariableSet); |
1034 | 1045 |
1035 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); | 1046 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); |
1036 virtual void VisitChildren(Visitor* visitor); | 1047 virtual void VisitChildren(Visitor* visitor); |
1037 | 1048 |
1038 VariableDeclaration* variable() { return variable_; } | 1049 VariableDeclaration* variable() { return variable_; } |
1039 Expression* expression() { return expression_; } | 1050 Expression* expression() { return expression_; } |
1040 | 1051 |
1041 private: | 1052 private: |
1042 VariableSet() {} | 1053 VariableSet() {} |
1043 | 1054 |
1044 Ref<VariableDeclaration> variable_; | 1055 Ref<VariableDeclaration> variable_; |
| 1056 intptr_t variable_kernel_offset_; |
1045 Child<Expression> expression_; | 1057 Child<Expression> expression_; |
1046 | 1058 |
1047 DISALLOW_COPY_AND_ASSIGN(VariableSet); | 1059 DISALLOW_COPY_AND_ASSIGN(VariableSet); |
1048 }; | 1060 }; |
1049 | 1061 |
1050 | 1062 |
1051 class PropertyGet : public Expression { | 1063 class PropertyGet : public Expression { |
1052 public: | 1064 public: |
1053 static PropertyGet* ReadFrom(Reader* reader); | 1065 static PropertyGet* ReadFrom(Reader* reader); |
1054 | 1066 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 NameIndex target_reference_; // Member canonical name. | 1157 NameIndex target_reference_; // Member canonical name. |
1146 Child<Expression> receiver_; | 1158 Child<Expression> receiver_; |
1147 Child<Expression> value_; | 1159 Child<Expression> value_; |
1148 | 1160 |
1149 DISALLOW_COPY_AND_ASSIGN(DirectPropertySet); | 1161 DISALLOW_COPY_AND_ASSIGN(DirectPropertySet); |
1150 }; | 1162 }; |
1151 | 1163 |
1152 | 1164 |
1153 class StaticGet : public Expression { | 1165 class StaticGet : public Expression { |
1154 public: | 1166 public: |
1155 explicit StaticGet(NameIndex target) : target_reference_(target) {} | 1167 StaticGet(NameIndex target, bool can_stream) : target_reference_(target) { |
| 1168 can_stream_ = can_stream; |
| 1169 } |
1156 | 1170 |
1157 static StaticGet* ReadFrom(Reader* reader); | 1171 static StaticGet* ReadFrom(Reader* reader); |
1158 | 1172 |
1159 virtual ~StaticGet(); | 1173 virtual ~StaticGet(); |
1160 | 1174 |
1161 DEFINE_CASTING_OPERATIONS(StaticGet); | 1175 DEFINE_CASTING_OPERATIONS(StaticGet); |
1162 | 1176 |
1163 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); | 1177 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); |
1164 virtual void VisitChildren(Visitor* visitor); | 1178 virtual void VisitChildren(Visitor* visitor); |
1165 | 1179 |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 public: | 2181 public: |
2168 static BreakStatement* ReadFrom(Reader* reader); | 2182 static BreakStatement* ReadFrom(Reader* reader); |
2169 | 2183 |
2170 virtual ~BreakStatement(); | 2184 virtual ~BreakStatement(); |
2171 | 2185 |
2172 DEFINE_CASTING_OPERATIONS(BreakStatement); | 2186 DEFINE_CASTING_OPERATIONS(BreakStatement); |
2173 | 2187 |
2174 virtual void AcceptStatementVisitor(StatementVisitor* visitor); | 2188 virtual void AcceptStatementVisitor(StatementVisitor* visitor); |
2175 virtual void VisitChildren(Visitor* visitor); | 2189 virtual void VisitChildren(Visitor* visitor); |
2176 | 2190 |
2177 LabeledStatement* target() { return target_; } | 2191 intptr_t target_index() { return target_index_; } |
2178 | 2192 |
2179 private: | 2193 private: |
2180 BreakStatement() {} | 2194 BreakStatement() {} |
2181 | 2195 |
2182 Ref<LabeledStatement> target_; | 2196 intptr_t target_index_; |
2183 | 2197 |
2184 DISALLOW_COPY_AND_ASSIGN(BreakStatement); | 2198 DISALLOW_COPY_AND_ASSIGN(BreakStatement); |
2185 }; | 2199 }; |
2186 | 2200 |
2187 | 2201 |
2188 class WhileStatement : public Statement { | 2202 class WhileStatement : public Statement { |
2189 public: | 2203 public: |
2190 static WhileStatement* ReadFrom(Reader* reader); | 2204 static WhileStatement* ReadFrom(Reader* reader); |
2191 | 2205 |
2192 virtual ~WhileStatement(); | 2206 virtual ~WhileStatement(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 public: | 2372 public: |
2359 static ContinueSwitchStatement* ReadFrom(Reader* reader); | 2373 static ContinueSwitchStatement* ReadFrom(Reader* reader); |
2360 | 2374 |
2361 virtual ~ContinueSwitchStatement(); | 2375 virtual ~ContinueSwitchStatement(); |
2362 | 2376 |
2363 DEFINE_CASTING_OPERATIONS(ContinueSwitchStatement); | 2377 DEFINE_CASTING_OPERATIONS(ContinueSwitchStatement); |
2364 | 2378 |
2365 virtual void AcceptStatementVisitor(StatementVisitor* visitor); | 2379 virtual void AcceptStatementVisitor(StatementVisitor* visitor); |
2366 virtual void VisitChildren(Visitor* visitor); | 2380 virtual void VisitChildren(Visitor* visitor); |
2367 | 2381 |
2368 SwitchCase* target() { return target_; } | 2382 intptr_t target_index() { return target_index_; } |
2369 | 2383 |
2370 private: | 2384 private: |
2371 ContinueSwitchStatement() {} | 2385 ContinueSwitchStatement() {} |
2372 | 2386 |
2373 Ref<SwitchCase> target_; | 2387 intptr_t target_index_; |
2374 | 2388 |
2375 DISALLOW_COPY_AND_ASSIGN(ContinueSwitchStatement); | 2389 DISALLOW_COPY_AND_ASSIGN(ContinueSwitchStatement); |
2376 }; | 2390 }; |
2377 | 2391 |
2378 | 2392 |
2379 class IfStatement : public Statement { | 2393 class IfStatement : public Statement { |
2380 public: | 2394 public: |
2381 static IfStatement* ReadFrom(Reader* reader); | 2395 static IfStatement* ReadFrom(Reader* reader); |
2382 | 2396 |
2383 virtual ~IfStatement(); | 2397 virtual ~IfStatement(); |
(...skipping 13 matching lines...) Expand all Loading... |
2397 Child<Expression> condition_; | 2411 Child<Expression> condition_; |
2398 Child<Statement> then_; | 2412 Child<Statement> then_; |
2399 Child<Statement> otherwise_; | 2413 Child<Statement> otherwise_; |
2400 | 2414 |
2401 DISALLOW_COPY_AND_ASSIGN(IfStatement); | 2415 DISALLOW_COPY_AND_ASSIGN(IfStatement); |
2402 }; | 2416 }; |
2403 | 2417 |
2404 | 2418 |
2405 class ReturnStatement : public Statement { | 2419 class ReturnStatement : public Statement { |
2406 public: | 2420 public: |
2407 explicit ReturnStatement(Expression* expression) : expression_(expression) {} | 2421 ReturnStatement(Expression* expression, bool can_stream) |
| 2422 : expression_(expression) { |
| 2423 can_stream_ = can_stream; |
| 2424 } |
2408 | 2425 |
2409 static ReturnStatement* ReadFrom(Reader* reader); | 2426 static ReturnStatement* ReadFrom(Reader* reader); |
2410 | 2427 |
2411 virtual ~ReturnStatement(); | 2428 virtual ~ReturnStatement(); |
2412 | 2429 |
2413 DEFINE_CASTING_OPERATIONS(ReturnStatement); | 2430 DEFINE_CASTING_OPERATIONS(ReturnStatement); |
2414 | 2431 |
2415 virtual void AcceptStatementVisitor(StatementVisitor* visitor); | 2432 virtual void AcceptStatementVisitor(StatementVisitor* visitor); |
2416 virtual void VisitChildren(Visitor* visitor); | 2433 virtual void VisitChildren(Visitor* visitor); |
2417 | 2434 |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3336 } // namespace kernel | 3353 } // namespace kernel |
3337 | 3354 |
3338 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, | 3355 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, |
3339 intptr_t buffer_length); | 3356 intptr_t buffer_length); |
3340 | 3357 |
3341 | 3358 |
3342 } // namespace dart | 3359 } // namespace dart |
3343 | 3360 |
3344 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 3361 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
3345 #endif // RUNTIME_VM_KERNEL_H_ | 3362 #endif // RUNTIME_VM_KERNEL_H_ |
OLD | NEW |