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

Unified Diff: runtime/vm/intermediate_language.h

Issue 2955073005: VM-codegen: Add IL instruction to check if a Smi is in a constant range
Patch Set: Created 3 years, 6 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
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h
index 69164b03d908061e87dcb6423b4d2594a83c2fc3..6455b4775107de12cbcad2feff0e6af8d92f9f28 100644
--- a/runtime/vm/intermediate_language.h
+++ b/runtime/vm/intermediate_language.h
@@ -415,6 +415,7 @@ class EmbeddedArray<T, 0> {
M(CloneContext) \
M(BinarySmiOp) \
M(CheckedSmiComparison) \
+ M(SmiRangeComparison) \
M(CheckedSmiOp) \
M(BinaryInt32Op) \
M(UnarySmiOp) \
@@ -6964,6 +6965,56 @@ class CheckedSmiComparisonInstr : public TemplateComparison<2, Throws> {
};
+// Instruction that checks whether a Smi input is in a constant
+// inclusive range.
+class SmiRangeComparisonInstr : public TemplateComparison<1, NoThrow, Pure> {
+ public:
+ SmiRangeComparisonInstr(TokenPosition token_pos,
+ Value* input,
+ intptr_t from,
+ intptr_t to)
+ : TemplateComparison(token_pos, Token::kIS, Thread::kNoDeoptId),
Vyacheslav Egorov (Google) 2017/06/28 13:53:47 Please comment here why Token::kIS makes sense for
erikcorry 2017/07/03 08:59:55 Done.
+ from_(from),
+ to_(to),
+ is_negated_(false) {
+ SetInputAt(0, input);
+ }
+
+ virtual bool ComputeCanDeoptimize() const { return false; }
+
+ virtual void NegateComparison() {
+ ComparisonInstr::NegateComparison();
+ is_negated_ = !is_negated_;
+ }
+
+ Value* input() const { return inputs_[0]; }
+
+ intptr_t from() { return from_; }
+ intptr_t to() { return to_; }
+ bool is_negated() const { return is_negated_; }
Vyacheslav Egorov (Google) 2017/06/28 13:53:47 I think you don't need is_negated_ member: is_neg
erikcorry 2017/07/03 08:59:55 Done.
+
+ virtual EffectSet Effects() const { return EffectSet::None(); }
+
+ virtual CompileType ComputeType() const;
+
+ PRINT_OPERANDS_TO_SUPPORT
+
+ DECLARE_COMPARISON_INSTRUCTION(SmiRangeComparison)
+
+ virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right);
+
+ virtual Representation RequiredInputRepresentation(intptr_t idx) const {
+ return kTagged;
+ }
+
+ private:
+ intptr_t from_;
Vyacheslav Egorov (Google) 2017/06/28 13:53:47 const intptr_t from_; const intptr_t to_; Also y
erikcorry 2017/07/03 08:59:55 Done.
+ intptr_t to_;
+ bool is_negated_;
+ DISALLOW_COPY_AND_ASSIGN(SmiRangeComparisonInstr);
+};
+
+
class BinaryIntegerOpInstr : public TemplateDefinition<2, NoThrow, Pure> {
public:
BinaryIntegerOpInstr(Token::Kind op_kind,

Powered by Google App Engine
This is Rietveld 408576698