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

Side by Side Diff: runtime/vm/kernel_to_il.h

Issue 2931773005: [kernel] Delete most of the AST (Closed)
Patch Set: Review Created 3 years, 5 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_reader.cc ('k') | runtime/vm/kernel_to_il.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 4
5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ 6 #define RUNTIME_VM_KERNEL_TO_IL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 9
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; 192 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray;
193 193
194 194
195 class ActiveClass { 195 class ActiveClass {
196 public: 196 public:
197 ActiveClass() 197 ActiveClass()
198 : kernel_class(NULL), 198 : kernel_class(NULL),
199 class_type_parameters(0), 199 class_type_parameters(0),
200 class_type_parameters_offset_start(-1), 200 class_type_parameters_offset_start(-1),
201 klass(NULL), 201 klass(NULL),
202 member(NULL),
203 member_is_procedure(false), 202 member_is_procedure(false),
204 member_is_factory_procedure(false), 203 member_is_factory_procedure(false),
205 member_type_parameters(0), 204 member_type_parameters(0),
206 member_type_parameters_offset_start(-1) {} 205 member_type_parameters_offset_start(-1) {}
207 206
208 // The current enclosing kernel class (if available, otherwise NULL). 207 // The current enclosing kernel class (if available, otherwise NULL).
209 Class* kernel_class; 208 Class* kernel_class;
210 intptr_t class_type_parameters; 209 intptr_t class_type_parameters;
211 intptr_t class_type_parameters_offset_start; 210 intptr_t class_type_parameters_offset_start;
212 211
213 // The current enclosing class (or the library top-level class). When this is 212 // The current enclosing class (or the library top-level class). When this is
214 // a library's top-level class, the kernel_class will be NULL. 213 // a library's top-level class, the kernel_class will be NULL.
215 const dart::Class* klass; 214 const dart::Class* klass;
216 215
217 // The enclosing member (e.g., Constructor, Procedure, or Field) if there
218 // is one.
219 Member* member;
220 bool member_is_procedure; 216 bool member_is_procedure;
221 bool member_is_factory_procedure; 217 bool member_is_factory_procedure;
222 intptr_t member_type_parameters; 218 intptr_t member_type_parameters;
223 intptr_t member_type_parameters_offset_start; 219 intptr_t member_type_parameters_offset_start;
224 }; 220 };
225 221
226 222
227 class ActiveClassScope { 223 class ActiveClassScope {
228 public: 224 public:
229 ActiveClassScope(ActiveClass* active_class, 225 ActiveClassScope(ActiveClass* active_class,
230 intptr_t class_type_parameters, 226 intptr_t class_type_parameters,
231 intptr_t class_type_parameters_offset_start, 227 intptr_t class_type_parameters_offset_start,
232 const dart::Class* klass) 228 const dart::Class* klass)
233 : active_class_(active_class), saved_(*active_class) { 229 : active_class_(active_class), saved_(*active_class) {
234 active_class_->kernel_class = NULL; 230 active_class_->kernel_class = NULL;
235 active_class_->class_type_parameters = class_type_parameters; 231 active_class_->class_type_parameters = class_type_parameters;
236 active_class_->class_type_parameters_offset_start = 232 active_class_->class_type_parameters_offset_start =
237 class_type_parameters_offset_start; 233 class_type_parameters_offset_start;
238 active_class_->klass = klass; 234 active_class_->klass = klass;
239 active_class_->member = NULL;
240 } 235 }
241 236
242 ~ActiveClassScope() { *active_class_ = saved_; } 237 ~ActiveClassScope() { *active_class_ = saved_; }
243 238
244 private: 239 private:
245 ActiveClass* active_class_; 240 ActiveClass* active_class_;
246 ActiveClass saved_; 241 ActiveClass saved_;
247 }; 242 };
248 243
249 244
250 class ActiveMemberScope { 245 class ActiveMemberScope {
251 public: 246 public:
252 ActiveMemberScope(ActiveClass* active_class, 247 ActiveMemberScope(ActiveClass* active_class,
253 bool member_is_procedure, 248 bool member_is_procedure,
254 bool member_is_factory_procedure, 249 bool member_is_factory_procedure,
255 intptr_t member_type_parameters, 250 intptr_t member_type_parameters,
256 intptr_t member_type_parameters_offset_start) 251 intptr_t member_type_parameters_offset_start)
257 : active_class_(active_class), saved_(*active_class) { 252 : active_class_(active_class), saved_(*active_class) {
258 // The class and kernel_class is inherited. 253 // The class and kernel_class is inherited.
259 active_class_->member = NULL;
260 active_class_->member_is_procedure = member_is_procedure; 254 active_class_->member_is_procedure = member_is_procedure;
261 active_class_->member_is_factory_procedure = member_is_factory_procedure; 255 active_class_->member_is_factory_procedure = member_is_factory_procedure;
262 active_class_->member_type_parameters = member_type_parameters; 256 active_class_->member_type_parameters = member_type_parameters;
263 active_class_->member_type_parameters_offset_start = 257 active_class_->member_type_parameters_offset_start =
264 member_type_parameters_offset_start; 258 member_type_parameters_offset_start;
265 } 259 }
266 260
267 ~ActiveMemberScope() { *active_class_ = saved_; } 261 ~ActiveMemberScope() { *active_class_ = saved_; }
268 262
269 private: 263 private:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 dart::String& DartSymbol(StringIndex string_index) const; 338 dart::String& DartSymbol(StringIndex string_index) const;
345 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; 339 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const;
346 340
347 const dart::String& DartClassName(NameIndex kernel_class); 341 const dart::String& DartClassName(NameIndex kernel_class);
348 342
349 const dart::String& DartConstructorName(NameIndex constructor); 343 const dart::String& DartConstructorName(NameIndex constructor);
350 344
351 const dart::String& DartProcedureName(NameIndex procedure); 345 const dart::String& DartProcedureName(NameIndex procedure);
352 346
353 const dart::String& DartSetterName(NameIndex setter); 347 const dart::String& DartSetterName(NameIndex setter);
354 const dart::String& DartSetterName(Name* setter_name);
355 const dart::String& DartSetterName(NameIndex parent, StringIndex setter); 348 const dart::String& DartSetterName(NameIndex parent, StringIndex setter);
356 349
357 const dart::String& DartGetterName(NameIndex getter); 350 const dart::String& DartGetterName(NameIndex getter);
358 const dart::String& DartGetterName(Name* getter_name);
359 const dart::String& DartGetterName(NameIndex parent, StringIndex getter); 351 const dart::String& DartGetterName(NameIndex parent, StringIndex getter);
360 352
361 const dart::String& DartFieldName(Name* kernel_name);
362 const dart::String& DartFieldName(NameIndex parent, StringIndex field); 353 const dart::String& DartFieldName(NameIndex parent, StringIndex field);
363 354
364 const dart::String& DartInitializerName(Name* kernel_name);
365
366 const dart::String& DartMethodName(NameIndex method); 355 const dart::String& DartMethodName(NameIndex method);
367 const dart::String& DartMethodName(Name* method_name);
368 const dart::String& DartMethodName(NameIndex parent, StringIndex method); 356 const dart::String& DartMethodName(NameIndex parent, StringIndex method);
369 357
370 const dart::String& DartFactoryName(NameIndex factory); 358 const dart::String& DartFactoryName(NameIndex factory);
371 359
372 const Array& ArgumentNames(List<NamedExpression>* named);
373
374 // A subclass overrides these when reading in the Kernel program in order to 360 // A subclass overrides these when reading in the Kernel program in order to
375 // support recursive type expressions (e.g. for "implements X" ... 361 // support recursive type expressions (e.g. for "implements X" ...
376 // annotations). 362 // annotations).
377 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library); 363 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library);
378 virtual RawClass* LookupClassByKernelClass(NameIndex klass); 364 virtual RawClass* LookupClassByKernelClass(NameIndex klass);
379 365
380 RawField* LookupFieldByKernelField(NameIndex field); 366 RawField* LookupFieldByKernelField(NameIndex field);
381 RawFunction* LookupStaticMethodByKernelProcedure(NameIndex procedure); 367 RawFunction* LookupStaticMethodByKernelProcedure(NameIndex procedure);
382 RawFunction* LookupConstructorByKernelConstructor(NameIndex constructor); 368 RawFunction* LookupConstructorByKernelConstructor(NameIndex constructor);
383 dart::RawFunction* LookupConstructorByKernelConstructor( 369 dart::RawFunction* LookupConstructorByKernelConstructor(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 Fragment CheckStackOverflow(); 537 Fragment CheckStackOverflow();
552 Fragment CloneContext(); 538 Fragment CloneContext();
553 Fragment Constant(const Object& value); 539 Fragment Constant(const Object& value);
554 Fragment CreateArray(); 540 Fragment CreateArray();
555 Fragment Goto(JoinEntryInstr* destination); 541 Fragment Goto(JoinEntryInstr* destination);
556 Fragment IntConstant(int64_t value); 542 Fragment IntConstant(int64_t value);
557 Fragment InstanceCall(TokenPosition position, 543 Fragment InstanceCall(TokenPosition position,
558 const dart::String& name, 544 const dart::String& name,
559 Token::Kind kind, 545 Token::Kind kind,
560 intptr_t argument_count, 546 intptr_t argument_count,
561 intptr_t num_args_checked = 1); 547 intptr_t checked_argument_count = 1);
562 Fragment InstanceCall(TokenPosition position, 548 Fragment InstanceCall(TokenPosition position,
563 const dart::String& name, 549 const dart::String& name,
564 Token::Kind kind, 550 Token::Kind kind,
565 intptr_t argument_count, 551 intptr_t argument_count,
566 const Array& argument_names, 552 const Array& argument_names,
567 intptr_t num_args_checked = 1); 553 intptr_t checked_argument_count = 1);
568 Fragment ClosureCall(intptr_t type_args_len, 554 Fragment ClosureCall(intptr_t type_args_len,
569 intptr_t argument_count, 555 intptr_t argument_count,
570 const Array& argument_names); 556 const Array& argument_names);
571 Fragment ThrowException(TokenPosition position); 557 Fragment ThrowException(TokenPosition position);
572 Fragment RethrowException(TokenPosition position, int catch_try_index); 558 Fragment RethrowException(TokenPosition position, int catch_try_index);
573 Fragment LoadClassId(); 559 Fragment LoadClassId();
574 Fragment LoadField(const dart::Field& field); 560 Fragment LoadField(const dart::Field& field);
575 Fragment LoadField(intptr_t offset, intptr_t class_id = kDynamicCid); 561 Fragment LoadField(intptr_t offset, intptr_t class_id = kDynamicCid);
576 Fragment LoadNativeField(MethodRecognizer::Kind kind, 562 Fragment LoadNativeField(MethodRecognizer::Kind kind,
577 intptr_t offset, 563 intptr_t offset,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 friend class StreamingFlowGraphBuilder; 724 friend class StreamingFlowGraphBuilder;
739 friend class ScopeBuilder; 725 friend class ScopeBuilder;
740 friend class SwitchBlock; 726 friend class SwitchBlock;
741 friend class TryCatchBlock; 727 friend class TryCatchBlock;
742 friend class TryFinallyBlock; 728 friend class TryFinallyBlock;
743 }; 729 };
744 730
745 731
746 class SwitchBlock { 732 class SwitchBlock {
747 public: 733 public:
748 SwitchBlock(FlowGraphBuilder* builder, intptr_t num_cases) 734 SwitchBlock(FlowGraphBuilder* builder, intptr_t case_count)
749 : builder_(builder), 735 : builder_(builder),
750 outer_(builder->switch_block_), 736 outer_(builder->switch_block_),
751 outer_finally_(builder->try_finally_block_), 737 outer_finally_(builder->try_finally_block_),
752 num_cases_(num_cases), 738 case_count_(case_count),
753 context_depth_(builder->context_depth_), 739 context_depth_(builder->context_depth_),
754 try_index_(builder->CurrentTryIndex()) { 740 try_index_(builder->CurrentTryIndex()) {
755 builder_->switch_block_ = this; 741 builder_->switch_block_ = this;
756 if (outer_ != NULL) { 742 if (outer_ != NULL) {
757 depth_ = outer_->depth_ + outer_->num_cases_; 743 depth_ = outer_->depth_ + outer_->case_count_;
758 } else { 744 } else {
759 depth_ = 0; 745 depth_ = 0;
760 } 746 }
761 } 747 }
762 ~SwitchBlock() { builder_->switch_block_ = outer_; } 748 ~SwitchBlock() { builder_->switch_block_ = outer_; }
763 749
764 bool HadJumper(intptr_t case_num) { 750 bool HadJumper(intptr_t case_num) {
765 return destinations_.Lookup(case_num) != NULL; 751 return destinations_.Lookup(case_num) != NULL;
766 } 752 }
767 753
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 797 }
812 return cached_inst; 798 return cached_inst;
813 } 799 }
814 800
815 FlowGraphBuilder* builder_; 801 FlowGraphBuilder* builder_;
816 SwitchBlock* outer_; 802 SwitchBlock* outer_;
817 803
818 IntMap<JoinEntryInstr*> destinations_; 804 IntMap<JoinEntryInstr*> destinations_;
819 805
820 TryFinallyBlock* outer_finally_; 806 TryFinallyBlock* outer_finally_;
821 intptr_t num_cases_; 807 intptr_t case_count_;
822 intptr_t depth_; 808 intptr_t depth_;
823 intptr_t context_depth_; 809 intptr_t context_depth_;
824 intptr_t try_index_; 810 intptr_t try_index_;
825 }; 811 };
826 812
827 813
828 class TryCatchBlock { 814 class TryCatchBlock {
829 public: 815 public:
830 explicit TryCatchBlock(FlowGraphBuilder* builder, 816 explicit TryCatchBlock(FlowGraphBuilder* builder,
831 intptr_t try_handler_index = -1) 817 intptr_t try_handler_index = -1)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 FlowGraphBuilder* builder_; 941 FlowGraphBuilder* builder_;
956 CatchBlock* outer_; 942 CatchBlock* outer_;
957 LocalVariable* exception_var_; 943 LocalVariable* exception_var_;
958 LocalVariable* stack_trace_var_; 944 LocalVariable* stack_trace_var_;
959 intptr_t catch_try_index_; 945 intptr_t catch_try_index_;
960 }; 946 };
961 947
962 948
963 RawObject* EvaluateMetadata(const dart::Field& metadata_field); 949 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
964 RawObject* BuildParameterDescriptor(const Function& function); 950 RawObject* BuildParameterDescriptor(const Function& function);
951 void CollectTokenPositionsFor(const Script& script);
952 String& GetSourceFor(const Script& script);
953 Array& GetLineStartsFor(const Script& script);
965 954
966 955
967 } // namespace kernel 956 } // namespace kernel
968 } // namespace dart 957 } // namespace dart
969 958
970 #else // !defined(DART_PRECOMPILED_RUNTIME) 959 #else // !defined(DART_PRECOMPILED_RUNTIME)
971 960
972 #include "vm/object.h" 961 #include "vm/object.h"
973 #include "vm/kernel.h" 962 #include "vm/kernel.h"
974 963
975 namespace dart { 964 namespace dart {
976 namespace kernel { 965 namespace kernel {
977 966
978 RawObject* EvaluateMetadata(const dart::Field& metadata_field); 967 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
979 RawObject* BuildParameterDescriptor(const Function& function); 968 RawObject* BuildParameterDescriptor(const Function& function);
980 969
981 } // namespace kernel 970 } // namespace kernel
982 } // namespace dart 971 } // namespace dart
983 972
984 #endif // !defined(DART_PRECOMPILED_RUNTIME) 973 #endif // !defined(DART_PRECOMPILED_RUNTIME)
985 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 974 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_reader.cc ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698