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

Unified Diff: runtime/vm/intermediate_language.h

Issue 10905233: Whenever possible use length passed to the List constructor for bounds checks instead of loading it… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 8f4b7225f5216ba5daeb863b89e7a037c8a3da55..2cd36e532b891b60b1b018718ecd2632ef5a1573 100644
--- a/runtime/vm/intermediate_language.h
+++ b/runtime/vm/intermediate_language.h
@@ -243,7 +243,7 @@ class EmbeddedArray<T, 0> {
M(UnboxDouble) \
M(BoxDouble) \
M(CheckArrayBound) \
-
+ M(CheckBound) \
#define FORWARD_DECLARATION(type) class type##Instr;
FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
@@ -445,6 +445,7 @@ FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
friend class CheckClassInstr;
friend class CheckSmiInstr;
friend class CheckArrayBoundInstr;
+ friend class CheckBoundInstr;
friend class CheckEitherNonSmiInstr;
friend class LICM;
@@ -1996,7 +1997,8 @@ class StaticCallInstr : public TemplateDefinition<0> {
function_(function),
argument_names_(argument_names),
arguments_(arguments),
- result_cid_(kDynamicCid) {
+ result_cid_(kDynamicCid),
+ is_constructor_(false) {
srdjan 2012/09/12 10:29:58 No need for the field since it can be derived from
ASSERT(function.IsZoneHandle());
ASSERT(argument_names.IsZoneHandle());
}
@@ -2020,12 +2022,18 @@ class StaticCallInstr : public TemplateDefinition<0> {
virtual intptr_t ResultCid() const { return result_cid_; }
void set_result_cid(intptr_t value) { result_cid_ = value; }
+ bool is_constructor() const { return is_constructor_; }
+ void set_is_constructor(bool is_constructor) {
+ is_constructor_ = is_constructor;
+ }
+
private:
const intptr_t token_pos_;
const Function& function_;
const Array& argument_names_;
ZoneGrowableArray<PushArgumentInstr*>* arguments_;
intptr_t result_cid_; // For some library functions we know the result.
+ bool is_constructor_; // Some library constructors have known semantics.
DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
};
@@ -3256,6 +3264,8 @@ class CheckArrayBoundInstr : public TemplateDefinition<2> {
intptr_t array_type() const { return array_type_; }
+ virtual Definition* Canonicalize();
+
private:
intptr_t array_type_;
@@ -3263,6 +3273,38 @@ class CheckArrayBoundInstr : public TemplateDefinition<2> {
};
+class CheckBoundInstr : public TemplateDefinition<2> {
+ public:
+ CheckBoundInstr(Value* length,
+ Value* index,
+ intptr_t deopt_id) {
+ ASSERT(length != NULL);
+ ASSERT(index != NULL);
+ inputs_[0] = length;
+ inputs_[1] = index;
+ deopt_id_ = deopt_id;
+ }
+
+ DECLARE_INSTRUCTION(CheckBound)
+ virtual RawAbstractType* CompileType() const;
+
+ virtual bool CanDeoptimize() const { return true; }
+ virtual intptr_t ResultCid() const { return kIllegalCid; }
+
+ virtual bool AttributesEqual(Definition* other) const {
+ return true;
+ }
+
+ virtual bool HasSideEffect() const { return false; }
srdjan 2012/09/12 10:29:58 AffectedBySideEffect is the new name.
+
+ Value* length() const { return inputs_[0]; }
+ Value* index() const { return inputs_[1]; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CheckBoundInstr);
+};
+
+
#undef DECLARE_INSTRUCTION
class Environment : public ZoneAllocated {

Powered by Google App Engine
This is Rietveld 408576698