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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10824349: Implement class id checks as a separate instruction and add a local CSE optimization pass. (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
Index: runtime/vm/intermediate_language.h
===================================================================
--- runtime/vm/intermediate_language.h (revision 10885)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -101,7 +101,8 @@
M(NumberNegate, NumberNegateComp) \
M(CheckStackOverflow, CheckStackOverflowComp) \
M(DoubleToDouble, DoubleToDoubleComp) \
- M(SmiToDouble, SmiToDoubleComp)
+ M(SmiToDouble, SmiToDoubleComp) \
+ M(CheckClass, CheckClassComp)
#define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
@@ -129,8 +130,8 @@
// Unique id used for deoptimization.
intptr_t deopt_id() const { return deopt_id_; }
- ICData* ic_data() const { return ic_data_; }
- void set_ic_data(ICData* value) { ic_data_ = value; }
+ const ICData* ic_data() const { return ic_data_; }
+ void set_ic_data(const ICData* value) { ic_data_ = value; }
bool HasICData() const {
return (ic_data() != NULL) && !ic_data()->IsNull();
}
@@ -153,6 +154,12 @@
// that wraps this computation or NULL if nothing to replace.
virtual Definition* TryReplace(BindInstr* instr) { return NULL; }
+ // Functions to support CSE.
srdjan 2012/08/17 22:30:22 Please document these functions briefly.
Florian Schneider 2012/08/20 12:09:37 Done.
+ bool Equals(Computation* other) const;
+ virtual intptr_t Hashcode() const;
+ virtual bool AttributesEqual(Computation* other) const { return true; }
+ virtual bool HasSideEffect() const { return true; }
+
// Compile time type of the computation, which typically depends on the
// compile time types (and possibly propagated types) of its inputs.
virtual RawAbstractType* CompileType() const = 0;
@@ -214,7 +221,7 @@
private:
intptr_t deopt_id_;
- ICData* ic_data_;
+ const ICData* ic_data_;
LocationSummary* locs_;
DISALLOW_COPY_AND_ASSIGN(Computation);
@@ -1773,6 +1780,34 @@
};
+class CheckClassComp : public TemplateComputation<1> {
srdjan 2012/08/17 22:30:22 Consider renaming it to CheckClassesComp since it
Florian Schneider 2012/08/20 12:09:37 Done.
+ public:
+ CheckClassComp(Value* value, InstanceCallComp* original)
+ : original_(original) {
+ ASSERT(value != NULL);
+ inputs_[0] = value;
+ }
+
+ DECLARE_COMPUTATION(CheckClass)
+
+ virtual bool CanDeoptimize() const { return true; }
+
+ virtual bool AttributesEqual(Computation* other) const;
+
+ virtual bool HasSideEffect() const { return false; }
srdjan 2012/08/17 22:30:22 Why is CheckClassComp the only computation that do
Florian Schneider 2012/08/20 12:09:37 Currently only CheckClass participates in CSE, but
+
+ Value* value() const { return inputs_[0]; }
+
+ intptr_t deopt_id() const { return original_->deopt_id(); }
+ intptr_t try_index() const { return original_->try_index(); }
+
+ private:
+ InstanceCallComp* original_;
+
+ DISALLOW_COPY_AND_ASSIGN(CheckClassComp);
+};
+
+
#undef DECLARE_COMPUTATION
@@ -1882,9 +1917,13 @@
// Removed this instruction from the graph.
Instruction* RemoveFromGraph(bool return_previous = true);
+
// Remove value uses within this instruction and its inputs.
virtual void RemoveInputUses() = 0;
+ // Insert this instruction before 'next'.
+ void InsertBefore(Instruction* next);
+
// Normal instructions can have 0 (inside a block) or 1 (last instruction in
// a block) successors. Branch instruction with >1 successors override this
// function.
@@ -2503,6 +2542,12 @@
virtual void RecordAssignedVars(BitVector* assigned_vars,
intptr_t fixed_parameter_count);
+ intptr_t Hashcode() const { return computation()->Hashcode(); }
+
+ bool Equals(BindInstr* other) const {
+ return computation()->Equals(other->computation());
+ }
+
virtual LocationSummary* locs() {
return computation()->locs();
}

Powered by Google App Engine
This is Rietveld 408576698