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

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

Issue 619903002: Generalize bounds checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
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_FLOW_GRAPH_H_ 5 #ifndef VM_FLOW_GRAPH_H_
6 #define VM_FLOW_GRAPH_H_ 6 #define VM_FLOW_GRAPH_H_
7 7
8 #include "vm/bit_vector.h"
8 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
9 #include "vm/hash_map.h" 10 #include "vm/hash_map.h"
10 #include "vm/intermediate_language.h" 11 #include "vm/intermediate_language.h"
11 #include "vm/parser.h" 12 #include "vm/parser.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 class BlockEffects; 16 class BlockEffects;
16 class FlowGraphBuilder; 17 class FlowGraphBuilder;
17 class ValueInliningContext; 18 class ValueInliningContext;
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // free of side effects. 437 // free of side effects.
437 bool IsSideEffectFreePath(BlockEntryInstr* from, BlockEntryInstr* to) const; 438 bool IsSideEffectFreePath(BlockEntryInstr* from, BlockEntryInstr* to) const;
438 439
439 // Per block sets of available blocks. Block A is available at the block B if 440 // Per block sets of available blocks. Block A is available at the block B if
440 // and only if A dominates B and all paths from A to B are free of side 441 // and only if A dominates B and all paths from A to B are free of side
441 // effects. 442 // effects.
442 GrowableArray<BitVector*> available_at_; 443 GrowableArray<BitVector*> available_at_;
443 }; 444 };
444 445
445 446
447 class DefinitionWorklist : public ValueObject {
448 public:
449 DefinitionWorklist(FlowGraph* flow_graph,
450 intptr_t initial_capacity)
451 : defs_(initial_capacity),
452 contains_vector_(
453 new BitVector(flow_graph->isolate(),
454 flow_graph->current_ssa_temp_index())) {
455 }
456
457 void Add(Definition* defn) {
458 if (!Contains(defn)) {
459 defs_.Add(defn);
460 contains_vector_->Add(defn->ssa_temp_index());
461 }
462 }
463
464 bool Contains(Definition* defn) const {
465 return (defn->ssa_temp_index() >= 0) &&
466 contains_vector_->Contains(defn->ssa_temp_index());
467 }
468
469 bool IsEmpty() const {
470 return defs_.is_empty();
471 }
472
473 Definition* RemoveLast() {
474 Definition* defn = defs_.RemoveLast();
475 contains_vector_->Remove(defn->ssa_temp_index());
476 return defn;
477 }
478
479 const GrowableArray<Definition*>& definitions() const { return defs_; }
480 BitVector* contains_vector() const { return contains_vector_; }
481
482 void Clear() {
483 defs_.TruncateTo(0);
484 contains_vector_->Clear();
485 }
486
487 private:
488 GrowableArray<Definition*> defs_;
489 BitVector* contains_vector_;
490 };
491
492
446 } // namespace dart 493 } // namespace dart
447 494
448 #endif // VM_FLOW_GRAPH_H_ 495 #endif // VM_FLOW_GRAPH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698