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

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

Issue 1574433003: Add ClassifyingTokenPositions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | no next file » | 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) 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
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(Box, -2) \
45 V(ParallelMove, -3) \
46 V(TempMove, -4)
47
48 // COMPILE_ASSERT that all CLASSIFYING_TOKEN_POSITIONS are less than
49 // Scanner::kNoSourcePos.
50 #define SANITY_CHECK_VALUES(name, value) \
51 COMPILE_ASSERT(value < Scanner::kNoSourcePos);
52 CLASSIFYING_TOKEN_POSITIONS(SANITY_CHECK_VALUES);
53 #undef SANITY_CHECK_VALUES
54
55 class ClassifyingTokenPositions : public AllStatic {
56 public:
57 #define DEFINE_VALUES(name, value) \
58 static const intptr_t k##name = value;
59 CLASSIFYING_TOKEN_POSITIONS(DEFINE_VALUES);
60 #undef DEFINE_VALUES
61
62 static const char* ToCString(intptr_t token_pos) {
63 ASSERT(token_pos < 0);
64 switch (token_pos) {
65 case Scanner::kNoSourcePos: return "NoSource";
66 #define DEFINE_CASE(name, value) \
67 case value: return #name;
68 CLASSIFYING_TOKEN_POSITIONS(DEFINE_CASE);
69 #undef DEFINE_CASE
70 default:
71 UNIMPLEMENTED();
72 }
73 }
74 };
75
41 // CompileType describes type of the value produced by the definition. 76 // CompileType describes type of the value produced by the definition.
42 // 77 //
43 // It captures the following properties: 78 // It captures the following properties:
44 // - whether value can potentially be null or it is definitely not null; 79 // - whether value can potentially be null or it is definitely not null;
45 // - concrete class id of the value or kDynamicCid if unknown statically; 80 // - concrete class id of the value or kDynamicCid if unknown statically;
46 // - abstract super type of the value, concrete type of the value in runtime 81 // - abstract super type of the value, concrete type of the value in runtime
47 // is guaranteed to be sub type of this type. 82 // is guaranteed to be sub type of this type.
48 // 83 //
49 // Values of CompileType form a lattice with a None type as a bottom and a 84 // Values of CompileType form a lattice with a None type as a bottom and a
50 // nullable Dynamic type as a top element. Method Union provides a join 85 // nullable Dynamic type as a top element. Method Union provides a join
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 } 1081 }
1047 1082
1048 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } 1083 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; }
1049 1084
1050 intptr_t NumMoves() const { return moves_.length(); } 1085 intptr_t NumMoves() const { return moves_.length(); }
1051 1086
1052 bool IsRedundant() const; 1087 bool IsRedundant() const;
1053 1088
1054 virtual void PrintTo(BufferFormatter* f) const; 1089 virtual void PrintTo(BufferFormatter* f) const;
1055 1090
1091 virtual intptr_t token_pos() const {
1092 return ClassifyingTokenPositions::kParallelMove;
1093 }
1094
1056 private: 1095 private:
1057 GrowableArray<MoveOperands*> moves_; // Elements cannot be null. 1096 GrowableArray<MoveOperands*> moves_; // Elements cannot be null.
1058 1097
1059 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); 1098 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr);
1060 }; 1099 };
1061 1100
1062 1101
1063 // Basic block entries are administrative nodes. There is a distinguished 1102 // Basic block entries are administrative nodes. There is a distinguished
1064 // graph entry with no predecessor. Joins are the only nodes with multiple 1103 // graph entry with no predecessor. Joins are the only nodes with multiple
1065 // predecessors. Targets are all other basic block entries. The types 1104 // predecessors. Targets are all other basic block entries. The types
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 3334
3296 virtual CompileType ComputeType() const; 3335 virtual CompileType ComputeType() const;
3297 3336
3298 virtual bool CanDeoptimize() const { return false; } 3337 virtual bool CanDeoptimize() const { return false; }
3299 3338
3300 virtual EffectSet Effects() const { 3339 virtual EffectSet Effects() const {
3301 UNREACHABLE(); // Eliminated by SSA construction. 3340 UNREACHABLE(); // Eliminated by SSA construction.
3302 return EffectSet::None(); 3341 return EffectSet::None();
3303 } 3342 }
3304 3343
3344 virtual intptr_t token_pos() const {
3345 return ClassifyingTokenPositions::kTempMove;
3346 }
3347
3305 private: 3348 private:
3306 DISALLOW_COPY_AND_ASSIGN(PushTempInstr); 3349 DISALLOW_COPY_AND_ASSIGN(PushTempInstr);
3307 }; 3350 };
3308 3351
3309 3352
3310 class DropTempsInstr : public Definition { 3353 class DropTempsInstr : public Definition {
3311 public: 3354 public:
3312 DropTempsInstr(intptr_t num_temps, Value* value) 3355 DropTempsInstr(intptr_t num_temps, Value* value)
3313 : num_temps_(num_temps), value_(NULL) { 3356 : num_temps_(num_temps), value_(NULL) {
3314 if (value != NULL) { 3357 if (value != NULL) {
(...skipping 22 matching lines...) Expand all
3337 virtual EffectSet Effects() const { 3380 virtual EffectSet Effects() const {
3338 UNREACHABLE(); // Eliminated by SSA construction. 3381 UNREACHABLE(); // Eliminated by SSA construction.
3339 return EffectSet::None(); 3382 return EffectSet::None();
3340 } 3383 }
3341 3384
3342 virtual bool MayThrow() const { 3385 virtual bool MayThrow() const {
3343 UNREACHABLE(); 3386 UNREACHABLE();
3344 return false; 3387 return false;
3345 } 3388 }
3346 3389
3390 virtual intptr_t token_pos() const {
3391 return ClassifyingTokenPositions::kTempMove;
3392 }
3393
3347 private: 3394 private:
3348 virtual void RawSetInputAt(intptr_t i, Value* value) { 3395 virtual void RawSetInputAt(intptr_t i, Value* value) {
3349 value_ = value; 3396 value_ = value;
3350 } 3397 }
3351 3398
3352 const intptr_t num_temps_; 3399 const intptr_t num_temps_;
3353 Value* value_; 3400 Value* value_;
3354 3401
3355 DISALLOW_COPY_AND_ASSIGN(DropTempsInstr); 3402 DISALLOW_COPY_AND_ASSIGN(DropTempsInstr);
3356 }; 3403 };
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
4734 ASSERT(idx == 0); 4781 ASSERT(idx == 0);
4735 return from_representation(); 4782 return from_representation();
4736 } 4783 }
4737 4784
4738 virtual bool AttributesEqual(Instruction* other) const { 4785 virtual bool AttributesEqual(Instruction* other) const {
4739 return other->AsBox()->from_representation() == from_representation(); 4786 return other->AsBox()->from_representation() == from_representation();
4740 } 4787 }
4741 4788
4742 Definition* Canonicalize(FlowGraph* flow_graph); 4789 Definition* Canonicalize(FlowGraph* flow_graph);
4743 4790
4791 virtual intptr_t token_pos() const {
4792 return ClassifyingTokenPositions::kBox;
4793 }
4794
4744 protected: 4795 protected:
4745 BoxInstr(Representation from_representation, Value* value) 4796 BoxInstr(Representation from_representation, Value* value)
4746 : from_representation_(from_representation) { 4797 : from_representation_(from_representation) {
4747 SetInputAt(0, value); 4798 SetInputAt(0, value);
4748 } 4799 }
4749 4800
4750 private: 4801 private:
4751 intptr_t ValueOffset() const { 4802 intptr_t ValueOffset() const {
4752 return Boxing::ValueOffset(from_representation()); 4803 return Boxing::ValueOffset(from_representation());
4753 } 4804 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4856 virtual bool AttributesEqual(Instruction* other) const { 4907 virtual bool AttributesEqual(Instruction* other) const {
4857 return representation() == other->AsUnbox()->representation(); 4908 return representation() == other->AsUnbox()->representation();
4858 } 4909 }
4859 4910
4860 Definition* Canonicalize(FlowGraph* flow_graph); 4911 Definition* Canonicalize(FlowGraph* flow_graph);
4861 4912
4862 virtual intptr_t DeoptimizationTarget() const { 4913 virtual intptr_t DeoptimizationTarget() const {
4863 return GetDeoptId(); 4914 return GetDeoptId();
4864 } 4915 }
4865 4916
4917 virtual intptr_t token_pos() const {
4918 return ClassifyingTokenPositions::kBox;
4919 }
4920
4866 protected: 4921 protected:
4867 UnboxInstr(Representation representation, 4922 UnboxInstr(Representation representation,
4868 Value* value, 4923 Value* value,
4869 intptr_t deopt_id) 4924 intptr_t deopt_id)
4870 : TemplateDefinition(deopt_id), 4925 : TemplateDefinition(deopt_id),
4871 representation_(representation) { 4926 representation_(representation) {
4872 SetInputAt(0, value); 4927 SetInputAt(0, value);
4873 } 4928 }
4874 4929
4875 private: 4930 private:
(...skipping 3264 matching lines...) Expand 10 before | Expand all | Expand 10 after
8140 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ 8195 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \
8141 UNIMPLEMENTED(); \ 8196 UNIMPLEMENTED(); \
8142 return NULL; \ 8197 return NULL; \
8143 } \ 8198 } \
8144 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8199 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8145 8200
8146 8201
8147 } // namespace dart 8202 } // namespace dart
8148 8203
8149 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8204 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698