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

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: Address Srdjan's comments 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
« no previous file with comments | « runtime/vm/flow_graph_builder.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
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h
index 8f4b7225f5216ba5daeb863b89e7a037c8a3da55..0873a9fbff822b947c0e184b39b422942f68f2b8 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_known_constructor_(false) {
ASSERT(function.IsZoneHandle());
ASSERT(argument_names.IsZoneHandle());
}
@@ -2020,6 +2022,11 @@ 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_known_constructor() const { return is_known_constructor_; }
+ void set_is_known_constructor(bool is_known_constructor) {
+ is_known_constructor_ = is_known_constructor;
+ }
+
private:
const intptr_t token_pos_;
const Function& function_;
@@ -2027,6 +2034,9 @@ class StaticCallInstr : public TemplateDefinition<0> {
ZoneGrowableArray<PushArgumentInstr*>* arguments_;
intptr_t result_cid_; // For some library functions we know the result.
+ // Some library constructors have known semantics.
+ bool is_known_constructor_;
+
DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
};
@@ -2868,7 +2878,7 @@ class MathSqrtInstr : public TemplateDefinition<1> {
Value* value() const { return inputs_[0]; }
virtual bool CanDeoptimize() const { return false; }
- virtual bool HasSideEffect() const { return false; }
+ virtual bool AffectedBySideEffect() const { return false; }
virtual bool AttributesEqual(Definition* other) const {
return true;
@@ -3256,6 +3266,8 @@ class CheckArrayBoundInstr : public TemplateDefinition<2> {
intptr_t array_type() const { return array_type_; }
+ virtual Definition* Canonicalize();
+
private:
intptr_t array_type_;
@@ -3263,6 +3275,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 AffectedBySideEffect() const { return false; }
+
+ 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 {
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698