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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10867086: Implement array bounds checks explicitly in the optimized IL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed CanDeoptimize() 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/flow_graph_optimizer.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 11394)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -108,7 +108,8 @@
M(CheckEitherNonSmi, CheckEitherNonSmiComp) \
M(UnboxedDoubleBinaryOp, UnboxedDoubleBinaryOpComp) \
M(UnboxDouble, UnboxDoubleComp) \
- M(BoxDouble, BoxDoubleComp)
+ M(BoxDouble, BoxDoubleComp) \
+ M(CheckArrayBound, CheckArrayBoundComp)
#define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
@@ -178,8 +179,11 @@
virtual intptr_t Hashcode() const;
// Compare attributes of an computation (except input operands and kind).
- // TODO(fschneider): Make this abstract and implement for all computations.
- virtual bool AttributesEqual(Computation* other) const { return true; }
+ // All computations that participate in CSE have to override this function.
+ virtual bool AttributesEqual(Computation* other) const {
+ UNREACHABLE();
+ return false;
+ }
// Returns true if the instruction may have side effects.
// TODO(fschneider): Make this abstract and implement for all computations
@@ -1143,10 +1147,8 @@
public:
LoadIndexedComp(Value* array,
Value* index,
- intptr_t receiver_type,
- InstanceCallComp* original)
- : receiver_type_(receiver_type),
- original_(original) {
+ intptr_t receiver_type)
+ : receiver_type_(receiver_type) {
ASSERT(array != NULL);
ASSERT(index != NULL);
inputs_[0] = array;
@@ -1160,14 +1162,11 @@
intptr_t receiver_type() const { return receiver_type_; }
- InstanceCallComp* original() const { return original_; }
-
- virtual bool CanDeoptimize() const { return true; }
+ virtual bool CanDeoptimize() const { return false; }
virtual intptr_t ResultCid() const { return kDynamicCid; }
private:
intptr_t receiver_type_;
- InstanceCallComp* original_;
DISALLOW_COPY_AND_ASSIGN(LoadIndexedComp);
};
@@ -1178,10 +1177,8 @@
StoreIndexedComp(Value* array,
Value* index,
Value* value,
- intptr_t receiver_type,
- InstanceCallComp* original)
- : receiver_type_(receiver_type),
- original_(original) {
+ intptr_t receiver_type)
+ : receiver_type_(receiver_type) {
ASSERT(array != NULL);
ASSERT(index != NULL);
ASSERT(value != NULL);
@@ -1196,16 +1193,13 @@
Value* index() const { return inputs_[1]; }
Value* value() const { return inputs_[2]; }
- InstanceCallComp* original() const { return original_; }
-
intptr_t receiver_type() const { return receiver_type_; }
- virtual bool CanDeoptimize() const { return true; }
+ virtual bool CanDeoptimize() const { return false; }
virtual intptr_t ResultCid() const { return kDynamicCid; }
private:
intptr_t receiver_type_;
- InstanceCallComp* original_;
DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp);
};
@@ -1723,6 +1717,8 @@
virtual bool CanDeoptimize() const { return true; }
virtual intptr_t ResultCid() const { return kIllegalCid; }
+ virtual bool AttributesEqual(Computation* other) const { return true; }
+
virtual bool HasSideEffect() const { return false; }
Value* left() const { return inputs_[0]; }
@@ -2115,6 +2111,44 @@
};
+class CheckArrayBoundComp : public TemplateComputation<2> {
+ public:
+ CheckArrayBoundComp(Value* array,
+ Value* index,
+ intptr_t array_type,
+ InstanceCallComp* original)
+ : array_type_(array_type), original_(original) {
+ ASSERT(array != NULL);
+ ASSERT(index != NULL);
+ inputs_[0] = array;
+ inputs_[1] = index;
+ }
+
+ DECLARE_COMPUTATION(CheckArrayBound)
+
+ virtual bool CanDeoptimize() const { return true; }
+ virtual intptr_t ResultCid() const { return kIllegalCid; }
+
+ virtual bool AttributesEqual(Computation* other) const;
+
+ virtual bool HasSideEffect() const { return false; }
+
+ Value* array() const { return inputs_[0]; }
+ Value* index() const { return inputs_[1]; }
+
+ intptr_t array_type() const { return array_type_; }
+
+ intptr_t deopt_id() const { return original_->deopt_id(); }
+ intptr_t try_index() const { return original_->try_index(); }
+
+ private:
+ intptr_t array_type_;
+ InstanceCallComp* original_;
+
+ DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundComp);
+};
+
+
#undef DECLARE_COMPUTATION
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698