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

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

Issue 9455054: Incorporate some review comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | « 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/growable_array.h" 9 #include "vm/growable_array.h"
10 #include "vm/handles_impl.h" 10 #include "vm/handles_impl.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void flip_mark() { mark_ = !mark_; } 205 void flip_mark() { mark_ = !mark_; }
206 206
207 #define INSTRUCTION_TYPE_CHECK(type) \ 207 #define INSTRUCTION_TYPE_CHECK(type) \
208 virtual bool Is##type() const { return false; } \ 208 virtual bool Is##type() const { return false; } \
209 virtual type##Instr* As##type() { return NULL; } 209 virtual type##Instr* As##type() { return NULL; }
210 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 210 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
211 #undef INSTRUCTION_TYPE_CHECK 211 #undef INSTRUCTION_TYPE_CHECK
212 212
213 private: 213 private:
214 bool mark_; 214 bool mark_;
215
216 DISALLOW_COPY_AND_ASSIGN(Instruction);
215 }; 217 };
216 218
217 219
218 // Basic block entries are administrative nodes. Joins are the only nodes 220 // Basic block entries are administrative nodes. Joins are the only nodes
219 // with multiple predecessors. Targets are the other basic block entries. 221 // with multiple predecessors. Targets are the other basic block entries.
220 // The types enforce edge-split form---joins are forbidden as the successors 222 // The types enforce edge-split form---joins are forbidden as the successors
221 // of branches. 223 // of branches.
222 class BlockEntryInstr : public Instruction { 224 class BlockEntryInstr : public Instruction {
223 public: 225 public:
224 virtual bool IsBlockEntry() const { return true; } 226 virtual bool IsBlockEntry() const { return true; }
225 227
226 static BlockEntryInstr* cast(Instruction* instr) { 228 static BlockEntryInstr* cast(Instruction* instr) {
227 ASSERT(instr->IsBlockEntry()); 229 ASSERT(instr->IsBlockEntry());
228 return reinterpret_cast<BlockEntryInstr*>(instr); 230 return reinterpret_cast<BlockEntryInstr*>(instr);
229 } 231 }
230 232
231 intptr_t block_number() const { return block_number_; } 233 intptr_t block_number() const { return block_number_; }
232 void set_block_number(intptr_t number) { block_number_ = number; } 234 void set_block_number(intptr_t number) { block_number_ = number; }
233 235
234 protected: 236 protected:
235 BlockEntryInstr() : Instruction(), block_number_(-1) { } 237 BlockEntryInstr() : Instruction(), block_number_(-1) { }
236 238
237 private: 239 private:
238 intptr_t block_number_; 240 intptr_t block_number_;
241
242 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr);
239 }; 243 };
240 244
241 245
242 class JoinEntryInstr : public BlockEntryInstr { 246 class JoinEntryInstr : public BlockEntryInstr {
243 public: 247 public:
244 JoinEntryInstr() : BlockEntryInstr(), successor_(NULL) { } 248 JoinEntryInstr() : BlockEntryInstr(), successor_(NULL) { }
245 249
246 DECLARE_INSTRUCTION(JoinEntry) 250 DECLARE_INSTRUCTION(JoinEntry)
247 251
248 virtual void SetSuccessor(Instruction* instr) { 252 virtual void SetSuccessor(Instruction* instr) {
249 ASSERT(successor_ == NULL); 253 ASSERT(successor_ == NULL);
250 successor_ = instr; 254 successor_ = instr;
251 } 255 }
252 256
253 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 257 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
254 258
255 private: 259 private:
256 Instruction* successor_; 260 Instruction* successor_;
261
262 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr);
257 }; 263 };
258 264
259 265
260 class TargetEntryInstr : public BlockEntryInstr { 266 class TargetEntryInstr : public BlockEntryInstr {
261 public: 267 public:
262 TargetEntryInstr() : BlockEntryInstr(), block_number_(-1), successor_(NULL) { 268 TargetEntryInstr() : BlockEntryInstr(), successor_(NULL) {
263 } 269 }
264 270
265 DECLARE_INSTRUCTION(TargetEntry) 271 DECLARE_INSTRUCTION(TargetEntry)
266 272
267 virtual void SetSuccessor(Instruction* instr) { 273 virtual void SetSuccessor(Instruction* instr) {
268 ASSERT(successor_ == NULL); 274 ASSERT(successor_ == NULL);
269 successor_ = instr; 275 successor_ = instr;
270 } 276 }
271 277
272 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 278 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
273 279
274 private: 280 private:
275 intptr_t block_number_;
276 Instruction* successor_; 281 Instruction* successor_;
282
283 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
277 }; 284 };
278 285
279 286
280 class DoInstr : public Instruction { 287 class DoInstr : public Instruction {
281 public: 288 public:
282 explicit DoInstr(Computation* comp) 289 explicit DoInstr(Computation* comp)
283 : Instruction(), computation_(comp), successor_(NULL) { } 290 : Instruction(), computation_(comp), successor_(NULL) { }
284 291
285 DECLARE_INSTRUCTION(Do) 292 DECLARE_INSTRUCTION(Do)
286 293
287 Computation* computation() const { return computation_; } 294 Computation* computation() const { return computation_; }
288 295
289 virtual void SetSuccessor(Instruction* instr) { 296 virtual void SetSuccessor(Instruction* instr) {
290 ASSERT(successor_ == NULL); 297 ASSERT(successor_ == NULL);
291 successor_ = instr; 298 successor_ = instr;
292 } 299 }
293 300
294 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 301 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
295 302
296 private: 303 private:
297 Computation* computation_; 304 Computation* computation_;
298 Instruction* successor_; 305 Instruction* successor_;
306
307 DISALLOW_COPY_AND_ASSIGN(DoInstr);
299 }; 308 };
300 309
301 310
302 class BindInstr : public Instruction { 311 class BindInstr : public Instruction {
303 public: 312 public:
304 BindInstr(intptr_t temp_index, Computation* computation) 313 BindInstr(intptr_t temp_index, Computation* computation)
305 : Instruction(), 314 : Instruction(),
306 temp_index_(temp_index), 315 temp_index_(temp_index),
307 computation_(computation), 316 computation_(computation),
308 successor_(NULL) { } 317 successor_(NULL) { }
309 318
310 DECLARE_INSTRUCTION(Bind) 319 DECLARE_INSTRUCTION(Bind)
311 320
312 intptr_t temp_index() const { return temp_index_; } 321 intptr_t temp_index() const { return temp_index_; }
313 Computation* computation() const { return computation_; } 322 Computation* computation() const { return computation_; }
314 323
315 virtual void SetSuccessor(Instruction* instr) { 324 virtual void SetSuccessor(Instruction* instr) {
316 ASSERT(successor_ == NULL); 325 ASSERT(successor_ == NULL);
317 successor_ = instr; 326 successor_ = instr;
318 } 327 }
319 328
320 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 329 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
321 330
322 private: 331 private:
323 const intptr_t temp_index_; 332 const intptr_t temp_index_;
324 Computation* computation_; 333 Computation* computation_;
325 Instruction* successor_; 334 Instruction* successor_;
335
336 DISALLOW_COPY_AND_ASSIGN(BindInstr);
326 }; 337 };
327 338
328 339
329 class ReturnInstr : public Instruction { 340 class ReturnInstr : public Instruction {
330 public: 341 public:
331 explicit ReturnInstr(Value* value) : Instruction(), value_(value) { } 342 explicit ReturnInstr(Value* value) : Instruction(), value_(value) { }
332 343
333 DECLARE_INSTRUCTION(Return) 344 DECLARE_INSTRUCTION(Return)
334 345
335 Value* value() const { return value_; } 346 Value* value() const { return value_; }
336 347
337 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 348 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
338 349
339 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 350 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
340 351
341 private: 352 private:
342 Value* value_; 353 Value* value_;
354
355 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
343 }; 356 };
344 357
345 358
346 class BranchInstr : public Instruction { 359 class BranchInstr : public Instruction {
347 public: 360 public:
348 explicit BranchInstr(Value* value) 361 explicit BranchInstr(Value* value)
349 : Instruction(), 362 : Instruction(),
350 value_(value), 363 value_(value),
351 true_successor_(NULL), 364 true_successor_(NULL),
352 false_successor_(NULL) { } 365 false_successor_(NULL) { }
353 366
354 DECLARE_INSTRUCTION(Branch) 367 DECLARE_INSTRUCTION(Branch)
355 368
356 Value* value() const { return value_; } 369 Value* value() const { return value_; }
357 TargetEntryInstr* true_successor() const { return true_successor_; } 370 TargetEntryInstr* true_successor() const { return true_successor_; }
358 TargetEntryInstr* false_successor() const { return false_successor_; } 371 TargetEntryInstr* false_successor() const { return false_successor_; }
359 372
360 TargetEntryInstr** true_successor_address() { return &true_successor_; } 373 TargetEntryInstr** true_successor_address() { return &true_successor_; }
361 TargetEntryInstr** false_successor_address() { return &false_successor_; } 374 TargetEntryInstr** false_successor_address() { return &false_successor_; }
362 375
363 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 376 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
364 377
365 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); 378 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries);
366 379
367 private: 380 private:
368 Value* value_; 381 Value* value_;
369 TargetEntryInstr* true_successor_; 382 TargetEntryInstr* true_successor_;
370 TargetEntryInstr* false_successor_; 383 TargetEntryInstr* false_successor_;
384
385 DISALLOW_COPY_AND_ASSIGN(BranchInstr);
371 }; 386 };
372 387
373 #undef DECLARE_INSTRUCTION 388 #undef DECLARE_INSTRUCTION
374 389
375 390
376 class InstructionVisitor { 391 class InstructionVisitor {
377 public: 392 public:
378 InstructionVisitor() { } 393 InstructionVisitor() { }
379 virtual ~InstructionVisitor() { } 394 virtual ~InstructionVisitor() { }
380 395
381 // Visit each block in the array list in reverse, and for each block its 396 // Visit each block in the array list in reverse, and for each block its
382 // instructions in order from the block entry to exit. 397 // instructions in order from the block entry to exit.
383 void VisitBlocks(const GrowableArray<BlockEntryInstr*>& block_order); 398 void VisitBlocks(const GrowableArray<BlockEntryInstr*>& block_order);
384 399
385 #define DECLARE_VISIT(type) \ 400 #define DECLARE_VISIT(type) \
386 virtual void Visit##type(type##Instr* instr) { } 401 virtual void Visit##type(type##Instr* instr) { }
387 FOR_EACH_INSTRUCTION(DECLARE_VISIT) 402 FOR_EACH_INSTRUCTION(DECLARE_VISIT)
388 #undef DECLARE_VISIT 403 #undef DECLARE_VISIT
389 404
390 private: 405 private:
391 DISALLOW_COPY_AND_ASSIGN(InstructionVisitor); 406 DISALLOW_COPY_AND_ASSIGN(InstructionVisitor);
392 }; 407 };
393 408
394 409
395 } // namespace dart 410 } // namespace dart
396 411
397 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 412 #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