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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10867012: Add a smi-check instruction for arithmetic smi operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 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 11146)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -103,6 +103,7 @@
M(DoubleToDouble, DoubleToDoubleComp) \
M(SmiToDouble, SmiToDoubleComp) \
M(CheckClass, CheckClassComp) \
+ M(CheckSmi, CheckSmiComp) \
M(Materialize, MaterializeComp)
@@ -152,9 +153,10 @@
// Returns true, if this computation can deoptimize.
virtual bool CanDeoptimize() const = 0;
- // Optimize this computation. Returns a replacement for the instruction
- // that wraps this computation or NULL if nothing to replace.
- virtual Definition* TryReplace(BindInstr* instr) { return NULL; }
+ // Returns a replacement for the instruction that wraps this computation.
+ // Returns NULL if instr can be eliminated.
+ // By default returns instr (input parameter) which means no change.
+ virtual Definition* TryReplace(BindInstr* instr) const;
// Compares two computations. Returns true, if:
// 1. They are of the same kind.
@@ -772,7 +774,8 @@
virtual bool CanDeoptimize() const { return false; }
- virtual Definition* TryReplace(BindInstr* instr);
+ virtual Definition* TryReplace(BindInstr* instr) const;
+
virtual intptr_t ResultCid() const { return kBoolCid; }
private:
@@ -1675,7 +1678,8 @@
DECLARE_COMPUTATION(BinarySmiOp)
- virtual bool CanDeoptimize() const { return true; }
+ virtual bool CanDeoptimize() const;
+
virtual intptr_t ResultCid() const;
private:
@@ -1890,6 +1894,8 @@
intptr_t deopt_id() const { return original_->deopt_id(); }
intptr_t try_index() const { return original_->try_index(); }
+ virtual void PrintOperandsTo(BufferFormatter* f) const;
+
private:
InstanceCallComp* original_;
@@ -1897,6 +1903,36 @@
};
+class CheckSmiComp : public TemplateComputation<1> {
+ public:
+ CheckSmiComp(Value* value, InstanceCallComp* original)
+ : original_(original) {
+ ASSERT(value != NULL);
+ inputs_[0] = value;
+ }
+
+ DECLARE_COMPUTATION(CheckSmi)
+
+ virtual bool CanDeoptimize() const { return true; }
+
+ virtual bool AttributesEqual(Computation* other) const { return true; }
+
+ virtual bool HasSideEffect() const { return false; }
+
+ virtual Definition* TryReplace(BindInstr* instr) const;
+
+ 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(CheckSmiComp);
+};
+
+
#undef DECLARE_COMPUTATION
@@ -3063,9 +3099,16 @@
return fixed_parameter_count_;
}
+ Environment* Copy() const;
+
void PrintTo(BufferFormatter* f) const;
private:
+ Environment(intptr_t length, intptr_t fixed_parameter_count)
+ : values_(length),
+ locations_(NULL),
+ fixed_parameter_count_(fixed_parameter_count) { }
+
GrowableArray<Value*> values_;
Location* locations_;
const intptr_t fixed_parameter_count_;
« 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