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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10536145: Fuse comparisons that are used by branches together. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intermediate_language.h
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h
index 81b69c7164b7ecf89520dbcbfb8187bf389775e9..50848fa8d620cc24330745b7298972861e7b5093 100644
--- a/runtime/vm/intermediate_language.h
+++ b/runtime/vm/intermediate_language.h
@@ -79,6 +79,7 @@ FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
// Forward declarations.
class BufferFormatter;
+class BranchInstr;
class Instruction;
class Value;
@@ -498,21 +499,43 @@ class InstanceCallComp : public Computation {
};
-class StrictCompareComp : public TemplateComputation<2> {
+class ComparisonComp : public TemplateComputation<2> {
public:
- StrictCompareComp(Token::Kind kind, Value* left, Value* right)
- : kind_(kind) {
- ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT));
+ ComparisonComp(Value* left, Value* right)
+ : fused_with_branch_(NULL) {
+ ASSERT(left != NULL);
+ ASSERT(right != NULL);
inputs_[0] = left;
inputs_[1] = right;
}
- DECLARE_COMPUTATION(StrictCompare)
+ void MarkFusedWithBranch(BranchInstr* branch) {
+ fused_with_branch_ = branch;
+ }
+
+ BranchInstr* fused_with_branch() const {
+ return fused_with_branch_;
+ }
srdjan 2012/06/13 15:29:35 Maybe also is_fused_with_branch => fused_with_bran
Vyacheslav Egorov (Google) 2012/06/13 16:23:43 Done.
- Token::Kind kind() const { return kind_; }
Value* left() const { return inputs_[0]; }
Value* right() const { return inputs_[1]; }
+ private:
+ BranchInstr* fused_with_branch_;
+};
+
+
+class StrictCompareComp : public ComparisonComp {
+ public:
+ StrictCompareComp(Token::Kind kind, Value* left, Value* right)
+ : ComparisonComp(left, right), kind_(kind) {
+ ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT));
+ }
+
+ DECLARE_COMPUTATION(StrictCompare)
+
+ Token::Kind kind() const { return kind_; }
+
virtual void PrintOperandsTo(BufferFormatter* f) const;
private:
@@ -522,26 +545,21 @@ class StrictCompareComp : public TemplateComputation<2> {
};
-class EqualityCompareComp : public TemplateComputation<2> {
+class EqualityCompareComp : public ComparisonComp {
public:
EqualityCompareComp(intptr_t token_index,
intptr_t try_index,
Value* left,
Value* right)
- : token_index_(token_index),
+ : ComparisonComp(left, right),
+ token_index_(token_index),
try_index_(try_index) {
- ASSERT(left != NULL);
- ASSERT(right != NULL);
- inputs_[0] = left;
- inputs_[1] = right;
}
DECLARE_COMPUTATION(EqualityCompare)
intptr_t token_index() const { return token_index_; }
intptr_t try_index() const { return try_index_; }
- Value* left() const { return inputs_[0]; }
- Value* right() const { return inputs_[1]; }
virtual void PrintOperandsTo(BufferFormatter* f) const;
@@ -553,22 +571,19 @@ class EqualityCompareComp : public TemplateComputation<2> {
};
-class RelationalOpComp : public TemplateComputation<2> {
+class RelationalOpComp : public ComparisonComp {
public:
RelationalOpComp(intptr_t token_index,
intptr_t try_index,
Token::Kind kind,
Value* left,
Value* right)
- : token_index_(token_index),
+ : ComparisonComp(left, right),
+ token_index_(token_index),
try_index_(try_index),
kind_(kind),
operands_class_id_(kObject) {
ASSERT(Token::IsRelationalOperator(kind));
- ASSERT(left != NULL);
- ASSERT(right != NULL);
- inputs_[0] = left;
- inputs_[1] = right;
}
DECLARE_COMPUTATION(RelationalOp)
@@ -576,14 +591,13 @@ class RelationalOpComp : public TemplateComputation<2> {
intptr_t token_index() const { return token_index_; }
intptr_t try_index() const { return try_index_; }
Token::Kind kind() const { return kind_; }
- Value* left() const { return inputs_[0]; }
- Value* right() const { return inputs_[1]; }
// TODO(srdjan): instead of class-id pass an enum that can differentiate
// between boxed and unboxed doubles and integers.
void set_operands_class_id(intptr_t value) {
operands_class_id_ = value;
}
+
intptr_t operands_class_id() const { return operands_class_id_; }
virtual void PrintOperandsTo(BufferFormatter* f) const;
@@ -2152,7 +2166,8 @@ class BranchInstr : public InstructionWithInputs {
: InstructionWithInputs(),
value_(value),
true_successor_(NULL),
- false_successor_(NULL) { }
+ false_successor_(NULL),
+ fused_with_comparison_(false) { }
DECLARE_INSTRUCTION(Branch)
@@ -2181,10 +2196,20 @@ class BranchInstr : public InstructionWithInputs {
virtual void EmitNativeCode(FlowGraphCompiler* compiler);
+ void EmitBranchOnCondition(FlowGraphCompiler* compiler,
+ Condition true_condition);
+
+ void MarkFusedWithComparison() {
+ fused_with_comparison_ = true;
+ }
+
+ bool is_fused_with_comparison() const { return fused_with_comparison_; }
+
private:
Value* value_;
TargetEntryInstr* true_successor_;
TargetEntryInstr* false_successor_;
+ bool fused_with_comparison_;
srdjan 2012/06/13 15:29:35 rename to is_fused_with_comparison_
Vyacheslav Egorov (Google) 2012/06/13 16:23:43 Done.
DISALLOW_COPY_AND_ASSIGN(BranchInstr);
};

Powered by Google App Engine
This is Rietveld 408576698