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

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

Issue 12600012: Add a new, separate block entry instruction for catch-blocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed IL printer Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.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) 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"
11 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 class BitVector; 17 class BitVector;
18 class BlockEntryInstr; 18 class BlockEntryInstr;
19 class BufferFormatter; 19 class BufferFormatter;
20 class CatchBlockEntryInstr;
20 class ComparisonInstr; 21 class ComparisonInstr;
21 class ControlInstruction; 22 class ControlInstruction;
22 class Definition; 23 class Definition;
23 class Environment; 24 class Environment;
24 class FlowGraphCompiler; 25 class FlowGraphCompiler;
25 class FlowGraphOptimizer; 26 class FlowGraphOptimizer;
26 class FlowGraphVisitor; 27 class FlowGraphVisitor;
27 class Instruction; 28 class Instruction;
28 class LocalVariable; 29 class LocalVariable;
29 class ParsedFunction; 30 class ParsedFunction;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 407
407 // Instructions. 408 // Instructions.
408 409
409 // M is a single argument macro. It is applied to each concrete instruction 410 // M is a single argument macro. It is applied to each concrete instruction
410 // type name. The concrete instruction classes are the name with Instr 411 // type name. The concrete instruction classes are the name with Instr
411 // concatenated. 412 // concatenated.
412 #define FOR_EACH_INSTRUCTION(M) \ 413 #define FOR_EACH_INSTRUCTION(M) \
413 M(GraphEntry) \ 414 M(GraphEntry) \
414 M(JoinEntry) \ 415 M(JoinEntry) \
415 M(TargetEntry) \ 416 M(TargetEntry) \
417 M(CatchBlockEntry) \
416 M(Phi) \ 418 M(Phi) \
417 M(Parameter) \ 419 M(Parameter) \
418 M(ParallelMove) \ 420 M(ParallelMove) \
419 M(PushArgument) \ 421 M(PushArgument) \
420 M(Return) \ 422 M(Return) \
421 M(Throw) \ 423 M(Throw) \
422 M(ReThrow) \ 424 M(ReThrow) \
423 M(Goto) \ 425 M(Goto) \
424 M(Branch) \ 426 M(Branch) \
425 M(AssertAssignable) \ 427 M(AssertAssignable) \
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 DECLARE_INSTRUCTION(GraphEntry) 1081 DECLARE_INSTRUCTION(GraphEntry)
1080 1082
1081 virtual intptr_t PredecessorCount() const { return 0; } 1083 virtual intptr_t PredecessorCount() const { return 0; }
1082 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1084 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1083 UNREACHABLE(); 1085 UNREACHABLE();
1084 return NULL; 1086 return NULL;
1085 } 1087 }
1086 virtual intptr_t SuccessorCount() const; 1088 virtual intptr_t SuccessorCount() const;
1087 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1089 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1088 1090
1089 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } 1091 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); }
1090 1092
1091 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1093 virtual void PrepareEntry(FlowGraphCompiler* compiler);
1092 1094
1093 GrowableArray<Definition*>* initial_definitions() { 1095 GrowableArray<Definition*>* initial_definitions() {
1094 return &initial_definitions_; 1096 return &initial_definitions_;
1095 } 1097 }
1096 ConstantInstr* constant_null(); 1098 ConstantInstr* constant_null();
1097 1099
1098 intptr_t spill_slot_count() const { return spill_slot_count_; } 1100 intptr_t spill_slot_count() const { return spill_slot_count_; }
1099 void set_spill_slot_count(intptr_t count) { 1101 void set_spill_slot_count(intptr_t count) {
1100 ASSERT(count >= 0); 1102 ASSERT(count >= 0);
1101 spill_slot_count_ = count; 1103 spill_slot_count_ = count;
1102 } 1104 }
1103 1105
1104 TargetEntryInstr* normal_entry() const { return normal_entry_; } 1106 TargetEntryInstr* normal_entry() const { return normal_entry_; }
1105 1107
1106 const ParsedFunction& parsed_function() const { 1108 const ParsedFunction& parsed_function() const {
1107 return parsed_function_; 1109 return parsed_function_;
1108 } 1110 }
1109 1111
1110 virtual void PrintTo(BufferFormatter* f) const; 1112 virtual void PrintTo(BufferFormatter* f) const;
1111 1113
1112 private: 1114 private:
1113 virtual void ClearPredecessors() {} 1115 virtual void ClearPredecessors() {}
1114 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1116 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1115 1117
1116 const ParsedFunction& parsed_function_; 1118 const ParsedFunction& parsed_function_;
1117 TargetEntryInstr* normal_entry_; 1119 TargetEntryInstr* normal_entry_;
1118 GrowableArray<TargetEntryInstr*> catch_entries_; 1120 GrowableArray<CatchBlockEntryInstr*> catch_entries_;
1119 GrowableArray<Definition*> initial_definitions_; 1121 GrowableArray<Definition*> initial_definitions_;
1120 intptr_t spill_slot_count_; 1122 intptr_t spill_slot_count_;
1121 1123
1122 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1124 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1123 }; 1125 };
1124 1126
1125 1127
1126 class JoinEntryInstr : public BlockEntryInstr { 1128 class JoinEntryInstr : public BlockEntryInstr {
1127 public: 1129 public:
1128 JoinEntryInstr(intptr_t block_id, intptr_t try_index) 1130 JoinEntryInstr(intptr_t block_id, intptr_t try_index)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1191
1190 private: 1192 private:
1191 ZoneGrowableArray<PhiInstr*>* phis_; 1193 ZoneGrowableArray<PhiInstr*>* phis_;
1192 intptr_t index_; 1194 intptr_t index_;
1193 }; 1195 };
1194 1196
1195 1197
1196 class TargetEntryInstr : public BlockEntryInstr { 1198 class TargetEntryInstr : public BlockEntryInstr {
1197 public: 1199 public:
1198 TargetEntryInstr(intptr_t block_id, intptr_t try_index) 1200 TargetEntryInstr(intptr_t block_id, intptr_t try_index)
1199 : BlockEntryInstr(block_id, try_index), 1201 : BlockEntryInstr(block_id, try_index), predecessor_(NULL) { }
1200 predecessor_(NULL),
1201 catch_try_index_(CatchClauseNode::kInvalidTryIndex),
1202 catch_handler_types_(Array::ZoneHandle()) { }
1203 1202
1204 DECLARE_INSTRUCTION(TargetEntry) 1203 DECLARE_INSTRUCTION(TargetEntry)
1205 1204
1206 virtual intptr_t PredecessorCount() const { 1205 virtual intptr_t PredecessorCount() const {
1207 return (predecessor_ == NULL) ? 0 : 1; 1206 return (predecessor_ == NULL) ? 0 : 1;
1208 } 1207 }
1209 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1208 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1210 ASSERT((index == 0) && (predecessor_ != NULL)); 1209 ASSERT((index == 0) && (predecessor_ != NULL));
1211 return predecessor_; 1210 return predecessor_;
1212 } 1211 }
1213 1212
1214 // Returns true if this Block is an entry of a catch handler. 1213 virtual void PrepareEntry(FlowGraphCompiler* compiler);
1215 bool IsCatchEntry() const { 1214
1216 return catch_try_index_ != CatchClauseNode::kInvalidTryIndex; 1215 virtual void PrintTo(BufferFormatter* f) const;
1216
1217 private:
1218 friend class BlockEntryInstr; // Access to predecessor_ when inlining.
1219
1220 virtual void ClearPredecessors() { predecessor_ = NULL; }
1221 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
1222 ASSERT(predecessor_ == NULL);
1223 predecessor_ = predecessor;
1224 }
1225
1226 BlockEntryInstr* predecessor_;
1227
1228 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
1229 };
1230
1231
1232 class CatchBlockEntryInstr : public BlockEntryInstr {
1233 public:
1234 CatchBlockEntryInstr(intptr_t block_id,
1235 intptr_t try_index,
1236 const Array& handler_types,
1237 intptr_t catch_try_index)
1238 : BlockEntryInstr(block_id, try_index),
1239 predecessor_(NULL),
1240 catch_handler_types_(Array::ZoneHandle(handler_types.raw())),
1241 catch_try_index_(catch_try_index) { }
1242
1243 DECLARE_INSTRUCTION(CatchBlockEntry)
1244
1245 virtual intptr_t PredecessorCount() const {
1246 return (predecessor_ == NULL) ? 0 : 1;
1247 }
1248 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1249 ASSERT((index == 0) && (predecessor_ != NULL));
1250 return predecessor_;
1217 } 1251 }
1218 1252
1219 // Returns try index for the try block to which this catch handler 1253 // Returns try index for the try block to which this catch handler
1220 // corresponds. 1254 // corresponds.
1221 intptr_t catch_try_index() const { 1255 intptr_t catch_try_index() const {
1222 ASSERT(IsCatchEntry());
1223 return catch_try_index_; 1256 return catch_try_index_;
1224 } 1257 }
1225 void set_catch_try_index(intptr_t index) { catch_try_index_ = index; }
1226 void set_catch_handler_types(const Array& handler_types) {
1227 catch_handler_types_ = handler_types.raw();
1228 }
1229 1258
1230 virtual void PrepareEntry(FlowGraphCompiler* compiler); 1259 virtual void PrepareEntry(FlowGraphCompiler* compiler);
1231 1260
1232 virtual void PrintTo(BufferFormatter* f) const; 1261 virtual void PrintTo(BufferFormatter* f) const;
1233 1262
1234 private: 1263 private:
1235 friend class BlockEntryInstr; // Access to predecessor_ when inlining. 1264 friend class BlockEntryInstr; // Access to predecessor_ when inlining.
1236 1265
1237 virtual void ClearPredecessors() { predecessor_ = NULL; } 1266 virtual void ClearPredecessors() { predecessor_ = NULL; }
1238 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 1267 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
1239 ASSERT(predecessor_ == NULL); 1268 ASSERT(predecessor_ == NULL);
1240 predecessor_ = predecessor; 1269 predecessor_ = predecessor;
1241 } 1270 }
1242 1271
1243 BlockEntryInstr* predecessor_; 1272 BlockEntryInstr* predecessor_;
1244 intptr_t catch_try_index_; 1273 const Array& catch_handler_types_;
1245 Array& catch_handler_types_; 1274 const intptr_t catch_try_index_;
1246 1275
1247 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 1276 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr);
1248 }; 1277 };
1249 1278
1250 1279
1251 // Abstract super-class of all instructions that define a value (Bind, Phi). 1280 // Abstract super-class of all instructions that define a value (Bind, Phi).
1252 class Definition : public Instruction { 1281 class Definition : public Instruction {
1253 public: 1282 public:
1254 enum UseKind { kEffect, kValue }; 1283 enum UseKind { kEffect, kValue };
1255 1284
1256 Definition(); 1285 Definition();
1257 1286
(...skipping 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4504 ForwardInstructionIterator* current_iterator_; 4533 ForwardInstructionIterator* current_iterator_;
4505 4534
4506 private: 4535 private:
4507 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4536 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4508 }; 4537 };
4509 4538
4510 4539
4511 } // namespace dart 4540 } // namespace dart
4512 4541
4513 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4542 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698