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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 14979007: - Canonicalize array bounds checks to avoid deopting when comparing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 6134 matching lines...) Expand 10 before | Expand all | Expand 10 after
6145 }; 6145 };
6146 6146
6147 6147
6148 class CheckArrayBoundInstr : public TemplateInstruction<2> { 6148 class CheckArrayBoundInstr : public TemplateInstruction<2> {
6149 public: 6149 public:
6150 CheckArrayBoundInstr(Value* length, 6150 CheckArrayBoundInstr(Value* length,
6151 Value* index, 6151 Value* index,
6152 intptr_t array_type, 6152 intptr_t array_type,
6153 InstanceCallInstr* instance_call) 6153 InstanceCallInstr* instance_call)
6154 : array_type_(array_type) { 6154 : array_type_(array_type) {
6155 SetInputAt(0, length); 6155 SetInputAt(locLength, length);
6156 SetInputAt(1, index); 6156 SetInputAt(locIndex, index);
6157 deopt_id_ = instance_call->deopt_id(); 6157 deopt_id_ = instance_call->deopt_id();
6158 } 6158 }
6159 6159
6160 Value* length() const { return inputs_[0]; } 6160 Value* length() const { return inputs_[locLength]; }
6161 Value* index() const { return inputs_[1]; } 6161 Value* index() const { return inputs_[locIndex]; }
6162 6162
6163 intptr_t array_type() const { return array_type_; } 6163 intptr_t array_type() const { return array_type_; }
6164 6164
6165 DECLARE_INSTRUCTION(CheckArrayBound) 6165 DECLARE_INSTRUCTION(CheckArrayBound)
6166 6166
6167 virtual intptr_t ArgumentCount() const { return 0; } 6167 virtual intptr_t ArgumentCount() const { return 0; }
6168 6168
6169 virtual bool CanDeoptimize() const { return true; } 6169 virtual bool CanDeoptimize() const { return true; }
6170 6170
6171 bool IsRedundant(RangeBoundary length); 6171 bool IsRedundant(RangeBoundary length);
6172 6172
6173 virtual Instruction* Canonicalize(FlowGraph* flow_graph);
6174
6173 // Returns the length offset for array and string types. 6175 // Returns the length offset for array and string types.
6174 static intptr_t LengthOffsetFor(intptr_t class_id); 6176 static intptr_t LengthOffsetFor(intptr_t class_id);
6175 6177
6176 static bool IsFixedLengthArrayType(intptr_t class_id); 6178 static bool IsFixedLengthArrayType(intptr_t class_id);
6177 6179
6178 virtual bool AllowsCSE() const { return true; } 6180 virtual bool AllowsCSE() const { return true; }
6179 virtual EffectSet Effects() const { return EffectSet::None(); } 6181 virtual EffectSet Effects() const { return EffectSet::None(); }
6180 virtual EffectSet Dependencies() const { return EffectSet::None(); } 6182 virtual EffectSet Dependencies() const { return EffectSet::None(); }
6181 virtual bool AttributesEqual(Instruction* other) const; 6183 virtual bool AttributesEqual(Instruction* other) const;
6182 6184
6183 virtual bool MayThrow() const { return false; } 6185 virtual bool MayThrow() const { return false; }
6184 6186
6185 private: 6187 private:
6188 // Give a name to the location/input indices.
6189 enum {
6190 locLength = 0,
6191 locIndex = 1
srdjan 2013/05/14 18:11:47 Optional: prefix constant with k, call it kLengthP
Ivan Posva 2013/05/14 18:30:30 Done + simplified the code where we use the length
6192 };
6186 intptr_t array_type_; 6193 intptr_t array_type_;
6187 6194
6188 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 6195 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
6189 }; 6196 };
6190 6197
6191 6198
6192 #undef DECLARE_INSTRUCTION 6199 #undef DECLARE_INSTRUCTION
6193 6200
6194 class Environment : public ZoneAllocated { 6201 class Environment : public ZoneAllocated {
6195 public: 6202 public:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
6406 ForwardInstructionIterator* current_iterator_; 6413 ForwardInstructionIterator* current_iterator_;
6407 6414
6408 private: 6415 private:
6409 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 6416 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
6410 }; 6417 };
6411 6418
6412 6419
6413 } // namespace dart 6420 } // namespace dart
6414 6421
6415 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 6422 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698