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

Side by Side Diff: vm/intermediate_language.h

Issue 10830275: Optimize expressions of the form (expr === true) when expr has boolean type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: addressed comments Created 8 years, 4 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 | « vm/il_printer.cc ('k') | 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) 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/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 106 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
107 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 107 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
108 #undef FORWARD_DECLARATION 108 #undef FORWARD_DECLARATION
109 109
110 // Forward declarations. 110 // Forward declarations.
111 class BindInstr; 111 class BindInstr;
112 class BranchInstr; 112 class BranchInstr;
113 class BufferFormatter; 113 class BufferFormatter;
114 class ComparisonComp; 114 class ComparisonComp;
115 class Definition;
115 class Instruction; 116 class Instruction;
116 class PushArgumentInstr; 117 class PushArgumentInstr;
117 class Value; 118 class Value;
118 119
119 class Computation : public ZoneAllocated { 120 class Computation : public ZoneAllocated {
120 public: 121 public:
121 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) { 122 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) {
122 Isolate* isolate = Isolate::Current(); 123 Isolate* isolate = Isolate::Current();
123 deopt_id_ = isolate->GetNextDeoptId(); 124 deopt_id_ = isolate->GetNextDeoptId();
124 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_); 125 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_);
(...skipping 15 matching lines...) Expand all
140 virtual Value* InputAt(intptr_t i) const = 0; 141 virtual Value* InputAt(intptr_t i) const = 0;
141 virtual void SetInputAt(intptr_t i, Value* value) = 0; 142 virtual void SetInputAt(intptr_t i, Value* value) = 0;
142 143
143 // Call computations override this function and return the 144 // Call computations override this function and return the
144 // number of pushed arguments. 145 // number of pushed arguments.
145 virtual intptr_t ArgumentCount() const = 0; 146 virtual intptr_t ArgumentCount() const = 0;
146 147
147 // Returns true, if this computation can deoptimize. 148 // Returns true, if this computation can deoptimize.
148 virtual bool CanDeoptimize() const = 0; 149 virtual bool CanDeoptimize() const = 0;
149 150
151 // Optimize this computation. Returns a replacement for the instruction
152 // that wraps this computation or NULL if nothing to replace.
153 virtual Definition* TryReplace(BindInstr* instr) { return NULL; }
154
150 // Compile time type of the computation, which typically depends on the 155 // Compile time type of the computation, which typically depends on the
151 // compile time types (and possibly propagated types) of its inputs. 156 // compile time types (and possibly propagated types) of its inputs.
152 virtual RawAbstractType* CompileType() const = 0; 157 virtual RawAbstractType* CompileType() const = 0;
153 158
154 // Mutate assigned_vars to add the local variable index for all 159 // Mutate assigned_vars to add the local variable index for all
155 // frame-allocated locals assigned to by the computation. 160 // frame-allocated locals assigned to by the computation.
156 virtual void RecordAssignedVars(BitVector* assigned_vars, 161 virtual void RecordAssignedVars(BitVector* assigned_vars,
157 intptr_t fixed_parameter_count); 162 intptr_t fixed_parameter_count);
158 163
159 virtual const char* DebugName() const = 0; 164 virtual const char* DebugName() const = 0;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 UseVal* previous_use() const { return previous_use_; } 352 UseVal* previous_use() const { return previous_use_; }
348 virtual void RemoveFromUseList(); 353 virtual void RemoveFromUseList();
349 virtual void RemoveInputUses() { RemoveFromUseList(); } 354 virtual void RemoveInputUses() { RemoveFromUseList(); }
350 355
351 private: 356 private:
352 void AddToUseList(); 357 void AddToUseList();
353 Definition* definition_; 358 Definition* definition_;
354 UseVal* next_use_; 359 UseVal* next_use_;
355 UseVal* previous_use_; 360 UseVal* previous_use_;
356 361
362 friend class Definition;
363
357 DISALLOW_COPY_AND_ASSIGN(UseVal); 364 DISALLOW_COPY_AND_ASSIGN(UseVal);
358 }; 365 };
359 366
360 367
361 class ConstantVal: public Value { 368 class ConstantVal: public Value {
362 public: 369 public:
363 explicit ConstantVal(const Object& value) 370 explicit ConstantVal(const Object& value)
364 : value_(value) { 371 : value_(value) {
365 ASSERT(value.IsZoneHandle()); 372 ASSERT(value.IsZoneHandle());
366 ASSERT(value.IsSmi() || value.IsOld()); 373 ASSERT(value.IsSmi() || value.IsOld());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 : ComparisonComp(kind, left, right) { 646 : ComparisonComp(kind, left, right) {
640 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); 647 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT));
641 } 648 }
642 649
643 DECLARE_COMPUTATION(StrictCompare) 650 DECLARE_COMPUTATION(StrictCompare)
644 651
645 virtual void PrintOperandsTo(BufferFormatter* f) const; 652 virtual void PrintOperandsTo(BufferFormatter* f) const;
646 653
647 virtual bool CanDeoptimize() const { return false; } 654 virtual bool CanDeoptimize() const { return false; }
648 655
656 virtual Definition* TryReplace(BindInstr* instr);
657
649 private: 658 private:
650 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 659 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
651 }; 660 };
652 661
653 662
654 class EqualityCompareComp : public ComparisonComp { 663 class EqualityCompareComp : public ComparisonComp {
655 public: 664 public:
656 EqualityCompareComp(intptr_t token_pos, 665 EqualityCompareComp(intptr_t token_pos,
657 intptr_t try_index, 666 intptr_t try_index,
658 Token::Kind kind, 667 Token::Kind kind,
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 propagated_type_ = propagated_type.raw(); 2376 propagated_type_ = propagated_type.raw();
2368 return changed; 2377 return changed;
2369 } 2378 }
2370 2379
2371 UseVal* use_list() { return use_list_; } 2380 UseVal* use_list() { return use_list_; }
2372 void set_use_list(UseVal* head) { 2381 void set_use_list(UseVal* head) {
2373 ASSERT(head == NULL || head->previous_use() == NULL); 2382 ASSERT(head == NULL || head->previous_use() == NULL);
2374 use_list_ = head; 2383 use_list_ = head;
2375 } 2384 }
2376 2385
2386 void ReplaceUsesWith(Definition* other);
2387
2377 private: 2388 private:
2378 intptr_t temp_index_; 2389 intptr_t temp_index_;
2379 intptr_t ssa_temp_index_; 2390 intptr_t ssa_temp_index_;
2380 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; 2391 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_;
2381 // For now: 2392 // For now:
2382 AbstractType& propagated_type_; 2393 AbstractType& propagated_type_;
2383 UseVal* use_list_; 2394 UseVal* use_list_;
2384 2395
2385 DISALLOW_COPY_AND_ASSIGN(Definition); 2396 DISALLOW_COPY_AND_ASSIGN(Definition);
2386 }; 2397 };
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2855 const GrowableArray<BlockEntryInstr*>& block_order_; 2866 const GrowableArray<BlockEntryInstr*>& block_order_;
2856 2867
2857 private: 2868 private:
2858 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2869 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2859 }; 2870 };
2860 2871
2861 2872
2862 } // namespace dart 2873 } // namespace dart
2863 2874
2864 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2875 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « vm/il_printer.cc ('k') | vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698