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 10867050: Separate branch on strict compare into a new IL instruction. (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
« 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 11303)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -1995,6 +1995,7 @@
M(ReThrow) \
M(Goto) \
M(Branch) \
+ M(StrictCompareAndBranch)
// Forward declarations for Instruction classes.
@@ -2956,8 +2957,71 @@
};
-class BranchInstr : public TemplateInstruction<2> {
+class ControlInstruction : public Instruction {
public:
+ ControlInstruction() : true_successor_(NULL), false_successor_(NULL) { }
+
+ TargetEntryInstr* true_successor() const { return true_successor_; }
+ TargetEntryInstr* false_successor() const { return false_successor_; }
+
+ TargetEntryInstr** true_successor_address() { return &true_successor_; }
+ TargetEntryInstr** false_successor_address() { return &false_successor_; }
+
+ virtual intptr_t SuccessorCount() const;
+ virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
+
+ virtual void DiscoverBlocks(
+ BlockEntryInstr* current_block,
+ GrowableArray<BlockEntryInstr*>* preorder,
+ GrowableArray<BlockEntryInstr*>* postorder,
+ GrowableArray<intptr_t>* parent,
+ GrowableArray<BitVector*>* assigned_vars,
+ intptr_t variable_count,
+ intptr_t fixed_parameter_count);
+
+
+ void EmitBranchOnCondition(FlowGraphCompiler* compiler,
+ Condition true_condition);
+
+ private:
+ TargetEntryInstr* true_successor_;
+ TargetEntryInstr* false_successor_;
+
+ DISALLOW_COPY_AND_ASSIGN(ControlInstruction);
+};
+
+
+template<intptr_t N>
+class TemplateControlInstruction: public ControlInstruction {
+ public:
+ TemplateControlInstruction<N>() : locs_(NULL) { }
+
+ virtual intptr_t InputCount() const { return N; }
+ virtual Value* InputAt(intptr_t i) const { return inputs_[i]; }
+ virtual void SetInputAt(intptr_t i, Value* value) {
+ ASSERT(value != NULL);
+ inputs_[i] = value;
+ }
+
+ virtual LocationSummary* locs() {
+ if (locs_ == NULL) {
+ locs_ = MakeLocationSummary();
+ }
+ return locs_;
+ }
+
+ virtual LocationSummary* MakeLocationSummary() const = 0;
+
+ protected:
+ EmbeddedArray<Value*, N> inputs_;
+
+ private:
+ LocationSummary* locs_;
+};
+
+
+class BranchInstr : public TemplateControlInstruction<2> {
+ public:
BranchInstr(intptr_t token_pos,
intptr_t try_index,
Value* left,
@@ -2967,13 +3031,12 @@
ic_data_(NULL),
token_pos_(token_pos),
try_index_(try_index),
- kind_(kind),
- true_successor_(NULL),
- false_successor_(NULL) {
+ kind_(kind) {
ASSERT(left != NULL);
ASSERT(right != NULL);
inputs_[0] = left;
inputs_[1] = right;
+ ASSERT(!Token::IsStrictEqualityOperator(kind));
ASSERT(Token::IsEqualityOperator(kind) ||
Token::IsRelationalOperator(kind) ||
Token::IsTypeTestOperator(kind));
@@ -2984,12 +3047,14 @@
DECLARE_INSTRUCTION(Branch)
+ Value* left() const { return inputs_[0]; }
+ Value* right() const { return inputs_[1]; }
+
virtual intptr_t ArgumentCount() const { return 0; }
- Value* left() const { return inputs_[0]; }
- Value* right() const { return inputs_[1]; }
Token::Kind kind() const { return kind_; }
void set_kind(Token::Kind kind) {
+ ASSERT(!Token::IsStrictEqualityOperator(kind));
ASSERT(Token::IsEqualityOperator(kind) ||
Token::IsRelationalOperator(kind) ||
Token::IsTypeTestOperator(kind));
@@ -3006,31 +3071,10 @@
intptr_t token_pos() const { return token_pos_;}
intptr_t try_index() const { return try_index_; }
- TargetEntryInstr* true_successor() const { return true_successor_; }
- TargetEntryInstr* false_successor() const { return false_successor_; }
-
- TargetEntryInstr** true_successor_address() { return &true_successor_; }
- TargetEntryInstr** false_successor_address() { return &false_successor_; }
-
- virtual intptr_t SuccessorCount() const;
- virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
-
- virtual void DiscoverBlocks(
- BlockEntryInstr* current_block,
- GrowableArray<BlockEntryInstr*>* preorder,
- GrowableArray<BlockEntryInstr*>* postorder,
- GrowableArray<intptr_t>* parent,
- GrowableArray<BitVector*>* assigned_vars,
- intptr_t variable_count,
- intptr_t fixed_parameter_count);
-
virtual LocationSummary* MakeLocationSummary() const;
virtual void EmitNativeCode(FlowGraphCompiler* compiler);
- void EmitBranchOnCondition(FlowGraphCompiler* compiler,
- Condition true_condition);
-
virtual bool CanDeoptimize() const { return true; }
private:
@@ -3039,13 +3083,44 @@
const intptr_t token_pos_;
const intptr_t try_index_;
Token::Kind kind_;
- TargetEntryInstr* true_successor_;
- TargetEntryInstr* false_successor_;
DISALLOW_COPY_AND_ASSIGN(BranchInstr);
};
+class StrictCompareAndBranchInstr : public TemplateControlInstruction<2> {
srdjan 2012/08/24 21:35:05 You could use this to replace BranchInstr in FlowG
Florian Schneider 2012/08/27 08:55:30 Currently it is not very convenient to replace bra
+ public:
+ StrictCompareAndBranchInstr(Value* left, Value* right, Token::Kind kind)
+ : kind_(kind) {
+ ASSERT(left != NULL);
+ ASSERT(right != NULL);
+ inputs_[0] = left;
+ inputs_[1] = right;
+ ASSERT(Token::IsStrictEqualityOperator(kind));
+ }
+
+ DECLARE_INSTRUCTION(StrictCompareAndBranch)
+
+ Value* left() const { return inputs_[0]; }
+ Value* right() const { return inputs_[1]; }
+
+ virtual intptr_t ArgumentCount() const { return 0; }
+
+ Token::Kind kind() const { return kind_; }
+
+ virtual LocationSummary* MakeLocationSummary() const;
+
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler);
+
+ virtual bool CanDeoptimize() const { return false; }
+
+ private:
+ Token::Kind kind_;
srdjan 2012/08/24 18:55:39 const
Florian Schneider 2012/08/27 08:55:30 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(StrictCompareAndBranchInstr);
+};
+
+
#undef DECLARE_INSTRUCTION
« 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