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

Unified Diff: runtime/vm/intermediate_language.h

Issue 11568044: Add DoubleToSmi optimistically, preventing boxing/unboxing of doubles and propagate smi-nessof the … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 16185)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -253,6 +253,7 @@
M(CheckStackOverflow) \
M(SmiToDouble) \
M(DoubleToInteger) \
+ M(DoubleToSmi) \
M(CheckClass) \
M(CheckSmi) \
M(Constant) \
@@ -534,6 +535,7 @@
friend class CheckEitherNonSmiInstr;
friend class StringCharCodeAtInstr;
friend class LICM;
+ friend class DoubleToSmiInstr;
intptr_t deopt_id_;
intptr_t lifetime_position_; // Position used by register allocator.
@@ -3975,7 +3977,7 @@
class DoubleToIntegerInstr : public TemplateDefinition<1> {
public:
- explicit DoubleToIntegerInstr(Value* value, InstanceCallInstr* instance_call)
+ DoubleToIntegerInstr(Value* value, InstanceCallInstr* instance_call)
: instance_call_(instance_call) {
ASSERT(value != NULL);
inputs_[0] = value;
@@ -4003,6 +4005,42 @@
};
+// Similar to 'DoubleToIntegerInstr' but expects unboxed double as input
+// and creates a Smi.
+class DoubleToSmiInstr : public TemplateDefinition<1> {
+ public:
+ DoubleToSmiInstr(Value* value, InstanceCallInstr* instance_call) {
+ ASSERT(value != NULL);
+ inputs_[0] = value;
+ deopt_id_ = instance_call->deopt_id();
+ }
+
+ Value* value() const { return inputs_[0]; }
+
+ DECLARE_INSTRUCTION(DoubleToSmi)
+ virtual RawAbstractType* CompileType() const;
+
+ virtual intptr_t ArgumentCount() const { return 1; }
Vyacheslav Egorov (Google) 2012/12/17 12:53:44 I think this should be zero because this instructi
srdjan 2012/12/18 00:12:47 Done.
Vyacheslav Egorov (Google) 2012/12/18 11:45:10 Actually Definition has a default implementation t
srdjan 2012/12/18 16:29:47 Done, thanks.
+
+ virtual bool CanDeoptimize() const { return true; }
+
+ virtual bool HasSideEffect() const { return false; }
+
+ // Result could be any of the int types.
+ virtual intptr_t ResultCid() const { return kSmiCid; }
Vyacheslav Egorov (Google) 2012/12/17 12:53:44 Comment does not match implementation.
srdjan 2012/12/18 00:12:47 Removed comment.
+
+ virtual Representation RequiredInputRepresentation(intptr_t idx) const {
+ ASSERT(idx == 0);
+ return kUnboxedDouble;
+ }
+
+ virtual intptr_t DeoptimizationTarget() const { return deopt_id_; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DoubleToSmiInstr);
+};
+
+
class CheckClassInstr : public TemplateInstruction<1> {
public:
CheckClassInstr(Value* value,

Powered by Google App Engine
This is Rietveld 408576698