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

Unified Diff: runtime/vm/intermediate_language.h

Issue 19792007: Recognize Math's min and max function for doubles and inline the operation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/flow_graph_type_propagator.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 25280)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -580,6 +580,7 @@
M(CheckEitherNonSmi) \
M(BinaryDoubleOp) \
M(MathSqrt) \
+ M(MathMinMax) \
M(UnboxDouble) \
M(BoxDouble) \
M(BoxFloat32x4) \
@@ -908,6 +909,7 @@
friend class ShiftMintOpInstr;
friend class UnaryMintOpInstr;
friend class MathSqrtInstr;
+ friend class MathMinMaxInstr;
friend class CheckClassInstr;
friend class GuardFieldInstr;
friend class CheckSmiInstr;
@@ -4632,6 +4634,69 @@
};
+// Represents Math's static min and max functions.
+class MathMinMaxInstr : public TemplateDefinition<2> {
+ public:
+ MathMinMaxInstr(MethodRecognizer::Kind op_kind,
+ Value* left_value,
+ Value* right_value,
+ intptr_t deopt_id,
+ intptr_t result_cid)
+ : op_kind_(op_kind), result_cid_(result_cid) {
+ ASSERT((result_cid == kSmiCid) || (result_cid == kDoubleCid));
+ SetInputAt(0, left_value);
+ SetInputAt(1, right_value);
+ deopt_id_ = deopt_id;
+ }
+
+ MethodRecognizer::Kind op_kind() const { return op_kind_; }
+
+ Value* left() const { return inputs_[0]; }
+ Value* right() const { return inputs_[1]; }
+
+ intptr_t result_cid() const { return result_cid_; }
+
+ virtual bool CanDeoptimize() const { return false; }
+
+ virtual Representation representation() const {
+ if (result_cid() == kSmiCid) {
+ return kTagged;
+ }
+ ASSERT(result_cid() == kDoubleCid);
+ return kUnboxedDouble;
+ }
+
+ virtual Representation RequiredInputRepresentation(intptr_t idx) const {
+ if (result_cid() == kSmiCid) {
+ return kTagged;
+ }
+ ASSERT(result_cid() == kDoubleCid);
+ return kUnboxedDouble;
+ }
+
+ virtual intptr_t DeoptimizationTarget() const {
+ // Direct access since this instruction cannot deoptimize, and the deopt-id
+ // was inherited from another instruction that could deoptimize.
+ return deopt_id_;
+ }
+
+ DECLARE_INSTRUCTION(MathMinMax)
+ virtual CompileType ComputeType() const;
+ virtual bool AllowsCSE() const { return true; }
+ virtual EffectSet Effects() const { return EffectSet::None(); }
+ virtual EffectSet Dependencies() const { return EffectSet::None(); }
+ virtual bool AttributesEqual(Instruction* other) const;
+
+ virtual bool MayThrow() const { return false; }
+
+ private:
+ const MethodRecognizer::Kind op_kind_;
+ const intptr_t result_cid_;
+
+ DISALLOW_COPY_AND_ASSIGN(MathMinMaxInstr);
+};
+
+
class BinaryDoubleOpInstr : public TemplateDefinition<2> {
public:
BinaryDoubleOpInstr(Token::Kind op_kind,
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698