OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 class FlowGraphCompiler; | 31 class FlowGraphCompiler; |
32 class FlowGraphVisitor; | 32 class FlowGraphVisitor; |
33 class Instruction; | 33 class Instruction; |
34 class LocalVariable; | 34 class LocalVariable; |
35 class ParsedFunction; | 35 class ParsedFunction; |
36 class Range; | 36 class Range; |
37 class RangeAnalysis; | 37 class RangeAnalysis; |
38 class RangeBoundary; | 38 class RangeBoundary; |
39 class UnboxIntegerInstr; | 39 class UnboxIntegerInstr; |
40 | 40 |
41 // These token positions are used to classify instructions that can't be | |
42 // directly tied to an actual source position. | |
43 #define CLASSIFYING_TOKEN_POSITIONS(V) \ | |
44 V(Private, -2) \ | |
45 V(Box, -3) \ | |
46 V(ParallelMove, -4) \ | |
47 V(TempMove, -5) \ | |
48 V(Constant, -6) \ | |
49 V(PushArgument, -7) \ | |
50 V(ControlFlow, -8) \ | |
51 V(Context, -9) | |
52 | |
53 // COMPILE_ASSERT that all CLASSIFYING_TOKEN_POSITIONS are less than | |
54 // Scanner::kNoSourcePos. | |
55 #define SANITY_CHECK_VALUES(name, value) \ | |
56 COMPILE_ASSERT(value < Scanner::kNoSourcePos); | |
57 CLASSIFYING_TOKEN_POSITIONS(SANITY_CHECK_VALUES); | |
58 #undef SANITY_CHECK_VALUES | |
59 | |
60 class ClassifyingTokenPositions : public AllStatic { | |
61 public: | |
62 #define DEFINE_VALUES(name, value) \ | |
63 static const intptr_t k##name = value; | |
64 CLASSIFYING_TOKEN_POSITIONS(DEFINE_VALUES); | |
65 #undef DEFINE_VALUES | |
66 | |
67 static const char* ToCString(intptr_t token_pos) { | |
68 ASSERT(token_pos < 0); | |
69 switch (token_pos) { | |
70 case Scanner::kNoSourcePos: return "NoSource"; | |
71 #define DEFINE_CASE(name, value) \ | |
72 case value: return #name; | |
73 CLASSIFYING_TOKEN_POSITIONS(DEFINE_CASE); | |
74 #undef DEFINE_CASE | |
75 default: | |
76 UNIMPLEMENTED(); | |
77 return NULL; | |
78 } | |
79 } | |
80 }; | |
81 | |
82 // CompileType describes type of the value produced by the definition. | 41 // CompileType describes type of the value produced by the definition. |
83 // | 42 // |
84 // It captures the following properties: | 43 // It captures the following properties: |
85 // - whether value can potentially be null or it is definitely not null; | 44 // - whether value can potentially be null or it is definitely not null; |
86 // - concrete class id of the value or kDynamicCid if unknown statically; | 45 // - concrete class id of the value or kDynamicCid if unknown statically; |
87 // - abstract super type of the value, concrete type of the value in runtime | 46 // - abstract super type of the value, concrete type of the value in runtime |
88 // is guaranteed to be sub type of this type. | 47 // is guaranteed to be sub type of this type. |
89 // | 48 // |
90 // Values of CompileType form a lattice with a None type as a bottom and a | 49 // Values of CompileType form a lattice with a None type as a bottom and a |
91 // nullable Dynamic type as a top element. Method Union provides a join | 50 // nullable Dynamic type as a top element. Method Union provides a join |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 virtual Tag tag() const = 0; | 620 virtual Tag tag() const = 0; |
662 | 621 |
663 intptr_t deopt_id() const { | 622 intptr_t deopt_id() const { |
664 ASSERT(CanDeoptimize() || CanBecomeDeoptimizationTarget()); | 623 ASSERT(CanDeoptimize() || CanBecomeDeoptimizationTarget()); |
665 return GetDeoptId(); | 624 return GetDeoptId(); |
666 } | 625 } |
667 | 626 |
668 const ICData* GetICData( | 627 const ICData* GetICData( |
669 const ZoneGrowableArray<const ICData*>& ic_data_array) const; | 628 const ZoneGrowableArray<const ICData*>& ic_data_array) const; |
670 | 629 |
671 virtual intptr_t token_pos() const { return Scanner::kNoSourcePos; } | 630 virtual intptr_t token_pos() const { return Token::kNoSourcePos; } |
672 | 631 |
673 virtual intptr_t InputCount() const = 0; | 632 virtual intptr_t InputCount() const = 0; |
674 virtual Value* InputAt(intptr_t i) const = 0; | 633 virtual Value* InputAt(intptr_t i) const = 0; |
675 void SetInputAt(intptr_t i, Value* value) { | 634 void SetInputAt(intptr_t i, Value* value) { |
676 ASSERT(value != NULL); | 635 ASSERT(value != NULL); |
677 value->set_instruction(this); | 636 value->set_instruction(this); |
678 value->set_use_index(i); | 637 value->set_use_index(i); |
679 RawSetInputAt(i, value); | 638 RawSetInputAt(i, value); |
680 } | 639 } |
681 | 640 |
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3305 | 3264 |
3306 AliasIdentity identity_; | 3265 AliasIdentity identity_; |
3307 | 3266 |
3308 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); | 3267 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); |
3309 }; | 3268 }; |
3310 | 3269 |
3311 | 3270 |
3312 class LoadLocalInstr : public TemplateDefinition<0, NoThrow> { | 3271 class LoadLocalInstr : public TemplateDefinition<0, NoThrow> { |
3313 public: | 3272 public: |
3314 LoadLocalInstr(const LocalVariable& local, | 3273 LoadLocalInstr(const LocalVariable& local, |
3315 intptr_t token_pos = Scanner::kNoSourcePos) | 3274 intptr_t token_pos) |
3316 : local_(local), is_last_(false), token_pos_(token_pos) { } | 3275 : local_(local), is_last_(false), token_pos_(token_pos) { } |
3317 | 3276 |
3318 DECLARE_INSTRUCTION(LoadLocal) | 3277 DECLARE_INSTRUCTION(LoadLocal) |
3319 virtual CompileType ComputeType() const; | 3278 virtual CompileType ComputeType() const; |
3320 | 3279 |
3321 const LocalVariable& local() const { return local_; } | 3280 const LocalVariable& local() const { return local_; } |
3322 | 3281 |
3323 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3282 virtual void PrintOperandsTo(BufferFormatter* f) const; |
3324 | 3283 |
3325 virtual bool CanDeoptimize() const { return false; } | 3284 virtual bool CanDeoptimize() const { return false; } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 Value* value_; | 3380 Value* value_; |
3422 | 3381 |
3423 DISALLOW_COPY_AND_ASSIGN(DropTempsInstr); | 3382 DISALLOW_COPY_AND_ASSIGN(DropTempsInstr); |
3424 }; | 3383 }; |
3425 | 3384 |
3426 | 3385 |
3427 class StoreLocalInstr : public TemplateDefinition<1, NoThrow> { | 3386 class StoreLocalInstr : public TemplateDefinition<1, NoThrow> { |
3428 public: | 3387 public: |
3429 StoreLocalInstr(const LocalVariable& local, | 3388 StoreLocalInstr(const LocalVariable& local, |
3430 Value* value, | 3389 Value* value, |
3431 intptr_t token_pos = Scanner::kNoSourcePos) | 3390 intptr_t token_pos) |
3432 : local_(local), is_dead_(false), is_last_(false), token_pos_(token_pos) { | 3391 : local_(local), is_dead_(false), is_last_(false), token_pos_(token_pos) { |
3433 SetInputAt(0, value); | 3392 SetInputAt(0, value); |
3434 } | 3393 } |
3435 | 3394 |
3436 DECLARE_INSTRUCTION(StoreLocal) | 3395 DECLARE_INSTRUCTION(StoreLocal) |
3437 virtual CompileType ComputeType() const; | 3396 virtual CompileType ComputeType() const; |
3438 | 3397 |
3439 const LocalVariable& local() const { return local_; } | 3398 const LocalVariable& local() const { return local_; } |
3440 Value* value() const { return inputs_[0]; } | 3399 Value* value() const { return inputs_[0]; } |
3441 | 3400 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 const intptr_t token_pos_; | 3709 const intptr_t token_pos_; |
3751 | 3710 |
3752 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldInstr); | 3711 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldInstr); |
3753 }; | 3712 }; |
3754 | 3713 |
3755 | 3714 |
3756 class StoreStaticFieldInstr : public TemplateDefinition<1, NoThrow> { | 3715 class StoreStaticFieldInstr : public TemplateDefinition<1, NoThrow> { |
3757 public: | 3716 public: |
3758 StoreStaticFieldInstr(const Field& field, | 3717 StoreStaticFieldInstr(const Field& field, |
3759 Value* value, | 3718 Value* value, |
3760 intptr_t token_pos = Scanner::kNoSourcePos) | 3719 intptr_t token_pos) |
3761 : field_(field), | 3720 : field_(field), |
3762 token_pos_(token_pos) { | 3721 token_pos_(token_pos) { |
3763 ASSERT(field.IsZoneHandle()); | 3722 ASSERT(field.IsZoneHandle()); |
3764 SetInputAt(kValuePos, value); | 3723 SetInputAt(kValuePos, value); |
3765 } | 3724 } |
3766 | 3725 |
3767 enum { | 3726 enum { |
3768 kValuePos = 0 | 3727 kValuePos = 0 |
3769 }; | 3728 }; |
3770 | 3729 |
(...skipping 4445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8216 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8175 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
8217 UNIMPLEMENTED(); \ | 8176 UNIMPLEMENTED(); \ |
8218 return NULL; \ | 8177 return NULL; \ |
8219 } \ | 8178 } \ |
8220 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8179 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
8221 | 8180 |
8222 | 8181 |
8223 } // namespace dart | 8182 } // namespace dart |
8224 | 8183 |
8225 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 8184 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |