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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 M(SmiToDouble) \ 236 M(SmiToDouble) \
237 M(CheckClass) \ 237 M(CheckClass) \
238 M(CheckSmi) \ 238 M(CheckSmi) \
239 M(Constant) \ 239 M(Constant) \
240 M(CheckEitherNonSmi) \ 240 M(CheckEitherNonSmi) \
241 M(UnboxedDoubleBinaryOp) \ 241 M(UnboxedDoubleBinaryOp) \
242 M(MathSqrt) \ 242 M(MathSqrt) \
243 M(UnboxDouble) \ 243 M(UnboxDouble) \
244 M(BoxDouble) \ 244 M(BoxDouble) \
245 M(CheckArrayBound) \ 245 M(CheckArrayBound) \
246 246 M(CheckBound) \
247 247
248 #define FORWARD_DECLARATION(type) class type##Instr; 248 #define FORWARD_DECLARATION(type) class type##Instr;
249 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 249 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
250 #undef FORWARD_DECLARATION 250 #undef FORWARD_DECLARATION
251 251
252 252
253 // Functions required in all concrete instruction classes. 253 // Functions required in all concrete instruction classes.
254 #define DECLARE_INSTRUCTION(type) \ 254 #define DECLARE_INSTRUCTION(type) \
255 virtual Tag tag() const { return k##type; } \ 255 virtual Tag tag() const { return k##type; } \
256 virtual void Accept(FlowGraphVisitor* visitor); \ 256 virtual void Accept(FlowGraphVisitor* visitor); \
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 private: 438 private:
439 friend class Definition; // Needed for InsertBefore, InsertAfter. 439 friend class Definition; // Needed for InsertBefore, InsertAfter.
440 440
441 // Classes that set deopt_id_. 441 // Classes that set deopt_id_.
442 friend class UnboxDoubleInstr; 442 friend class UnboxDoubleInstr;
443 friend class UnboxedDoubleBinaryOpInstr; 443 friend class UnboxedDoubleBinaryOpInstr;
444 friend class MathSqrtInstr; 444 friend class MathSqrtInstr;
445 friend class CheckClassInstr; 445 friend class CheckClassInstr;
446 friend class CheckSmiInstr; 446 friend class CheckSmiInstr;
447 friend class CheckArrayBoundInstr; 447 friend class CheckArrayBoundInstr;
448 friend class CheckBoundInstr;
448 friend class CheckEitherNonSmiInstr; 449 friend class CheckEitherNonSmiInstr;
449 friend class LICM; 450 friend class LICM;
450 451
451 intptr_t deopt_id_; 452 intptr_t deopt_id_;
452 intptr_t lifetime_position_; // Position used by register allocator. 453 intptr_t lifetime_position_; // Position used by register allocator.
453 Instruction* previous_; 454 Instruction* previous_;
454 Instruction* next_; 455 Instruction* next_;
455 Environment* env_; 456 Environment* env_;
456 DISALLOW_COPY_AND_ASSIGN(Instruction); 457 DISALLOW_COPY_AND_ASSIGN(Instruction);
457 }; 458 };
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 class StaticCallInstr : public TemplateDefinition<0> { 1990 class StaticCallInstr : public TemplateDefinition<0> {
1990 public: 1991 public:
1991 StaticCallInstr(intptr_t token_pos, 1992 StaticCallInstr(intptr_t token_pos,
1992 const Function& function, 1993 const Function& function,
1993 const Array& argument_names, 1994 const Array& argument_names,
1994 ZoneGrowableArray<PushArgumentInstr*>* arguments) 1995 ZoneGrowableArray<PushArgumentInstr*>* arguments)
1995 : token_pos_(token_pos), 1996 : token_pos_(token_pos),
1996 function_(function), 1997 function_(function),
1997 argument_names_(argument_names), 1998 argument_names_(argument_names),
1998 arguments_(arguments), 1999 arguments_(arguments),
1999 result_cid_(kDynamicCid) { 2000 result_cid_(kDynamicCid),
2001 is_constructor_(false) {
srdjan 2012/09/12 10:29:58 No need for the field since it can be derived from
2000 ASSERT(function.IsZoneHandle()); 2002 ASSERT(function.IsZoneHandle());
2001 ASSERT(argument_names.IsZoneHandle()); 2003 ASSERT(argument_names.IsZoneHandle());
2002 } 2004 }
2003 2005
2004 DECLARE_INSTRUCTION(StaticCall) 2006 DECLARE_INSTRUCTION(StaticCall)
2005 virtual RawAbstractType* CompileType() const; 2007 virtual RawAbstractType* CompileType() const;
2006 2008
2007 // Accessors forwarded to the AST node. 2009 // Accessors forwarded to the AST node.
2008 const Function& function() const { return function_; } 2010 const Function& function() const { return function_; }
2009 const Array& argument_names() const { return argument_names_; } 2011 const Array& argument_names() const { return argument_names_; }
2010 intptr_t token_pos() const { return token_pos_; } 2012 intptr_t token_pos() const { return token_pos_; }
2011 2013
2012 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2014 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2013 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2015 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2014 return (*arguments_)[index]; 2016 return (*arguments_)[index];
2015 } 2017 }
2016 2018
2017 virtual void PrintOperandsTo(BufferFormatter* f) const; 2019 virtual void PrintOperandsTo(BufferFormatter* f) const;
2018 2020
2019 virtual bool CanDeoptimize() const { return true; } 2021 virtual bool CanDeoptimize() const { return true; }
2020 virtual intptr_t ResultCid() const { return result_cid_; } 2022 virtual intptr_t ResultCid() const { return result_cid_; }
2021 void set_result_cid(intptr_t value) { result_cid_ = value; } 2023 void set_result_cid(intptr_t value) { result_cid_ = value; }
2022 2024
2025 bool is_constructor() const { return is_constructor_; }
2026 void set_is_constructor(bool is_constructor) {
2027 is_constructor_ = is_constructor;
2028 }
2029
2023 private: 2030 private:
2024 const intptr_t token_pos_; 2031 const intptr_t token_pos_;
2025 const Function& function_; 2032 const Function& function_;
2026 const Array& argument_names_; 2033 const Array& argument_names_;
2027 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2034 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2028 intptr_t result_cid_; // For some library functions we know the result. 2035 intptr_t result_cid_; // For some library functions we know the result.
2036 bool is_constructor_; // Some library constructors have known semantics.
2029 2037
2030 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 2038 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
2031 }; 2039 };
2032 2040
2033 2041
2034 class LoadLocalInstr : public TemplateDefinition<0> { 2042 class LoadLocalInstr : public TemplateDefinition<0> {
2035 public: 2043 public:
2036 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) 2044 LoadLocalInstr(const LocalVariable& local, intptr_t context_level)
2037 : local_(local), 2045 : local_(local),
2038 context_level_(context_level) { } 2046 context_level_(context_level) { }
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 3257
3250 virtual bool AttributesEqual(Definition* other) const; 3258 virtual bool AttributesEqual(Definition* other) const;
3251 3259
3252 virtual bool AffectedBySideEffect() const { return false; } 3260 virtual bool AffectedBySideEffect() const { return false; }
3253 3261
3254 Value* array() const { return inputs_[0]; } 3262 Value* array() const { return inputs_[0]; }
3255 Value* index() const { return inputs_[1]; } 3263 Value* index() const { return inputs_[1]; }
3256 3264
3257 intptr_t array_type() const { return array_type_; } 3265 intptr_t array_type() const { return array_type_; }
3258 3266
3267 virtual Definition* Canonicalize();
3268
3259 private: 3269 private:
3260 intptr_t array_type_; 3270 intptr_t array_type_;
3261 3271
3262 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 3272 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
3263 }; 3273 };
3264 3274
3265 3275
3276 class CheckBoundInstr : public TemplateDefinition<2> {
3277 public:
3278 CheckBoundInstr(Value* length,
3279 Value* index,
3280 intptr_t deopt_id) {
3281 ASSERT(length != NULL);
3282 ASSERT(index != NULL);
3283 inputs_[0] = length;
3284 inputs_[1] = index;
3285 deopt_id_ = deopt_id;
3286 }
3287
3288 DECLARE_INSTRUCTION(CheckBound)
3289 virtual RawAbstractType* CompileType() const;
3290
3291 virtual bool CanDeoptimize() const { return true; }
3292 virtual intptr_t ResultCid() const { return kIllegalCid; }
3293
3294 virtual bool AttributesEqual(Definition* other) const {
3295 return true;
3296 }
3297
3298 virtual bool HasSideEffect() const { return false; }
srdjan 2012/09/12 10:29:58 AffectedBySideEffect is the new name.
3299
3300 Value* length() const { return inputs_[0]; }
3301 Value* index() const { return inputs_[1]; }
3302
3303 private:
3304 DISALLOW_COPY_AND_ASSIGN(CheckBoundInstr);
3305 };
3306
3307
3266 #undef DECLARE_INSTRUCTION 3308 #undef DECLARE_INSTRUCTION
3267 3309
3268 class Environment : public ZoneAllocated { 3310 class Environment : public ZoneAllocated {
3269 public: 3311 public:
3270 // Iterate the non-NULL values in the innermost level of an environment. 3312 // Iterate the non-NULL values in the innermost level of an environment.
3271 class ShallowIterator : public ValueObject { 3313 class ShallowIterator : public ValueObject {
3272 public: 3314 public:
3273 explicit ShallowIterator(Environment* environment) 3315 explicit ShallowIterator(Environment* environment)
3274 : environment_(environment), index_(0) { } 3316 : environment_(environment), index_(0) { }
3275 3317
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 ForwardInstructionIterator* current_iterator_; 3486 ForwardInstructionIterator* current_iterator_;
3445 3487
3446 private: 3488 private:
3447 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3489 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3448 }; 3490 };
3449 3491
3450 3492
3451 } // namespace dart 3493 } // namespace dart
3452 3494
3453 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3495 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698