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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10887009: Refactor branch instructions to enable further optimizations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/il_printer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.h
===================================================================
--- runtime/vm/intermediate_language.h (revision 11450)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -226,6 +226,11 @@
// TODO(fschneider): Make EmitNativeCode and locs const.
virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0;
+ virtual void EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch) {
+ UNREACHABLE();
+ }
+
static LocationSummary* MakeCallSummary();
// Declare an enum value used to define kind-test predicates.
@@ -252,6 +257,8 @@
#undef DECLARE_PREDICATE
private:
+ friend class BranchInstr;
+
intptr_t deopt_id_;
const ICData* ic_data_;
LocationSummary* locs_;
@@ -811,6 +818,9 @@
virtual intptr_t ResultCid() const { return kBoolCid; }
+ virtual void EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch);
+
private:
DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
};
@@ -844,6 +854,9 @@
virtual bool CanDeoptimize() const { return true; }
virtual intptr_t ResultCid() const;
+ virtual void EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch);
+
private:
const intptr_t token_pos_;
const intptr_t try_index_;
@@ -885,6 +898,9 @@
virtual bool CanDeoptimize() const { return true; }
virtual intptr_t ResultCid() const;
+ virtual void EmitBranchCode(FlowGraphCompiler* compiler,
+ BranchInstr* branch);
+
private:
const intptr_t token_pos_;
const intptr_t try_index_;
@@ -2202,7 +2218,6 @@
M(ReThrow) \
M(Goto) \
M(Branch) \
- M(StrictCompareAndBranch)
// Forward declarations for Instruction classes.
@@ -3212,129 +3227,49 @@
};
-template<intptr_t N>
-class TemplateControlInstruction: public ControlInstruction {
+class BranchInstr : public ControlInstruction {
public:
- TemplateControlInstruction<N>() : locs_(NULL) { }
+ explicit BranchInstr(ComparisonComp* computation)
+ : computation_(computation), locs_(NULL) { }
- virtual intptr_t InputCount() const { return N; }
- virtual Value* InputAt(intptr_t i) const { return inputs_[i]; }
- virtual void SetInputAt(intptr_t i, Value* value) {
- ASSERT(value != NULL);
- inputs_[i] = value;
- }
+ DECLARE_INSTRUCTION(Branch)
- virtual LocationSummary* locs() {
- if (locs_ == NULL) {
- locs_ = MakeLocationSummary();
- }
- return locs_;
+ virtual intptr_t ArgumentCount() const {
+ return computation()->ArgumentCount();
}
+ intptr_t InputCount() const { return computation()->InputCount(); }
- virtual LocationSummary* MakeLocationSummary() const = 0;
+ Value* InputAt(intptr_t i) const { return computation()->InputAt(i); }
- protected:
- EmbeddedArray<Value*, N> inputs_;
-
- private:
- LocationSummary* locs_;
-};
-
-
-class BranchInstr : public TemplateControlInstruction<2> {
- public:
- BranchInstr(intptr_t token_pos,
- intptr_t try_index,
- Value* left,
- Value* right,
- Token::Kind kind)
- : deopt_id_(Isolate::kNoDeoptId),
- ic_data_(NULL),
- token_pos_(token_pos),
- try_index_(try_index),
- kind_(kind) {
- ASSERT(left != NULL);
- ASSERT(right != NULL);
- inputs_[0] = left;
- inputs_[1] = right;
- ASSERT(!Token::IsStrictEqualityOperator(kind));
- ASSERT(Token::IsEqualityOperator(kind) ||
- Token::IsRelationalOperator(kind) ||
- Token::IsTypeTestOperator(kind));
- Isolate* isolate = Isolate::Current();
- deopt_id_ = isolate->GetNextDeoptId();
- ic_data_ = isolate->GetICDataForDeoptId(deopt_id_);
+ void SetInputAt(intptr_t i, Value* value) {
+ computation()->SetInputAt(i, value);
}
- DECLARE_INSTRUCTION(Branch)
+ virtual bool CanDeoptimize() const { return computation()->CanDeoptimize(); }
- Value* left() const { return inputs_[0]; }
- Value* right() const { return inputs_[1]; }
+ ComparisonComp* computation() const { return computation_; }
+ void set_computation(ComparisonComp* value) { computation_ = value; }
- virtual intptr_t ArgumentCount() const { return 0; }
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler);
- Token::Kind kind() const { return kind_; }
-
- intptr_t deopt_id() const { return deopt_id_; }
-
- const ICData* ic_data() const { return ic_data_; }
- bool HasICData() const {
- return (ic_data() != NULL) && !ic_data()->IsNull();
+ virtual LocationSummary* locs() {
+ if (computation_->locs_ == NULL) {
+ LocationSummary* summary = computation_->MakeLocationSummary();
+ // Branches don't produce a result.
+ summary->set_out(Location::NoLocation());
+ computation_->locs_ = summary;
+ }
+ return computation_->locs_;
}
- intptr_t token_pos() const { return token_pos_;}
- intptr_t try_index() const { return try_index_; }
-
- virtual LocationSummary* MakeLocationSummary() const;
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
- virtual bool CanDeoptimize() const { return true; }
-
private:
- intptr_t deopt_id_;
- const ICData* ic_data_;
- const intptr_t token_pos_;
- const intptr_t try_index_;
- const Token::Kind kind_;
+ ComparisonComp* computation_;
+ LocationSummary* locs_;
DISALLOW_COPY_AND_ASSIGN(BranchInstr);
};
-class StrictCompareAndBranchInstr : public TemplateControlInstruction<2> {
- public:
- StrictCompareAndBranchInstr(Value* left, Value* right, Token::Kind kind)
- : kind_(kind) {
- ASSERT(left != NULL);
- ASSERT(right != NULL);
- inputs_[0] = left;
- inputs_[1] = right;
- ASSERT(Token::IsStrictEqualityOperator(kind));
- }
-
- DECLARE_INSTRUCTION(StrictCompareAndBranch)
-
- Value* left() const { return inputs_[0]; }
- Value* right() const { return inputs_[1]; }
-
- virtual intptr_t ArgumentCount() const { return 0; }
-
- Token::Kind kind() const { return kind_; }
-
- virtual LocationSummary* MakeLocationSummary() const;
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
- virtual bool CanDeoptimize() const { return false; }
-
- private:
- const Token::Kind kind_;
-
- DISALLOW_COPY_AND_ASSIGN(StrictCompareAndBranchInstr);
-};
-
-
#undef DECLARE_INSTRUCTION
« 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